public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); bool characterIsAdmin = Utils.IsCharacterAdmin(bot.AccountSettings.AdminCharacters, characterName); if (thisChannel.ChipsClearance == ChipsClearanceLevel.ChannelOp && command.ops == null) { bot.RequestChannelOpListAndQueueFurtherRequest(command); } else if ((thisChannel.ChipsClearance == ChipsClearanceLevel.DicebotAdmin && !characterIsAdmin) || (thisChannel.ChipsClearance == ChipsClearanceLevel.ChannelOp && !command.ops.Contains(characterName) && !characterIsAdmin)) { bot.SendMessageInChannel(Utils.GetCharacterUserTags(characterName) + " cannot perform [" + Name + "] under the current chip settings for this channel.", channel); } else if (thisChannel.AllowChips) { string messageString = bot.DiceBot.RemoveChipsPile(characterName, channel); commandController.SaveChipsToDisk(); bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowChips) { bool all = false; int betAmount = Utils.GetNumberFromInputs(terms); if (terms != null && terms.Length >= 1 && terms.Contains("all")) { all = true; } string messageString = ""; if (betAmount == 0 && !all) { messageString = "Error: You must input a number or 'all' to make a bet."; } else { messageString = bot.DiceBot.BetChips(characterName, channel, betAmount, all); commandController.SaveChipsToDisk(); } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowChips) { string messageString = ""; ChipPile existing = bot.DiceBot.GetChipPile(characterName, channel, false); if (existing != null) { messageString = Utils.GetCharacterUserTags(characterName) + " is already registered."; } else { messageString = Utils.GetCharacterUserTags(characterName) + " was registered for a chips pile."; if (thisChannel.StartWith500Chips) { messageString += "\n[b]500 chips[/b] were given to " + Utils.GetCharacterUserTags(characterName) + " to start."; } bot.DiceBot.AddChips(characterName, channel, 0, false); commandController.SaveChipsToDisk(); } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowTableInfo) { string tableName = commandController.GetTableNameFromCommandTerms(terms); SavedRollTable infoTable = Utils.GetTableFromId(bot.SavedTables, tableName); string sendMessage = "Table \'" + tableName + "\' not found."; if (infoTable != null) { sendMessage = "Table id [b]" + infoTable.TableId + "[/b] created by [user]" + infoTable.OriginCharacter + "[/user]"; if (infoTable.Table != null) { string tabledesc = infoTable.Table.Description + "\n"; sendMessage += "\n\n Name: [b]" + infoTable.Table.Name + "[/b]\n " + tabledesc + " Roll Die: d" + infoTable.Table.DieSides + " Roll Bonus: " + infoTable.Table.RollBonus; sendMessage += "\n" + infoTable.Table.GetTableEntryList(); } else { sendMessage += "\n (Rolltable contents not found)"; } } bot.SendMessageInChannel(sendMessage, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowChips) { bool half = false; bool third = false; if (terms != null && terms.Length >= 1 && terms.Contains("half")) { half = true; } if (terms != null && terms.Length >= 1 && terms.Contains("third")) { third = true; } string messageString = bot.DiceBot.ClaimPot(characterName, channel, half, third); commandController.SaveChipsToDisk(); bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowGames) { string messageString = ""; IGame gametype = commandController.GetGameTypeFromCommandTerms(bot.DiceBot, terms); bool adminCancel = terms.Contains("override"); if (gametype == null) { //check game sessions and see if this channel has a session for anything var gamesPresent = bot.DiceBot.GameSessions.Where(a => a.ChannelId == channel); if (gamesPresent.Count() == 0) { messageString = "Error: No game sessions are active in this channel to cancel."; } else if (gamesPresent.Count() > 1) { messageString = "Error: You must specify a game type if more than one game session exists in the channel."; } else if (gamesPresent.Count() == 1) { GameSession sesh = gamesPresent.First(); gametype = sesh.CurrentGame; } } if (gametype != null) { GameSession sesh = bot.DiceBot.GetGameSession(channel, gametype, false); if (sesh != null) { ChipPile potChips = bot.DiceBot.GetChipPile(DiceBot.PotName, channel); if (!adminCancel && sesh.Ante > 0 && potChips.Chips > 0) { messageString = "The pot already has chips in it. The pot must be empty before cancelling a game with ante."; } else { messageString = bot.DiceBot.CancelGame(channel, gametype); } } else { messageString = "Error: Game session for " + gametype.GetGameName() + " not found or created."; } } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowChips) { bool all = false; bool pot = false; bool secret = false; if (terms != null && terms.Length >= 1 && terms.Contains("all")) { all = true; } if (terms != null && terms.Length >= 1 && terms.Contains("pot")) { pot = true; } if (terms != null && terms.Length >= 1 && terms.Contains("secret")) { secret = true; } string messageString = ""; if (all) { messageString = bot.DiceBot.ListAllChipPiles(channel); } else { if (pot) { messageString = bot.DiceBot.DisplayChipPile(channel, DiceBot.PotName); } else { messageString = bot.DiceBot.DisplayChipPile(channel, characterName); } } if (all || secret) { bot.SendPrivateMessage(messageString, characterName); } else { bot.SendMessageInChannel(messageString, channel); } } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowChips) { if (thisChannel.ChipsClearance != ChipsClearanceLevel.DicebotAdmin) { bot.SendMessageInChannel("Redeemchips is only functional in channels that have [b]restricted[/b] chips pools. Please try using '!addchips' instead.", channel); } else { string messageString = ""; if (rawTerms.Count() < 1) { messageString = "Error: This command requires a chips code."; } else { string chipsCode = rawTerms[0]; //find chips coupon ChipsCoupon coupon = bot.ChipsCoupons.FirstOrDefault(a => a.Code == chipsCode); if (coupon == null) { messageString = "chips code not found (" + chipsCode + ")"; } else if (coupon.Redeemed) { messageString = "This chips code (" + chipsCode + ") has already been redeemed."; } else { //mark redeemed and add chips to the redeeming character coupon.Redeemed = true; coupon.RedeemedBy = characterName; messageString = "Chips code redeemed.\n" + bot.DiceBot.AddChips(characterName, channel, coupon.ChipsAmount, false) + "\n[sub]Thank you for purchasing Dice Bot chips![/sub]"; commandController.SaveChipsToDisk(); commandController.SaveCouponsToDisk(); } } bot.SendMessageInChannel(messageString, channel); } } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); bool characterIsAdmin = Utils.IsCharacterAdmin(bot.AccountSettings.AdminCharacters, characterName); if (thisChannel.ChipsClearance == ChipsClearanceLevel.ChannelOp && command.ops == null) { bot.RequestChannelOpListAndQueueFurtherRequest(command); } else if ((thisChannel.ChipsClearance == ChipsClearanceLevel.DicebotAdmin && !characterIsAdmin) || (thisChannel.ChipsClearance == ChipsClearanceLevel.ChannelOp && !command.ops.Contains(characterName) && !characterIsAdmin)) { bot.SendMessageInChannel(Utils.GetCharacterUserTags(characterName) + " cannot perform [" + Name + "] under the current chip settings for this channel.", channel); } else if (thisChannel.AllowChips) { string messageString = ""; if (terms.Length < 2) { messageString = "Error: This command requires a number (first) and a user name (second)."; } else { bool all = false; int giveAmount = Utils.GetNumberFromInputs(terms); string[] rawTermsMost = new string[rawTerms.Length - 1]; for (int i = 1; i < rawTerms.Length; i++) { rawTermsMost[i - 1] = rawTerms[i]; } string targetUserName = Utils.GetFullStringOfInputs(rawTermsMost).Trim(); if (giveAmount <= 0 && !all) { messageString = "Error: You must input a number to take an amount of chips."; } else { messageString = bot.DiceBot.TakeChips(characterName, targetUserName, channel, giveAmount, all); commandController.SaveChipsToDisk(); } } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings existing = bot.GetChannelSettings(channel); string sendMessage = "[b]Added[/b] " + channel + " to list of startup channels."; if (existing.StartupChannel) { sendMessage = "[b]Removed[/b] " + channel + " from list of startup channels."; } existing.StartupChannel = !existing.StartupChannel; Utils.WriteToFileAsData(bot.SavedChannelSettings, Utils.GetTotalFileName(BotMain.FileFolder, BotMain.ChannelSettingsFileName)); bot.SendMessageInChannel(sendMessage, channel); }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); string allSettings = string.Format("{0} [b]Channel Settings[/b]: \n" + "[b]StartupChannel:[/b] {1}, [b]AllowTableInfo:[/b] {2}, [b]AllowTableRolls:[/b] {3},\n" + "[b]AllowCustomTableRolls:[/b] {4}, [b]GreetNewUsers:[/b] {5}, [b]AllowChips:[/b] {6} \n" + "[b]Add Chips Restriction:[/b] {7} (OnlyOpAddChips), [b]StartWith500Chips[/b]: {8} \n" + "[b]AllowGames:[/b] {9}", thisChannel.Name, thisChannel.StartupChannel, thisChannel.AllowTableInfo, thisChannel.AllowTableRolls, thisChannel.AllowCustomTableRolls, thisChannel.GreetNewUsers, thisChannel.AllowChips, thisChannel.ChipsClearance.ToString(), thisChannel.StartWith500Chips, thisChannel.AllowGames); bot.SendMessageInChannel(allSettings, channel); }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); bool characterIsAdmin = Utils.IsCharacterAdmin(bot.AccountSettings.AdminCharacters, characterName); bool characterIsTrustedForChannel = Utils.IsCharacterTrusted(bot.AccountSettings.TrustedCharacters, characterName, channel); if (thisChannel.ChipsClearance == ChipsClearanceLevel.ChannelOp && command.ops == null) { bot.RequestChannelOpListAndQueueFurtherRequest(command); } else if ((thisChannel.ChipsClearance == ChipsClearanceLevel.DicebotAdmin && !characterIsAdmin && !characterIsTrustedForChannel) || (thisChannel.ChipsClearance == ChipsClearanceLevel.ChannelOp && !command.ops.Contains(characterName) && !characterIsAdmin)) { bot.SendMessageInChannel(Utils.GetCharacterUserTags(characterName) + " cannot perform [" + Name + "] under the current chip settings for this channel.", channel); } else if (thisChannel.AllowChips) { bool pot = false; int chipAmount = Utils.GetNumberFromInputs(terms); if (terms != null && terms.Length >= 1 && terms.Contains("pot")) { pot = true; } string messageString = ""; if (chipAmount <= 0) { messageString = "Error: You must specify a number of chips above 0 to add."; } else { messageString = bot.DiceBot.AddChips(characterName, channel, chipAmount, pot); commandController.SaveChipsToDisk(); } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowGames) { string messageString = ""; if (terms.Length < 1) { messageString = "Error: This command requires a game name."; } else { IGame gametype = commandController.GetGameTypeFromCommandTerms(bot.DiceBot, terms); if (gametype == null) { messageString = "Error: Game type not found."; } else { GameSession sesh = bot.DiceBot.GetGameSession(channel, gametype, false); if (sesh != null) { double secondsRemain = bot.DiceBot.GetSecondsRemainingOnCountdownTimer(channel, gametype.GetGameName()); messageString = sesh.GetStatus(secondsRemain); } else { messageString = "Game session for " + gametype.GetGameName() + " not found or created."; } } } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowChips) { string messageString = ""; if (terms.Length < 2) { messageString = "Error: This command requires a number (first) and a user name (second)."; } else { bool all = false; int giveAmount = Utils.GetNumberFromInputs(rawTerms); string[] rawTermsMost = new string[rawTerms.Length - 1]; for (int i = 1; i < rawTerms.Length; i++) { rawTermsMost[i - 1] = rawTerms[i]; } string targetUserName = Utils.GetFullStringOfInputs(rawTermsMost).Trim(); if (giveAmount <= 0 && !all) { messageString = "Error: You must input a number to give an amount of chips."; } else { messageString = bot.DiceBot.GiveChips(characterName, targetUserName, channel, giveAmount, all); commandController.SaveChipsToDisk(); } } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowChips) { string messageString = ""; if (terms.Length < 1) { messageString = "Error: This command requires a number."; } else { bool pot = false; int chipAmount = Utils.GetNumberFromInputs(terms); if (terms != null && terms.Length >= 1 && terms.Contains("pot")) { pot = true; } messageString = ""; if (chipAmount <= 0) { messageString = "Error: You must specify a number of chips above 0 to remove."; } else { messageString = bot.DiceBot.AddChips(characterName, channel, -1 * chipAmount, pot); commandController.SaveChipsToDisk(); } } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowTableRolls) { bool includeLabel = true; bool secondaryRolls = true; if (terms != null && terms.Length >= 1 && terms.Contains("nolabel")) { includeLabel = false; } if (terms != null && terms.Length >= 1 && terms.Contains("nosecondary")) { secondaryRolls = false; } int rollModifier = commandController.GetRollModifierFromCommandTerms(terms); string tableName = commandController.GetTableNameFromCommandTerms(terms); SavedRollTable savedTable = Utils.GetTableFromId(bot.SavedTables, tableName); if (savedTable.DefaultTable || thisChannel.AllowCustomTableRolls) { string sendMessage = bot.DiceBot.GetRollTableResult(bot.SavedTables, tableName, characterName, channel, rollModifier, includeLabel, secondaryRolls, 3); bot.SendMessageInChannel(sendMessage, channel); } else { bot.SendMessageInChannel("Only default talbes are allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowGames) { string messageString = ""; IGame gametype = commandController.GetGameTypeFromCommandTerms(bot.DiceBot, terms); bool keepSession = terms.Contains("keepsession") || terms.Contains("keepgame"); bool endSession = terms.Contains("endsession") || terms.Contains("endgame"); if (gametype == null) { //check game sessions and see if this channel has a session for anything var gamesParticipated = bot.DiceBot.GameSessions.Where(a => a.ChannelId == channel && a.Players.Contains(characterName)); if (gamesParticipated.Count() == 0) { messageString = "Error: Game type not found."; } else if (gamesParticipated.Count() > 1) { messageString = "Error: You must specify a game type if you are in more than one game."; } else if (gamesParticipated.Count() == 1) { GameSession sesh = gamesParticipated.First(); gametype = sesh.CurrentGame; } } if (gametype != null) //gametype can be set above after being null so this should no longer be 'else' { GameSession sesh = bot.DiceBot.GetGameSession(channel, gametype); if (sesh != null) { ChipPile potChips = bot.DiceBot.GetChipPile(DiceBot.PotName, channel); if (sesh.Ante > 0 && potChips.Chips > 0) { messageString = "The pot already has chips in it. The pot must be empty before starting a game with ante."; } else if (sesh.CurrentGame.GetMinPlayers() > sesh.Players.Count) { messageString = "Cannot start " + sesh.CurrentGame.GetGameName() + " because there are currently less than [b]" + sesh.CurrentGame.GetMinPlayers() + " players[/b]."; } else if (sesh.State == GameState.GameInProgress) { messageString = "Cannot start " + sesh.CurrentGame.GetGameName() + " because the game is already in progress. Please finish the current round first."; } else if (sesh.CurrentGame.GetType() == typeof(Roulette) && !bot.DiceBot.CountdownFinishedOrNotStarted(channel, sesh.CurrentGame.GetGameName())) { double secondsRemain = bot.DiceBot.GetSecondsRemainingOnCountdownTimer(channel, gametype.GetGameName()); messageString = "Cannot start " + sesh.CurrentGame.GetGameName() + " because the starting countdown is not yet finished. [b]" + secondsRemain.ToString("N3") + " seconds [/b]remain."; } else { messageString = sesh.CurrentGame.GetStartingDisplay(); messageString += "\n" + bot.DiceBot.StartGame(channel, gametype, bot, keepSession, endSession); if (sesh.CurrentGame.GetType() == typeof(Roulette)) { bot.DiceBot.StartCountdownTimer(channel, gametype.GetGameName(), characterName, 5 * 60 * 1000); } commandController.SaveChipsToDisk(); } } else { messageString = "Error: Game session for " + gametype.GetGameName() + " not found or created."; } } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowGames) { string messageString = ""; if (terms.Length < 1) { messageString = "Error: This command requires a game name."; } else { IGame gametype = commandController.GetGameTypeFromCommandTerms(bot.DiceBot, terms); if (gametype == null) { //check game sessions and see if this channel has a session for anything var gamesPresent = bot.DiceBot.GameSessions.Where(a => a.ChannelId == channel); if (gamesPresent.Count() == 0) { messageString = "Error: No game sessions are active in this channel to cancel."; } else if (gamesPresent.Count() > 1) { messageString = "Error: You must specify a game type if more than one game session exists in the channel."; } else if (gamesPresent.Count() == 1) { GameSession sesh = gamesPresent.First(); gametype = sesh.CurrentGame; } } if (gametype == null) { messageString = "Error: Game type not found."; } else { GameSession sesh = bot.DiceBot.GetGameSession(channel, gametype, false); if (sesh != null) { messageString = bot.DiceBot.IssueGameCommand(characterName, channel, sesh, terms); } else { messageString = "Game session for " + gametype.GetGameName() + " not found or created."; } } } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowGames) { string messageString = ""; IGame gametype = commandController.GetGameTypeFromCommandTerms(bot.DiceBot, terms); if (gametype == null) { //TODO: make this code somewhere else - it's repeated in many game commands //check game sessions and see if this channel has a session for anything var gamesParticipated = bot.DiceBot.GameSessions.Where(a => a.ChannelId == channel && a.Players.Contains(characterName)); if (gamesParticipated.Count() == 0) { messageString = "Error: Game type not found."; } else if (gamesParticipated.Count() > 1) { messageString = "Error: You must specify a game type if you are in more than one game."; } else if (gamesParticipated.Count() == 1) { GameSession sesh = gamesParticipated.First(); gametype = sesh.CurrentGame; } } if (gametype != null) { GameSession sesh = bot.DiceBot.GetGameSession(channel, gametype, false); if (sesh != null) { if (!sesh.Players.Contains(characterName)) { messageString = Utils.GetCharacterUserTags(characterName) + " has not joined " + sesh.CurrentGame.GetGameName() + "."; } else { messageString = bot.DiceBot.LeaveGame(characterName, channel, gametype); messageString += "\n" + sesh.Players.Count + " / " + sesh.CurrentGame.GetMaxPlayers() + " players ready."; if (sesh.CurrentGame.GetType() == typeof(Roulette)) { sesh.RemoveRouletteBet(characterName); } if (sesh.Players.Count >= sesh.CurrentGame.GetMinPlayers()) { messageString += "[b] (Ready to start!)[/b]"; } } } else { messageString = "Error: Game session for " + gametype.GetGameName() + " not found or created."; } } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { SettingType changed = SettingType.NONE; ChannelSettings thisChannel = bot.GetChannelSettings(channel); bool setValue = false; if (terms != null && terms.Length >= 1) { if (terms.Contains("useeicons")) changed = SettingType.UseEicons; if (terms.Contains("greetnewusers")) changed = SettingType.GreetNewUsers; if (terms.Contains("allowtablerolls")) changed = SettingType.AllowTableRolls; if (terms.Contains("allowcustomtablerolls")) changed = SettingType.AllowCustomTableRolls; if (terms.Contains("allowtableinfo")) changed = SettingType.AllowTableInfo; if (terms.Contains("allowchips")) changed = SettingType.AllowChips; if (terms.Contains("allowgames")) changed = SettingType.AllowGames; if (terms.Contains("usevcaccount")) changed = SettingType.UseVcAccountForChips; if (terms.Contains("startupchannel")) changed = SettingType.StartupChannel; if (terms.Contains("startwith500chips")) changed = SettingType.StartWith500Chips; if (terms.Contains("onlyopaddchips")) changed = SettingType.OnlyOpAddChips; if (terms.Contains("onlyopbotcommands")) changed = SettingType.OnlyOpBotCommands; if (terms.Contains("onlyopdeckcontrols")) changed = SettingType.OnlyOpDeckControls; if (terms.Contains("onlyoptablecommands")) changed = SettingType.OnlyOpTableCommands; if (terms.Contains("on") || terms.Contains("true")) setValue = true; if (terms.Contains("off") || terms.Contains("false")) setValue = false; } switch (changed) { case SettingType.NONE: break; case SettingType.UseEicons: thisChannel.UseEicons = setValue; break; case SettingType.GreetNewUsers: thisChannel.GreetNewUsers = setValue; break; case SettingType.AllowTableRolls: thisChannel.AllowTableRolls = setValue; break; case SettingType.AllowCustomTableRolls: thisChannel.AllowCustomTableRolls = setValue; break; case SettingType.AllowTableInfo: thisChannel.AllowTableInfo = setValue; break; case SettingType.AllowChips: thisChannel.AllowChips = setValue; break; case SettingType.AllowGames: thisChannel.AllowGames = setValue; break; case SettingType.UseVcAccountForChips: thisChannel.UseVcAccountForChips = setValue; break; case SettingType.StartupChannel: thisChannel.StartupChannel = setValue; break; case SettingType.StartWith500Chips: thisChannel.StartWith500Chips = setValue; break; case SettingType.OnlyOpAddChips: { if(thisChannel.ChipsClearance != ChipsClearanceLevel.DicebotAdmin) { if(setValue) { thisChannel.ChipsClearance = ChipsClearanceLevel.ChannelOp; } else { thisChannel.ChipsClearance = ChipsClearanceLevel.NONE; } } } break; case SettingType.OnlyOpBotCommands: thisChannel.OnlyChannelOpsCanUseAnyBotCommands = setValue; break; case SettingType.OnlyOpDeckControls: thisChannel.OnlyChannelOpsCanUseDeckControls = setValue; break; case SettingType.OnlyOpTableCommands: thisChannel.OnlyChannelOpsCanUseTableCommands = setValue; break; } if (changed == SettingType.NONE) { string output = "Setting not found. Be sure to specify which setting to change, followed by 'true' or 'false'. Settings use the same name displayed in the !viewsettings command."; bot.SendMessageInChannel(output, channel); } else { Utils.WriteToFileAsData(bot.SavedChannelSettings, Utils.GetTotalFileName(BotMain.FileFolder, BotMain.ChannelSettingsFileName)); string output = "(Channel setting updated) " + Utils.GetCharacterUserTags(characterName) + " set " + changed + " to " + setValue; if (changed == SettingType.OnlyOpAddChips && thisChannel.ChipsClearance == ChipsClearanceLevel.DicebotAdmin) { output = "(" + changed + " Channel setting cannot be updated for this channel) "; } bot.SendMessageInChannel(output, channel); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { ChannelSettings thisChannel = bot.GetChannelSettings(channel); if (thisChannel.AllowGames) { string messageString = ""; int ante = Utils.GetNumberFromInputs(terms); if (ante < 0) { ante = 0; } if (ante > 0 && !thisChannel.AllowChips) { messageString = Name + " [b]with chips[/b] is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel."; } else { IGame gametype = commandController.GetGameTypeFromCommandTerms(bot.DiceBot, terms); if (gametype == null) { //check game sessions and see if this channel has a session for anything var gamesPresent = bot.DiceBot.GameSessions.Where(a => a.ChannelId == channel); if (gamesPresent.Count() == 0) { messageString = "Error: No game type specified. [i]You must create a game session by specifying the game type as the first player.[/i]"; } else if (gamesPresent.Count() > 1) { messageString = "Error: You must specify a game type if more than one game session exists in the channel."; } else if (gamesPresent.Count() == 1) { GameSession sesh = gamesPresent.First(); gametype = sesh.CurrentGame; } } if (gametype != null) { if (!gametype.AllowAnte() && ante > 0) { messageString = Name + " cannot be played with ante. Try joining the game without an ante amount."; } else { GameSession sesh = bot.DiceBot.GetGameSession(channel, gametype); if (sesh != null) { ChipPile characterChips = bot.DiceBot.GetChipPile(characterName, channel); if (sesh.Players.Contains(characterName)) { messageString = Utils.GetCharacterUserTags(characterName) + " is already in " + sesh.CurrentGame.GetGameName() + "."; } else if (sesh.Players.Count > sesh.CurrentGame.GetMaxPlayers()) { messageString = Utils.GetCharacterUserTags(characterName) + " cannot join " + sesh.CurrentGame.GetGameName() + " because it is already at the [b]maximum amount of players[/b]."; } else if (ante > 0 && characterChips.Chips < ante) { messageString = Utils.GetCharacterUserTags(characterName) + " cannot make a bet for " + ante + " because they do not have enough chips."; } else { //TODO: change game join logic so that each game uses its own method to verify and add players if (gametype.GetType() == typeof(Roulette)) { #region gametype roulette RouletteBet betType = RouletteBet.NONE; int betNumber = -1; if (terms.Contains("red")) { betType = RouletteBet.Red; } else if (terms.Contains("black")) { betType = RouletteBet.Black; } else if (terms.Contains("even")) { betType = RouletteBet.Even; } else if (terms.Contains("odd")) { betType = RouletteBet.Odd; } else if (terms.Contains("first12")) { betType = RouletteBet.First12; } else if (terms.Contains("second12")) { betType = RouletteBet.Second12; } else if (terms.Contains("third12")) { betType = RouletteBet.Third12; } else if (terms.Contains("firsthalf")) { betType = RouletteBet.OneToEighteen; } else if (terms.Contains("secondhalf")) { betType = RouletteBet.NineteenToThirtySix; } else if (terms.Contains("#1")) { betType = RouletteBet.SpecificNumber; betNumber = 1; } else if (terms.Contains("#2")) { betType = RouletteBet.SpecificNumber; betNumber = 2; } else if (terms.Contains("#3")) { betType = RouletteBet.SpecificNumber; betNumber = 3; } else if (terms.Contains("#4")) { betType = RouletteBet.SpecificNumber; betNumber = 4; } else if (terms.Contains("#5")) { betType = RouletteBet.SpecificNumber; betNumber = 5; } else if (terms.Contains("#6")) { betType = RouletteBet.SpecificNumber; betNumber = 6; } else if (terms.Contains("#7")) { betType = RouletteBet.SpecificNumber; betNumber = 7; } else if (terms.Contains("#8")) { betType = RouletteBet.SpecificNumber; betNumber = 8; } else if (terms.Contains("#9")) { betType = RouletteBet.SpecificNumber; betNumber = 9; } else if (terms.Contains("#10")) { betType = RouletteBet.SpecificNumber; betNumber = 10; } else if (terms.Contains("#11")) { betType = RouletteBet.SpecificNumber; betNumber = 11; } else if (terms.Contains("#12")) { betType = RouletteBet.SpecificNumber; betNumber = 12; } else if (terms.Contains("#13")) { betType = RouletteBet.SpecificNumber; betNumber = 13; } else if (terms.Contains("#14")) { betType = RouletteBet.SpecificNumber; betNumber = 14; } else if (terms.Contains("#15")) { betType = RouletteBet.SpecificNumber; betNumber = 15; } else if (terms.Contains("#16")) { betType = RouletteBet.SpecificNumber; betNumber = 16; } else if (terms.Contains("#17")) { betType = RouletteBet.SpecificNumber; betNumber = 17; } else if (terms.Contains("#18")) { betType = RouletteBet.SpecificNumber; betNumber = 18; } else if (terms.Contains("#19")) { betType = RouletteBet.SpecificNumber; betNumber = 19; } else if (terms.Contains("#20")) { betType = RouletteBet.SpecificNumber; betNumber = 20; } else if (terms.Contains("#21")) { betType = RouletteBet.SpecificNumber; betNumber = 21; } else if (terms.Contains("#22")) { betType = RouletteBet.SpecificNumber; betNumber = 22; } else if (terms.Contains("#23")) { betType = RouletteBet.SpecificNumber; betNumber = 23; } else if (terms.Contains("#24")) { betType = RouletteBet.SpecificNumber; betNumber = 24; } else if (terms.Contains("#25")) { betType = RouletteBet.SpecificNumber; betNumber = 25; } else if (terms.Contains("#26")) { betType = RouletteBet.SpecificNumber; betNumber = 26; } else if (terms.Contains("#27")) { betType = RouletteBet.SpecificNumber; betNumber = 27; } else if (terms.Contains("#28")) { betType = RouletteBet.SpecificNumber; betNumber = 28; } else if (terms.Contains("#29")) { betType = RouletteBet.SpecificNumber; betNumber = 29; } else if (terms.Contains("#30")) { betType = RouletteBet.SpecificNumber; betNumber = 30; } else if (terms.Contains("#31")) { betType = RouletteBet.SpecificNumber; betNumber = 31; } else if (terms.Contains("#32")) { betType = RouletteBet.SpecificNumber; betNumber = 32; } else if (terms.Contains("#33")) { betType = RouletteBet.SpecificNumber; betNumber = 33; } else if (terms.Contains("#34")) { betType = RouletteBet.SpecificNumber; betNumber = 34; } else if (terms.Contains("#35")) { betType = RouletteBet.SpecificNumber; betNumber = 35; } else if (terms.Contains("#36")) { betType = RouletteBet.SpecificNumber; betNumber = 36; } if (betType == RouletteBet.NONE) { messageString = "No bet type was found in the [b]!joingame " + sesh.CurrentGame.GetGameName() + "[/b] command. Try adding a bet amount and a bet type."; } else if (ante <= 0) { messageString = "No bet amount was found in the [b]!joingame " + sesh.CurrentGame.GetGameName() + "[/b] command. Try adding a bet amount and a bet type."; } else { RouletteBetData betData = new RouletteBetData() { bet = betType, specificNumberBet = betNumber, characterName = characterName, amount = ante }; string timerString = ""; double secondsRemain = bot.DiceBot.GetSecondsRemainingOnCountdownTimer(channel, gametype.GetGameName()); if (secondsRemain > 0) { timerString = "[i] (game can begin in " + secondsRemain.ToString("N3") + " seconds)[/i]"; } string addDataString = bot.DiceBot.AddGameData(channel, gametype, betData); if (addDataString != "success") { messageString = "Error: Failed to add bet data to game session for " + gametype.GetGameName() + ". Game session terminated."; bot.DiceBot.CancelGame(channel, gametype); } else { messageString = bot.DiceBot.JoinGame(characterName, channel, gametype); messageString += "\n" + sesh.Players.Count + " / " + sesh.CurrentGame.GetMaxPlayers() + " players ready."; if (!string.IsNullOrEmpty(timerString)) { messageString += timerString; } else if (sesh.Players.Count >= sesh.CurrentGame.GetMinPlayers()) { messageString += "[b] (Ready to start!)[/b]"; } } } #endregion } else { bool anteJustSet = false; if (!sesh.AnteSet) //leave as separate if { sesh.AnteSet = true; anteJustSet = true; sesh.Ante = ante > 0 ? ante : 0; } if (anteJustSet && ante > 0 && characterChips.Chips < sesh.Ante) { messageString = Utils.GetCharacterUserTags(characterName) + " does not have [b]" + ante + " chips[/b] to start a game with an ante this high."; bot.DiceBot.RemoveGameSession(channel, sesh.CurrentGame); } else if (sesh.AnteSet && ante > 0 && sesh.Ante != ante) { messageString = "The ante for " + sesh.CurrentGame.GetGameName() + " has already been set to something else. Use [b]!joingame " + sesh.CurrentGame.GetGameName() + "[/b] without an ante."; } else if (characterChips.Chips < sesh.Ante) { messageString = Utils.GetCharacterUserTags(characterName) + " cannot join " + sesh.CurrentGame.GetGameName() + " because they have less than the ante amount of [b]" + sesh.Ante + " chips.[/b]"; } else if (sesh.Players.Contains(characterName)) { messageString = Utils.GetCharacterUserTags(characterName) + " is already in " + sesh.CurrentGame.GetGameName() + "."; } else if (sesh.Players.Count > sesh.CurrentGame.GetMaxPlayers()) { messageString = Utils.GetCharacterUserTags(characterName) + " cannot join " + sesh.CurrentGame.GetGameName() + " because it is already at the [b]maximum amount of players[/b]."; } else { messageString = bot.DiceBot.JoinGame(characterName, channel, gametype); messageString += "\n" + sesh.Players.Count + " / " + sesh.CurrentGame.GetMaxPlayers() + " players ready."; if (sesh.Players.Count >= sesh.CurrentGame.GetMinPlayers()) { messageString += "[b] (Ready to start!)[/b]"; } } } }//end too many players or player already joined } else { messageString = "Error: Game session for " + gametype.GetGameName() + " not found or created."; } //end game session null } } //end if gametype != null } bot.SendMessageInChannel(messageString, channel); } else { bot.SendMessageInChannel(Name + " is currently not allowed in this channel under " + Utils.GetCharacterUserTags("Dice Bot") + "'s settings for this channel.", channel); } }