Commit 42d05cff authored by mercury233's avatar mercury233

record activated count to prevent infinite actions

parent 1371c7dc
...@@ -83,18 +83,10 @@ namespace WindBot.Game.AI.Decks ...@@ -83,18 +83,10 @@ namespace WindBot.Game.AI.Decks
private int m_swapFrogSummoned; private int m_swapFrogSummoned;
private int m_flipFlopFrogSummoned; private int m_flipFlopFrogSummoned;
private int m_treebornFrogCount = 0;
public override void OnNewTurn()
{
m_treebornFrogCount = 0;
base.OnNewTurn();
}
private bool TreebornFrog() private bool TreebornFrog()
{ {
m_treebornFrogCount++; return true;
return m_treebornFrogCount <= 5;
} }
private bool SwapFrogSummon() private bool SwapFrogSummon()
......
...@@ -184,7 +184,6 @@ namespace WindBot.Game.AI.Decks ...@@ -184,7 +184,6 @@ namespace WindBot.Game.AI.Decks
private bool JetSynchronUsed = false; private bool JetSynchronUsed = false;
private bool ScrapWyvernUsed = false; private bool ScrapWyvernUsed = false;
private bool MaskedChameleonUsed = false; private bool MaskedChameleonUsed = false;
private int ShootingRiserDragonCount = 0;
private int[] HandCosts = new[] private int[] HandCosts = new[]
{ {
...@@ -218,7 +217,6 @@ namespace WindBot.Game.AI.Decks ...@@ -218,7 +217,6 @@ namespace WindBot.Game.AI.Decks
JetSynchronUsed = false; JetSynchronUsed = false;
ScrapWyvernUsed = false; ScrapWyvernUsed = false;
MaskedChameleonUsed = false; MaskedChameleonUsed = false;
ShootingRiserDragonCount = 0;
} }
public override void OnChainEnd() public override void OnChainEnd()
...@@ -845,9 +843,8 @@ namespace WindBot.Game.AI.Decks ...@@ -845,9 +843,8 @@ namespace WindBot.Game.AI.Decks
} }
else else
{ {
if (Duel.LastChainPlayer == 0 || ShootingRiserDragonCount >= 10) if (Duel.LastChainPlayer == 0)
return false; return false;
ShootingRiserDragonCount++;
AI.SelectCard(new[] { AI.SelectCard(new[] {
CardId.BlackRoseMoonlightDragon, CardId.BlackRoseMoonlightDragon,
CardId.ScrapDragon, CardId.ScrapDragon,
......
...@@ -230,7 +230,6 @@ namespace WindBot.Game.AI.Decks ...@@ -230,7 +230,6 @@ namespace WindBot.Game.AI.Decks
} }
int Ultimate_ss = 0; int Ultimate_ss = 0;
int Enemy_atk = 0; int Enemy_atk = 0;
int TG_WonderMagician_count = 0;
bool Pillused = false; bool Pillused = false;
bool CrystronNeedlefibereff_used = false; bool CrystronNeedlefibereff_used = false;
bool OvertexCoatlseff_used = false; bool OvertexCoatlseff_used = false;
...@@ -275,7 +274,6 @@ namespace WindBot.Game.AI.Decks ...@@ -275,7 +274,6 @@ namespace WindBot.Game.AI.Decks
ShaddollSquamata_used = false; ShaddollSquamata_used = false;
ShaddollDragon_used = false; ShaddollDragon_used = false;
ShaddollHedgehog_used = false; ShaddollHedgehog_used = false;
TG_WonderMagician_count = 0;
} }
private bool Luminasummon() private bool Luminasummon()
...@@ -576,8 +574,7 @@ namespace WindBot.Game.AI.Decks ...@@ -576,8 +574,7 @@ namespace WindBot.Game.AI.Decks
private bool TG_WonderMagicianeff() private bool TG_WonderMagicianeff()
{ {
TG_WonderMagician_count++; return true;
return TG_WonderMagician_count <= 10;
} }
private bool AllureofDarkness() private bool AllureofDarkness()
{ {
......
...@@ -181,7 +181,6 @@ namespace WindBot.Game.AI.Decks ...@@ -181,7 +181,6 @@ namespace WindBot.Game.AI.Decks
private bool CymbalSkeletonUsed = false; private bool CymbalSkeletonUsed = false;
private bool BorrelswordDragonUsed = false; private bool BorrelswordDragonUsed = false;
private ClientCard RustyBardicheTarget = null; private ClientCard RustyBardicheTarget = null;
private int ShootingRiserDragonCount = 0;
private int[] HandCosts = new[] private int[] HandCosts = new[]
{ {
...@@ -215,7 +214,6 @@ namespace WindBot.Game.AI.Decks ...@@ -215,7 +214,6 @@ namespace WindBot.Game.AI.Decks
CymbalSkeletonUsed = false; CymbalSkeletonUsed = false;
BorrelswordDragonUsed = false; BorrelswordDragonUsed = false;
RustyBardicheTarget = null; RustyBardicheTarget = null;
ShootingRiserDragonCount = 0;
} }
public override void OnChainEnd() public override void OnChainEnd()
...@@ -611,10 +609,7 @@ namespace WindBot.Game.AI.Decks ...@@ -611,10 +609,7 @@ namespace WindBot.Game.AI.Decks
} }
else else
{ {
if (Duel.LastChainPlayer == 0) return Duel.LastChainPlayer != 0;
return false;
ShootingRiserDragonCount++;
return ShootingRiserDragonCount <= 10;
} }
} }
...@@ -825,8 +820,8 @@ namespace WindBot.Game.AI.Decks ...@@ -825,8 +820,8 @@ namespace WindBot.Game.AI.Decks
if (ActivateDescription == 96) if (ActivateDescription == 96)
{ {
// TODO: more FogBlade lost target // TODO: more FogBlade lost target
if ((Duel.Phase == DuelPhase.Main1 || Duel.Phase == DuelPhase.Main2) && Duel.CurrentChain.Count == 0) if ((Duel.Phase == DuelPhase.Main1 || Duel.Phase == DuelPhase.Main2) && Duel.CurrentChain.Count == 0)
return false; return false;
AI.SelectCard(CardId.OrcustCymbalSkeleton); AI.SelectCard(CardId.OrcustCymbalSkeleton);
return true; return true;
} }
...@@ -1130,22 +1125,22 @@ namespace WindBot.Game.AI.Decks ...@@ -1130,22 +1125,22 @@ namespace WindBot.Game.AI.Decks
{ {
return Duel.LastChainPlayer == 1; return Duel.LastChainPlayer == 1;
} }
else if (Duel.Phase == DuelPhase.End) else if (Duel.Phase == DuelPhase.End)
{ {
ClientCard target = null; ClientCard target = null;
target = Bot.Banished.GetFirstMatchingFaceupCard(card=>card.IsCode(CardId.OrcustCymbalSkeleton)); target = Bot.Banished.GetFirstMatchingFaceupCard(card=>card.IsCode(CardId.OrcustCymbalSkeleton));
if (target == null) if (target == null)
target = Bot.Banished.GetFirstMatchingFaceupCard(card => card.IsCode(CardId.OrcustHarpHorror)); target = Bot.Banished.GetFirstMatchingFaceupCard(card => card.IsCode(CardId.OrcustHarpHorror));
if (target != null) if (target != null)
{ {
AI.SelectCard(target); AI.SelectCard(target);
return true; return true;
} }
if(!Bot.HasInHand(CardId.OrcustHarpHorror) && Bot.GetRemainingCount(CardId.OrcustHarpHorror, 2) > 1) if(!Bot.HasInHand(CardId.OrcustHarpHorror) && Bot.GetRemainingCount(CardId.OrcustHarpHorror, 2) > 1)
{ {
AI.SelectCard(CardId.OrcustHarpHorror); AI.SelectCard(CardId.OrcustHarpHorror);
return true; return true;
} }
} }
return false; return false;
} }
......
...@@ -117,13 +117,11 @@ namespace WindBot.Game.AI.Decks ...@@ -117,13 +117,11 @@ namespace WindBot.Game.AI.Decks
bool summon_used = false; bool summon_used = false;
bool CardOfDemiseeff_used = false; bool CardOfDemiseeff_used = false;
bool SeaStealthAttackeff_used = false; bool SeaStealthAttackeff_used = false;
int City_count = 0;
public override void OnNewTurn() public override void OnNewTurn()
{ {
summon_used = false; summon_used = false;
CardOfDemiseeff_used = false; CardOfDemiseeff_used = false;
SeaStealthAttackeff_used = false; SeaStealthAttackeff_used = false;
City_count = 0;
base.OnNewTurn(); base.OnNewTurn();
} }
private bool PreventFeatherDustereff() private bool PreventFeatherDustereff()
...@@ -356,9 +354,6 @@ namespace WindBot.Game.AI.Decks ...@@ -356,9 +354,6 @@ namespace WindBot.Game.AI.Decks
} }
else else
{ {
if (City_count > 10)
return false;
ClientCard target = null; ClientCard target = null;
foreach(ClientCard s in Bot.GetSpells()) foreach(ClientCard s in Bot.GetSpells())
{ {
...@@ -380,7 +375,6 @@ namespace WindBot.Game.AI.Decks ...@@ -380,7 +375,6 @@ namespace WindBot.Game.AI.Decks
break; break;
} }
} }
City_count++;
AI.SelectPlace(Zones.z1 | Zones.z3); AI.SelectPlace(Zones.z1 | Zones.z3);
AI.SelectCard(CardId.PhantasmSprialBattle); AI.SelectCard(CardId.PhantasmSprialBattle);
return true; return true;
......
...@@ -215,8 +215,7 @@ namespace WindBot.Game.AI.Decks ...@@ -215,8 +215,7 @@ namespace WindBot.Game.AI.Decks
private bool Summon_used; private bool Summon_used;
private bool Pilica_eff; private bool Pilica_eff;
private bool plan_A; private bool plan_A;
private int SnowBell_count = 0;
//TODO: reset the flags when they should reset ( public override void OnNewTurn() )
public PureWindsExecutor(GameAI ai, Duel duel) public PureWindsExecutor(GameAI ai, Duel duel)
: base(ai, duel) : base(ai, duel)
{ {
...@@ -302,7 +301,6 @@ namespace WindBot.Game.AI.Decks ...@@ -302,7 +301,6 @@ namespace WindBot.Game.AI.Decks
Summon_used = false; Summon_used = false;
Pilica_eff = false; Pilica_eff = false;
plan_A = false; plan_A = false;
SnowBell_count = 0;
base.OnNewTurn(); base.OnNewTurn();
} }
private bool windaset() private bool windaset()
...@@ -770,7 +768,6 @@ namespace WindBot.Game.AI.Decks ...@@ -770,7 +768,6 @@ namespace WindBot.Game.AI.Decks
private bool WindwitchSnowBellsp() private bool WindwitchSnowBellsp()
{ {
if (SnowBell_count >= 5) return false;
if ((Bot.HasInMonstersZone(CardId.CrystalWingSynchroDragon) || if ((Bot.HasInMonstersZone(CardId.CrystalWingSynchroDragon) ||
Bot.HasInMonstersZone(CardId.DaigustoSphreez) || Bot.HasInMonstersZone(CardId.DaigustoSphreez) ||
Bot.HasInMonstersZone(CardId.MistWurm)) && Bot.HasInMonstersZone(CardId.MistWurm)) &&
...@@ -786,7 +783,6 @@ namespace WindBot.Game.AI.Decks ...@@ -786,7 +783,6 @@ namespace WindBot.Game.AI.Decks
(Util.GetBotAvailZonesFromExtraDeck() == 0)) (Util.GetBotAvailZonesFromExtraDeck() == 0))
return false; return false;
AI.SelectPosition(CardPosition.FaceUpDefence); AI.SelectPosition(CardPosition.FaceUpDefence);
SnowBell_count++;
return true; return true;
} }
private bool DaigustoSphreezsp() private bool DaigustoSphreezsp()
......
...@@ -73,7 +73,6 @@ namespace WindBot.Game.AI.Decks ...@@ -73,7 +73,6 @@ namespace WindBot.Game.AI.Decks
bool snake_four_s = false; bool snake_four_s = false;
bool tuner_eff_used = false; bool tuner_eff_used = false;
bool crystal_eff_used = false; bool crystal_eff_used = false;
int red_ss_count = 0;
bool white_eff_used = false; bool white_eff_used = false;
bool lockbird_useful = false; bool lockbird_useful = false;
bool lockbird_used = false; bool lockbird_used = false;
...@@ -758,7 +757,6 @@ namespace WindBot.Game.AI.Decks ...@@ -758,7 +757,6 @@ namespace WindBot.Game.AI.Decks
public bool Red_ss() public bool Red_ss()
{ {
if (red_ss_count >= 6) return false;
if ((Util.ChainContainsCard(CardId.DarkHole) || Util.ChainContainsCard(99330325) || Util.ChainContainsCard(53582587)) && Util.ChainContainsCard(CardId.Red)) return false; if ((Util.ChainContainsCard(CardId.DarkHole) || Util.ChainContainsCard(99330325) || Util.ChainContainsCard(53582587)) && Util.ChainContainsCard(CardId.Red)) return false;
if (Duel.LastChainPlayer == 0 && Util.GetLastChainCard().IsCode(CardId.Red)) if (Duel.LastChainPlayer == 0 && Util.GetLastChainCard().IsCode(CardId.Red))
{ {
...@@ -766,7 +764,6 @@ namespace WindBot.Game.AI.Decks ...@@ -766,7 +764,6 @@ namespace WindBot.Game.AI.Decks
{ {
if (Util.IsChainTarget(m) && IsTrickstar(m.Id)) if (Util.IsChainTarget(m) && IsTrickstar(m.Id))
{ {
red_ss_count += 1;
AI.SelectCard(m); AI.SelectCard(m);
Red_SelectPos(); Red_SelectPos();
return true; return true;
...@@ -789,7 +786,6 @@ namespace WindBot.Game.AI.Decks ...@@ -789,7 +786,6 @@ namespace WindBot.Game.AI.Decks
{ {
AI.SelectCard(c); AI.SelectCard(c);
Red_SelectPos(c); Red_SelectPos(c);
red_ss_count += 1;
return true; return true;
} }
if (c.IsCode(CardId.Pink)) return false; if (c.IsCode(CardId.Pink)) return false;
...@@ -800,14 +796,12 @@ namespace WindBot.Game.AI.Decks ...@@ -800,14 +796,12 @@ namespace WindBot.Game.AI.Decks
if (tosolve_enemy.Attack > 3200) AI.SelectPosition(CardPosition.FaceUpDefence); if (tosolve_enemy.Attack > 3200) AI.SelectPosition(CardPosition.FaceUpDefence);
AI.SelectCard(c); AI.SelectCard(c);
Red_SelectPos(c); Red_SelectPos(c);
red_ss_count += 1;
return true; return true;
} }
if (!Bot.HasInHand(CardId.White) && tosolve_enemy.Attack <= 3200 && c.IsCode(CardId.White)) if (!Bot.HasInHand(CardId.White) && tosolve_enemy.Attack <= 3200 && c.IsCode(CardId.White))
{ {
AI.SelectCard(c); AI.SelectCard(c);
Red_SelectPos(c); Red_SelectPos(c);
red_ss_count += 1;
return true; return true;
} }
if (!Bot.HasInHand(CardId.White) && c.Attack < tosolve_enemy.Attack) if (!Bot.HasInHand(CardId.White) && c.Attack < tosolve_enemy.Attack)
...@@ -824,7 +818,6 @@ namespace WindBot.Game.AI.Decks ...@@ -824,7 +818,6 @@ namespace WindBot.Game.AI.Decks
if (tosolve_enemy.Attack > 1600) AI.SelectPosition(CardPosition.FaceUpDefence); if (tosolve_enemy.Attack > 1600) AI.SelectPosition(CardPosition.FaceUpDefence);
AI.SelectCard(c); AI.SelectCard(c);
Red_SelectPos(c); Red_SelectPos(c);
red_ss_count += 1;
return true; return true;
} }
} }
...@@ -845,7 +838,6 @@ namespace WindBot.Game.AI.Decks ...@@ -845,7 +838,6 @@ namespace WindBot.Game.AI.Decks
{ {
AI.SelectCard(card); AI.SelectCard(card);
Red_SelectPos(card); Red_SelectPos(card);
red_ss_count += 1;
return true; return true;
} }
} }
...@@ -1710,7 +1702,6 @@ namespace WindBot.Game.AI.Decks ...@@ -1710,7 +1702,6 @@ namespace WindBot.Game.AI.Decks
pink_ss = false; pink_ss = false;
snake_four_s = false; snake_four_s = false;
crystal_eff_used = false; crystal_eff_used = false;
red_ss_count = 0;
white_eff_used = false; white_eff_used = false;
lockbird_useful = false; lockbird_useful = false;
lockbird_used = false; lockbird_used = false;
......
...@@ -197,7 +197,6 @@ namespace WindBot.Game.AI.Decks ...@@ -197,7 +197,6 @@ namespace WindBot.Game.AI.Decks
bool MagicianRightHand_used = false; bool MagicianRightHand_used = false;
ClientCard MagiciansLeftHand_negate = null; ClientCard MagiciansLeftHand_negate = null;
ClientCard MagicianRightHand_negate = null; ClientCard MagicianRightHand_negate = null;
int PSYOmega_count = 0;
// go first // go first
public override bool OnSelectHand() public override bool OnSelectHand()
...@@ -271,7 +270,6 @@ namespace WindBot.Game.AI.Decks ...@@ -271,7 +270,6 @@ namespace WindBot.Game.AI.Decks
public override void OnNewTurn() public override void OnNewTurn()
{ {
CrossoutDesignatorTarget = 0; CrossoutDesignatorTarget = 0;
PSYOmega_count = 0;
MadameVerreGainedATK = false; MadameVerreGainedATK = false;
summoned = false; summoned = false;
enemy_activate_MaxxC = false; enemy_activate_MaxxC = false;
...@@ -2501,20 +2499,15 @@ namespace WindBot.Game.AI.Decks ...@@ -2501,20 +2499,15 @@ namespace WindBot.Game.AI.Decks
// recycle from grave // recycle from grave
if (Card.Location == CardLocation.Grave) if (Card.Location == CardLocation.Grave)
{ {
if (PSYOmega_count >= 5){
return false;
}
List<ClientCard> enemy_danger = CheckDangerousCardinEnemyGrave(); List<ClientCard> enemy_danger = CheckDangerousCardinEnemyGrave();
if (enemy_danger.Count > 0) if (enemy_danger.Count > 0)
{ {
AI.SelectCard(enemy_danger); AI.SelectCard(enemy_danger);
PSYOmega_count ++;
return true; return true;
} }
if (!Bot.HasInHandOrInSpellZoneOrInGraveyard(CardId.Holiday) && Bot.HasInGraveyard(important_witchcraft)) if (!Bot.HasInHandOrInSpellZoneOrInGraveyard(CardId.Holiday) && Bot.HasInGraveyard(important_witchcraft))
{ {
AI.SelectCard(important_witchcraft); AI.SelectCard(important_witchcraft);
PSYOmega_count ++;
return true; return true;
} }
if (CheckProblematicCards() == null) if (CheckProblematicCards() == null)
...@@ -2523,7 +2516,6 @@ namespace WindBot.Game.AI.Decks ...@@ -2523,7 +2516,6 @@ namespace WindBot.Game.AI.Decks
CardId.MaxxC, CardId.AshBlossom_JoyousSpring, CardId.MaxxC, CardId.AshBlossom_JoyousSpring,
CardId.MagicianRightHand, CardId.MagiciansLeftHand, CardId.MagiciansRestage, CardId.Patronus, CardId.MagicianRightHand, CardId.MagiciansLeftHand, CardId.MagiciansRestage, CardId.Patronus,
CardId.LightningStorm, CardId.Reasoning); CardId.LightningStorm, CardId.Reasoning);
PSYOmega_count ++;
return true; return true;
} }
} }
......
...@@ -100,6 +100,7 @@ namespace WindBot.Game.AI.Decks ...@@ -100,6 +100,7 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.Summon, CardId.Goblindbergh); AddExecutor(ExecutorType.Summon, CardId.Goblindbergh);
AddExecutor(ExecutorType.Summon, CardId.TinGoldfish); AddExecutor(ExecutorType.Summon, CardId.TinGoldfish);
AddExecutor(ExecutorType.Summon, CardId.SummonerMonk); AddExecutor(ExecutorType.Summon, CardId.SummonerMonk);
AddExecutor(ExecutorType.Summon, CardId.Honest);
// Summons: Effects // Summons: Effects
AddExecutor(ExecutorType.Activate, CardId.Goblindbergh, GoblindberghEffect); AddExecutor(ExecutorType.Activate, CardId.Goblindbergh, GoblindberghEffect);
...@@ -122,13 +123,6 @@ namespace WindBot.Game.AI.Decks ...@@ -122,13 +123,6 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.Activate, CardId.SolemnStrike, DefaultSolemnStrike); AddExecutor(ExecutorType.Activate, CardId.SolemnStrike, DefaultSolemnStrike);
} }
private int ZwCount = 0;
public override void OnNewTurn()
{
ZwCount = 0;
}
public override bool OnSelectHand() public override bool OnSelectHand()
{ {
return false; return false;
...@@ -177,8 +171,7 @@ namespace WindBot.Game.AI.Decks ...@@ -177,8 +171,7 @@ namespace WindBot.Game.AI.Decks
private bool ZwWeapon() private bool ZwWeapon()
{ {
ZwCount++; return true;
return ZwCount < 10;
} }
private bool ReinforcementOfTheArmy() private bool ReinforcementOfTheArmy()
......
...@@ -47,7 +47,6 @@ namespace WindBot.Game.AI.Decks ...@@ -47,7 +47,6 @@ namespace WindBot.Game.AI.Decks
bool TigermortarSpsummoned = false; bool TigermortarSpsummoned = false;
bool ChakanineSpsummoned = false; bool ChakanineSpsummoned = false;
bool BroadbullSpsummoned = false; bool BroadbullSpsummoned = false;
int WhiptailEffectCount = 0;
public ZoodiacExecutor(GameAI ai, Duel duel) public ZoodiacExecutor(GameAI ai, Duel duel)
: base(ai, duel) : base(ai, duel)
...@@ -128,7 +127,6 @@ namespace WindBot.Game.AI.Decks ...@@ -128,7 +127,6 @@ namespace WindBot.Game.AI.Decks
TigermortarSpsummoned = false; TigermortarSpsummoned = false;
ChakanineSpsummoned = false; ChakanineSpsummoned = false;
BroadbullSpsummoned = false; BroadbullSpsummoned = false;
WhiptailEffectCount = 0;
} }
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender) public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
...@@ -431,7 +429,7 @@ namespace WindBot.Game.AI.Decks ...@@ -431,7 +429,7 @@ namespace WindBot.Game.AI.Decks
{ {
if (Duel.Phase == DuelPhase.Main1 || Duel.Phase == DuelPhase.Main2) if (Duel.Phase == DuelPhase.Main1 || Duel.Phase == DuelPhase.Main2)
return false; return false;
if (Card.IsDisabled() || WhiptailEffectCount >= 3) if (Card.IsDisabled())
return false; return false;
ClientCard target = null; ClientCard target = null;
List<ClientCard> monsters = Bot.GetMonsters(); List<ClientCard> monsters = Bot.GetMonsters();
...@@ -461,7 +459,6 @@ namespace WindBot.Game.AI.Decks ...@@ -461,7 +459,6 @@ namespace WindBot.Game.AI.Decks
CardId.Drident CardId.Drident
}); });
} }
WhiptailEffectCount++;
return true; return true;
} }
......
...@@ -103,8 +103,6 @@ namespace WindBot.Game.AI ...@@ -103,8 +103,6 @@ namespace WindBot.Game.AI
public const int AntiSpellFragrance = 58921041; public const int AntiSpellFragrance = 58921041;
} }
int HonestEffectCount = 0;
protected DefaultExecutor(GameAI ai, Duel duel) protected DefaultExecutor(GameAI ai, Duel duel)
: base(ai, duel) : base(ai, duel)
{ {
...@@ -263,7 +261,7 @@ namespace WindBot.Game.AI ...@@ -263,7 +261,7 @@ namespace WindBot.Game.AI
public override void OnNewTurn() public override void OnNewTurn()
{ {
HonestEffectCount = 0;
} }
/// <summary> /// <summary>
...@@ -1110,13 +1108,7 @@ namespace WindBot.Game.AI ...@@ -1110,13 +1108,7 @@ namespace WindBot.Game.AI
|| ((Bot.BattlingMonster.Attack < Enemy.BattlingMonster.Defense) && (Bot.BattlingMonster.Attack + Enemy.BattlingMonster.Attack > Enemy.BattlingMonster.Defense))); || ((Bot.BattlingMonster.Attack < Enemy.BattlingMonster.Defense) && (Bot.BattlingMonster.Attack + Enemy.BattlingMonster.Attack > Enemy.BattlingMonster.Defense)));
} }
if (Util.IsTurn1OrMain2() && HonestEffectCount <= 5) return Util.IsTurn1OrMain2();
{
//HonestEffectCount++;
return true;
}
return false;
} }
} }
} }
...@@ -13,12 +13,16 @@ namespace WindBot.Game ...@@ -13,12 +13,16 @@ namespace WindBot.Game
private Dialogs _dialogs; private Dialogs _dialogs;
// record activated count to prevent infinite actions
private Dictionary<int, int> _activatedCards;
public GameAI(GameClient game, Duel duel) public GameAI(GameClient game, Duel duel)
{ {
Game = game; Game = game;
Duel = duel; Duel = duel;
_dialogs = new Dialogs(game); _dialogs = new Dialogs(game);
_activatedCards = new Dictionary<int, int>();
} }
/// <summary> /// <summary>
...@@ -81,6 +85,7 @@ namespace WindBot.Game ...@@ -81,6 +85,7 @@ namespace WindBot.Game
/// </summary> /// </summary>
public void OnNewTurn() public void OnNewTurn()
{ {
_activatedCards.Clear();
Executor.OnNewTurn(); Executor.OnNewTurn();
} }
...@@ -1107,11 +1112,28 @@ namespace WindBot.Game ...@@ -1107,11 +1112,28 @@ namespace WindBot.Game
private bool ShouldExecute(CardExecutor exec, ClientCard card, ExecutorType type, int desc = -1) private bool ShouldExecute(CardExecutor exec, ClientCard card, ExecutorType type, int desc = -1)
{ {
if (card.Id != 0 && type == ExecutorType.Activate &&
_activatedCards.ContainsKey(card.Id) && _activatedCards[card.Id] >= 9)
{
return false;
}
Executor.SetCard(type, card, desc); Executor.SetCard(type, card, desc);
return card != null && bool result = card != null && exec.Type == type &&
exec.Type == type && (exec.CardId == -1 || exec.CardId == card.Id) &&
(exec.CardId == -1 || exec.CardId == card.Id) && (exec.Func == null || exec.Func());
(exec.Func == null || exec.Func()); if (card.Id != 0 && type == ExecutorType.Activate && result)
{
int count = card.IsDisabled() ? 3 : 1;
if (!_activatedCards.ContainsKey(card.Id))
{
_activatedCards.Add(card.Id, count);
}
else
{
_activatedCards[card.Id] += count;
}
}
return result;
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment