private async Task EndGameWithWinner(GroupType winningGroup) { List <PlayerReward> players = await RewardPlayers(Phases.ToList(), winningGroup); await DayChannel.SendMessageAsync(GameEndView.Message(winningGroup)); await DayChannel.SendMessageAsync(string.Empty, false, GameEndView.Of(winningGroup, players)); await Dispose(); }
public void OnGet() { GameBoard = new GameBoard(4, 4); GameBoardArray = GameBoard.ToArray(); MenuView = new MenuView(); Settings = Settings.GetSettings(); IsPaused = true; MachinePlay = false; GameStates = new List <GameState>(); LoadGameView = new LoadGameView(); Games = LoadGameView.GetGames(); GameEndView = new GameEndView(); }
public IActionResult OnPost(int menuItemPushed, List <int> hiddenPlayedColumnsList, int[] settings, List <GameState> hiddenGameStates, MenuType[] hiddenMenuStack) { Settings = Settings.GetSettings(); if (settings != null) { for (var i = 0; i < settings.Length; i++) { Settings.settings[i].Value = settings[i]; } } MenuView.ReconstructMenuStack(hiddenMenuStack); GameStates = hiddenGameStates; GameBoard.PlayedColumns = hiddenPlayedColumnsList; GameBoard.Board = LoadGameView.CreateBoardFromPlayedColumns(GameBoard.FirstMove, GameBoard.Height, GameBoard.Width, hiddenPlayedColumnsList); if (!(menuItemPushed < MenuView.MenuItems.Count)) { return(Page()); } var appAction = MenuView.MenuItems[menuItemPushed].AppActionToTake; var app = ConsoleApp.GetAppStateUponAction(GameBoard, MenuView, Settings, IsPaused, appAction, MachinePlay, Input, GameStates, LoadGameView); GameBoard = app.GameBoard; GameBoardArray = GameBoard.ToArray(); MenuView = app.MenuView; GameEndView = app.GameEndView; if (MenuView.MenuStackSize == 0) { return(Redirect("./End")); } Settings = app.Settings; IsPaused = app.Ispaused; MachinePlay = app.MachinePlay; GameStates = app.GameStates; LoadGameView = app.LoadView; Games = LoadGameView.GetGames(); return(Page()); }
public async Task PlayerRewardsTest() { IEnumerable <IUser> users = _client.Guilds.SelectMany(g => g.Users).Take(8); GameObject game = new GameObject(users.ToList()); Random random = new Random(Guid.NewGuid().GetHashCode()); ICollection <GamePhase> gamePhases = new List <GamePhase>(); while (!InformedGroupWins(game) && !InformedGroupWins(game)) { List <Player> activePlayers = game.Players.Where(p => p.Active).ToList(); Player playerToBeRemoved = activePlayers[random.Next(activePlayers.Count)]; RemoveUserFromPlay(playerToBeRemoved.User, game); gamePhases.Add(new GamePhase { Target = playerToBeRemoved.User, Phase = playerToBeRemoved.Group == GroupType.Informed ? PhaseType.Day : PhaseType.Night }); } GroupType winers = InformedGroupWins(game) ? GroupType.Informed : GroupType.Uninformed; List <PlayerReward> rewards = GetPlayerRewards(game, gamePhases, game.Players.ToList(), winers); IUser me = _client.Guilds.SelectMany(g => g.Users).FirstOrDefault(u => u.Username == "JJ 3maj"); await me.SendMessageAsync(string.Empty, false, GameEndView.Of(winers, rewards)); }