private async void RemovePlayer (PlayerViewModel item) { var index = _players.IndexOf (item); _players.Remove (item); Model.Participants.RemoveAt (index); await GameService.SaveParticipantsAsync(Model); }
private PlayerViewModel GetNewPlayer(string text) { var result = new PlayerViewModel {PlayerName = text }; SetCommands(result); return result; }
public void Reveal(PlayerViewModel winner) { PlayersSelector.ScrollTo(winner, ScrollToPosition.Center, true); }
private PlayerViewModel GetNewPlayer(string name) { var result = new PlayerViewModel(new User {Name = name}); SetCommands(result); return result; }
private void SetCommands(PlayerViewModel item) { item.DeleteCommand = new Command(() => RemovePlayer(item)); }
public async void Play() { if (Players.Any() == false) { return; } foreach (var item in Players) { item.IsWinner = false; } var random = new Random(DateTime.Now.Millisecond); var lucky = random.Next(0, Players.Count()); var selectedPlayer = Players.ElementAtOrDefault(lucky); if (selectedPlayer != null) { selectedPlayer.IsWinner = true; Winner = selectedPlayer; //History.Add(new EventLogViewModel(string.Format("{0} winned!", selectedPlayer.PlayerName))); Model.History.Add(string.Format("{0} winned!", selectedPlayer.PlayerName)); await GameService.SaveHistoryAsync(Model); } }
private void SetCommands(PlayerViewModel item) { item.DeleteCommand = new Command(() => RemovePlayer(item)); }