protected async Task AddPlayer(Player player) { if (SelectedPlayers.Contains(player)) { return; } SelectedPlayers.Add(player); }
protected async Task MoveDown(Player player) { var index = SelectedPlayers.IndexOf(player); if (index < SelectedPlayers.Count - 1) { SelectedPlayers.Remove(player); SelectedPlayers.Insert(index + 1, player); } }
protected async Task MoveUp(Player player) { var index = SelectedPlayers.IndexOf(player); if (index > 0) { SelectedPlayers.Remove(player); SelectedPlayers.Insert(index - 1, player); } }
public void RemovePlayer(object parameter) { playerEngine.ActivePlayers.Remove(SelectedPlayer); AvailablePlayers.Add(SelectedPlayer); if (SelectedPlayer != null) { SelectedPlayers.Remove(SelectedPlayer); SelectedPlayer = null; } SelectedPlayer = null; }
protected async Task NewPlayer(string playerName) { var player = new Player { Name = playerName, }; DbContext.Players.Add(player); await DbContext.SaveChangesAsync(); SelectedPlayers.Add(player); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid || SelectedPlayers.Count() == 0 || StartTime == EndTime) { return(Page()); } FootballGame.StartTime = DateTime + StartTime; FootballGame.EndTime = DateTime + EndTime; TimeSpan duration = EndTime - StartTime; FootballGame.Duration = duration.Hours; foreach (FootballPlayer p in AllFootballPlayers) { if (SelectedPlayers.Contains(p.Id)) { FootballGame.FootballPlayers.Add(p); } } IdentityUser User = await _userManager.GetUserAsync(HttpContext.User); FootballGame.IdentityUserId = Guid.Parse(User.Id); List <FootballTeam> Teams = _footballTeamSorter.CreateFairTeams(FootballGame.FootballPlayers.ToList()); FootballTeam TeamA = await _footballTeamService.SaveFootballTeam(Teams[0]); FootballTeam TeamB = await _footballTeamService.SaveFootballTeam(Teams[1]); FootballGame.FootballTeams.Add(TeamA); FootballGame.FootballTeams.Add(TeamB); _context.FootballGames.Add(FootballGame); await _context.SaveChangesAsync(); await _playerGamesService.LinkPlayersToFootballGame(FootballGame.FootballPlayers.ToList(), FootballGame.Id); await _playerTeamsService.LinkPlayersToFootballTeam(TeamA.FootballPlayers.ToList(), TeamA.Id); await _playerTeamsService.LinkPlayersToFootballTeam(TeamB.FootballPlayers.ToList(), TeamB.Id); return(RedirectToPage("./Index")); }
public void ResetSelection() { SelectedPlayers.Clear(); substitutionPlayer = null; if (homePlayers != null) { foreach (PlayerObject player in homePlayers) { player.Active = false; } } if (awayPlayers != null) { foreach (PlayerObject player in awayPlayers) { player.Active = false; } } homeButton.Active = false; awayButton.Active = false; }
protected async Task StartGame() { var players = new List <Player>(); var game = new Game() { Start = DateTimeOffset.Now, }; game.GamePlayers = SelectedPlayers .Select((p, i) => new GamePlayer { Player = p, Order = i, }) .ToList(); DbContext.Games.Add(game); await DbContext.SaveChangesAsync(); NavigationManager.NavigateTo($"/game/{game.GameId}"); }
void HandlePlayerClickedEvent(ICanvasObject co) { PlayerObject player = co as PlayerObject; if (SubstitutionMode) { if (substitutionPlayer == null) { substitutionPlayer = player; } else { if (substitutionPlayer.Team == player.Team) { EmitSubsitutionEvent(player, substitutionPlayer); } else { player.Active = false; } } } else { if (player.Active) { SelectedPlayers.Add(player.Player); } else { SelectedPlayers.Remove(player.Player); } if (PlayersSelectionChangedEvent != null) { PlayersSelectionChangedEvent(SelectedPlayers); } } }
public void Select(Player player, bool silent = false, bool reset = false) { PlayerObject po; po = homePlayers.FirstOrDefault(p => p.Player == player); if (po == null) { po = awayPlayers.FirstOrDefault(p => p.Player == player); } if (po != null) { if (reset) { ResetSelection(); } SelectedPlayers.Add(player); po.Active = true; if (!silent && PlayersSelectionChangedEvent != null) { PlayersSelectionChangedEvent(SelectedPlayers); } } }
protected async Task RemovePlayer(Player player) { SelectedPlayers.Remove(player); }