Retour à la version de la semaine dernière pour modifier les joueurs
continuous-integration/drone/push Build is passing Details

pull/108/head
Remi NEVEU 11 months ago
parent e70e826715
commit 941587fe4c

@ -131,6 +131,20 @@ namespace Models.Game
return true;
}
public bool ModifyPlayer(string pseudo, string newpseudo)
{
foreach (var index in Players)
{
if (index.Pseudo == pseudo)
{
index.Pseudo = newpseudo;
return true;
}
}
return false;
}
public void LoadData()
{
var data = PersistenceManager.LoadData();

@ -10,8 +10,13 @@ namespace Models.Game
/// Represents a player in the game.
/// </summary>
[DataContract]
public class Player
public class Player : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
void OnPropertyChanged([CallerMemberName] string propertyName = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
/// <summary>
/// It is he pseudo of the player.
/// </summary>
@ -25,6 +30,7 @@ namespace Models.Game
if (_pseudo == value)
return;
_pseudo = value;
OnPropertyChanged();
}
}

@ -61,28 +61,35 @@ public partial class PageProfiles : ContentPage
async void Button_ClickedModify(System.Object sender, System.EventArgs e)
{
throw new NotImplementedException();
/*
if (ProfileManager.Players.Count == 0)
{
await DisplayAlert("Info", "There is no player actually\nPlease add one", "Ok");
return;
}
string result = await DisplayPromptAsync("Info", $"Choose a name to modify : ", "Ok");
Debug.WriteLine("Answer: " + result);
if (result != null)
if (result == null)
{
Debug.WriteLine("Did not found");
return;
}
string tomodify = await DisplayPromptAsync("Info", $"How will you rename it ?: ", "Ok");
Debug.WriteLine("Answer: " + tomodify);
if (tomodify == 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");
}
Debug.WriteLine("Did not found");
return;
}
else Debug.WriteLine("Did not found");
*/
Debug.WriteLine("bam, modified");
bool ismodified = ProfileManager.ModifyPlayer(result, tomodify);
if (ismodified)
{
Debug.WriteLine("Modified");
ProfileManager.SaveData();
}
else Debug.WriteLine("Player not found");
}
}

Loading…
Cancel
Save