diff --git a/source/Trek-12/Models/Game/Player.cs b/source/Trek-12/Models/Game/Player.cs
index 9ac6b8a..97940d4 100644
--- a/source/Trek-12/Models/Game/Player.cs
+++ b/source/Trek-12/Models/Game/Player.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
+using System.Runtime.CompilerServices;
namespace Models.Game
{
@@ -8,10 +9,29 @@ namespace Models.Game
///
public class Player : INotifyPropertyChanged
{
+
+ public event PropertyChangedEventHandler? PropertyChanged;
+
+ void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+
+
///
/// It is he pseudo of the player.
///
- public string Pseudo { get; private set; }
+ private string _pseudo;
+ public string Pseudo
+ {
+ get => _pseudo;
+ set
+ {
+ if (_pseudo == value)
+ return;
+ _pseudo = value;
+ OnPropertyChanged();
+ }
+ }
+ private int hairCount;
///
/// It is the profile picture of the player.
@@ -48,15 +68,6 @@ namespace Models.Game
ProfilePicture = profilePicture;
}
- public event PropertyChangedEventHandler? PropertyChanged;
-
- void OnPropertyChanged(string propertyName)
- {
- if (PropertyChanged != null)
- {
- PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
- }
- }
///
/// Chooses the operation for the player.
diff --git a/source/Trek-12/Stub/Stub.cs b/source/Trek-12/Stub/Stub.cs
index 2008dca..46a4511 100644
--- a/source/Trek-12/Stub/Stub.cs
+++ b/source/Trek-12/Stub/Stub.cs
@@ -21,9 +21,31 @@ namespace Stub
listplayer.Add(new Player());
listplayer.Add(new Player("Lucas", "profile.jpg"));
- listplayer.Add(new Player("relavergne"));
- listplayer.Add(new Player("reneveu"));
+ listplayer.Add(new Player("relavergne", "profile.jpg"));
+ listplayer.Add(new Player("reneveu", "profile.jpg"));
}
+
+ public void Add(string pseudo, string profilePicture)
+ {
+ listplayer.Add(new Player(pseudo, profilePicture));
+ }
+
+ public void Pop(string pseudo, string profilePicture)
+ {
+ listplayer.Remove(new Player(pseudo, profilePicture));
+ }
+ public bool Modify(string pseudo, string newpseudo)
+ {
+ foreach(var index in listplayer)
+ {
+ if (index.Pseudo == pseudo)
+ {
+ index.Pseudo = newpseudo;
+ return true;
+ }
+ }
+ return false;
+ }
}
}
diff --git a/source/Trek-12/Trek-12/Views/pageProfils.xaml b/source/Trek-12/Trek-12/Views/pageProfils.xaml
index 12a2cb3..ac1720c 100644
--- a/source/Trek-12/Trek-12/Views/pageProfils.xaml
+++ b/source/Trek-12/Trek-12/Views/pageProfils.xaml
@@ -27,9 +27,9 @@
-
-
-
+
+
+
diff --git a/source/Trek-12/Trek-12/Views/pageProfils.xaml.cs b/source/Trek-12/Trek-12/Views/pageProfils.xaml.cs
index fa86eef..9047a40 100644
--- a/source/Trek-12/Trek-12/Views/pageProfils.xaml.cs
+++ b/source/Trek-12/Trek-12/Views/pageProfils.xaml.cs
@@ -1,5 +1,8 @@
namespace Trek_12.Views;
using Stub;
+using System.Diagnostics;
+using CommunityToolkit.Maui.Alerts;
+using CommunityToolkit.Maui.Core;
public partial class PageProfils : ContentPage
{
@@ -10,4 +13,54 @@ public partial class PageProfils : ContentPage
InitializeComponent();
BindingContext = MyStub;
}
-}
\ No newline at end of file
+
+
+ async void Button_ClickedAdd(System.Object sender, System.EventArgs e)
+ {
+ string result = await DisplayPromptAsync("Info", $"Choose a name : ", "Ok");
+ Debug.WriteLine("Answer: " + result);
+ if (result != null)
+ {
+ Debug.WriteLine("bam, added");
+ MyStub.Add(result, "profile.jpg");
+ }
+ }
+
+
+ async void Button_ClickedPop(System.Object sender, System.EventArgs e)
+ {
+ string result = await DisplayPromptAsync("Info", $"Choose a name to delete : ", "Ok");
+ Debug.WriteLine("Answer: " + result);
+ if (result != null)
+ {
+ Debug.WriteLine("bam, deleted");
+ MyStub.Pop(result, "profile.jpg");
+ }
+ else Debug.WriteLine("Pseudo not found");
+ }
+
+ async void Button_ClickedModify(System.Object sender, System.EventArgs e)
+ {
+ string result = await DisplayPromptAsync("Info", $"Choose a name to modify : ", "Ok");
+ Debug.WriteLine("Answer: " + result);
+ if (result != null)
+ {
+ string tomodify = await DisplayPromptAsync("Info", $"How will you rename it ?: ", "Ok");
+ Debug.WriteLine("Answer: " + tomodify);
+ if (tomodify != null)
+ {
+ Debug.WriteLine("bam, modified");
+ bool ismodified = MyStub.Modify(result, tomodify);
+
+ if (ismodified)
+ {
+ Debug.WriteLine("Modified");
+ }
+ else Debug.WriteLine("Player not found");
+ }
+ }
+ else Debug.WriteLine("Did not found");
+ }
+
+}
+