Commit 6b4c0ccb authored by mercury233's avatar mercury233

ai tweaks

parent e7486c04
......@@ -23,7 +23,6 @@
70368879
71490127
73628505
73628505
81439173
5318639
5318639
......@@ -32,6 +31,7 @@
60004971
62265044
62265044
62265044
44095762
58120309
58120309
......
......@@ -6,6 +6,9 @@
74852097
74852097
74852097
81823360
81823360
81823360
75195825
75195825
75195825
......@@ -15,9 +18,6 @@
33256280
33256280
33256280
51934376
51934376
51934376
85138716
85138716
85138716
......
......@@ -121,9 +121,9 @@ namespace WindBot.Game.AI
return count;
}
public static IList<ClientCard> GetMonsters(this IEnumerable<ClientCard> cards)
public static List<ClientCard> GetMonsters(this IEnumerable<ClientCard> cards)
{
IList<ClientCard> cardlist = new List<ClientCard>();
List<ClientCard> cardlist = new List<ClientCard>();
foreach (ClientCard card in cards)
{
......@@ -135,9 +135,9 @@ namespace WindBot.Game.AI
return cardlist;
}
public static IList<ClientCard> GetFaceupPendulumMonsters(this IEnumerable<ClientCard> cards)
public static List<ClientCard> GetFaceupPendulumMonsters(this IEnumerable<ClientCard> cards)
{
IList<ClientCard> cardlist = new List<ClientCard>();
List<ClientCard> cardlist = new List<ClientCard>();
foreach (ClientCard card in cards)
{
......
......@@ -123,11 +123,6 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.SpellSet, SpellSet);
}
public override bool OnSelectHand()
{
return Program.Rand.Next(2) > 0;
}
public override void OnNewTurn()
{
// reset
......@@ -322,17 +317,17 @@ namespace WindBot.Game.AI.Decks
private bool AlternativeWhiteDragonEffect()
{
ClientCard card = AI.Utils.GetProblematicEnemyMonster(Card.GetDefensePower());
if (card != null)
ClientCard target = AI.Utils.GetProblematicEnemyMonster(Card.GetDefensePower());
if (target != null)
{
AI.SelectCard(card);
AI.SelectCard(target);
UsedAlternativeWhiteDragon.Add(Card);
return true;
}
if (CanDealWithUsedAlternativeWhiteDragon())
{
card = AI.Utils.GetBestEnemyMonster();
AI.SelectCard(card);
target = AI.Utils.GetBestEnemyMonster();
AI.SelectCard(target);
UsedAlternativeWhiteDragon.Add(Card);
return true;
}
......@@ -442,14 +437,13 @@ namespace WindBot.Game.AI.Decks
CardId.WhiteStoneOfLegend,
CardId.WhiteStoneOfAncients
});
List<ClientCard> spells = Enemy.GetSpells();
if (spells.Count == 0)
if (Enemy.GetSpellCount() > 0)
{
AI.SelectNextCard(CardId.WhiteDragon);
AI.SelectNextCard(CardId.DragonSpiritOfWhite);
}
else
{
AI.SelectNextCard(CardId.DragonSpiritOfWhite);
AI.SelectNextCard(CardId.WhiteDragon);
}
return true;
}
......@@ -462,25 +456,24 @@ namespace WindBot.Game.AI.Decks
AI.SelectCard(target);
return true;
}
else
else if (HaveEnoughWhiteDragonInHand())
{
if (Duel.Player == 0 && Duel.Phase == DuelPhase.BattleStart)
{
return HaveEnoughWhiteDragonInHand() && Card.Attacked;
return Card.Attacked;
}
if (Duel.Player == 1 && Duel.Phase == DuelPhase.End)
{
return HaveEnoughWhiteDragonInHand()
&& Bot.HasInMonstersZone(CardId.AzureEyesSilverDragon, true)
return Bot.HasInMonstersZone(CardId.AzureEyesSilverDragon, true)
&& !Bot.HasInGraveyard(CardId.DragonSpiritOfWhite)
&& !Bot.HasInGraveyard(CardId.WhiteDragon);
}
if (AI.Utils.IsChainTarget(Card))
{
return HaveEnoughWhiteDragonInHand();
return true;
}
return false;
}
return false;
}
private bool BlueEyesSpiritDragonEffect()
......@@ -547,14 +540,13 @@ namespace WindBot.Game.AI.Decks
}
else
{
List<ClientCard> spells = Enemy.GetSpells();
if (spells.Count == 0)
if (Enemy.GetSpellCount() > 0)
{
AI.SelectCard(CardId.WhiteDragon);
AI.SelectCard(CardId.DragonSpiritOfWhite);
}
else
{
AI.SelectCard(CardId.DragonSpiritOfWhite);
AI.SelectCard(CardId.WhiteDragon);
}
return true;
}
......@@ -620,8 +612,7 @@ namespace WindBot.Game.AI.Decks
{
if (Bot.HasInMonstersZone(CardId.GalaxyEyesCipherDragon))
{
List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters)
foreach (ClientCard monster in Bot.GetMonsters())
{
if ((monster.IsDisabled() && monster.HasType(CardType.Xyz) && !monster.Equals(UsedGalaxyEyesCipherDragon))
|| (Duel.Phase == DuelPhase.Main2 && monster.Equals(UsedGalaxyEyesCipherDragon)))
......@@ -706,8 +697,7 @@ namespace WindBot.Game.AI.Decks
AI.SelectCard(target);
return true;
}
List<ClientCard> spells = Enemy.GetSpells();
foreach (ClientCard spell in spells)
foreach (ClientCard spell in Enemy.GetSpells())
{
if (spell.IsFaceup())
{
......@@ -896,7 +886,7 @@ namespace WindBot.Game.AI.Decks
if (Bot.HasInMonstersZone(CardId.BlueEyesSpiritDragon, true))
return false;
int count = Bot.GetGraveyardMonsters().Count;
int space = 5 - Bot.GetMonsterCount();
int space = 5 - Bot.GetMonstersInMainZone().Count;
if (count < space)
count = space;
if (count < 2 || Duel.LifePoints[0] < count*1000)
......@@ -905,16 +895,14 @@ namespace WindBot.Game.AI.Decks
{
int attack = 0;
int defence = 0;
List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters)
foreach (ClientCard monster in Bot.GetMonsters())
{
if (!monster.IsDefense())
{
attack += monster.Attack;
}
}
monsters = Enemy.GetMonsters();
foreach (ClientCard monster in monsters)
foreach (ClientCard monster in Enemy.GetMonsters())
{
defence += monster.GetDefensePower();
}
......
......@@ -200,7 +200,7 @@ namespace WindBot.Game.AI.Decks
else
option = 1;
if (ActivateDescription != CardId.DragonRavine*16 + option)
if (ActivateDescription != AI.Utils.GetStringId(CardId.DragonRavine, option))
return false;
AI.SelectCard(tributeId);
......@@ -243,20 +243,13 @@ namespace WindBot.Game.AI.Decks
private bool FoolishBurial()
{
if (Bot.HasInGraveyard(CardId.DragunityPhalanx))
return false;
if (Bot.HasInHand(CardId.DragunityPhalanx))
return false;
int remaining = 3;
foreach (ClientCard card in Bot.Banished)
if (card.Id == CardId.DragunityPhalanx)
remaining--;
if (remaining > 0)
AI.SelectCard(new[]
{
AI.SelectCard(CardId.DragunityPhalanx);
return true;
}
return false;
CardId.DragunityPhalanx,
CardId.AssaultBeast,
CardId.StardustDragonAssaultMode
});
return true;
}
private bool MonsterReborn()
......
......@@ -16,11 +16,13 @@ namespace WindBot.Game.AI.Decks
public const int Shell = 90885155;
public const int Helix = 37991342;
public const int Carrier = 91907707;
public const int DarkHole = 53129443;
public const int CardOfDemise = 59750328;
public const int SummonersArt = 79816536;
public const int PotOfDuality = 98645731;
public const int Saqlifice = 17639150;
public const int MirrorForce = 44095762;
public const int TorrentialTribute = 53582587;
public const int DimensionalBarrier = 83326048;
......@@ -136,11 +138,18 @@ namespace WindBot.Game.AI.Decks
{
return null;
}
IList<ClientCard> selected = new List<ClientCard>();
// select the last cards
// pendulum summon, select the last cards
IList<ClientCard> selected = new List<ClientCard>();
for (int i = 1; i <= max; ++i)
selected.Add(cards[cards.Count - i]);
{
ClientCard card = cards[cards.Count - i];
if (card.Id != CardId.Scout || (card.Location == CardLocation.Extra && !Duel.IsNewRule))
selected.Add(card);
}
if (selected.Count == 0)
selected.Add(cards[cards.Count - 1]);
return selected;
}
......@@ -189,9 +198,9 @@ namespace WindBot.Game.AI.Decks
private bool TrapSetUnique()
{
foreach (ClientCard card in Bot.SpellZone)
foreach (ClientCard card in Bot.GetSpells())
{
if (card != null && card.Id == Card.Id)
if (card.Id == Card.Id)
return false;
}
return TrapSetWhenZoneFree();
......
......@@ -16,7 +16,7 @@ namespace WindBot.Game.AI.Decks
public const int MasterPendulumTheDracoslayer = 75195825;
public const int AngelTrumpeter = 87979586;
public const int MetalfoesGoldriver = 33256280;
public const int Kabazauls = 51934376;
public const int MegalosmasherX = 81823360;
public const int RescueRabbit = 85138716;
public const int UnexpectedDai = 911883;
......@@ -67,7 +67,7 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.Activate, CardId.PotOfDesires, DefaultPotOfDesires);
AddExecutor(ExecutorType.Summon, CardId.AngelTrumpeter, AngelTrumpeterSummon);
AddExecutor(ExecutorType.Summon, CardId.Kabazauls, KabazaulsSummon);
AddExecutor(ExecutorType.Summon, CardId.MegalosmasherX, KabazaulsSummon);
AddExecutor(ExecutorType.Summon, CardId.MasterPendulumTheDracoslayer, MasterPendulumTheDracoslayerSummon);
AddExecutor(ExecutorType.Summon, CardId.MysteryShellDragon, MysteryShellDragonSummon);
AddExecutor(ExecutorType.Summon, CardId.PhantomGryphon, PhantomGryphonSummon);
......@@ -142,11 +142,6 @@ namespace WindBot.Game.AI.Decks
{
NormalSummoned = false;
}
public override bool OnSelectHand()
{
return Program.Rand.Next(2) > 0;
}
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
{
......@@ -164,21 +159,22 @@ namespace WindBot.Game.AI.Decks
AI.SelectCard(new[]
{
CardId.MysteryShellDragon,
CardId.PhantomGryphon
CardId.PhantomGryphon,
CardId.MegalosmasherX
});
else if (AI.Utils.IsTurn1OrMain2())
{
if (Bot.HasInHand(CardId.MysteryShellDragon))
AI.SelectCard(CardId.MysteryShellDragon);
else if (Bot.HasInHand(CardId.Kabazauls))
AI.SelectCard(CardId.Kabazauls);
else if (Bot.HasInHand(CardId.MegalosmasherX))
AI.SelectCard(CardId.MegalosmasherX);
else if (Bot.HasInHand(CardId.AngelTrumpeter))
AI.SelectCard(CardId.AngelTrumpeter);
}
else
{
if (Bot.HasInHand(CardId.Kabazauls))
AI.SelectCard(CardId.Kabazauls);
if (Bot.HasInHand(CardId.MegalosmasherX))
AI.SelectCard(CardId.MegalosmasherX);
else if (Bot.HasInHand(CardId.MasterPendulumTheDracoslayer))
AI.SelectCard(CardId.MasterPendulumTheDracoslayer);
else if (Bot.HasInHand(CardId.PhantomGryphon))
......@@ -196,20 +192,24 @@ namespace WindBot.Game.AI.Decks
private bool RescueRabbitEffect()
{
if (AI.Utils.IsTurn1OrMain2())
{
AI.SelectCard(new[]
{
CardId.Kabazauls,
CardId.MegalosmasherX,
CardId.MysteryShellDragon
});
}
else
{
AI.SelectCard(new[]
{
CardId.MasterPendulumTheDracoslayer,
CardId.PhantomGryphon,
CardId.Kabazauls,
CardId.MegalosmasherX,
CardId.MetalfoesGoldriver,
CardId.AngelTrumpeter
});
}
return true;
}
......@@ -235,7 +235,7 @@ namespace WindBot.Game.AI.Decks
}
private bool KabazaulsSummon()
{
return Bot.HasInMonstersZone(CardId.Kabazauls);
return Bot.HasInMonstersZone(CardId.MegalosmasherX);
}
private bool NormalSummon()
{
......@@ -314,16 +314,14 @@ namespace WindBot.Game.AI.Decks
private bool LightningChidoriSummon()
{
List<ClientCard> monsters = Enemy.GetMonsters();
foreach (ClientCard monster in monsters)
foreach (ClientCard monster in Enemy.GetMonsters())
{
if (monster.IsFacedown())
{
return true;
}
}
List<ClientCard> spells = Enemy.GetSpells();
foreach (ClientCard spell in spells)
foreach (ClientCard spell in Enemy.GetSpells())
{
if (spell.IsFacedown())
{
......@@ -343,7 +341,7 @@ namespace WindBot.Game.AI.Decks
private bool EvolzarLaggiaSummon()
{
return (AI.Utils.IsAllEnemyBetterThanValue(1700, false) && !AI.Utils.IsOneEnemyBetterThanValue(2400, true)) || AI.Utils.IsTurn1OrMain2();
return (AI.Utils.IsAllEnemyBetterThanValue(2000, false) && !AI.Utils.IsOneEnemyBetterThanValue(2400, true)) || AI.Utils.IsTurn1OrMain2();
}
private bool EvilswarmNightmareSummon()
......
......@@ -60,7 +60,6 @@ namespace WindBot.Game.AI.Decks
// Level 5 monsters without side effects
AddExecutor(ExecutorType.SpSummon, CardId.CyberDragon);
AddExecutor(ExecutorType.SpSummon, CardId.SolarWindJammer, SolarWindJammerSummon);
AddExecutor(ExecutorType.SpSummon, CardId.ZWEagleClaw);
AddExecutor(ExecutorType.Summon, CardId.ChronomalyGoldenJet, NormalSummon);
AddExecutor(ExecutorType.Activate, CardId.ChronomalyGoldenJet, ChronomalyGoldenJetEffect);
......@@ -80,6 +79,7 @@ namespace WindBot.Game.AI.Decks
// Level 5 monsters with side effects
AddExecutor(ExecutorType.SpSummon, CardId.SolarWindJammer, SolarWindJammerSummon);
AddExecutor(ExecutorType.SpSummon, CardId.QuickdrawSynchron, QuickdrawSynchronSummon);
AddExecutor(ExecutorType.Summon, CardId.MistArchfiend, MistArchfiendSummon);
AddExecutor(ExecutorType.Activate, CardId.InstantFusion, InstantFusionEffect);
......@@ -126,13 +126,15 @@ namespace WindBot.Game.AI.Decks
private bool SolarWindJammerSummon()
{
if (!NeedLV5())
return false;
AI.SelectPosition(CardPosition.FaceUpDefence);
return true;
}
private bool QuickdrawSynchronSummon()
{
if (!needLV5())
if (!NeedLV5())
return false;
AI.SelectCard(new[]
{
......@@ -150,7 +152,7 @@ namespace WindBot.Game.AI.Decks
private bool MistArchfiendSummon()
{
if (!needLV5())
if (!NeedLV5())
return false;
AI.SelectOption(1);
NormalSummoned = true;
......@@ -159,20 +161,21 @@ namespace WindBot.Game.AI.Decks
private bool InstantFusionEffect()
{
if (!needLV5())
if (!NeedLV5())
return false;
InstantFusionUsed = true;
return true;
}
private bool needLV5()
private bool NeedLV5()
{
if (HaveLV5OnField())
if (HaveOtherLV5OnField())
return true;
int lv5Count = 0;
IList<ClientCard> hand = Bot.Hand;
foreach (ClientCard card in hand)
foreach (ClientCard card in Bot.Hand)
{
if (card.Id == CardId.SolarWindJammer && Bot.GetMonsterCount() == 0)
++lv5Count;
if (card.Id == CardId.InstantFusion && !InstantFusionUsed)
++lv5Count;
if (card.Id == CardId.QuickdrawSynchron && Bot.Hand.ContainsMonsterWithLevel(4))
......@@ -189,7 +192,7 @@ namespace WindBot.Game.AI.Decks
private bool WindUpSoldierEffect()
{
return HaveLV5OnField();
return HaveOtherLV5OnField();
}
private bool ChronomalyGoldenJetEffect()
......@@ -201,18 +204,17 @@ namespace WindBot.Game.AI.Decks
{
if (!NormalSummoned || DoubleSummonUsed)
return false;
IList<ClientCard> hand = Bot.Hand;
foreach (ClientCard card in hand)
{
if (card.Id == CardId.MistArchfiend ||
card.Id == CardId.WindUpSoldier ||
card.Id == CardId.StarDrawing ||
card.Id == CardId.ChronomalyGoldenJet)
if (Bot.HasInHand(new[]
{
NormalSummoned = false;
DoubleSummonUsed = true;
return true;
}
CardId.MistArchfiend,
CardId.WindUpSoldier,
CardId.StarDrawing,
CardId.ChronomalyGoldenJet
}))
{
NormalSummoned = false;
DoubleSummonUsed = true;
return true;
}
return false;
}
......@@ -253,9 +255,8 @@ namespace WindBot.Game.AI.Decks
}
else
{
List<ClientCard> monsters = Enemy.GetMonsters();
ClientCard bestmonster = null;
foreach (ClientCard monster in monsters)
foreach (ClientCard monster in Enemy.GetMonsters())
{
if (monster.IsAttack() && (bestmonster == null || monster.Attack >= bestmonster.Attack))
bestmonster = monster;
......@@ -290,6 +291,8 @@ namespace WindBot.Game.AI.Decks
private bool TirasKeeperOfGenesisEffect()
{
ClientCard target = AI.Utils.GetProblematicEnemyCard();
if (target == null)
target = AI.Utils.GetBestEnemyCard();
if (target != null)
{
AI.SelectCard(target);
......@@ -304,8 +307,7 @@ namespace WindBot.Game.AI.Decks
AI.SelectCard(CardId.Number61Volcasaurus);
return true;
}
List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters)
foreach (ClientCard monster in Bot.GetMonsters())
{
if (monster.HasType(CardType.Xyz) && !monster.HasXyzMaterial())
{
......@@ -318,13 +320,8 @@ namespace WindBot.Game.AI.Decks
private bool XyzRebornEffect()
{
foreach (ClientCard card in Bot.SpellZone)
{
if (card != null &&
card.Id == Card.Id &&
card.HasPosition(CardPosition.FaceUp))
return false;
}
if (!UniqueFaceupSpell())
return false;
AI.SelectCard(new[]
{
CardId.CyberDragonInfinity,
......@@ -338,8 +335,15 @@ namespace WindBot.Game.AI.Decks
private bool XyzUnitEffect()
{
List<ClientCard> monsters = Bot.GetMonsters();
return monsters.Exists(p => p.HasType(CardType.Xyz));
foreach (ClientCard monster in Bot.GetMonsters())
{
if (monster.HasType(CardType.Xyz))
{
AI.SelectCard(monster);
return true;
}
}
return false;
}
private bool PanzerDragonEffect()
......@@ -355,14 +359,9 @@ namespace WindBot.Game.AI.Decks
private bool XyzVeilEffect()
{
List<ClientCard> spells = Bot.GetSpells();
foreach (ClientCard spell in spells)
{
if (spell.Id == CardId.XyzVeil && !spell.IsFacedown())
return false;
}
List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters)
if (!UniqueFaceupSpell())
return false;
foreach (ClientCard monster in Bot.GetMonsters())
{
if (monster.HasType(CardType.Xyz))
return true;
......@@ -370,10 +369,9 @@ namespace WindBot.Game.AI.Decks
return false;
}
private bool HaveLV5OnField()
private bool HaveOtherLV5OnField()
{
List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters)
foreach (ClientCard monster in Bot.GetMonsters())
{
if (monster.HasType(CardType.Monster) &&
!monster.HasType(CardType.Xyz) &&
......
......@@ -237,8 +237,7 @@ namespace WindBot.Game.AI.Decks
private bool MoonMirrorShieldEffect()
{
List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters)
foreach (ClientCard monster in Bot.GetMonsters())
{
AI.SelectCard(monster);
return true;
......@@ -250,8 +249,7 @@ namespace WindBot.Game.AI.Decks
{
if (Card.Location == CardLocation.Hand)
return DefaultField();
IList<ClientCard> cards = Enemy.Graveyard;
foreach (ClientCard card in cards)
foreach (ClientCard card in Enemy.Graveyard)
{
if (card.IsMonster())
{
......@@ -269,16 +267,10 @@ namespace WindBot.Game.AI.Decks
{
return false;
}
foreach (ClientCard card in Bot.SpellZone)
{
if (card != null &&
card.Id == Card.Id &&
card.HasPosition(CardPosition.FaceUp))
return false;
}
if (!UniqueFaceupSpell())
return false;
bool selected = false;
List<ClientCard> monsters = Bot.GetMonstersInExtraZone();
foreach (ClientCard monster in monsters)
foreach (ClientCard monster in Bot.GetMonstersInExtraZone())
{
if (monster.Attack > 1000)
{
......@@ -289,7 +281,7 @@ namespace WindBot.Game.AI.Decks
}
if (!selected)
{
monsters = Bot.GetMonsters();
List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters)
{
if (monster.Id == CardId.BalancerLord)
......
......@@ -173,7 +173,6 @@ namespace WindBot.Game.AI.Decks
return true;
}
private bool FoolishBurialEffect()
{
if (Bot.HasInHand(CardId.GraydleSlimeJr) && !Bot.HasInGraveyard(CardId.GraydleSlimeJr))
......@@ -281,8 +280,7 @@ namespace WindBot.Game.AI.Decks
private bool NormalSummon()
{
List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters)
foreach (ClientCard monster in Bot.GetMonsters())
{
if (monster.Level==2)
{
......@@ -323,35 +321,41 @@ namespace WindBot.Game.AI.Decks
return true;
}
}
bool haveAquariumStage = Bot.HasInSpellZone(CardId.AquariumStage, true);
foreach (ClientCard monster in monsters)
if (!Bot.HasInSpellZone(CardId.AquariumStage, true))
{
if (monster.Id == CardId.DupeFrog && !haveAquariumStage)
foreach (ClientCard monster in monsters)
{
AI.SelectCard(monster);
return true;
if (monster.Id == CardId.DupeFrog)
{
AI.SelectCard(monster);
return true;
}
}
}
monsters = (List<ClientCard>)Bot.Hand;
bool HaveTwoGraydleSlimeJrInHand = Bot.GetCountCardInZone(Bot.Hand, CardId.GraydleSlimeJr) >= 2;
foreach (ClientCard monster in monsters)
List<ClientCard> hands = Bot.Hand.GetMonsters();
if (Bot.GetCountCardInZone(Bot.Hand, CardId.GraydleSlimeJr) >= 2)
{
if (monster.Id == CardId.GraydleSlimeJr && HaveTwoGraydleSlimeJrInHand)
foreach (ClientCard monster in hands)
{
AI.SelectCard(monster);
return true;
if (monster.Id == CardId.GraydleSlimeJr)
{
AI.SelectCard(monster);
return true;
}
}
}
bool NeedDupeFrogInGrave = Bot.HasInGraveyard(CardId.Ronintoadin) && !Bot.HasInGraveyard(CardId.DupeFrog) && !Bot.HasInGraveyard(CardId.SwapFrog);
foreach (ClientCard monster in monsters)
if (Bot.HasInGraveyard(CardId.Ronintoadin) && !Bot.HasInGraveyard(CardId.DupeFrog) && !Bot.HasInGraveyard(CardId.SwapFrog))
{
if (monster.Id == CardId.DupeFrog && NeedDupeFrogInGrave)
foreach (ClientCard monster in hands)
{
AI.SelectCard(monster);
return true;
if (monster.Id == CardId.DupeFrog)
{
AI.SelectCard(monster);
return true;
}
}
}
foreach (ClientCard monster in monsters)
foreach (ClientCard monster in hands)
{
if (monster.Id == CardId.Ronintoadin || monster.Id == CardId.DupeFrog)
{
......@@ -359,7 +363,7 @@ namespace WindBot.Game.AI.Decks
return true;
}
}
foreach (ClientCard monster in monsters)
foreach (ClientCard monster in hands)
{
AI.SelectCard(monster);
return true;
......@@ -418,15 +422,14 @@ namespace WindBot.Game.AI.Decks
private bool CatSharkSummon()
{
bool should = Bot.HasInMonstersZone(CardId.ToadallyAwesome)
&& ((AI.Utils.IsOneEnemyBetter(true)
&& !Bot.HasInMonstersZone(new[]
{
CardId.CatShark,
CardId.SkyCavalryCentaurea
}, true, true))
|| !Bot.HasInExtra(CardId.ToadallyAwesome));
if (should)
if (Bot.HasInMonstersZone(CardId.ToadallyAwesome)
&& ((AI.Utils.IsOneEnemyBetter(true)
&& !Bot.HasInMonstersZone(new[]
{
CardId.CatShark,
CardId.SkyCavalryCentaurea
}, true, true))
|| !Bot.HasInExtra(CardId.ToadallyAwesome)))
{
AI.SelectPosition(CardPosition.FaceUpDefence);
return true;
......@@ -470,8 +473,7 @@ namespace WindBot.Game.AI.Decks
private bool SkyCavalryCentaureaSummon()
{
int num = 0;
List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters)
foreach (ClientCard monster in Bot.GetMonsters())
{
if (monster.Level ==2)
{
......@@ -493,16 +495,14 @@ namespace WindBot.Game.AI.Decks
{
int attack = 0;
int defence = 0;
List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters)
foreach (ClientCard monster in Bot.GetMonsters())
{
if (!monster.IsDefense())
{
attack += monster.Attack;
}
}
monsters = Enemy.GetMonsters();
foreach (ClientCard monster in monsters)
foreach (ClientCard monster in Enemy.GetMonsters())
{
defence += monster.GetDefensePower();
}
......@@ -520,11 +520,9 @@ namespace WindBot.Game.AI.Decks
private bool Repos()
{
bool enemyBetter = AI.Utils.IsAllEnemyBetter(true);
if (Card.IsFacedown())
return true;
if (Card.IsDefense() && !enemyBetter && Card.Attack >= Card.Defense)
if (Card.IsDefense() && !AI.Utils.IsAllEnemyBetter(true) && Card.Attack >= Card.Defense)
return true;
return false;
}
......
......@@ -233,9 +233,9 @@ namespace WindBot.Game.AI.Decks
private bool HaveAnotherYosenjuWithSameNameInHand()
{
foreach (ClientCard card in Bot.Hand)
foreach (ClientCard card in Bot.Hand.GetMonsters())
{
if (card != null && !card.Equals(Card) && card.Id == Card.Id)
if (!card.Equals(Card) && card.Id == Card.Id)
return true;
}
return false;
......@@ -243,9 +243,9 @@ namespace WindBot.Game.AI.Decks
private bool TrapSetUnique()
{
foreach (ClientCard card in Bot.SpellZone)
foreach (ClientCard card in Bot.GetSpells())
{
if (card != null && card.Id == Card.Id)
if (card.Id == Card.Id)
return false;
}
return TrapSetWhenZoneFree();
......@@ -308,12 +308,5 @@ namespace WindBot.Game.AI.Decks
}
return true;
}
private bool NumberS39UtopiatheLightningSummon()
{
int selfBestAttack = AI.Utils.GetBestAttack(Bot);
int oppoBestAttack = AI.Utils.GetBestPower(Enemy);
return selfBestAttack <= oppoBestAttack;
}
}
}
\ No newline at end of file
......@@ -174,10 +174,9 @@ namespace WindBot.Game.AI.Decks
{
if (Duel.LifePoints[0] <= 1000)
return false;
List<ClientCard> monsters = Bot.GetMonsters();
int count4 = 0;
int count5 = 0;
foreach (ClientCard card in monsters)
foreach (ClientCard card in Bot.GetMonsters())
{
if (card.Level == 5)
++count5;
......@@ -214,10 +213,9 @@ namespace WindBot.Game.AI.Decks
private bool GoblindberghFirst()
{
IList<ClientCard> hand = Bot.Hand;
foreach (ClientCard card in hand)
foreach (ClientCard card in Bot.Hand.GetMonsters())
{
if (card != Card && card.IsMonster() && card.Level == 4)
if (!card.Equals(Card) && card.Level == 4)
return true;
}
return false;
......@@ -237,24 +235,26 @@ namespace WindBot.Game.AI.Decks
private bool SummonerMonkEffect()
{
if (Bot.HasInHand(CardId.InstantFusion) ||
Bot.HasInHand(CardId.MysticalSpaceTyphoon))
IList<int> costs = new[]
{
CardId.XyzChangeTactics,
CardId.DarkHole,
CardId.MysticalSpaceTyphoon,
CardId.InstantFusion
};
if (Bot.HasInHand(costs))
{
AI.SelectCard(new[]
AI.SelectCard(costs);
AI.SelectNextCard(new[]
{
CardId.InstantFusion,
CardId.MysticalSpaceTyphoon
CardId.SacredCrane,
CardId.StarDrawing,
CardId.Goblindbergh,
CardId.TinGoldfish
});
AI.SelectPosition(CardPosition.FaceUpDefence);
return true;
}
AI.SelectNextCard(new[]
{
CardId.Goblindbergh,
CardId.TinGoldfish,
CardId.StarDrawing,
CardId.Kagetokage,
CardId.SacredCrane
});
return false;
}
......
......@@ -222,9 +222,7 @@ namespace WindBot.Game.AI.Decks
private void SelectAleisterInGrave()
{
IList<ClientCard> materials0 = Bot.Graveyard;
IList<ClientCard> materials1 = Enemy.Graveyard;
foreach (ClientCard card in materials1)
foreach (ClientCard card in Enemy.Graveyard)
{
if (card.Id == CardId.AleisterTheInvoker)
{
......@@ -232,7 +230,7 @@ namespace WindBot.Game.AI.Decks
return;
}
}
foreach (ClientCard card in materials0)
foreach (ClientCard card in Bot.Graveyard)
{
if (card.Id == CardId.AleisterTheInvoker)
{
......@@ -541,8 +539,7 @@ namespace WindBot.Game.AI.Decks
private bool ZoodiacBarrageEffect()
{
IList<ClientCard> spells = Bot.GetSpells();
foreach (ClientCard spell in spells)
foreach (ClientCard spell in Bot.GetSpells())
{
if (spell.Id == CardId.ZoodiacBarrage && !Card.Equals(spell))
return false;
......
......@@ -47,7 +47,7 @@ namespace WindBot.Game.AI
/// </summary>
/// <param name="attacker">Card that attack.</param>
/// <param name="defender">Card that defend.</param>
/// <returns>true if the attack can be done.</returns>
/// <returns>false if the attack can't be done.</returns>
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
{
if (attacker.RealPower <= 0)
......@@ -56,14 +56,10 @@ namespace WindBot.Game.AI
if (!attacker.IsMonsterHasPreventActivationEffectInBattle())
{
if (defender.IsMonsterDangerous() || (defender.IsMonsterInvincible() && defender.IsDefense()))
{
return false;
}
if (defender.Id == _CardId.CrystalWingSynchroDragon && !defender.IsDisabled() && attacker.Level >= 5)
{
return false;
}
if (defender.Id == _CardId.NumberS39UtopiaTheLightning && !defender.IsDisabled() && defender.HasXyzMaterial(2, _CardId.Number39Utopia))
defender.RealPower = 5000;
......@@ -358,13 +354,8 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultTributeSummon()
{
foreach (ClientCard card in Bot.MonsterZone)
{
if (card != null &&
card.Id == Card.Id &&
card.HasPosition(CardPosition.FaceUp))
return false;
}
if (!UniqueFaceupMonster())
return false;
int tributecount = (int)Math.Ceiling((Card.Level - 4.0d) / 2.0d);
for (int j = 0; j < 7; ++j)
{
......@@ -414,14 +405,32 @@ namespace WindBot.Game.AI
if (HasChainedTrap(0))
return false;
foreach (ClientCard card in Bot.SpellZone)
return UniqueFaceupSpell();
}
/// <summary>
/// Check no other our spell or trap card with same name face-up.
/// </summary>
protected bool UniqueFaceupSpell()
{
foreach (ClientCard card in Bot.GetSpells())
{
if (card != null &&
card.Id == Card.Id &&
card.HasPosition(CardPosition.FaceUp))
if (card.Id == Card.Id && card.IsFaceup())
return false;
}
return true;
}
/// <summary>
/// Check no other our monster card with same name face-up.
/// </summary>
protected bool UniqueFaceupMonster()
{
foreach (ClientCard card in Bot.GetMonsters())
{
if (card.Id == Card.Id && card.IsFaceup())
return false;
}
return true;
}
......
......@@ -99,6 +99,17 @@ namespace WindBot.Game
return cards;
}
public List<ClientCard> GetMonstersInMainZone()
{
List<ClientCard> cards = new List<ClientCard>();
for (int i = 0; i < 5; i++)
{
if (MonsterZone[i] != null)
cards.Add(MonsterZone[i]);
}
return cards;
}
public bool HasInHand(int cardId)
{
return HasInCards(Hand, cardId);
......
......@@ -123,6 +123,10 @@ The parameters are same as commandlines, but low cased.
* `AI.SelectTribute`
* Select cards to pendulum summon in executor.
* Get equip of card.
* Better new master rule support
* Update the known card enums
......
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