private List <GameInstruction> SwapHalf() { List <GameInstruction> instructions = new List <GameInstruction>(); if (partOfRound == HalfOfRound.FirstHalf) { partOfRound = HalfOfRound.SecondHalf; sectionOfRound = SectionOfRound.Settlements; game.CurrentPlayingTeam.Moves = 0; var switchI = new GameInstruction($"Switching turns", BothChannels); instructions.Add(switchI); game.SwitchTeamTurn(); game.CurrentPlayingTeam.Moves = 6 - currentDieRoll; if (currentDieRoll != 6) { if (debug) { var i = new GameInstruction($"{CurrentPlayerName} can take {6 - currentDieRoll} {(6 - currentDieRoll == 1 ? "resource" : "resources")}.", OutputChannel); instructions.Add(i); } else { var playerI = new GameInstruction($"It is your turn. You can take {6 - currentDieRoll} {(6 - currentDieRoll == 1 ? "resource" : "resources")}.", OutputChannel); var otherPlayerI = new GameInstruction($"It is the enemy's turn. The enemy can take {6 - currentDieRoll} {(6 - currentDieRoll == 1 ? "resource" : "resources")}.", OtherChannel); instructions.Add(playerI); instructions.Add(otherPlayerI); } instructions.AddRange(OutputBeginningOfRound()); } else { if (debug) { var i = new GameInstruction($"{CurrentPlayerName} cannot play this turn.", OutputChannel); instructions.Add(i); } else { var playerI = new GameInstruction($"You cannot play this turn.", OutputChannel); var otherPlayerI = new GameInstruction($"The enemy cannot play this turn.", OtherChannel); instructions.Add(playerI); instructions.Add(otherPlayerI); } instructions.AddRange(OutputEndOfRound()); } } else { instructions.AddRange(OutputEndOfRound()); } return(instructions); }
public List <GameInstruction> StartYear() { WaitingForRoundResponse = false; WaitingForDieRollResponse = true; partOfRound = HalfOfRound.FirstHalf; sectionOfRound = SectionOfRound.Settlements; List <GameInstruction> instructions = new List <GameInstruction>(); if (!PlayersHaveDie) { int roll = game.RollDie(); return(ProcessDieRoll(roll.ToString())); } else { var i = new GameInstruction($"Please roll your die and then enter the die roll", OutputChannel); instructions.Add(i); } return(instructions); }
public List <GameInstruction> OutputEndOfRound() { List <GameInstruction> instructions = new List <GameInstruction>(); game.CurrentPlayingTeam.Moves = 0; game.Advance(); var pointAnnoucment = new GameInstruction($"Red: {game.GetTeamPopulationTotalString(Constants.Teams.Red)} ({game.GetTeamPopulationDifferenceString(Constants.Teams.Red)}). Blue: {game.GetTeamPopulationTotalString(Constants.Teams.Blue)} ({game.GetTeamPopulationDifferenceString(Constants.Teams.Blue)}).", BothChannels); instructions.Add(pointAnnoucment); if (game.RedTeam.Population >= Constants.WinningScore && game.BlueTeam.Population >= Constants.WinningScore) { if (game.RedTeam.Population > game.BlueTeam.Population) { var i = new GameInstruction("The Red side has won the game.", BothChannels); instructions.Add(i); } else if (game.RedTeam.Population < game.BlueTeam.Population) { var i = new GameInstruction("The Blue side has won the game.", BothChannels); instructions.Add(i); } else { var i = new GameInstruction("The game has ended in a draw.", BothChannels); instructions.Add(i); } GameIsOver = true; return(instructions); } else if (game.RedTeam.Population >= Constants.WinningScore) { var i = new GameInstruction("The Red side has won the game.", BothChannels); instructions.Add(i); GameIsOver = true; return(instructions); } else if (game.BlueTeam.Population >= Constants.WinningScore) { var i = new GameInstruction("The Blue side has won the game.", BothChannels); instructions.Add(i); GameIsOver = true; return(instructions); } if (game.ResolveSwap) { var swapAnnoucement = new GameInstruction("PLEASE SWITCH SIDES. YOU ARE NOW ON THE OTHER TEAM. MOVE POSITIONS. REMEMBER, G.O.D. IS ON YOUR SIDE.", BothChannels); instructions.Add(swapAnnoucement); if (!game.AlreadySwapped) { var gameChangeAnnouncement = new GameInstruction("Points are now people. When you bomb a tile you kill all people living the affected settlements.", BothChannels); instructions.Add(gameChangeAnnouncement); var newScoreAnnouncement = new GameInstruction($"You are now trying to reach a population of {Constants.WinningScore}.", BothChannels); instructions.Add(newScoreAnnouncement); var drawI = new GameInstruction($"You can now initiate a draw by sending draw. Both sides must agree to draw on the same turn. You can propose a draw every turn.", BothChannels); instructions.Add(drawI); } game.ResolveSwap = false; game.AlreadySwapped = true; game.StartKilingPopulation(); } instructions.AddRange(ResetDraw()); partOfRound = HalfOfRound.FirstHalf; sectionOfRound = SectionOfRound.Settlements; instructions.AddRange(StartYear()); return(instructions); }
public List <GameInstruction> ProcessSettlements(string text) { List <GameInstruction> instructions = new List <GameInstruction>(); if (text != "NONE" && text != "NO") { List <string> moves = new List <string>(); string[] commaSplit = text.Split(','); foreach (var fragment in commaSplit) { string[] spaceSplit = fragment.Trim().Split(' '); foreach (var coord in spaceSplit) { moves.Add(coord); } } if (moves.Count > game.CurrentPlayingTeam.Moves) { var i = new GameInstruction("Entered too many moves. Please enter your settlement coordinates again.", OutputChannel); instructions.Add(i); return(instructions); } foreach (var move in moves) { if (!Constants.ValidCoord(move)) { var i = new GameInstruction("Invalid move. Please enter your settlement coordinates again.", OutputChannel); instructions.Add(i); return(instructions); } } game.CurrentPlayingTeam.Moves -= moves.Count; List <string> failedMoves = game.AttemptPlaySettlements(moves); if (failedMoves.Count > 0) { string failed = string.Empty; foreach (var str in failedMoves) { failed += $" {str}"; } var i = new GameInstruction($"The following moves failed:{failed}. These settlements are lost.", OutputChannel); instructions.Add(i); } } if (game.CurrentPlayingTeam.Moves > 0) { if (debug) { var rocketsI = new GameInstruction($"{CurrentPlayerName}, you have {game.CurrentPlayingTeam.Moves} remaining. Play your missiles and then input coordinates. Use spaces or commas to separate entries. Enter none for no missiles.", OutputChannel); instructions.Add(rocketsI); } else { var rocketsI = new GameInstruction($"You have {game.CurrentPlayingTeam.Moves} remaining. Input missile coordinates. Use spaces or commas to separate entries. Enter none for no missiles.", OutputChannel); instructions.Add(rocketsI); } sectionOfRound = SectionOfRound.Missiles; } else { if (debug) { var noMovesLeftI = new GameInstruction($"{CurrentPlayerName}, you have no moves left.", OutputChannel); instructions.Add(noMovesLeftI); } else { var noMovesLeftI = new GameInstruction($"You have no moves left.", OutputChannel); instructions.Add(noMovesLeftI); } instructions.AddRange(SwapHalf()); } return(instructions); }