private string GetPlayerNameAndNumber(GameSession session, int playerNumer) { string playerString = "player number not found"; if (session.KingsGamePlayers != null && session.KingsGamePlayers.Count > 0) { KingsGamePlayer p = session.KingsGamePlayers.FirstOrDefault(a => a.Role == playerNumer); if (p != null) { playerString = "#" + playerNumer + ": " + Utils.GetCharacterUserTags(p.Name); } } return(playerString); }
public string IssueGameCommand(DiceBot diceBot, BotMain botMain, string character, string channel, GameSession session, string[] terms) { string returnString = ""; if (terms.Contains("showallnumbers")) { if (session.State == GameState.GameInProgress) { string messageString = "Showing all information for this round of The King's Game:\n" + GetPlayerNumbers(session); botMain.SendPrivateMessage(messageString, character); returnString = Utils.GetCharacterUserTags(character) + " has been sent the information for this round's secret numbers."; } else { returnString = "The King's Game is not already in progress, there are no numbers to show."; } } else if (terms.Contains("endround")) { returnString = "King's Game round has ended manually."; ResetGameRound(session); } else if (terms.Contains("awardpoints")) { if (session.State == GameState.GameInProgress) { if (PlayerIsKing(session, character)) { if (session.KingsGamePlayers == null || session.KingsGamePlayers.Count < GetMinPlayers()) { returnString = "Error: King's Game players list not set correctly."; } else { List <int> playerAwardsTemp = Utils.GetAllNumbersFromInputs(terms); List <int> playerAwards = new List <int>(); //decrease all the numbers by 1 to match array indexes, rather than the card position for a player if (playerAwardsTemp.Count > 0) { foreach (int i in playerAwardsTemp) { if (i > 0 && i < session.KingsGamePlayers.Count) { playerAwards.Add(i); } } } string playerAwardsList = ""; if (playerAwards.Count > 0) { foreach (int i in playerAwards) { playerAwardsList += GetPlayerNameAndNumber(session, i); KingsGamePlayer player = session.KingsGamePlayers.FirstOrDefault(a => a.Role == i); if (player != null) { string chipsAward = diceBot.AddChips(player.Name, channel, 100, false); playerAwardsList += "\n" + chipsAward; } playerAwardsList += "\n"; } } else { playerAwardsList = "no one"; } string messageString = "King " + Utils.GetCharacterUserTags(character) + " is awarding Points to :\n" + playerAwardsList; returnString = messageString + "\n This round has finished."; ResetGameRound(session); } } else { returnString = "Only the king can award points for the round."; } } else { returnString = "The King's Game is not already in progress, points cannot be awarded."; } } else { returnString = "A command for " + GetGameName() + " was not found."; } return(returnString); }