public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { string newStatus = Utils.GetFullStringOfInputs(rawTerms); bot.SetStatus(STAStatus.Online, newStatus); bot.SendMessageInChannel("[b][ADMIN] Status updated.[/b]", channel); }
public static List <TerritoryIDType> MakePicks(BotMain bot) { if (bot.Map.IsScenarioDistribution(bot.Settings.DistributionModeID)) { var us = bot.Map.GetTerritoriesForScenario(bot.Settings.DistributionModeID, bot.GamePlayerReference.ScenarioID); if (bot.UseRandomness) { return(us.OrderByRandom().ToList()); } else { return(us.OrderBy(o => (int)o).ToList()); } } else { int maxPicks = bot.Settings.LimitDistributionTerritories == 0 ? bot.Map.Territories.Count : (bot.Settings.LimitDistributionTerritories * bot.Players.Values.Count(o => o.State == GamePlayerState.Playing)); var allAvailable = bot.DistributionStandingOpt.Territories.Values.Where(o => o.OwnerPlayerID == TerritoryStanding.AvailableForDistribution).Select(o => o.ID).ToHashSet(true); if (allAvailable.Count > 300) //if there are too many picks, it would take forever to run our weighting algorithm on all of them. Therefore, revert to just picking a single cluster of the map. { return(PickCluster.Go(bot, allAvailable, maxPicks)); } else { return(PickByWeight.Go(bot, allAvailable, maxPicks)); } } }
private void LeaveGame() { ResetGold(); ResetXp(); ZetaDia.Service.Party.LeaveGame(); BotMain.PauseWhile(() => ZetaDia.IsInGame); }
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 static Moves CalculateDefendBonusTask(BotMain state, BotBonus bonus, int maxDeployment, bool acceptNotAllDefense, BotTerritory.DeploymentType lowerConservativeLevel, BotTerritory.DeploymentType upperConservativeLevel) { var outvar = new Moves(); var threateningTerritories = GetThreateningTerritories(bonus); // First see if we can remove the threat by hitting the threatening // territory if (threateningTerritories.Count == 1) { var threatTerritory = threateningTerritories[0]; var territoriesUnderThreat = GetAmountOfTerritoriesUnderThreat(threatTerritory, bonus); if (territoriesUnderThreat >= 2 && lowerConservativeLevel != 0) { var removeThreatMoves = OneHitBreakTerritoryTask.CalculateBreakTerritoryTask(state, threatTerritory, maxDeployment, lowerConservativeLevel); if (removeThreatMoves != null) { removeThreatMoves.Orders.OfType <BotOrderAttackTransfer>().First().Message = AttackMessage.EarlyAttack; return(removeThreatMoves); } } } // If this is not possible try the classic defense var territoriesUnderThreat_1 = bonus.GetOwnedTerritoriesBorderingNeighborsOwnedByOpponent(); outvar = state.DefendTerritoriesTask.CalculateDefendTerritoriesTask(territoriesUnderThreat_1, maxDeployment, acceptNotAllDefense, lowerConservativeLevel, upperConservativeLevel); return(outvar); }
public static Moves CalculateBreakTerritoryTask(BotMain state, BotTerritory opponentTerritory, int maxDeployment, BotTerritory.DeploymentType conservativeLevel) { var outvar = new Moves(); var opponentArmies = opponentTerritory.GetArmiesAfterDeploymentAndIncomingAttacks(conservativeLevel); var neededAttackArmies = opponentTerritory.getNeededBreakArmies(opponentArmies.DefensePower); var ownedNeighbors = opponentTerritory.GetOwnedNeighbors(); var presortedOwnedNeighbors = state.TerritoryValueCalculator.SortDefenseValue(ownedNeighbors); var sortedOwnedNeighbors = BotMap.GetOrderedListOfTerritoriesByIdleArmies(presortedOwnedNeighbors); var territoryToUse = sortedOwnedNeighbors[0]; var idleArmies = territoryToUse.GetIdleArmies(); var neededDeployment = Math.Max(0, neededAttackArmies - idleArmies.AttackPower); if (neededDeployment > maxDeployment) { return(null); } if (neededDeployment > 0) { outvar.AddOrder(new BotOrderDeploy(state.Me.ID, territoryToUse, neededDeployment)); } var atm = new BotOrderAttackTransfer(state.Me.ID, territoryToUse, opponentTerritory, idleArmies.Add(new Armies(neededDeployment)), "OneHitBreakTerritoryTask"); outvar.AddOrder(atm); return(outvar); }
public static Moves CalculateNoPlanBreakBestTerritoryTask(BotMain state, int maxDeployment, List <BotTerritory> territoriesToConsider, BotMap visibleMap, BotMap workingMap, string source) { var wmOpponentTerritories = workingMap.AllOpponentTerritories.Where(o => o.IsVisible).ToList(); var vmOpponentTerritories = visibleMap.CopyTerritories(wmOpponentTerritories); var sortedOpponentTerritories = state.TerritoryValueCalculator.SortAttackValue(vmOpponentTerritories); if (territoriesToConsider != null) { var territoriesToRemove = new List <BotTerritory>(); foreach (var territory in sortedOpponentTerritories) { if (!territoriesToConsider.Contains(territory)) { territoriesToRemove.Add(territory); } } territoriesToRemove.ForEach(o => sortedOpponentTerritories.Remove(o)); } foreach (var territory_1 in sortedOpponentTerritories) { if (territory_1.IsVisible) { var breakTerritoryMoves = state.BreakTerritoryTask.CalculateBreakTerritoryTask(territory_1, maxDeployment, BotTerritory.DeploymentType.Normal, BotTerritory.DeploymentType.Normal, source); if (breakTerritoryMoves != null) { return(breakTerritoryMoves); } } } return(null); }
public static void PrintTerritories(BotMap map, BotMain BotState) { List <BotTerritory> territories = map.Territories.Values.ToList(); //List<BotTerritory> opponentTerritories = territories.Where(o => o.OwnerPlayerID == BotState.Opponents.First().ID).ToList(); AILog.Log("Debug", "Territories:"); foreach (BotTerritory territory in territories) { string player = "fog"; if (territory.OwnerPlayerID == TerritoryStanding.NeutralPlayerID) { player = "neutral"; } else if (territory.OwnerPlayerID == BotState.Me.ID) { player = "Me"; } else if (territory.OwnerPlayerID == BotState.Opponents.First().ID) { player = "opponent"; } AILog.Log("Debug", territory.Details.Name + ": (" + player + " | " + territory.IsOwnershipHeuristic + ") --> " + territory.Armies.AttackPower); } }
public static void PrintTerritoryValues(BotMap map, BotMain BotState) { //AILog.Log("Debug", "Territory attack values:"); //foreach (BotTerritory territory in map.Territories.Values) //{ // if (territory.IsVisible && BotState.IsOpponent(territory.OwnerPlayerID)) // { // AILog.Log("Debug", territory.Details.Name + ": " + territory.AttackTerritoryValue); // } //} //AILog.Log("Debug", "Territory expansion values:"); //foreach (BotTerritory territory in map.Territories.Values) //{ // if (territory.IsVisible && territory.OwnerPlayerID == TerritoryStanding.NeutralPlayerID) // { // AILog.Log("Debug", territory.Details.Name + ": " + territory.ExpansionTerritoryValue); // } //} //AILog.Log("Debug", "Territory defend values:"); //foreach (BotTerritory territory in map.Territories.Values) //{ // if (territory.OwnerPlayerID == BotState.Me.ID && territory.GetOpponentNeighbors().Count > 0) // { // AILog.Log("Debug", territory.Details.Name + ": " + territory.DefenceTerritoryValue); // } //} }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { if (rawTerms.Length < 2) { bot.SendMessageInChannel("Error: This command requires 2 terms. (Amount and chip code)", channel); } else { int chipAmount = Utils.GetNumberFromInputs(terms); string chipCode = rawTerms[1]; if (chipAmount > 0 && !string.IsNullOrEmpty(chipCode)) { bot.ChipsCoupons.Add(new ChipsCoupon() { ChipsAmount = chipAmount, Code = chipCode }); commandController.SaveCouponsToDisk(); bot.SendMessageInChannel("Added code " + chipCode + " for " + chipAmount + " chips.", channel); } else { bot.SendMessageInChannel("Error on inputs for chips code.", channel); } } }
public static void PrintDebugOutput(BotMain state) { foreach (var opp in state.Opponents) { PrintOpponentBonuses(opp.ID, state); } }
/// <summary> /// Runs the commander away from opponents /// </summary> private static void DoCommander(BotMain bot, TerritoryStanding cmdrTerritory, Commander cmdr) { var directive = CommanderDirective(bot, cmdrTerritory.ID); if (directive.HasValue) { AILog.Log("SpecialUnits", "Directive directs us to move the commander from " + bot.TerrString(cmdrTerritory.ID) + " to " + bot.TerrString(directive.Value)); if (directive.Value != cmdrTerritory.ID) { bot.Orders.AddAttack(cmdrTerritory.ID, directive.Value, AttackTransferEnum.AttackTransfer, cmdrTerritory.NumArmies.NumArmies, false, commanders: true); } bot.AvoidTerritories.Add(cmdrTerritory.ID); //add this so we don't deploy there, we want the commander to stay alone return; } var powerDiff = bot.Map.Territories[cmdrTerritory.ID].ConnectedTo.Keys .Select(o => bot.Standing.Territories[o]) .Where(o => bot.IsOpponent(o.OwnerPlayerID) && o.NumArmies.Fogged == false) .Sum(o => o.NumArmies.AttackPower) - cmdrTerritory.NumArmies.DefensePower; var toDeploy = Math.Max(0, powerDiff); if (powerDiff > 0) { if (bot.UseRandomness) { toDeploy = SharedUtility.Round(toDeploy * RandomUtility.BellRandom(0.5, 1.5)); } if (toDeploy > bot.MakeOrders.IncomeTracker.RemainingUndeployed) { toDeploy = bot.MakeOrders.IncomeTracker.RemainingUndeployed; } if (toDeploy > 0 && bot.Orders.TryDeploy(cmdrTerritory.ID, toDeploy)) { AILog.Log("SpecialUnits", "Deployed " + toDeploy + " to defend commander"); } } //Consider this territory and all adjacent territories. Which is the furthest from any enemy? var terrDistances = bot.Map.Territories[cmdrTerritory.ID].ConnectedTo.Keys.ConcatOne(cmdrTerritory.ID) .Where(o => bot.Standing.Territories[o].OwnerPlayerID == bot.PlayerID || bot.Standing.Territories[o].NumArmies.DefensePower <= 4) //don't go somewhere that's defended heavily .ToDictionary(o => o, o => bot.DistanceFromEnemy(o)); AILog.Log("SpecialUnits", "Commander run options: " + terrDistances.Select(o => bot.TerrString(o.Key) + " dist=" + o.Value).JoinStrings(", ")); var sorted = terrDistances.OrderByDescending(o => o.Value).ToList(); sorted.RemoveWhere(o => o.Value < sorted[0].Value); var runTo = bot.UseRandomness ? sorted.Random().Key : sorted[0].Key; if (runTo == cmdrTerritory.ID) { return; //already there } AILog.Log("SpecialUnits", "Moving commander from " + bot.TerrString(cmdrTerritory.ID) + " to " + bot.TerrString(runTo)); bot.Orders.AddAttack(cmdrTerritory.ID, runTo, AttackTransferEnum.AttackTransfer, cmdrTerritory.NumArmies.NumArmies + toDeploy, false, commanders: true); }
public static void CleanupMoves(BotMain state, Moves moves) { Debug.Debug.PrintMoves(state, moves); DeleteOldMovesFromMap(state); MergeMoves(state, moves); state.MapUpdater.UpdateMap(state.WorkingMap); }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { string characterDrawName = commandController.GetCharacterDrawNameFromCommandTerms(characterName, terms); DeckType deckType = commandController.GetDeckTypeFromCommandTerms(terms); string customDeckName = Utils.GetCustomDeckName(characterName); string deckTypeString = Utils.GetDeckTypeStringHidePlaying(deckType, customDeckName); Hand h = bot.DiceBot.GetHand(channel, deckType, characterDrawName); string displayName = characterDrawName; if (displayName.Contains(DiceBot.PlaySuffix)) { displayName = displayName.Replace(DiceBot.PlaySuffix, ""); } string outputString = "[i]" + deckTypeString + "Showing [user]" + displayName + "[/user]'s " + h.GetCollectionName() + ": [/i]" + h.ToString(); if (characterDrawName == DiceBot.BurnCardsName) { outputString = "[i]" + deckTypeString + "Showing burned cards: [/i]" + h.ToString(); } else if (characterDrawName == DiceBot.DealerName) { outputString = "[i]" + deckTypeString + "Showing the dealer's hand: [/i]" + h.ToString(); } else if (characterDrawName == DiceBot.DiscardName) { outputString = "[i]" + deckTypeString + "Showing discarded cards: [/i]" + h.ToString(); } bot.SendMessageInChannel(outputString, channel); }
public static Moves CalculatePreventBonusTask(BotMain state, BotBonus bonusToPrevent, PlayerIDType opponentID, int maxDeployment, BotTerritory.DeploymentType conservativeLevel) { var territoriesToPrevent = bonusToPrevent.GetOwnedTerritories(); var opponentAttacks = PreventTerritoriesTask.CalculateGuessedOpponentTakeOverMoves(state, territoriesToPrevent, opponentID, true, conservativeLevel); if (opponentAttacks == null) { return(new Moves()); } var preventTerritoryMovesByDeploying = PreventTerritoriesTask.CalculatePreventTerritoriesTask(state, territoriesToPrevent, opponentID, maxDeployment, conservativeLevel); var visibleOpponentTerritories = bonusToPrevent.GetVisibleOpponentTerritories(); var breakBestTerritoryMoves = NoPlanBreakBestTerritoryTask.CalculateNoPlanBreakBestTerritoryTask(state, maxDeployment, visibleOpponentTerritories, state.VisibleMap, state.WorkingMap, "PreventBonusTask"); if (breakBestTerritoryMoves == null) { return(preventTerritoryMovesByDeploying); } else if (breakBestTerritoryMoves.GetTotalDeployment() <= preventTerritoryMovesByDeploying.GetTotalDeployment()) { return(breakBestTerritoryMoves); } else { return(preventTerritoryMovesByDeploying); } }
private static List <BotTerritory> GetPossibleTerritoriesToAttack(BotMain state, bool attackLowImportantTerritories, bool attackMediumImportantTerritories, bool attackHighImportantTerritories) { var possibleCandidates = new List <BotTerritory>(); foreach (var territory in state.VisibleMap.AllOpponentTerritories) { if (territory.IsVisible) { if (territory.AttackTerritoryValue >= TerritoryValueCalculator.LOWEST_HIGH_PRIORITY_VALUE && attackHighImportantTerritories) { possibleCandidates.Add(territory); } else if (territory.AttackTerritoryValue >= TerritoryValueCalculator.LOWEST_MEDIUM_PRIORITY_VALUE && attackMediumImportantTerritories) { possibleCandidates.Add(territory); } else if (attackLowImportantTerritories) { possibleCandidates.Add(territory); } } } var outvar = new List <BotTerritory>(); foreach (var territory_1 in possibleCandidates) { if (territory_1.Armies.DefensePower <= 2 && territory_1.IncomingMoves.None(o => o.Armies.AttackPower > 1)) { outvar.Add(territory_1); } } return(outvar); }
public static Moves CalculateTransferMoves2(BotMain state) { var outvar = new Moves(); foreach (var territory in state.VisibleMap.GetOwnedTerritories()) { if (territory.GetIdleArmies().IsEmpty == false && territory.GetOpponentNeighbors().Count == 0) { var ownedNeighbors = GetOwnedNeighborsAfterExpansion(state, territory); if (ownedNeighbors.Count > 0) { var bestNeighbor = territory; foreach (var neighbor in ownedNeighbors) { bestNeighbor = GetCloserTerritory(bestNeighbor, neighbor); } if (bestNeighbor != territory) { var atm = new BotOrderAttackTransfer(state.Me.ID, territory, bestNeighbor, territory.GetIdleArmies(), "TransferMovesChooser2"); outvar.AddOrder(atm); } } } } return(outvar); }
public static void SetConfirmedPicks(BotMain bot) { List <TerritoryIDType> chosenPicks = new List <TerritoryIDType>(); foreach (BotTerritory terr in bot.VisibleMap.Territories.Values) { if (terr.OwnerPlayerID == bot.Me.ID) { chosenPicks.Add(terr.ID); } } SetChosenPickList(chosenPicks); List <TerritoryIDType> enemyPicks = new List <TerritoryIDType>(); int chosenFound = 0; foreach (TerritoryIDType terrId in _picks) { if (chosenFound > 2) { break; } if (_chosenPicks.Contains(terrId)) { chosenFound++; } else { enemyPicks.Add(terrId); } } SetEnemyPickList(enemyPicks); Memory.CycleTracker.SetCyclePicks(_picks, _chosenPicks); }
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); } }
private static bool PlayBombCard(BotMain bot, CardInstance card) { var allBombableEnemyTerritories = bot.Standing.Territories.Values .Where(o => o.OwnerPlayerID == bot.PlayerID) .SelectMany(o => bot.Map.Territories[o.ID].ConnectedTo.Keys) .Distinct() .Select(o => bot.Standing.Territories[o]) .Where(o => bot.IsOpponent(o.OwnerPlayerID) && o.NumArmies.Fogged == false) .ToList(); var minArmies = !bot.UseRandomness ? bot.BaseIncome.Total * 2 : SharedUtility.Round(bot.BaseIncome.Total * RandomUtility.BellRandom(1, 3)); var weights = allBombableEnemyTerritories.Where(o => o.NumArmies.NumArmies > minArmies).ToDictionary(o => o.ID, o => o.NumArmies.NumArmies - minArmies); if (weights.Count == 0) { return(false); } var bomb = bot.UseRandomness ? RandomUtility.WeightedRandom(weights.Keys, o => weights[o]) : weights.OrderByDescending(o => o.Value).First().Key; AILog.Log("PlayCards", "Bombing " + bot.TerrString(bomb)); bot.Orders.AddOrder(GameOrderPlayCardBomb.Create(card.ID, bot.PlayerID, bomb)); return(true); }
private static void MergeMoves(BotMain state, Moves moves) { var deployedTo = new HashSet <TerritoryIDType>(); var attackedBetween = new HashSet <KeyValuePair <TerritoryIDType, TerritoryIDType> >(); for (int i = 0; i < moves.Orders.Count; i++) { var order = moves.Orders[i]; if (order is BotOrderDeploy) { var deploy = (BotOrderDeploy)order; if (deploy.Armies <= 0) { moves.Orders.RemoveAt(i); i--; } else if (deployedTo.Contains(deploy.Territory.ID)) { moves.Orders.OfType <BotOrderDeploy>().First(o => o.Territory.ID == deploy.Territory.ID).Armies += deploy.Armies; moves.Orders.RemoveAt(i); i--; } else { deployedTo.Add(deploy.Territory.ID); } } else if (order is BotOrderAttackTransfer) { var attack = (BotOrderAttackTransfer)order; var key = new KeyValuePair <TerritoryIDType, TerritoryIDType>(attack.From.ID, attack.To.ID); if (attack.Armies.IsEmpty) { moves.Orders.RemoveAt(i); i--; } else if (attackedBetween.Contains(key)) { var existing = moves.Orders.OfType <BotOrderAttackTransfer>().First(o => o.From == attack.From && o.To == attack.To); existing.Armies = existing.Armies.Add(attack.Armies); if (existing.Message == AttackMessage.None) { existing.Message = attack.Message; } moves.Orders.RemoveAt(i); i--; } else { attackedBetween.Add(key); } } } MovesCommitter.CommittMoves(state, moves); }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { CardCommandOptions options = new CardCommandOptions(commandController, terms, characterName); int numberDrawn = Utils.GetNumberFromInputs(terms); if (numberDrawn > 1) { options.cardsS = "s"; } string customDeckName = Utils.GetCustomDeckName(characterName); string deckTypeString = Utils.GetDeckTypeStringHidePlaying(options.deckType, customDeckName); string cardDrawingCharacterString = Utils.GetCharacterStringFromSpecialName(options.characterDrawName); string trueDraw = ""; string drawOutput = bot.DiceBot.DrawCards(numberDrawn, options.jokers, options.deckDraw, channel, options.deckType, options.characterDrawName, options.secretDraw, out trueDraw); string channelMessageOutput = "[i]" + cardDrawingCharacterString + ": " + deckTypeString + "Card" + options.cardsS + " drawn:[/i] " + drawOutput; if (options.secretDraw && !(options.characterDrawName == DiceBot.DealerName || options.characterDrawName == DiceBot.BurnCardsName || options.characterDrawName == DiceBot.DiscardName)) { string playerMessageOutput = "[i]" + cardDrawingCharacterString + ": " + deckTypeString + "Card" + options.cardsS + " drawn:[/i] " + trueDraw; bot.SendPrivateMessage(playerMessageOutput, characterName); } bot.SendMessageInChannel(channelMessageOutput, channel); }
public static Moves CalculateMoveIdleArmiesTask(BotMain state) { var outvar = new Moves(); foreach (var ownedTerritory in state.VisibleMap.GetOwnedTerritories()) { var outgoingMoves = ownedTerritory.OutgoingMoves; BotOrderAttackTransfer mostImportantMove = null; var currentHighestValue = -1; foreach (var atm in outgoingMoves) { if (state.IsOpponent(atm.To.OwnerPlayerID) && atm.Armies.AttackPower > 1 && atm.Message != AttackMessage.TryoutAttack) { var attackValue = atm.To.AttackTerritoryValue; if (attackValue > currentHighestValue) { currentHighestValue = attackValue; mostImportantMove = atm; } } } var idleArmies = ownedTerritory.GetIdleArmies(); if (mostImportantMove != null && idleArmies.IsEmpty == false) { var atm_1 = new BotOrderAttackTransfer(state.Me.ID, ownedTerritory, mostImportantMove.To, ownedTerritory.GetIdleArmies(), "MoveIdleArmiesTask1"); outvar.AddOrder(atm_1); } } return(outvar); }
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) { if (command.ops == null) { bot.RequestChannelOpListAndQueueFurtherRequest(new UserGeneratedCommand() { channel = channel, terms = terms, rawTerms = rawTerms, ops = null, characterName = characterName, commandName = Name }); } else { Console.WriteLine("Channeloprequest completing"); string[] opsList = command.ops; string output = ""; if (opsList == null) { output = "opslist was null"; } else { output = Utils.PrintList(opsList); output += " " + Utils.GetCharacterUserTags(characterName) + " is an op? " + opsList.Contains(characterName); } bot.SendMessageInChannel("[b][ADMIN] [/b]" + output, channel); } }
static void DeployRemainingFreeArmies(BotMain bot) { var count = bot.MakeOrders.IncomeTracker.FreeArmiesUndeployed; if (count == 0) { return; } var ourTerritories = bot.Standing.Territories.Values.Where(o => o.OwnerPlayerID == bot.PlayerID).Select(o => o.ID).ToList(); if (ourTerritories.Count == 0) { return; } if (bot.BorderTerritories.Any()) { Deploy(bot, "DeployRemainingFreeArmies borders", bot.BorderTerritories.Select(o => o.ID), count); } else { Deploy(bot, "DeployRemainingFreeArmies all", ourTerritories, count); } }
public override void Run(BotMain bot, BotCommandController commandController, string[] rawTerms, string[] terms, string characterName, string channel, UserGeneratedCommand command) { string customDeckName = Utils.GetCustomDeckName(characterName); SavedDeck deleteDeck = Utils.GetDeckFromId(bot.SavedDecks, customDeckName); string sendMessage = "No decks found for [user]" + characterName + "[/user]"; if (deleteDeck != null) { if (characterName == deleteDeck.OriginCharacter) { bot.SavedDecks.Remove(deleteDeck); sendMessage = "[b]" + deleteDeck.DeckId + "[/b] deleted by [user]" + characterName + "[/user]"; Utils.WriteToFileAsData(bot.SavedDecks, Utils.GetTotalFileName(BotMain.FileFolder, BotMain.SavedDecksFileName)); } else { sendMessage = "Only " + deleteDeck.OriginCharacter + " can delete their own saved deck."; } } bot.SendMessageInChannel(sendMessage, channel); }
/// <summary> /// Figure out which one of the territories in terrs most needs deployments, and deploy there. Will also add to attacks from that territory if necessary. /// </summary> /// <param name="bot"></param> /// <param name="source">Just for debugging</param> /// <param name="terrs"></param> /// <param name="armies">Number of armies to deploy</param> private static void Deploy(BotMain bot, string source, IEnumerable <TerritoryIDType> terrs, int armies) { var canDeployOn = terrs.Where(o => bot.AvoidTerritories.Contains(o) == false).ToList(); if (canDeployOn.Count == 0) { canDeployOn = terrs.ToList(); //if we can't deploy otherwise, ignore AvoidTerritories } Assert.Fatal(canDeployOn.Count > 0, "No deploy options"); if (!bot.UseRandomness) { DeployExact(bot, source, canDeployOn, armies); } else { //In randomness, break the deployment up into chunks (we could just call it on every army individually, but that's inefficient when our income gets very high) var chunkSize = Math.Max(1, (int)(armies / 10)); var armiesDone = 0; while (armiesDone < armies) { var deploy = Math.Min(armies - armiesDone, chunkSize); DeployExact(bot, source, canDeployOn, deploy); armiesDone += deploy; } } }
private void PauseWhileMouseDown() { if (Core.Settings.Advanced.LazyRaider && !BotMain.IsPaused && MouseLeft()) { BotMain.PauseWhile(MouseLeft); } }
public static Moves CalculateGuessedOpponentTakeOverMoves(BotMain state, List <BotTerritory> territories, PlayerIDType opponentID, bool doesOpponentDeploy, BotTerritory.DeploymentType conservativeLevel) { var opponentIncome = state.Settings.MinimumArmyBonus; if (conservativeLevel == BotTerritory.DeploymentType.Conservative) { opponentIncome = state.GetGuessedOpponentIncome(opponentID, state.VisibleMap); } var ownedTerritories = territories.Where(o => o.OwnerPlayerID == state.Me.ID).ToList(); var opponentAttacks = CalculateMinimumOpponentMoves(state, opponentID, ownedTerritories, conservativeLevel); if (opponentAttacks.GetTotalDeployment() > opponentIncome) { return(null); } if (doesOpponentDeploy) { var remainingOpponentIncome = opponentIncome - opponentAttacks.GetTotalDeployment(); while (remainingOpponentIncome > 0 && opponentAttacks.Orders.OfType <BotOrderAttackTransfer>().Any()) { foreach (var atm in opponentAttacks.Orders.OfType <BotOrderAttackTransfer>()) { atm.Armies = atm.Armies.Add(new Armies(1)); remainingOpponentIncome--; if (remainingOpponentIncome == 0) { break; } } } } return(opponentAttacks); }