diff --git a/libWindbot/Game/AI/CardExtension.cs b/libWindbot/Game/AI/CardExtension.cs index 8b30394..1fcc453 100644 --- a/libWindbot/Game/AI/CardExtension.cs +++ b/libWindbot/Game/AI/CardExtension.cs @@ -11,7 +11,9 @@ public static class CardExtension /// public static bool IsMonsterInvincible(this ClientCard card) { - return !card.IsDisabled() && Enum.IsDefined(typeof(InvincibleMonster), card.Id); + return !card.IsDisabled() && + (card.Controller == 0 && Enum.IsDefined(typeof(InvincibleBotMonster), card.Id) || + card.Controller == 1 && Enum.IsDefined(typeof(InvincibleEnemyMonster), card.Id)); } /// diff --git a/libWindbot/Game/AI/Decks/AltergeistExecutor.cs b/libWindbot/Game/AI/Decks/AltergeistExecutor.cs index 0b90166..33733f8 100644 --- a/libWindbot/Game/AI/Decks/AltergeistExecutor.cs +++ b/libWindbot/Game/AI/Decks/AltergeistExecutor.cs @@ -2742,8 +2742,6 @@ public override BattlePhaseAction OnSelectAttackTarget(ClientCard attacker, ILis public override IList OnSelectCard(IList cards, int min, int max, int hint, bool cancelable) { - - int HIINT_TOGRAVE = 504; if (max == 1 && cards[0].Location == CardLocation.Deck && Util.GetLastChainCard() != null && Util.GetLastChainCard().IsCode(23002292) && Bot.GetRemainingCount(CardId.WakingtheDragon,1) > 0) { @@ -2764,7 +2762,7 @@ public override IList OnSelectCard(IList cards, int min, Logger.DebugWriteLine("EvenlyMatched: min=" + min.ToString() + ", max=" + max.ToString()); } else if (cards[0].Location == CardLocation.Hand && cards[cards.Count - 1].Location == CardLocation.Hand - && (hint == 501 || hint == HIINT_TOGRAVE) && min == max) + && (hint == HintMsg.Discard || hint == HintMsg.ToGrave) && min == max) { if (Duel.LastChainPlayer == 0 && Util.GetLastChainCard().IsCode(CardId.OneForOne)) return null; Logger.DebugWriteLine("Hand drop except OneForOne"); diff --git a/libWindbot/Game/AI/Decks/DoEveryThingExecutor.cs b/libWindbot/Game/AI/Decks/DoEveryThingExecutor.cs index b96bcad..8699807 100644 --- a/libWindbot/Game/AI/Decks/DoEveryThingExecutor.cs +++ b/libWindbot/Game/AI/Decks/DoEveryThingExecutor.cs @@ -20,7 +20,7 @@ public DoEverythingExecutor(GameAI ai, Duel duel) { AddExecutor(ExecutorType.SpSummon); AddExecutor(ExecutorType.Activate, DefaultDontChainMyself); - AddExecutor(ExecutorType.SummonOrSet); + AddExecutor(ExecutorType.SummonOrSet, DefaultMonsterSummon); AddExecutor(ExecutorType.Repos, DefaultMonsterRepos); AddExecutor(ExecutorType.SpellSet); } diff --git a/libWindbot/Game/AI/Decks/FamiliarPossessedExecutor.cs b/libWindbot/Game/AI/Decks/FamiliarPossessedExecutor.cs new file mode 100644 index 0000000..81a8457 --- /dev/null +++ b/libWindbot/Game/AI/Decks/FamiliarPossessedExecutor.cs @@ -0,0 +1,629 @@ +using YGOSharp.OCGWrapper; +using YGOSharp.OCGWrapper.Enums; +using System.Collections.Generic; +using WindBot; +using WindBot.Game; +using WindBot.Game.AI; +using System.Linq; + +namespace WindBot.Game.AI.Decks +{ + [Deck("FamiliarPossessed", "AI_FamiliarPossessed")] + public class FamiliarPossessedExecutor : DefaultExecutor + { + public class CardId + { + public const int MetalSnake = 71197066; + public const int InspectBoarder = 15397015; + public const int AshBlossomAndJoyousSpring = 14558127; + public const int GrenMajuDaEizo = 36584821; + public const int MaxxC = 23434538; + + public const int Aussa = 31887906; + public const int Eria = 68881650; + public const int Wynn = 31764354; + public const int Hiita = 4376659; + public const int Lyna = 40542825; + public const int Awakening = 62256492; + public const int Unpossessed = 25704359; + + public const int NaturalExterio = 99916754; + public const int NaturalBeast = 33198837; + public const int SwordsmanLV7 = 37267041; + public const int RoyalDecreel = 51452091; + + public const int HarpieFeatherDuster = 18144506; + public const int PotOfDesires = 35261759; + public const int PotofExtravagance = 49238328; + public const int Scapegoat = 73915051; + public const int MacroCosmos = 30241314; + public const int Crackdown = 36975314; + public const int ImperialOrder = 61740673; + public const int SolemnWarning = 84749824; + public const int SolemStrike = 40605147; + public const int SolemnJudgment = 41420027; + public const int SkillDrain = 82732705; + public const int Mistake = 59305593; + + public const int BorreloadDragon = 31833038; + public const int BirrelswordDragon = 85289965; + public const int KnightmareGryphon = 65330383; + public const int KnightmareUnicorn = 38342335; + public const int KnightmarePhoenix = 2857636; + public const int KnightmareCerberus = 75452921; + public const int LinkSpider = 98978921; + public const int Linkuriboh = 41999284; + public const int GagagaCowboy = 12014404; + + public const int AussaP = 97661969; + public const int EriaP = 73309655; + public const int WynnP = 30674956; + public const int HiitaP = 48815792; + public const int LynaP = 9839945; + + } + + public FamiliarPossessedExecutor(GameAI ai, Duel duel) + : base(ai, duel) + { + // do first + AddExecutor(ExecutorType.Activate, CardId.PotofExtravagance, PotofExtravaganceActivate); + // burn if enemy's LP is below 800 + AddExecutor(ExecutorType.SpSummon, CardId.GagagaCowboy, GagagaCowboySummon); + AddExecutor(ExecutorType.Activate, CardId.GagagaCowboy); + //Sticker + AddExecutor(ExecutorType.Activate, CardId.MacroCosmos, MacroCosmoseff); + //counter + AddExecutor(ExecutorType.Activate, CardId.AshBlossomAndJoyousSpring, DefaultAshBlossomAndJoyousSpring); + AddExecutor(ExecutorType.Activate, CardId.MaxxC, DefaultMaxxC); + AddExecutor(ExecutorType.Activate, CardId.SolemnWarning, DefaultSolemnWarning); + AddExecutor(ExecutorType.Activate, CardId.SolemStrike, DefaultSolemnStrike); + AddExecutor(ExecutorType.Activate, CardId.ImperialOrder, ImperialOrderfirst); + AddExecutor(ExecutorType.Activate, CardId.ImperialOrder, ImperialOrdereff); + AddExecutor(ExecutorType.Activate, CardId.SolemnJudgment, DefaultSolemnJudgment); + AddExecutor(ExecutorType.Activate, CardId.SkillDrain, SkillDrainEffect); + AddExecutor(ExecutorType.Activate, CardId.Mistake, DefaultUniqueTrap); + AddExecutor(ExecutorType.Activate, CardId.Awakening); + AddExecutor(ExecutorType.Activate, CardId.Unpossessed, UnpossessedEffect); + //first do + AddExecutor(ExecutorType.Activate, CardId.HarpieFeatherDuster, DefaultHarpiesFeatherDusterFirst); + AddExecutor(ExecutorType.Activate, CardId.PotOfDesires, PotOfDesireseff); + //sp + AddExecutor(ExecutorType.Activate, CardId.Linkuriboh, Linkuriboheff); + AddExecutor(ExecutorType.SpSummon, CardId.Linkuriboh, Linkuribohsp); + AddExecutor(ExecutorType.SpSummon, CardId.KnightmareCerberus, Knightmaresp); + AddExecutor(ExecutorType.SpSummon, CardId.KnightmarePhoenix, Knightmaresp); + AddExecutor(ExecutorType.SpSummon, CardId.AussaP, AussaPsp); + AddExecutor(ExecutorType.Activate, CardId.AussaP, AussaPeff); + AddExecutor(ExecutorType.SpSummon, CardId.EriaP, EriaPsp); + AddExecutor(ExecutorType.Activate, CardId.EriaP, EriaPeff); + AddExecutor(ExecutorType.SpSummon, CardId.WynnP, WynnPsp); + AddExecutor(ExecutorType.Activate, CardId.WynnP, WynnPeff); + AddExecutor(ExecutorType.SpSummon, CardId.HiitaP, HiitaPsp); + AddExecutor(ExecutorType.Activate, CardId.HiitaP, HiitaPeff); + AddExecutor(ExecutorType.SpSummon, CardId.LynaP, LynaPsp); + AddExecutor(ExecutorType.Activate, CardId.LynaP, LynaPeff); + + AddExecutor(ExecutorType.SpSummon, CardId.Linkuriboh, Linkuribohsp); + AddExecutor(ExecutorType.SpSummon, CardId.LinkSpider); + AddExecutor(ExecutorType.SpSummon, CardId.BorreloadDragon, BorreloadDragonsp); + AddExecutor(ExecutorType.Activate, CardId.BorreloadDragon, BorreloadDragoneff); + AddExecutor(ExecutorType.SpSummon, CardId.BirrelswordDragon, BirrelswordDragonsp); + AddExecutor(ExecutorType.Activate, CardId.BirrelswordDragon, BirrelswordDragoneff); + // normal summon + AddExecutor(ExecutorType.Summon, CardId.InspectBoarder, InspectBoardersummon); + AddExecutor(ExecutorType.Summon, CardId.GrenMajuDaEizo, GrenMajuDaEizosummon); + AddExecutor(ExecutorType.SpSummon, CardId.BorreloadDragon, BorreloadDragonspsecond); + + AddExecutor(ExecutorType.Summon, CardId.Aussa, FamiliarPossessedsummon); + AddExecutor(ExecutorType.Summon, CardId.Eria, FamiliarPossessedsummon); + AddExecutor(ExecutorType.Summon, CardId.Wynn, FamiliarPossessedsummon); + AddExecutor(ExecutorType.Summon, CardId.Hiita, FamiliarPossessedsummon); + AddExecutor(ExecutorType.Summon, CardId.Lyna, FamiliarPossessedsummon); + + AddExecutor(ExecutorType.Activate, CardId.MetalSnake, MetalSnakesp); + AddExecutor(ExecutorType.Activate, CardId.MetalSnake, MetalSnakeeff); + //spell + AddExecutor(ExecutorType.Activate, CardId.Crackdown, Crackdowneff); + AddExecutor(ExecutorType.Activate, CardId.Scapegoat, DefaultScapegoat); + AddExecutor(ExecutorType.Repos, DefaultMonsterRepos); + //set + AddExecutor(ExecutorType.SpellSet, SpellSet); + } + + public void SelectSTPlace(ClientCard card = null, bool avoid_Impermanence = false, List avoid_list = null) + { + List list = new List { 0, 1, 2, 3, 4 }; + int n = list.Count; + while (n-- > 1) + { + int index = Program.Rand.Next(n + 1); + int temp = list[index]; + list[index] = list[n]; + list[n] = temp; + } + foreach (int seq in list) + { + int zone = (int)System.Math.Pow(2, seq); + if (Bot.SpellZone[seq] == null) + { + if (card != null && card.Location == CardLocation.Hand && avoid_Impermanence) continue; + if (avoid_list != null && avoid_list.Contains(seq)) continue; + AI.SelectPlace(zone); + return; + }; + } + AI.SelectPlace(0); + } + + public bool SpellNegatable(bool isCounter = false, ClientCard target = null) + { + // target default set + if (target == null) target = Card; + // won't negate if not on field + if (target.Location != CardLocation.SpellZone && target.Location != CardLocation.Hand) return false; + + // negate judge + if (Enemy.HasInMonstersZone(CardId.NaturalExterio, true) && !isCounter) return true; + if (target.IsSpell()) + { + if (Enemy.HasInMonstersZone(CardId.NaturalBeast, true)) return true; + if (Enemy.HasInSpellZone(CardId.ImperialOrder, true) || Bot.HasInSpellZone(CardId.ImperialOrder, true)) return true; + if (Enemy.HasInMonstersZone(CardId.SwordsmanLV7, true) || Bot.HasInMonstersZone(CardId.SwordsmanLV7, true)) return true; + } + if (target.IsTrap()) + { + if (Enemy.HasInSpellZone(CardId.RoyalDecreel, true) || Bot.HasInSpellZone(CardId.RoyalDecreel, true)) return true; + } + // how to get here? + return false; + } + + private bool MacroCosmoseff() + { + + return (Duel.LastChainPlayer == 1 || Duel.LastSummonPlayer == 1 || Duel.Player == 0) && UniqueFaceupSpell(); + } + + private bool ImperialOrderfirst() + { + if (Util.GetLastChainCard() != null && Util.GetLastChainCard().IsCode(CardId.PotOfDesires)) + return false; + return DefaultOnBecomeTarget() && Util.GetLastChainCard().HasType(CardType.Spell); + } + + private bool ImperialOrdereff() + { + if (Util.GetLastChainCard() != null && Util.GetLastChainCard().IsCode(CardId.PotOfDesires)) + return false; + if (Duel.LastChainPlayer == 1) + { + foreach (ClientCard check in Enemy.GetSpells()) + { + if (Util.GetLastChainCard() == check) + return true; + } + } + return false; + } + + private bool PotOfDesireseff() + { + return Bot.Deck.Count > 14 && !DefaultSpellWillBeNegated(); + } + + // activate of PotofExtravagance + public bool PotofExtravaganceActivate() + { + // won't activate if it'll be negate + if (SpellNegatable()) return false; + SelectSTPlace(Card, true); + AI.SelectOption(1); + return true; + } + + private bool Crackdowneff() + { + if (Util.GetOneEnemyBetterThanMyBest(true, true) != null && Bot.UnderAttack) + AI.SelectCard(Util.GetOneEnemyBetterThanMyBest(true, true)); + return Util.GetOneEnemyBetterThanMyBest(true, true) != null && Bot.UnderAttack; + } + + private bool SkillDrainEffect() + { + return (Bot.LifePoints > 1000) && DefaultUniqueTrap(); + } + + private bool UnpossessedEffect() + { + AI.SelectCard(new List() { + CardId.Lyna, + CardId.Hiita, + CardId.Wynn, + CardId.Eria, + CardId.Aussa + }); + return true; + } + + private bool InspectBoardersummon() + { + if (Bot.MonsterZone[0] == null) + AI.SelectPlace(Zones.z0); + else + AI.SelectPlace(Zones.z4); + return true; + } + + private bool GrenMajuDaEizosummon() + { + if (Duel.Turn == 1) return false; + if (Bot.HasInSpellZone(CardId.SkillDrain) || Enemy.HasInSpellZone(CardId.SkillDrain)) return false; + if (Bot.MonsterZone[0] == null) + AI.SelectPlace(Zones.z0); + else + AI.SelectPlace(Zones.z4); + return Bot.Banished.Count >= 6; + } + + private bool FamiliarPossessedsummon() + { + if (Bot.MonsterZone[0] == null) + AI.SelectPlace(Zones.z0); + else + AI.SelectPlace(Zones.z4); + return true; + } + + private bool BorreloadDragonsp() + { + if (!(Bot.HasInMonstersZone(new[] { CardId.KnightmareCerberus, CardId.KnightmarePhoenix, CardId.LynaP, CardId.HiitaP, CardId.WynnP, CardId.EriaP, CardId.AussaP }))) return false; + IList material_list = new List(); + foreach (ClientCard monster in Bot.GetMonsters()) + { + if (monster.IsCode(CardId.LynaP, CardId.HiitaP, CardId.WynnP, CardId.EriaP, CardId.AussaP, CardId.KnightmareCerberus, CardId.KnightmarePhoenix, CardId.LinkSpider, CardId.Linkuriboh)) + material_list.Add(monster); + if (material_list.Count == 3) break; + } + if (material_list.Count >= 3) + { + AI.SelectMaterials(material_list); + return true; + } + return false; + } + private bool BorreloadDragonspsecond() + { + if (!(Bot.HasInMonstersZone(new[] { CardId.KnightmareCerberus, CardId.KnightmarePhoenix, CardId.LynaP, CardId.HiitaP, CardId.WynnP, CardId.EriaP, CardId.AussaP }))) return false; + IList material_list = new List(); + foreach (ClientCard monster in Bot.GetMonsters()) + { + if (monster.IsCode(CardId.LynaP, CardId.HiitaP, CardId.WynnP, CardId.EriaP, CardId.AussaP, CardId.KnightmareCerberus, CardId.KnightmarePhoenix, CardId.LinkSpider, CardId.Linkuriboh)) + material_list.Add(monster); + if (material_list.Count == 3) break; + } + if (material_list.Count >= 3) + { + AI.SelectMaterials(material_list); + return true; + } + return false; + } + public bool BorreloadDragoneff() + { + if (ActivateDescription == -1 && (Duel.Phase == DuelPhase.BattleStart || Duel.Phase == DuelPhase.End)) + { + ClientCard enemy_monster = Enemy.BattlingMonster; + if (enemy_monster != null && enemy_monster.HasPosition(CardPosition.Attack)) + { + return (Card.Attack - enemy_monster.Attack < Enemy.LifePoints); + } + return true; + }; + ClientCard BestEnemy = Util.GetBestEnemyMonster(true); + ClientCard WorstBot = Bot.GetMonsters().GetLowestAttackMonster(); + if (BestEnemy == null || BestEnemy.HasPosition(CardPosition.FaceDown)) return false; + if (WorstBot == null || WorstBot.HasPosition(CardPosition.FaceDown)) return false; + if (BestEnemy.Attack >= WorstBot.RealPower) + { + AI.SelectCard(BestEnemy); + return true; + } + return false; + } + + private bool BirrelswordDragonsp() + { + IList material_list = new List(); + foreach (ClientCard m in Bot.GetMonsters()) + { + if (m.IsCode(CardId.KnightmareCerberus, CardId.KnightmarePhoenix, CardId.LynaP, CardId.HiitaP, CardId.WynnP, CardId.EriaP, CardId.AussaP)) + { + material_list.Add(m); + break; + } + } + foreach (ClientCard m in Bot.GetMonsters()) + { + if (m.IsCode(CardId.Linkuriboh) || m.Level == 1) + { + material_list.Add(m); + if (material_list.Count == 3) + break; + } + } + if (material_list.Count == 3) + { + AI.SelectMaterials(material_list); + return true; + } + return false; + } + + private bool BirrelswordDragoneff() + { + if (ActivateDescription == Util.GetStringId(CardId.BirrelswordDragon, 0)) + { + if (Util.IsChainTarget(Card) && Util.GetBestEnemyMonster(true, true) != null) + { + AI.SelectCard(Util.GetBestEnemyMonster(true, true)); + return true; + } + if (Duel.Player == 1 && Bot.BattlingMonster == Card) + { + AI.SelectCard(Enemy.BattlingMonster); + return true; + } + if (Duel.Player == 1 && Bot.BattlingMonster != null && + (Enemy.BattlingMonster.Attack - Bot.BattlingMonster.Attack) >= Bot.LifePoints) + { + AI.SelectCard(Enemy.BattlingMonster); + return true; + } + if (Duel.Player == 0 && Duel.Phase == DuelPhase.BattleStart) + { + foreach (ClientCard check in Enemy.GetMonsters()) + { + if (check.IsAttack()) + { + AI.SelectCard(check); + return true; + } + } + } + return false; + } + return true; + } + + private bool MetalSnakesp() + { + if (ActivateDescription == Util.GetStringId(CardId.MetalSnake, 0) && !Bot.HasInMonstersZone(CardId.MetalSnake)) + { + if (Duel.Player == 1 && Duel.Phase >= DuelPhase.BattleStart) + return Bot.Deck.Count >= 12; + if (Duel.Player == 0 && Duel.Phase >= DuelPhase.Main1) + return Bot.Deck.Count >= 12; + } + return false; + } + + private bool MetalSnakeeff() + { + ClientCard target = Util.GetOneEnemyBetterThanMyBest(true, true); + if (ActivateDescription == Util.GetStringId(CardId.MetalSnake, 1) && target != null) + { + AI.SelectCard(new[] + { + CardId.LynaP, + CardId.HiitaP, + CardId.WynnP, + CardId.EriaP, + CardId.KnightmareGryphon + }); + AI.SelectNextCard(target); + return true; + } + return false; + + } + + private bool AussaPsp() + { + IList material_list = new List(); + foreach (ClientCard monster in Bot.GetMonsters()) + { + if (monster.HasAttribute(CardAttribute.Earth) && !monster.IsCode(CardId.KnightmareCerberus, CardId.InspectBoarder, CardId.GrenMajuDaEizo, CardId.KnightmarePhoenix, CardId.LynaP, CardId.HiitaP, CardId.WynnP, CardId.EriaP, CardId.AussaP, CardId.KnightmareUnicorn, CardId.KnightmareGryphon, CardId.BorreloadDragon, CardId.BirrelswordDragon)) + material_list.Add(monster); + if (material_list.Count == 2) break; + } + if (material_list.Count < 2) return false; + if (Bot.HasInMonstersZone(CardId.AussaP)) return false; + AI.SelectMaterials(material_list); + if (Bot.MonsterZone[0] == null && Bot.MonsterZone[2] == null && Bot.MonsterZone[5] == null) + AI.SelectPlace(Zones.z5); + else + AI.SelectPlace(Zones.z6); + return true; + } + + private bool AussaPeff() + { + AI.SelectCard(CardId.MaxxC, CardId.Aussa); + return true; + } + + private bool EriaPsp() + { + IList material_list = new List(); + foreach (ClientCard monster in Bot.GetMonsters()) + { + if (monster.HasAttribute(CardAttribute.Water) && !monster.IsCode(CardId.KnightmareCerberus, CardId.InspectBoarder, CardId.GrenMajuDaEizo, CardId.KnightmarePhoenix, CardId.LynaP, CardId.HiitaP, CardId.WynnP, CardId.EriaP, CardId.AussaP, CardId.KnightmareUnicorn, CardId.KnightmareGryphon, CardId.BorreloadDragon, CardId.BirrelswordDragon)) + material_list.Add(monster); + if (material_list.Count == 2) break; + } + if (material_list.Count < 2) return false; + if (Bot.HasInMonstersZone(CardId.EriaP)) return false; + AI.SelectMaterials(material_list); + if (Bot.MonsterZone[0] == null && Bot.MonsterZone[2] == null && Bot.MonsterZone[5] == null) + AI.SelectPlace(Zones.z5); + else + AI.SelectPlace(Zones.z6); + return true; + } + + private bool EriaPeff() + { + AI.SelectCard(CardId.Eria); + return true; + } + + private bool WynnPsp() + { + IList material_list = new List(); + foreach (ClientCard monster in Bot.GetMonsters()) + { + if (monster.HasAttribute(CardAttribute.Wind) && !monster.IsCode(CardId.KnightmareCerberus, CardId.InspectBoarder, CardId.GrenMajuDaEizo, CardId.KnightmarePhoenix, CardId.LynaP, CardId.HiitaP, CardId.WynnP, CardId.EriaP, CardId.AussaP, CardId.KnightmareUnicorn, CardId.KnightmareGryphon, CardId.BorreloadDragon, CardId.BirrelswordDragon)) + material_list.Add(monster); + if (material_list.Count == 2) break; + } + if (material_list.Count < 2) return false; + if (Bot.HasInMonstersZone(CardId.WynnP)) return false; + AI.SelectMaterials(material_list); + if (Bot.MonsterZone[0] == null && Bot.MonsterZone[2] == null && Bot.MonsterZone[5] == null) + AI.SelectPlace(Zones.z5); + else + AI.SelectPlace(Zones.z6); + return true; + } + + private bool WynnPeff() + { + AI.SelectCard(CardId.Wynn); + return true; + } + + private bool HiitaPsp() + { + IList material_list = new List(); + foreach (ClientCard monster in Bot.GetMonsters()) + { + if (monster.HasAttribute(CardAttribute.Fire) && !monster.IsCode(CardId.KnightmareCerberus, CardId.InspectBoarder, CardId.GrenMajuDaEizo, CardId.KnightmarePhoenix, CardId.LynaP, CardId.HiitaP, CardId.WynnP, CardId.EriaP, CardId.AussaP, CardId.KnightmareUnicorn, CardId.KnightmareGryphon, CardId.BorreloadDragon, CardId.BirrelswordDragon)) + material_list.Add(monster); + if (material_list.Count == 2) break; + } + if (material_list.Count < 2) return false; + if (Bot.HasInMonstersZone(CardId.HiitaP)) return false; + AI.SelectMaterials(material_list); + if (Bot.MonsterZone[0] == null && Bot.MonsterZone[2] == null && Bot.MonsterZone[5] == null) + AI.SelectPlace(Zones.z5); + else + AI.SelectPlace(Zones.z6); + return true; + } + + private bool HiitaPeff() + { + AI.SelectCard(CardId.Hiita); + return true; + } + + private bool LynaPsp() + { + IList material_list = new List(); + foreach (ClientCard monster in Bot.GetMonsters()) + { + if (monster.HasAttribute(CardAttribute.Light) && !monster.IsCode(CardId.KnightmareCerberus, CardId.InspectBoarder, CardId.GrenMajuDaEizo, CardId.KnightmarePhoenix, CardId.LynaP, CardId.HiitaP, CardId.WynnP, CardId.EriaP, CardId.AussaP, CardId.KnightmareUnicorn, CardId.KnightmareGryphon, CardId.BorreloadDragon, CardId.BirrelswordDragon)) + material_list.Add(monster); + if (material_list.Count == 2) break; + } + if (material_list.Count < 2) return false; + if (Bot.HasInMonstersZone(CardId.LynaP)) return false; + AI.SelectMaterials(material_list); + if (Bot.MonsterZone[0] == null && Bot.MonsterZone[2] == null && Bot.MonsterZone[5] == null) + AI.SelectPlace(Zones.z5); + else + AI.SelectPlace(Zones.z6); + return true; + } + + private bool LynaPeff() + { + AI.SelectCard(CardId.Lyna); + return true; + } + + private bool Linkuribohsp() + { + + foreach (ClientCard c in Bot.GetMonsters()) + { + if (c.Level == 1) + { + AI.SelectMaterials(c); + return true; + } + } + return false; + } + + private bool Knightmaresp() + { + int[] firstMats = new[] { + CardId.KnightmareCerberus, + CardId.KnightmarePhoenix + }; + if (Bot.MonsterZone.GetMatchingCardsCount(card => card.IsCode(firstMats)) >= 1) return false; + foreach (ClientCard c in Bot.GetMonsters()) + { + if (c.Level == 1) + { + AI.SelectMaterials(c); + return true; + } + } + return false; + } + private bool Linkuriboheff() + { + if (Duel.LastChainPlayer == 0 && Util.GetLastChainCard().IsCode(CardId.Linkuriboh)) return false; + return true; + } + + private bool GagagaCowboySummon() + { + if (Enemy.LifePoints <= 800 || (Bot.GetMonsterCount() >= 4 && Enemy.LifePoints <= 1600)) + { + AI.SelectPosition(CardPosition.FaceUpDefence); + return true; + } + return false; + } + private bool SpellSet() + { + if (Card.IsCode(CardId.MacroCosmos) && Bot.HasInSpellZone(CardId.MacroCosmos)) return false; + if (Card.IsCode(CardId.Unpossessed) && Bot.HasInSpellZone(CardId.Unpossessed)) return false; + if (Card.IsCode(CardId.Crackdown) && Bot.HasInSpellZone(CardId.Crackdown)) return false; + if (Card.IsCode(CardId.SkillDrain) && Bot.HasInSpellZone(CardId.SkillDrain)) return false; + if (Card.IsCode(CardId.Mistake) && Bot.HasInSpellZone(CardId.Mistake)) return false; + if (Card.IsCode(CardId.Scapegoat)) + return true; + if (Card.HasType(CardType.Trap)) + return Bot.GetSpellCountWithoutField() < 4; + return false; + } + public override ClientCard OnSelectAttacker(IList attackers, IList defenders) + { + for (int i = 0; i < attackers.Count; ++i) + { + ClientCard attacker = attackers[i]; + if (attacker.IsCode(CardId.BirrelswordDragon, CardId.BorreloadDragon)) return attacker; + } + return null; + } + public override bool OnSelectHand() + { + return true; + } + } +} \ No newline at end of file diff --git a/libWindbot/Game/AI/Decks/FrogExecutor.cs b/libWindbot/Game/AI/Decks/FrogExecutor.cs index b313057..bae73e3 100644 --- a/libWindbot/Game/AI/Decks/FrogExecutor.cs +++ b/libWindbot/Game/AI/Decks/FrogExecutor.cs @@ -83,18 +83,10 @@ public FrogExecutor(GameAI ai, Duel duel) private int m_swapFrogSummoned; private int m_flipFlopFrogSummoned; - private int m_treebornFrogCount = 0; - - public override void OnNewTurn() - { - m_treebornFrogCount = 0; - base.OnNewTurn(); - } private bool TreebornFrog() { - m_treebornFrogCount++; - return m_treebornFrogCount <= 5; + return true; } private bool SwapFrogSummon() diff --git a/libWindbot/Game/AI/Decks/HorusExecutor.cs b/libWindbot/Game/AI/Decks/HorusExecutor.cs index 97fe2f7..f1525f0 100644 --- a/libWindbot/Game/AI/Decks/HorusExecutor.cs +++ b/libWindbot/Game/AI/Decks/HorusExecutor.cs @@ -56,7 +56,7 @@ public HorusExecutor(GameAI ai, Duel duel) : base(ai, duel) AddExecutor(ExecutorType.Activate, CardId.MonsterReborn, MonsterReborn); AddExecutor(ExecutorType.Summon, CardId.WhiteNightDragon, WhiteNightDragon); - AddExecutor(ExecutorType.Summon, CardId.HorusTheBlackFlameDragonLv6, DefaultTributeSummon); + AddExecutor(ExecutorType.Summon, CardId.HorusTheBlackFlameDragonLv6, DefaultMonsterSummon); AddExecutor(ExecutorType.Summon, CardId.AlexandriteDragon); AddExecutor(ExecutorType.SummonOrSet, CardId.AxeDragonute); AddExecutor(ExecutorType.SummonOrSet, CardId.DodgerDragon); @@ -157,7 +157,7 @@ private bool WhiteNightDragon() if (card.IsCode(11224103)) return false; - return DefaultTributeSummon(); + return DefaultMonsterSummon(); } private bool HorusTheBlackFlameDragonLv8() diff --git a/libWindbot/Game/AI/Decks/Level8Executor.cs b/libWindbot/Game/AI/Decks/Level8Executor.cs index 0cd7215..75800b8 100644 --- a/libWindbot/Game/AI/Decks/Level8Executor.cs +++ b/libWindbot/Game/AI/Decks/Level8Executor.cs @@ -184,7 +184,6 @@ public Level8Executor(GameAI ai, Duel duel) private bool JetSynchronUsed = false; private bool ScrapWyvernUsed = false; private bool MaskedChameleonUsed = false; - private int ShootingRiserDragonCount = 0; private int[] HandCosts = new[] { @@ -218,7 +217,6 @@ public override void OnNewTurn() JetSynchronUsed = false; ScrapWyvernUsed = false; MaskedChameleonUsed = false; - ShootingRiserDragonCount = 0; } public override void OnChainEnd() @@ -845,9 +843,8 @@ private bool ShootingRiserDragonEffect() } else { - if (Duel.LastChainPlayer == 0 || ShootingRiserDragonCount >= 10) + if (Duel.LastChainPlayer == 0) return false; - ShootingRiserDragonCount++; AI.SelectCard(new[] { CardId.BlackRoseMoonlightDragon, CardId.ScrapDragon, diff --git a/libWindbot/Game/AI/Decks/LightswornShaddoldinosourExecutor.cs b/libWindbot/Game/AI/Decks/LightswornShaddoldinosourExecutor.cs index 99666f8..4e6d7b3 100644 --- a/libWindbot/Game/AI/Decks/LightswornShaddoldinosourExecutor.cs +++ b/libWindbot/Game/AI/Decks/LightswornShaddoldinosourExecutor.cs @@ -1,1280 +1,1277 @@ -using YGOSharp.OCGWrapper.Enums; -using System.Collections.Generic; -using WindBot; -using WindBot.Game; -using WindBot.Game.AI; - -namespace WindBot.Game.AI.Decks -{ - [Deck("LightswornShaddoldinosour", "AI_LightswornShaddoldinosour")] - public class LightswornShaddoldinosour : DefaultExecutor - { - public class CardId - { - //monster - public const int UltimateConductorTytanno = 18940556; - public const int DogorantheMadFlameKaiju = 93332803; - public const int GamecieltheSeaTurtleKaiju = 55063751; - public const int RadiantheMultidimensionalKaiju = 28674152; - public const int OvertexCoatls = 41782653; - public const int ShaddollBeast = 3717252; - public const int GiantRex = 80280944; - public const int ShaddollDragon = 77723643; - public const int FairyTailSnow = 55623480; - public const int KeeperOfDragonicMagic = 48048590; - public const int ShaddollSquamata = 30328508; - public const int SouleatingOviraptor = 44335251; - public const int Raiden = 77558536; - public const int Lumina = 95503687; - public const int ShaddollHedgehog = 4939890; - public const int AshBlossom = 14558127; - public const int GhostOgre = 59438930; - public const int ShaddollFalco = 37445295; - public const int MaxxC = 23434538; - public const int PlaguespreaderZombie = 33420078; - public const int GlowUpBulb = 67441435; - - //spell - public const int AllureofDarkness = 1475311; - public const int ThatGrassLooksgreener = 11110587; - public const int HarpiesFeatherDuster = 18144506; - public const int DoubleEvolutionPill = 38179121; - public const int ShaddollFusion = 44394295; - public const int PotOfAvarice = 67169062; - public const int FoolishBurial = 81439173; - public const int MonsterReborn = 83764718; - public const int ChargeOfTheLightBrigade = 94886282; - public const int InterruptedKaijuSlumber = 99330325; - //public const int ElShaddollFusion = 6417578; - - //trap - public const int infiniteTransience = 10045474; - public const int LostWind = 74003290; - public const int SinisterShadowGames = 77505534; - public const int ShaddollCore = 4904633; - - //extra - public const int ElShaddollShekhinaga = 74822425; - public const int ElShaddollConstruct = 20366274; - public const int ElShaddollGrysra = 48424886; - public const int ElShaddollWinda = 94977269; - public const int CrystalWingSynchroDragon = 50954680; - public const int ScarlightRedDragon = 80666118; - public const int Michael = 4779823; - public const int BlackRoseMoonlightDragon = 33698022; - public const int RedWyvern = 76547525; - public const int CoralDragon = 42566602; - public const int TG_WonderMagician = 98558751; - public const int MinervaTheExalte = 30100551; - public const int Sdulldeat = 74997493; - public const int CrystronNeedlefiber = 50588353; - } - - - - public LightswornShaddoldinosour(GameAI ai, Duel duel) - : base(ai, duel) - { - //counter - AddExecutor(ExecutorType.Activate, CardId.GhostOgre, Hand_act_eff); - AddExecutor(ExecutorType.Activate, CardId.AshBlossom, Hand_act_eff); - AddExecutor(ExecutorType.Activate, CardId.MaxxC,MaxxC); - //first do - AddExecutor(ExecutorType.Activate, CardId.HarpiesFeatherDuster, DefaultHarpiesFeatherDusterFirst); - AddExecutor(ExecutorType.Activate, CardId.infiniteTransience, DefaultBreakthroughSkill); - AddExecutor(ExecutorType.Activate, CardId.ThatGrassLooksgreener); - AddExecutor(ExecutorType.Summon, CardId.SouleatingOviraptor); - AddExecutor(ExecutorType.Activate, CardId.SouleatingOviraptor, SouleatingOviraptoreff); - AddExecutor(ExecutorType.Activate, CardId.AllureofDarkness, DefaultAllureofDarkness); - AddExecutor(ExecutorType.Activate, CardId.PotOfAvarice, PotofAvariceeff); - AddExecutor(ExecutorType.Activate, CardId.ChargeOfTheLightBrigade, ChargeOfTheLightBrigadeEffect); - AddExecutor(ExecutorType.Activate, CardId.FoolishBurial, FoolishBurialEffect); - AddExecutor(ExecutorType.Activate, CardId.InterruptedKaijuSlumber, InterruptedKaijuSlumbereff); - AddExecutor(ExecutorType.Activate, CardId.ShaddollFusion, ShaddollFusioneff); - //Normal Summon - AddExecutor(ExecutorType.Summon, CardId.Raiden); - AddExecutor(ExecutorType.Activate, CardId.Raiden); - AddExecutor(ExecutorType.Summon , CardId.KeeperOfDragonicMagic); - AddExecutor(ExecutorType.Activate, CardId.KeeperOfDragonicMagic, KeeperOfDragonicMagiceff); - AddExecutor(ExecutorType.MonsterSet, CardId.ShaddollSquamata); - AddExecutor(ExecutorType.MonsterSet, CardId.GlowUpBulb); - AddExecutor(ExecutorType.Summon, CardId.Lumina, Luminasummon); - AddExecutor(ExecutorType.MonsterSet, CardId.ShaddollHedgehog); - AddExecutor(ExecutorType.MonsterSet, CardId.ShaddollDragon); - AddExecutor(ExecutorType.Summon, CardId.FairyTailSnow,FairyTailSnowsummon); - AddExecutor(ExecutorType.Activate, CardId.FairyTailSnow, FairyTailSnoweff); - AddExecutor(ExecutorType.Activate, CardId.Lumina, Luminaeff); - //activate - AddExecutor(ExecutorType.Activate, CardId.GlowUpBulb, GlowUpBulbeff); - AddExecutor(ExecutorType.Activate, CardId.TG_WonderMagician, TG_WonderMagicianeff); - AddExecutor(ExecutorType.Activate, CardId.CoralDragon, CoralDragoneff); - AddExecutor(ExecutorType.Activate, CardId.RedWyvern, RedWyverneff); - AddExecutor(ExecutorType.Activate, CardId.CrystalWingSynchroDragon, CrystalWingSynchroDragoneff); - AddExecutor(ExecutorType.Activate, CardId.BlackRoseMoonlightDragon, BlackRoseMoonlightDragoneff); - AddExecutor(ExecutorType.Activate, CardId.Sdulldeat, Sdulldeateff); - AddExecutor(ExecutorType.Activate, CardId.Michael, Michaeleff); - AddExecutor(ExecutorType.Activate, CardId.ScarlightRedDragon, ScarlightRedDragoneff); - //Sp Summon - - AddExecutor(ExecutorType.Activate, CardId.CrystronNeedlefiber, CrystronNeedlefibereff); - AddExecutor(ExecutorType.SpSummon, CardId.UltimateConductorTytanno, UltimateConductorTytannosp); - AddExecutor(ExecutorType.Activate, CardId.UltimateConductorTytanno, UltimateConductorTytannoeff); - AddExecutor(ExecutorType.Activate, CardId.DoubleEvolutionPill, DoubleEvolutionPilleff); - //extra - AddExecutor(ExecutorType.SpSummon, CardId.CrystalWingSynchroDragon); - AddExecutor(ExecutorType.Activate, CardId.CrystalWingSynchroDragon, CrystalWingSynchroDragoneff); - AddExecutor(ExecutorType.SpSummon, CardId.ScarlightRedDragon, ScarlightRedDragonsp); - AddExecutor(ExecutorType.Activate, CardId.ScarlightRedDragon, ScarlightRedDragoneff); - AddExecutor(ExecutorType.SpSummon, CardId.Michael, Michaelsp); - AddExecutor(ExecutorType.Activate, CardId.Michael, Michaeleff); - AddExecutor(ExecutorType.SpSummon, CardId.RedWyvern, RedWyvernsp); - AddExecutor(ExecutorType.Activate, CardId.RedWyvern, RedWyverneff); - AddExecutor(ExecutorType.SpSummon, CardId.MinervaTheExalte); - AddExecutor(ExecutorType.Activate, CardId.MinervaTheExalte, MinervaTheExaltedEffect); - AddExecutor(ExecutorType.SpSummon, CardId.CrystronNeedlefiber, CrystronNeedlefibersp); - //Kaiju - AddExecutor(ExecutorType.SpSummon, CardId.GamecieltheSeaTurtleKaiju, GamecieltheSeaTurtleKaijusp); - AddExecutor(ExecutorType.SpSummon, CardId.RadiantheMultidimensionalKaiju, RadiantheMultidimensionalKaijusp); - AddExecutor(ExecutorType.SpSummon, CardId.DogorantheMadFlameKaiju, DogorantheMadFlameKaijusp); - //Reborn - AddExecutor(ExecutorType.Activate, CardId.MonsterReborn, Reborneff); - //activate chain - AddExecutor(ExecutorType.Activate, CardId.OvertexCoatls, OvertexCoatlseff); - AddExecutor(ExecutorType.Activate, CardId.ShaddollCore, ShaddollCoreeff); - AddExecutor(ExecutorType.Activate, CardId.ShaddollBeast, ShaddollBeasteff); - AddExecutor(ExecutorType.Activate, CardId.ShaddollFalco, ShaddollFalcoeff); - AddExecutor(ExecutorType.Activate, CardId.ShaddollDragon, ShaddollDragoneff); - AddExecutor(ExecutorType.Activate, CardId.ShaddollHedgehog, ShaddollHedgehogeff); - AddExecutor(ExecutorType.Activate, CardId.ShaddollSquamata, ShaddollSquamataeff); - AddExecutor(ExecutorType.Activate, CardId.GiantRex); - AddExecutor(ExecutorType.Activate, CardId.ElShaddollConstruct, ElShaddollConstructeff); - AddExecutor(ExecutorType.Activate, CardId.ElShaddollGrysra, ElShaddollGrysraeff); - AddExecutor(ExecutorType.Activate, CardId.ElShaddollShekhinaga, ElShaddollShekhinagaeff); - AddExecutor(ExecutorType.Activate, CardId.ElShaddollWinda); - //spellset - AddExecutor(ExecutorType.SpellSet, CardId.ThatGrassLooksgreener, SpellSetZone); - AddExecutor(ExecutorType.SpellSet, SpellSetZone); - //trapset - AddExecutor(ExecutorType.SpellSet, CardId.LostWind); - AddExecutor(ExecutorType.SpellSet, CardId.SinisterShadowGames); - AddExecutor(ExecutorType.SpellSet, CardId.ShaddollCore); - AddExecutor(ExecutorType.SpellSet, CardId.infiniteTransience, SetIsFieldEmpty); - //trap activate - AddExecutor(ExecutorType.Activate, CardId.LostWind, LostWindeff); - AddExecutor(ExecutorType.Activate, CardId.SinisterShadowGames, SinisterShadowGameseff); - - AddExecutor(ExecutorType.Repos, MonsterRepos); - } - public int[] all_List() - { - return new[] - { - CardId.UltimateConductorTytanno, - CardId.DogorantheMadFlameKaiju, - CardId.GamecieltheSeaTurtleKaiju, - CardId.RadiantheMultidimensionalKaiju, - CardId.OvertexCoatls, - CardId.ShaddollBeast, - CardId.GiantRex, - CardId.ShaddollDragon, - CardId.FairyTailSnow, - CardId.KeeperOfDragonicMagic, - CardId.ShaddollSquamata, - CardId.SouleatingOviraptor, - CardId.Raiden, - CardId.Lumina, - CardId.ShaddollHedgehog, - CardId.AshBlossom, - CardId.GhostOgre, - CardId.ShaddollFalco, - CardId.MaxxC, - CardId.PlaguespreaderZombie, - CardId.GlowUpBulb, - - CardId.AllureofDarkness, - CardId.ThatGrassLooksgreener, - CardId.HarpiesFeatherDuster, - CardId.DoubleEvolutionPill, - CardId.ShaddollFusion, - CardId.PotOfAvarice, - CardId.FoolishBurial, - CardId.MonsterReborn, - CardId.ChargeOfTheLightBrigade, - CardId.InterruptedKaijuSlumber, - //CardId.ElShaddollFusion, - - CardId.infiniteTransience, - CardId.LostWind, - CardId.SinisterShadowGames, - CardId.ShaddollCore, - - - }; - } - public int[] Useless_List() - { - return new[] - { - CardId.GlowUpBulb, - CardId.PlaguespreaderZombie, - CardId.ChargeOfTheLightBrigade, - CardId.ThatGrassLooksgreener, - CardId.HarpiesFeatherDuster, - CardId.FairyTailSnow, - CardId.GiantRex, - CardId.Lumina, - CardId.OvertexCoatls, - CardId.InterruptedKaijuSlumber, - CardId.FoolishBurial, - }; - } - int Ultimate_ss = 0; - int Enemy_atk = 0; - int TG_WonderMagician_count = 0; - bool Pillused = false; - bool CrystronNeedlefibereff_used = false; - bool OvertexCoatlseff_used = false; - bool ShaddollBeast_used = false; - bool ShaddollFalco_used = false; - bool ShaddollSquamata_used = false; - bool ShaddollDragon_used = false; - bool ShaddollHedgehog_used = false; - - public int GetTotalATK(IList list) - { - - int atk = 0; - foreach (ClientCard c in list) - { - if (c == null) continue; - atk += c.Attack; - } - return atk; - } - - public override void OnNewPhase() - { - Enemy_atk = 0; - IList list = new List(); - foreach (ClientCard monster in Enemy.GetMonsters()) - { - if(monster.IsAttack()) - list.Add(monster); - } - //if (GetTotalATK(list) / 2 >= Bot.LifePoints) return false; - Enemy_atk = GetTotalATK(list); - //SLogger.DebugWriteLine("++++++++++++++++++" + Enemy_atk + "++++++++++++"); - } - public override void OnNewTurn() - { - Pillused = false; - OvertexCoatlseff_used = false; - CrystronNeedlefibereff_used = false; - ShaddollBeast_used = false; - ShaddollFalco_used = false; - ShaddollSquamata_used = false; - ShaddollDragon_used = false; - ShaddollHedgehog_used = false; - TG_WonderMagician_count = 0; - } - - private bool Luminasummon() - { - if (Bot.Deck.Count >= 20) return true; - IList extra = Bot.GetMonstersInExtraZone(); - if (extra != null) - foreach (ClientCard monster in extra) - if (!monster.HasType(CardType.Link)) - return false; - if (Bot.LifePoints <= 3000) return true; - if (Bot.HasInGraveyard(CardId.Raiden)) return true; - return false; - } - private bool Luminaeff() - { - if (Bot.HasInGraveyard(CardId.Raiden)) - { - AI.SelectCard(Useless_List()); - AI.SelectNextCard(CardId.Raiden); - return true; - } - return false; - } - - - private bool UltimateConductorTytannoeff() - { - IList targets = new[] { - CardId.OvertexCoatls, - CardId.ShaddollBeast, - CardId.ShaddollSquamata, - CardId.ShaddollHedgehog, - CardId.ShaddollDragon, - CardId.ShaddollFalco, - CardId.GlowUpBulb, - CardId.PlaguespreaderZombie, - CardId.FairyTailSnow, - CardId.KeeperOfDragonicMagic, - CardId.DogorantheMadFlameKaiju, - CardId.GamecieltheSeaTurtleKaiju, - CardId.RadiantheMultidimensionalKaiju, - CardId.GiantRex, - CardId.ShaddollCore, - CardId.SouleatingOviraptor, - CardId.Raiden, - CardId.Lumina, - CardId.AshBlossom, - CardId.GhostOgre, - CardId.MaxxC, - }; - - if (Duel.Phase == DuelPhase.Main1) - { - if(Duel.Player==0) - { - int count = 0; - IList check = Enemy.GetMonsters(); - foreach (ClientCard monster in check) - if (monster.Attack > 2500 || monster == Enemy.MonsterZone.GetDangerousMonster()) - count++; - if(count==0)return false; - } - if (!Bot.HasInHand(targets)) - { - if(!Bot.HasInMonstersZone(targets)) - return false; - } - AI.SelectCard(targets); - return true; - } - if (Duel.Phase == DuelPhase.BattleStart) - { - AI.SelectYesNo(true); - return true; - } - return false; - - } - - private bool GamecieltheSeaTurtleKaijusp() - { - if (!Bot.HasInMonstersZone(CardId.UltimateConductorTytanno)) - return DefaultKaijuSpsummon(); - return false; - } - - private bool RadiantheMultidimensionalKaijusp() - { - if (Enemy.HasInMonstersZone(CardId.GamecieltheSeaTurtleKaiju)) return true; - if (Bot.HasInHand(CardId.DogorantheMadFlameKaiju) && !Bot.HasInMonstersZone(CardId.UltimateConductorTytanno)) return DefaultKaijuSpsummon(); - return false; - } - - - private bool DogorantheMadFlameKaijusp() - { - if (Enemy.HasInMonstersZone(CardId.GamecieltheSeaTurtleKaiju)) return true; - if (Enemy.HasInMonstersZone(CardId.RadiantheMultidimensionalKaiju)) return true; - return false; - } - - - private bool InterruptedKaijuSlumbereff() - { - if (Enemy.GetMonsterCount() - Bot.GetMonsterCount() >= 2 ) - return DefaultInterruptedKaijuSlumber(); - return false; - } - private bool UltimateConductorTytannosp() - { - - Pillused = true; - foreach (ClientCard card in Bot.GetMonsters()) - { - if (card.IsCode(CardId.UltimateConductorTytanno) && card.IsFaceup()) - return false; - } - Ultimate_ss++; - return true; - - } - - private bool KeeperOfDragonicMagiceff() - { - if (ActivateDescription == -1) - { - AI.SelectCard(Useless_List()); - return true; - } - return true; - } - - private bool MonsterRepos() - { - if (Card.IsCode(CardId.UltimateConductorTytanno) && Card.IsFacedown()) return true; - if (Card.IsCode(CardId.ElShaddollConstruct) && Card.IsFacedown()) return true; - if (Card.IsCode(CardId.ElShaddollConstruct) && Card.IsAttack()) return false; - if (Card.IsCode(CardId.GlowUpBulb) && Card.IsDefense()) return false; - if (Card.IsCode(CardId.ShaddollDragon) && Card.IsFacedown() && Enemy.GetMonsterCount() >= 0) return true; - if (Card.IsCode(CardId.ShaddollSquamata) && Card.IsFacedown() && Enemy.GetMonsterCount() >= 0) return true; - return base.DefaultMonsterRepos(); - } - - private bool OvertexCoatlseff() - { - if (Card.Location == CardLocation.MonsterZone) return false; - OvertexCoatlseff_used = true; - return true; - } - - private bool DoubleEvolutionPilleff() - { - foreach (ClientCard card in Bot.GetMonsters()) - { - if (card.IsCode(CardId.UltimateConductorTytanno) && card.IsFaceup()) - return false; - } - if (Pillused == true) return false; - Pillused = true; - IList targets = new[] { - CardId.GiantRex, - CardId.DogorantheMadFlameKaiju, - CardId.GamecieltheSeaTurtleKaiju, - CardId.RadiantheMultidimensionalKaiju, - CardId.OvertexCoatls, - CardId.SouleatingOviraptor, - CardId.UltimateConductorTytanno, - }; - if (Bot.HasInGraveyard(targets)) - { - AI.SelectCard(CardId.GiantRex, CardId.DogorantheMadFlameKaiju, CardId.OvertexCoatls, CardId.GamecieltheSeaTurtleKaiju, CardId.RadiantheMultidimensionalKaiju, CardId.SouleatingOviraptor, CardId.UltimateConductorTytanno); - } - else - { - AI.SelectCard(CardId.GiantRex, CardId.DogorantheMadFlameKaiju, CardId.GamecieltheSeaTurtleKaiju, CardId.RadiantheMultidimensionalKaiju, CardId.OvertexCoatls, CardId.SouleatingOviraptor, CardId.UltimateConductorTytanno); - } - IList targets2 = new[] { - CardId.GiantRex, - CardId.DogorantheMadFlameKaiju, - CardId.GamecieltheSeaTurtleKaiju, - CardId.RadiantheMultidimensionalKaiju, - CardId.OvertexCoatls, - CardId.SouleatingOviraptor, - CardId.UltimateConductorTytanno, - }; - if (Bot.HasInGraveyard(targets)) - { - AI.SelectNextCard(CardId.ShaddollBeast, CardId.ShaddollDragon, CardId.KeeperOfDragonicMagic, CardId.ShaddollSquamata, CardId.SouleatingOviraptor, CardId.Raiden, CardId.Lumina, CardId.ShaddollHedgehog, CardId.AshBlossom, CardId.GhostOgre, CardId.ShaddollFalco, CardId.MaxxC, CardId.PlaguespreaderZombie, CardId.GlowUpBulb, CardId.FairyTailSnow); - } - else - AI.SelectNextCard(CardId.ShaddollBeast, CardId.ShaddollDragon, CardId.KeeperOfDragonicMagic, CardId.ShaddollSquamata, CardId.SouleatingOviraptor, CardId.Raiden, CardId.Lumina, CardId.ShaddollHedgehog, CardId.AshBlossom, CardId.GhostOgre, CardId.ShaddollFalco, CardId.MaxxC, CardId.PlaguespreaderZombie, CardId.GlowUpBulb, CardId.FairyTailSnow); - - AI.SelectThirdCard(new[] { - CardId.UltimateConductorTytanno, - - }); - - return Enemy.GetMonsterCount() >= 1; - } - - - private bool FairyTailSnowsummon() - { - ClientCard target = Util.GetBestEnemyMonster(true, true); - if(target != null) - { - return true; - } - return false; - } - - - private bool FairyTailSnoweff() - { - - if (Card.Location == CardLocation.MonsterZone) - { - AI.SelectCard(Util.GetBestEnemyMonster(true, true)); - return true; - } - else - { - - int spell_count = 0; - IList grave = Bot.Graveyard; - IList all = new List(); - foreach (ClientCard check in grave) - { - if (check.IsCode(CardId.GiantRex)) - { - all.Add(check); - } - } - foreach (ClientCard check in grave) - { - if(check.HasType(CardType.Spell)||check.HasType(CardType.Trap)) - { - spell_count++; - all.Add(check); - } - } - foreach (ClientCard check in grave) - { - if (check.HasType(CardType.Monster)) - { - all.Add(check); - } - } - if (Util.ChainContainsCard(CardId.FairyTailSnow)) return false; - - if ( Duel.Player == 1 && Duel.Phase == DuelPhase.BattleStart && Bot.BattlingMonster == null && Enemy_atk >=Bot.LifePoints || - Duel.Player == 0 && Duel.Phase==DuelPhase.BattleStart && Enemy.BattlingMonster == null && Enemy.LifePoints<=1850 - ) - { - AI.SelectCard(all); - AI.SelectNextCard(Util.GetBestEnemyMonster()); - return true; - } - } - return false; - } - - - private bool SouleatingOviraptoreff() - { - if (!OvertexCoatlseff_used && Bot.GetRemainingCount(CardId.OvertexCoatls, 3) > 0) - { - AI.SelectCard(CardId.OvertexCoatls); - AI.SelectOption(0); - } - else - { - AI.SelectCard(CardId.UltimateConductorTytanno); - AI.SelectOption(1); - } - return true; - } - - private bool GlowUpBulbeff() - { - IList check = Bot.GetMonstersInExtraZone(); - foreach (ClientCard monster in check) - if (monster.HasType(CardType.Fusion)) return false; - if (Bot.HasInMonstersZone(CardId.Lumina) || - Bot.HasInMonstersZone(CardId.FairyTailSnow) || - Bot.HasInMonstersZone(CardId.KeeperOfDragonicMagic) || - Bot.HasInMonstersZone(CardId.SouleatingOviraptor) || - Bot.HasInMonstersZone(CardId.GiantRex) || - Bot.HasInMonstersZone(CardId.Raiden) - ) - { - AI.SelectPosition(CardPosition.FaceUpDefence); - return true; - } - return false; - } - +using YGOSharp.OCGWrapper.Enums; +using System.Collections.Generic; +using WindBot; +using WindBot.Game; +using WindBot.Game.AI; + +namespace WindBot.Game.AI.Decks +{ + [Deck("LightswornShaddoldinosour", "AI_LightswornShaddoldinosour")] + public class LightswornShaddoldinosour : DefaultExecutor + { + public class CardId + { + //monster + public const int UltimateConductorTytanno = 18940556; + public const int DogorantheMadFlameKaiju = 93332803; + public const int GamecieltheSeaTurtleKaiju = 55063751; + public const int RadiantheMultidimensionalKaiju = 28674152; + public const int OvertexCoatls = 41782653; + public const int ShaddollBeast = 3717252; + public const int GiantRex = 80280944; + public const int ShaddollDragon = 77723643; + public const int FairyTailSnow = 55623480; + public const int KeeperOfDragonicMagic = 48048590; + public const int ShaddollSquamata = 30328508; + public const int SouleatingOviraptor = 44335251; + public const int Raiden = 77558536; + public const int Lumina = 95503687; + public const int ShaddollHedgehog = 4939890; + public const int AshBlossom = 14558127; + public const int GhostOgre = 59438930; + public const int ShaddollFalco = 37445295; + public const int MaxxC = 23434538; + public const int PlaguespreaderZombie = 33420078; + public const int GlowUpBulb = 67441435; + + //spell + public const int AllureofDarkness = 1475311; + public const int ThatGrassLooksgreener = 11110587; + public const int HarpiesFeatherDuster = 18144506; + public const int DoubleEvolutionPill = 38179121; + public const int ShaddollFusion = 44394295; + public const int PotOfAvarice = 67169062; + public const int FoolishBurial = 81439173; + public const int MonsterReborn = 83764718; + public const int ChargeOfTheLightBrigade = 94886282; + public const int InterruptedKaijuSlumber = 99330325; + //public const int ElShaddollFusion = 6417578; + + //trap + public const int infiniteTransience = 10045474; + public const int LostWind = 74003290; + public const int SinisterShadowGames = 77505534; + public const int ShaddollCore = 4904633; + + //extra + public const int ElShaddollShekhinaga = 74822425; + public const int ElShaddollConstruct = 20366274; + public const int ElShaddollGrysra = 48424886; + public const int ElShaddollWinda = 94977269; + public const int CrystalWingSynchroDragon = 50954680; + public const int ScarlightRedDragon = 80666118; + public const int Michael = 4779823; + public const int BlackRoseMoonlightDragon = 33698022; + public const int RedWyvern = 76547525; + public const int CoralDragon = 42566602; + public const int TG_WonderMagician = 98558751; + public const int MinervaTheExalte = 30100551; + public const int Sdulldeat = 74997493; + public const int CrystronNeedlefiber = 50588353; + } + + + + public LightswornShaddoldinosour(GameAI ai, Duel duel) + : base(ai, duel) + { + //counter + AddExecutor(ExecutorType.Activate, CardId.GhostOgre, Hand_act_eff); + AddExecutor(ExecutorType.Activate, CardId.AshBlossom, Hand_act_eff); + AddExecutor(ExecutorType.Activate, CardId.MaxxC,MaxxC); + //first do + AddExecutor(ExecutorType.Activate, CardId.HarpiesFeatherDuster, DefaultHarpiesFeatherDusterFirst); + AddExecutor(ExecutorType.Activate, CardId.infiniteTransience, DefaultBreakthroughSkill); + AddExecutor(ExecutorType.Activate, CardId.ThatGrassLooksgreener); + AddExecutor(ExecutorType.Summon, CardId.SouleatingOviraptor); + AddExecutor(ExecutorType.Activate, CardId.SouleatingOviraptor, SouleatingOviraptoreff); + AddExecutor(ExecutorType.Activate, CardId.AllureofDarkness, DefaultAllureofDarkness); + AddExecutor(ExecutorType.Activate, CardId.PotOfAvarice, PotofAvariceeff); + AddExecutor(ExecutorType.Activate, CardId.ChargeOfTheLightBrigade, ChargeOfTheLightBrigadeEffect); + AddExecutor(ExecutorType.Activate, CardId.FoolishBurial, FoolishBurialEffect); + AddExecutor(ExecutorType.Activate, CardId.InterruptedKaijuSlumber, InterruptedKaijuSlumbereff); + AddExecutor(ExecutorType.Activate, CardId.ShaddollFusion, ShaddollFusioneff); + //Normal Summon + AddExecutor(ExecutorType.Summon, CardId.Raiden); + AddExecutor(ExecutorType.Activate, CardId.Raiden); + AddExecutor(ExecutorType.Summon , CardId.KeeperOfDragonicMagic); + AddExecutor(ExecutorType.Activate, CardId.KeeperOfDragonicMagic, KeeperOfDragonicMagiceff); + AddExecutor(ExecutorType.MonsterSet, CardId.ShaddollSquamata); + AddExecutor(ExecutorType.MonsterSet, CardId.GlowUpBulb); + AddExecutor(ExecutorType.Summon, CardId.Lumina, Luminasummon); + AddExecutor(ExecutorType.MonsterSet, CardId.ShaddollHedgehog); + AddExecutor(ExecutorType.MonsterSet, CardId.ShaddollDragon); + AddExecutor(ExecutorType.Summon, CardId.FairyTailSnow,FairyTailSnowsummon); + AddExecutor(ExecutorType.Activate, CardId.FairyTailSnow, FairyTailSnoweff); + AddExecutor(ExecutorType.Activate, CardId.Lumina, Luminaeff); + //activate + AddExecutor(ExecutorType.Activate, CardId.GlowUpBulb, GlowUpBulbeff); + AddExecutor(ExecutorType.Activate, CardId.TG_WonderMagician, TG_WonderMagicianeff); + AddExecutor(ExecutorType.Activate, CardId.CoralDragon, CoralDragoneff); + AddExecutor(ExecutorType.Activate, CardId.RedWyvern, RedWyverneff); + AddExecutor(ExecutorType.Activate, CardId.CrystalWingSynchroDragon, CrystalWingSynchroDragoneff); + AddExecutor(ExecutorType.Activate, CardId.BlackRoseMoonlightDragon, BlackRoseMoonlightDragoneff); + AddExecutor(ExecutorType.Activate, CardId.Sdulldeat, Sdulldeateff); + AddExecutor(ExecutorType.Activate, CardId.Michael, Michaeleff); + AddExecutor(ExecutorType.Activate, CardId.ScarlightRedDragon, ScarlightRedDragoneff); + //Sp Summon + + AddExecutor(ExecutorType.Activate, CardId.CrystronNeedlefiber, CrystronNeedlefibereff); + AddExecutor(ExecutorType.SpSummon, CardId.UltimateConductorTytanno, UltimateConductorTytannosp); + AddExecutor(ExecutorType.Activate, CardId.UltimateConductorTytanno, UltimateConductorTytannoeff); + AddExecutor(ExecutorType.Activate, CardId.DoubleEvolutionPill, DoubleEvolutionPilleff); + //extra + AddExecutor(ExecutorType.SpSummon, CardId.CrystalWingSynchroDragon); + AddExecutor(ExecutorType.Activate, CardId.CrystalWingSynchroDragon, CrystalWingSynchroDragoneff); + AddExecutor(ExecutorType.SpSummon, CardId.ScarlightRedDragon, ScarlightRedDragonsp); + AddExecutor(ExecutorType.Activate, CardId.ScarlightRedDragon, ScarlightRedDragoneff); + AddExecutor(ExecutorType.SpSummon, CardId.Michael, Michaelsp); + AddExecutor(ExecutorType.Activate, CardId.Michael, Michaeleff); + AddExecutor(ExecutorType.SpSummon, CardId.RedWyvern, RedWyvernsp); + AddExecutor(ExecutorType.Activate, CardId.RedWyvern, RedWyverneff); + AddExecutor(ExecutorType.SpSummon, CardId.MinervaTheExalte); + AddExecutor(ExecutorType.Activate, CardId.MinervaTheExalte, MinervaTheExaltedEffect); + AddExecutor(ExecutorType.SpSummon, CardId.CrystronNeedlefiber, CrystronNeedlefibersp); + //Kaiju + AddExecutor(ExecutorType.SpSummon, CardId.GamecieltheSeaTurtleKaiju, GamecieltheSeaTurtleKaijusp); + AddExecutor(ExecutorType.SpSummon, CardId.RadiantheMultidimensionalKaiju, RadiantheMultidimensionalKaijusp); + AddExecutor(ExecutorType.SpSummon, CardId.DogorantheMadFlameKaiju, DogorantheMadFlameKaijusp); + //Reborn + AddExecutor(ExecutorType.Activate, CardId.MonsterReborn, Reborneff); + //activate chain + AddExecutor(ExecutorType.Activate, CardId.OvertexCoatls, OvertexCoatlseff); + AddExecutor(ExecutorType.Activate, CardId.ShaddollCore, ShaddollCoreeff); + AddExecutor(ExecutorType.Activate, CardId.ShaddollBeast, ShaddollBeasteff); + AddExecutor(ExecutorType.Activate, CardId.ShaddollFalco, ShaddollFalcoeff); + AddExecutor(ExecutorType.Activate, CardId.ShaddollDragon, ShaddollDragoneff); + AddExecutor(ExecutorType.Activate, CardId.ShaddollHedgehog, ShaddollHedgehogeff); + AddExecutor(ExecutorType.Activate, CardId.ShaddollSquamata, ShaddollSquamataeff); + AddExecutor(ExecutorType.Activate, CardId.GiantRex); + AddExecutor(ExecutorType.Activate, CardId.ElShaddollConstruct, ElShaddollConstructeff); + AddExecutor(ExecutorType.Activate, CardId.ElShaddollGrysra, ElShaddollGrysraeff); + AddExecutor(ExecutorType.Activate, CardId.ElShaddollShekhinaga, ElShaddollShekhinagaeff); + AddExecutor(ExecutorType.Activate, CardId.ElShaddollWinda); + //spellset + AddExecutor(ExecutorType.SpellSet, CardId.ThatGrassLooksgreener, SpellSetZone); + AddExecutor(ExecutorType.SpellSet, SpellSetZone); + //trapset + AddExecutor(ExecutorType.SpellSet, CardId.LostWind); + AddExecutor(ExecutorType.SpellSet, CardId.SinisterShadowGames); + AddExecutor(ExecutorType.SpellSet, CardId.ShaddollCore); + AddExecutor(ExecutorType.SpellSet, CardId.infiniteTransience, SetIsFieldEmpty); + //trap activate + AddExecutor(ExecutorType.Activate, CardId.LostWind, LostWindeff); + AddExecutor(ExecutorType.Activate, CardId.SinisterShadowGames, SinisterShadowGameseff); + + AddExecutor(ExecutorType.Repos, MonsterRepos); + } + public int[] all_List() + { + return new[] + { + CardId.UltimateConductorTytanno, + CardId.DogorantheMadFlameKaiju, + CardId.GamecieltheSeaTurtleKaiju, + CardId.RadiantheMultidimensionalKaiju, + CardId.OvertexCoatls, + CardId.ShaddollBeast, + CardId.GiantRex, + CardId.ShaddollDragon, + CardId.FairyTailSnow, + CardId.KeeperOfDragonicMagic, + CardId.ShaddollSquamata, + CardId.SouleatingOviraptor, + CardId.Raiden, + CardId.Lumina, + CardId.ShaddollHedgehog, + CardId.AshBlossom, + CardId.GhostOgre, + CardId.ShaddollFalco, + CardId.MaxxC, + CardId.PlaguespreaderZombie, + CardId.GlowUpBulb, + + CardId.AllureofDarkness, + CardId.ThatGrassLooksgreener, + CardId.HarpiesFeatherDuster, + CardId.DoubleEvolutionPill, + CardId.ShaddollFusion, + CardId.PotOfAvarice, + CardId.FoolishBurial, + CardId.MonsterReborn, + CardId.ChargeOfTheLightBrigade, + CardId.InterruptedKaijuSlumber, + //CardId.ElShaddollFusion, + + CardId.infiniteTransience, + CardId.LostWind, + CardId.SinisterShadowGames, + CardId.ShaddollCore, + + + }; + } + public int[] Useless_List() + { + return new[] + { + CardId.GlowUpBulb, + CardId.PlaguespreaderZombie, + CardId.ChargeOfTheLightBrigade, + CardId.ThatGrassLooksgreener, + CardId.HarpiesFeatherDuster, + CardId.FairyTailSnow, + CardId.GiantRex, + CardId.Lumina, + CardId.OvertexCoatls, + CardId.InterruptedKaijuSlumber, + CardId.FoolishBurial, + }; + } + int Ultimate_ss = 0; + int Enemy_atk = 0; + bool Pillused = false; + bool CrystronNeedlefibereff_used = false; + bool OvertexCoatlseff_used = false; + bool ShaddollBeast_used = false; + bool ShaddollFalco_used = false; + bool ShaddollSquamata_used = false; + bool ShaddollDragon_used = false; + bool ShaddollHedgehog_used = false; + + public int GetTotalATK(IList list) + { + + int atk = 0; + foreach (ClientCard c in list) + { + if (c == null) continue; + atk += c.Attack; + } + return atk; + } + + public override void OnNewPhase() + { + Enemy_atk = 0; + IList list = new List(); + foreach (ClientCard monster in Enemy.GetMonsters()) + { + if(monster.IsAttack()) + list.Add(monster); + } + //if (GetTotalATK(list) / 2 >= Bot.LifePoints) return false; + Enemy_atk = GetTotalATK(list); + //SLogger.DebugWriteLine("++++++++++++++++++" + Enemy_atk + "++++++++++++"); + } + public override void OnNewTurn() + { + Pillused = false; + OvertexCoatlseff_used = false; + CrystronNeedlefibereff_used = false; + ShaddollBeast_used = false; + ShaddollFalco_used = false; + ShaddollSquamata_used = false; + ShaddollDragon_used = false; + ShaddollHedgehog_used = false; + } + + private bool Luminasummon() + { + if (Bot.Deck.Count >= 20) return true; + IList extra = Bot.GetMonstersInExtraZone(); + if (extra != null) + foreach (ClientCard monster in extra) + if (!monster.HasType(CardType.Link)) + return false; + if (Bot.LifePoints <= 3000) return true; + if (Bot.HasInGraveyard(CardId.Raiden)) return true; + return false; + } + private bool Luminaeff() + { + if (Bot.HasInGraveyard(CardId.Raiden)) + { + AI.SelectCard(Useless_List()); + AI.SelectNextCard(CardId.Raiden); + return true; + } + return false; + } + + + private bool UltimateConductorTytannoeff() + { + IList targets = new[] { + CardId.OvertexCoatls, + CardId.ShaddollBeast, + CardId.ShaddollSquamata, + CardId.ShaddollHedgehog, + CardId.ShaddollDragon, + CardId.ShaddollFalco, + CardId.GlowUpBulb, + CardId.PlaguespreaderZombie, + CardId.FairyTailSnow, + CardId.KeeperOfDragonicMagic, + CardId.DogorantheMadFlameKaiju, + CardId.GamecieltheSeaTurtleKaiju, + CardId.RadiantheMultidimensionalKaiju, + CardId.GiantRex, + CardId.ShaddollCore, + CardId.SouleatingOviraptor, + CardId.Raiden, + CardId.Lumina, + CardId.AshBlossom, + CardId.GhostOgre, + CardId.MaxxC, + }; + + if (Duel.Phase == DuelPhase.Main1) + { + if(Duel.Player==0) + { + int count = 0; + IList check = Enemy.GetMonsters(); + foreach (ClientCard monster in check) + if (monster.Attack > 2500 || monster == Enemy.MonsterZone.GetDangerousMonster()) + count++; + if(count==0)return false; + } + if (!Bot.HasInHand(targets)) + { + if(!Bot.HasInMonstersZone(targets)) + return false; + } + AI.SelectCard(targets); + return true; + } + if (Duel.Phase == DuelPhase.BattleStart) + { + AI.SelectYesNo(true); + return true; + } + return false; + + } + + private bool GamecieltheSeaTurtleKaijusp() + { + if (!Bot.HasInMonstersZone(CardId.UltimateConductorTytanno)) + return DefaultKaijuSpsummon(); + return false; + } + + private bool RadiantheMultidimensionalKaijusp() + { + if (Enemy.HasInMonstersZone(CardId.GamecieltheSeaTurtleKaiju)) return true; + if (Bot.HasInHand(CardId.DogorantheMadFlameKaiju) && !Bot.HasInMonstersZone(CardId.UltimateConductorTytanno)) return DefaultKaijuSpsummon(); + return false; + } + + + private bool DogorantheMadFlameKaijusp() + { + if (Enemy.HasInMonstersZone(CardId.GamecieltheSeaTurtleKaiju)) return true; + if (Enemy.HasInMonstersZone(CardId.RadiantheMultidimensionalKaiju)) return true; + return false; + } + + + private bool InterruptedKaijuSlumbereff() + { + if (Enemy.GetMonsterCount() - Bot.GetMonsterCount() >= 2 ) + return DefaultInterruptedKaijuSlumber(); + return false; + } + private bool UltimateConductorTytannosp() + { + + Pillused = true; + foreach (ClientCard card in Bot.GetMonsters()) + { + if (card.IsCode(CardId.UltimateConductorTytanno) && card.IsFaceup()) + return false; + } + Ultimate_ss++; + return true; + + } + + private bool KeeperOfDragonicMagiceff() + { + if (ActivateDescription == -1) + { + AI.SelectCard(Useless_List()); + return true; + } + return true; + } + + private bool MonsterRepos() + { + if (Card.IsCode(CardId.UltimateConductorTytanno) && Card.IsFacedown()) return true; + if (Card.IsCode(CardId.ElShaddollConstruct) && Card.IsFacedown()) return true; + if (Card.IsCode(CardId.ElShaddollConstruct) && Card.IsAttack()) return false; + if (Card.IsCode(CardId.GlowUpBulb) && Card.IsDefense()) return false; + if (Card.IsCode(CardId.ShaddollDragon) && Card.IsFacedown() && Enemy.GetMonsterCount() >= 0) return true; + if (Card.IsCode(CardId.ShaddollSquamata) && Card.IsFacedown() && Enemy.GetMonsterCount() >= 0) return true; + return base.DefaultMonsterRepos(); + } + + private bool OvertexCoatlseff() + { + if (Card.Location == CardLocation.MonsterZone) return false; + OvertexCoatlseff_used = true; + return true; + } + + private bool DoubleEvolutionPilleff() + { + foreach (ClientCard card in Bot.GetMonsters()) + { + if (card.IsCode(CardId.UltimateConductorTytanno) && card.IsFaceup()) + return false; + } + if (Pillused == true) return false; + Pillused = true; + IList targets = new[] { + CardId.GiantRex, + CardId.DogorantheMadFlameKaiju, + CardId.GamecieltheSeaTurtleKaiju, + CardId.RadiantheMultidimensionalKaiju, + CardId.OvertexCoatls, + CardId.SouleatingOviraptor, + CardId.UltimateConductorTytanno, + }; + if (Bot.HasInGraveyard(targets)) + { + AI.SelectCard(CardId.GiantRex, CardId.DogorantheMadFlameKaiju, CardId.OvertexCoatls, CardId.GamecieltheSeaTurtleKaiju, CardId.RadiantheMultidimensionalKaiju, CardId.SouleatingOviraptor, CardId.UltimateConductorTytanno); + } + else + { + AI.SelectCard(CardId.GiantRex, CardId.DogorantheMadFlameKaiju, CardId.GamecieltheSeaTurtleKaiju, CardId.RadiantheMultidimensionalKaiju, CardId.OvertexCoatls, CardId.SouleatingOviraptor, CardId.UltimateConductorTytanno); + } + IList targets2 = new[] { + CardId.GiantRex, + CardId.DogorantheMadFlameKaiju, + CardId.GamecieltheSeaTurtleKaiju, + CardId.RadiantheMultidimensionalKaiju, + CardId.OvertexCoatls, + CardId.SouleatingOviraptor, + CardId.UltimateConductorTytanno, + }; + if (Bot.HasInGraveyard(targets)) + { + AI.SelectNextCard(CardId.ShaddollBeast, CardId.ShaddollDragon, CardId.KeeperOfDragonicMagic, CardId.ShaddollSquamata, CardId.SouleatingOviraptor, CardId.Raiden, CardId.Lumina, CardId.ShaddollHedgehog, CardId.AshBlossom, CardId.GhostOgre, CardId.ShaddollFalco, CardId.MaxxC, CardId.PlaguespreaderZombie, CardId.GlowUpBulb, CardId.FairyTailSnow); + } + else + AI.SelectNextCard(CardId.ShaddollBeast, CardId.ShaddollDragon, CardId.KeeperOfDragonicMagic, CardId.ShaddollSquamata, CardId.SouleatingOviraptor, CardId.Raiden, CardId.Lumina, CardId.ShaddollHedgehog, CardId.AshBlossom, CardId.GhostOgre, CardId.ShaddollFalco, CardId.MaxxC, CardId.PlaguespreaderZombie, CardId.GlowUpBulb, CardId.FairyTailSnow); + + AI.SelectThirdCard(new[] { + CardId.UltimateConductorTytanno, + + }); + + return Enemy.GetMonsterCount() >= 1; + } + + + private bool FairyTailSnowsummon() + { + ClientCard target = Util.GetBestEnemyMonster(true, true); + if(target != null) + { + return true; + } + return false; + } + + + private bool FairyTailSnoweff() + { + + if (Card.Location == CardLocation.MonsterZone) + { + AI.SelectCard(Util.GetBestEnemyMonster(true, true)); + return true; + } + else + { + + int spell_count = 0; + IList grave = Bot.Graveyard; + IList all = new List(); + foreach (ClientCard check in grave) + { + if (check.IsCode(CardId.GiantRex)) + { + all.Add(check); + } + } + foreach (ClientCard check in grave) + { + if(check.HasType(CardType.Spell)||check.HasType(CardType.Trap)) + { + spell_count++; + all.Add(check); + } + } + foreach (ClientCard check in grave) + { + if (check.HasType(CardType.Monster)) + { + all.Add(check); + } + } + if (Util.ChainContainsCard(CardId.FairyTailSnow)) return false; + + if ( Duel.Player == 1 && Duel.Phase == DuelPhase.BattleStart && Bot.BattlingMonster == null && Enemy_atk >=Bot.LifePoints || + Duel.Player == 0 && Duel.Phase==DuelPhase.BattleStart && Enemy.BattlingMonster == null && Enemy.LifePoints<=1850 + ) + { + AI.SelectCard(all); + AI.SelectNextCard(Util.GetBestEnemyMonster()); + return true; + } + } + return false; + } + + + private bool SouleatingOviraptoreff() + { + if (!OvertexCoatlseff_used && Bot.GetRemainingCount(CardId.OvertexCoatls, 3) > 0) + { + AI.SelectCard(CardId.OvertexCoatls); + AI.SelectOption(0); + } + else + { + AI.SelectCard(CardId.UltimateConductorTytanno); + AI.SelectOption(1); + } + return true; + } + + private bool GlowUpBulbeff() + { + IList check = Bot.GetMonstersInExtraZone(); + foreach (ClientCard monster in check) + if (monster.HasType(CardType.Fusion)) return false; + if (Bot.HasInMonstersZone(CardId.Lumina) || + Bot.HasInMonstersZone(CardId.FairyTailSnow) || + Bot.HasInMonstersZone(CardId.KeeperOfDragonicMagic) || + Bot.HasInMonstersZone(CardId.SouleatingOviraptor) || + Bot.HasInMonstersZone(CardId.GiantRex) || + Bot.HasInMonstersZone(CardId.Raiden) + ) + { + AI.SelectPosition(CardPosition.FaceUpDefence); + return true; + } + return false; + } + private bool TG_WonderMagicianeff() { - TG_WonderMagician_count++; - return TG_WonderMagician_count <= 10; - } - private bool AllureofDarkness() - { - IList materials = Bot.Hand; - // IList check = new List(); - ClientCard mat = null; - foreach (ClientCard card in materials) - { - if (card.HasAttribute(CardAttribute.Dark)) - { - mat = card; - break; - } - } - if (mat != null) - { - return true; - } - return false; - } - - - private bool Reborneff() - { - if(Bot.HasInGraveyard(CardId.UltimateConductorTytanno)&&Ultimate_ss>0) - { - AI.SelectCard(CardId.UltimateConductorTytanno); - return true; - } - if (!Util.IsOneEnemyBetter(true)) return false; - IList targets = new[] { - CardId.ElShaddollConstruct, - CardId.DogorantheMadFlameKaiju, - CardId.GamecieltheSeaTurtleKaiju, - CardId.SouleatingOviraptor, - }; - if (!Bot.HasInGraveyard(targets)) - { - return false; - } - AI.SelectCard(targets); - return true; - } - - - private bool PotofAvariceeff() - { - return true; - } - - private bool MaxxC() - { - return Duel.Player == 1; - } - - - private bool SetIsFieldEmpty() - { - return !Bot.IsFieldEmpty(); - } - - - private bool SpellSetZone() - { - return (Bot.GetHandCount()>6 && Duel.Phase==DuelPhase.Main2); - } - - private bool ChargeOfTheLightBrigadeEffect() - { - if (Bot.HasInGraveyard(CardId.Raiden) || Bot.HasInHand(CardId.Raiden)) - AI.SelectCard(CardId.Lumina); - else - AI.SelectCard(CardId.Raiden); - return true; - } - - - // all Shaddoll - private bool SinisterShadowGameseff() - { - if (Bot.HasInGraveyard(CardId.ShaddollFusion)) - AI.SelectCard(CardId.ShaddollCore); - else - AI.SelectCard(new[] - { - CardId.ShaddollBeast, - }); - return true; - } - - - private bool ShaddollCoreeff() - { - if (Card.Location == CardLocation.SpellZone) - { - - if (Duel.Player == 1 && Bot.BattlingMonster == null && Duel.Phase==DuelPhase.BattleStart|| DefaultOnBecomeTarget()) - { - Logger.DebugWriteLine("+++++++++++ShaddollCoreeffdododoo++++++++++"); - AI.SelectPosition(CardPosition.FaceUpDefence); - return true; - } - return false; - } - return true; - } - - - private bool ShaddollFusioneff() - { - List extra_zone_check = Bot.GetMonstersInExtraZone(); - foreach (ClientCard extra_monster in extra_zone_check) - if (extra_monster.HasType(CardType.Xyz) || extra_monster.HasType(CardType.Fusion) || extra_monster.HasType(CardType.Synchro)) return false; - - bool deck_check = false; - List monsters = Enemy.GetMonsters(); - foreach (ClientCard monster in monsters) - { - if (monster.HasType(CardType.Synchro) || monster.HasType(CardType.Fusion) || monster.HasType(CardType.Xyz) || monster.HasType(CardType.Link)) - deck_check = true; - } - - if (deck_check) - { - AI.SelectCard( - CardId.ElShaddollConstruct, - CardId.ElShaddollShekhinaga, - CardId.ElShaddollGrysra, - CardId.ElShaddollWinda - ); - AI.SelectNextCard( - CardId.ShaddollSquamata, - CardId.ShaddollBeast, - CardId.ShaddollHedgehog, - CardId.ShaddollDragon, - CardId.ShaddollFalco, - CardId.FairyTailSnow - ); - AI.SelectPosition(CardPosition.FaceUpAttack); - return true; - } - - if (Enemy.GetMonsterCount() == 0) - { - int dark_count = 0; - IList m0 = Bot.Hand; - IList m1 = Bot.MonsterZone; - IList all = new List(); - foreach (ClientCard monster in m0) - { - if (dark_count == 2) break; - if (monster.HasAttribute(CardAttribute.Dark)) - { - dark_count++; - all.Add(monster); - } - } - foreach (ClientCard monster in m1) - { - if (dark_count == 2) break; - if (monster != null) - { - if (monster.HasAttribute(CardAttribute.Dark)) - { - dark_count++; - all.Add(monster); - } - } - - - } - if (dark_count == 2) - { - AI.SelectCard(CardId.ElShaddollWinda); - AI.SelectMaterials(all); - AI.SelectPosition(CardPosition.FaceUpAttack); - return true; - } - } - if (!Util.IsOneEnemyBetter()) return false; - - - foreach (ClientCard monster in Bot.Hand) - { - if (monster.HasAttribute(CardAttribute.Light)) - { - AI.SelectCard(CardId.ElShaddollConstruct); - AI.SelectPosition(CardPosition.FaceUpAttack); - return true; - } - - } - List material_1 = Bot.GetMonsters(); - foreach (ClientCard monster in material_1) - { - if (monster == null) break; - if (monster.HasAttribute(CardAttribute.Light)) - { - AI.SelectCard(CardId.ElShaddollConstruct); - AI.SelectPosition(CardPosition.FaceUpAttack); - return true; - } - - } - return false; - - } - - - private bool ElShaddollShekhinagaeff() - { - if (Card.Location != CardLocation.MonsterZone) - return true; - else - { - if (DefaultBreakthroughSkill()) - { - AI.SelectCard( - CardId.ShaddollBeast, - CardId.ShaddollSquamata, - CardId.ShaddollHedgehog, - CardId.ShaddollDragon, - CardId.ShaddollFalco - ); - } - else - return false; - } - return true; - } - - - private bool ElShaddollGrysraeff() - { - if (Card.Location != CardLocation.MonsterZone) - return true; - return true; - } - - - private bool ElShaddollConstructeff() - { - - if (!ShaddollBeast_used) - AI.SelectCard(CardId.ShaddollBeast); - else - AI.SelectCard(CardId.ShaddollFalco); - - return true; - } - - - private bool ShaddollSquamataeff() - { - ShaddollSquamata_used = true; - if (Card.Location != CardLocation.MonsterZone) - { - if(Util.ChainContainsCard(CardId.ElShaddollConstruct)) - { - if (!Bot.HasInHand(CardId.ShaddollFusion) && Bot.HasInGraveyard(CardId.ShaddollFusion)) - AI.SelectNextCard(CardId.ShaddollCore); - if (!ShaddollBeast_used) AI.SelectNextCard(CardId.ShaddollBeast); - else if (!ShaddollFalco_used) AI.SelectNextCard(CardId.ShaddollFalco); - else if(!ShaddollHedgehog_used) AI.SelectNextCard(CardId.ShaddollHedgehog); - } - else - { - if (!Bot.HasInHand(CardId.ShaddollFusion) && Bot.HasInGraveyard(CardId.ShaddollFusion)) - AI.SelectCard(CardId.ShaddollCore); - if (!ShaddollBeast_used) AI.SelectCard(CardId.ShaddollBeast); - else if (!ShaddollFalco_used) AI.SelectCard(CardId.ShaddollFalco); - else if (!ShaddollHedgehog_used) AI.SelectCard(CardId.ShaddollHedgehog); - } - - } - else - { - if (Enemy.GetMonsterCount() == 0) return false; - ClientCard target = Util.GetBestEnemyMonster(); - AI.SelectCard(target); - } - return true; - } - - - private bool ShaddollBeasteff() - { - ShaddollBeast_used = true; - return true; - } - - - private bool ShaddollFalcoeff() - { - ShaddollFalco_used = true; - if (Card.Location != CardLocation.MonsterZone) - return true; - else - { - AI.SelectCard( - CardId.ElShaddollConstruct, - CardId.ElShaddollShekhinaga, - CardId.ElShaddollGrysra, - CardId.ElShaddollWinda, - CardId.ShaddollSquamata - ); - - } - return true; - } - - - private bool ShaddollHedgehogeff() - { - ShaddollHedgehog_used = true; - if (Card.Location != CardLocation.MonsterZone) - { - if (Util.ChainContainsCard(CardId.ElShaddollConstruct)) - { - AI.SelectNextCard( - CardId.ShaddollFalco, - CardId.ShaddollSquamata, - CardId.ShaddollDragon - ); - - } - else - { - AI.SelectCard( - CardId.ShaddollSquamata, - CardId.ShaddollDragon - ); - } - - } - else - { - AI.SelectCard( - CardId.ShaddollFusion, - CardId.SinisterShadowGames - ); - } - return true; - } - - - private bool ShaddollDragoneff() - { - ShaddollDragon_used = true; - if (Card.Location == CardLocation.MonsterZone) - { - ClientCard target = Util.GetBestEnemyCard(); - AI.SelectCard(target); - return true; - } - else - { - if (Enemy.GetSpellCount() == 0) return false; - ClientCard target = Util.GetBestEnemySpell(); - AI.SelectCard(target); - return true; - } - } - - - private bool LostWindeff() - { - if (Card.Location == CardLocation.Grave) - return true; - List check = Enemy.GetMonsters(); - foreach (ClientCard m in check) - { - if (m.Attack>=2000) return DefaultBreakthroughSkill(); - } - return false; - } - - private bool FoolishBurialEffect() - { - if (Bot.GetRemainingCount(CardId.DoubleEvolutionPill, 3) > 0) - { - if (!OvertexCoatlseff_used) - { - AI.SelectCard(new[] - { - CardId.OvertexCoatls, - }); - return true; - } - return false; - } - else - { - AI.SelectCard(CardId.ShaddollSquamata, CardId.FairyTailSnow); - } - return true; - } - - - public bool Hand_act_eff() - { - //if (Card.IsCode(CardId.Urara) && Bot.HasInHand(CardId.LockBird) && Bot.HasInSpellZone(CardId.Re)) return false; - if (Card.IsCode(CardId.GhostOgre) && Card.Location == CardLocation.Hand && Bot.HasInMonstersZone(CardId.GhostOgre)) return false; - return (Duel.LastChainPlayer == 1); - } - //other extra - - private bool Michaelsp() - { - IList targets = new[] { - CardId.Raiden, - CardId.Lumina - }; - if (!Bot.HasInMonstersZone(targets)) - return false; - AI.SelectCard(targets); - return true; - } - private bool Michaeleff() - { - if (Card.Location == CardLocation.Grave) - return true; - if (Bot.LifePoints <= 1000) return false; - ClientCard select = Util.GetBestEnemyCard(); - if (select == null) return false; - if(select!=null) - { - - AI.SelectCard(select); - return true; - } - return false; - } - - private bool MinervaTheExaltedEffect() - { - if (Card.Location == CardLocation.MonsterZone) - { - if (Bot.Deck.Count <= 10) return false; - return true; - } - else - { - IList targets = new List(); - - ClientCard target1 = Util.GetBestEnemyMonster(); - if (target1 != null) - targets.Add(target1); - ClientCard target2 = Util.GetBestEnemySpell(); - if (target2 != null) - targets.Add(target2); - - foreach (ClientCard target in Enemy.GetMonsters()) - { - if (targets.Count >= 3) - break; - if (!targets.Contains(target)) - targets.Add(target); - } - foreach (ClientCard target in Enemy.GetSpells()) - { - if (targets.Count >= 3) - break; - if (!targets.Contains(target)) - targets.Add(target); - } - if (targets.Count == 0) - return false; - - AI.SelectCard(0); - AI.SelectNextCard(targets); - return true; - } - } - - - public bool CrystronNeedlefibersp() - { - if (Bot.HasInMonstersZone(CardId.ElShaddollConstruct) || - Bot.HasInMonstersZone(CardId.ElShaddollGrysra) || - Bot.HasInMonstersZone(CardId.ElShaddollShekhinaga) || - Bot.HasInMonstersZone(CardId.ElShaddollWinda)) - return false; - - if (CrystronNeedlefibereff_used) return false; - if (Bot.HasInMonstersZone(CardId.CrystronNeedlefiber)) return false; - IList check = new[] - { - CardId.GlowUpBulb, - CardId.FairyTailSnow, - CardId.KeeperOfDragonicMagic, - CardId.SouleatingOviraptor, - CardId.GiantRex, - CardId.Lumina, - CardId.Raiden, - - }; - int count=0; - foreach (ClientCard monster in Bot.GetMonsters()) - if (monster.IsCode(CardId.GlowUpBulb, CardId.FairyTailSnow, CardId.KeeperOfDragonicMagic, - CardId.SouleatingOviraptor, CardId.GiantRex, CardId.Lumina, CardId.Raiden)) - count++; - if (!Bot.HasInMonstersZone(CardId.GlowUpBulb) || count<2) - return false; - AI.SelectCard(check); - AI.SelectNextCard(check); - - return true; - } - - public bool CrystronNeedlefibereff() - { - bool DarkHole = false; - foreach (ClientCard card in Enemy.GetSpells()) - { - if (card.IsCode(53129443) && card.IsFaceup()) - { - DarkHole = true; - } - } - if (Duel.Player == 0) - { - - CrystronNeedlefibereff_used = true; - AI.SelectCard( - CardId.GhostOgre, - CardId.GlowUpBulb, - CardId.PlaguespreaderZombie, - CardId.ShaddollFalco - ); - return true; - } - - else if (DarkHole || Util.IsChainTarget(Card) || Util.GetProblematicEnemySpell() != null) - { - AI.SelectCard(CardId.TG_WonderMagician); - return true; - } - - else if (Duel.Player == 1 && Duel.Phase == DuelPhase.BattleStart && Util.IsOneEnemyBetterThanValue(1500, true)) - { - AI.SelectCard(CardId.TG_WonderMagician); - if (Util.IsOneEnemyBetterThanValue(1900, true)) - { - AI.SelectPosition(CardPosition.FaceUpDefence); - } - else - { - AI.SelectPosition(CardPosition.FaceUpAttack); - } - return true; - } - return false; - } - - private bool ScarlightRedDragonsp() - { - return false; - } - - private bool ScarlightRedDragoneff() - { - IList targets = new List(); - ClientCard target1 = Util.GetBestEnemyMonster(); - if (target1 != null) - { - targets.Add(target1); - AI.SelectCard(targets); - return true; - } - return false; - } - - - private bool CrystalWingSynchroDragoneff() - { - return Duel.LastChainPlayer != 0; - } - - private bool Sdulldeateff() - { - /* if (snake_four_s) - { - snake_four_s = false; - AI.SelectCard(Useless_List()); - return true; - } - //if (ActivateDescription == Util.GetStringId(CardId.snake, 2)) return true; - if (ActivateDescription == Util.GetStringId(CardId.snake, 1)) - { - foreach (ClientCard hand in Bot.Hand) - { - if (hand.IsCode(CardId.Red, CardId.Pink)) - { - AI.SelectCard(hand); - return true; - } - if (hand.IsCode(CardId.Urara, CardId.Ghost)) - { - if (Tuner_ss()) - { - AI.SelectCard(hand); - return true; - } - } - } - }*/ - return false; - } - - private bool BlackRoseMoonlightDragoneff() - { - IList targets = new List(); - ClientCard target1 = Util.GetBestEnemyMonster(); - if (target1 != null) - { - targets.Add(target1); - AI.SelectCard(targets); - return true; - } - return false; - - } - - private bool RedWyvernsp() - { - return false; - } - - private bool RedWyverneff() - { - IList check = Enemy.GetMonsters(); - ClientCard best = null; - foreach (ClientCard monster in check) - { - if (monster.Attack >= 2400) best = monster; - } - if (best != null) - { - AI.SelectCard(best); - return true; - } - return false; - } - - private bool CoralDragoneff() - { - if (Card.Location != CardLocation.MonsterZone) - return true; - IList targets = new List(); - - ClientCard target1 = Util.GetBestEnemyMonster(); - if (target1 != null) - targets.Add(target1); - ClientCard target2 = Util.GetBestEnemySpell(); - if (target2 != null) - targets.Add(target2); - else if (Util.IsChainTarget(Card) || Util.GetProblematicEnemySpell() != null) - { - AI.SelectCard(targets); - return true; - } - else if (Duel.Player == 1 && Duel.Phase == DuelPhase.BattleStart && Util.IsOneEnemyBetterThanValue(2400, true)) - { - AI.SelectCard(targets); - return true; - } - return false; - } - - public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender) - { - if (!defender.IsMonsterHasPreventActivationEffectInBattle()) - { - if (attacker.IsCode(CardId.ElShaddollConstruct) && !attacker.IsDisabled()) // TODO: && defender.IsSpecialSummoned - attacker.RealPower = 9999; - if (attacker.IsCode(CardId.UltimateConductorTytanno) && !attacker.IsDisabled() && defender.IsDefense()) - attacker.RealPower = 9999; - } - return base.OnPreBattleBetween(attacker, defender); - } - - public override bool OnSelectHand() - { - return true; - } - /* - private bool GoblindberghSummon() - { - foreach (ClientCard card in Bot.Hand.GetMonsters()) - { - if (!card.Equals(Card) && card.Level == 4) - return true; - } - return false; - }*/ - - - } + return true; + } + private bool AllureofDarkness() + { + IList materials = Bot.Hand; + // IList check = new List(); + ClientCard mat = null; + foreach (ClientCard card in materials) + { + if (card.HasAttribute(CardAttribute.Dark)) + { + mat = card; + break; + } + } + if (mat != null) + { + return true; + } + return false; + } + + + private bool Reborneff() + { + if(Bot.HasInGraveyard(CardId.UltimateConductorTytanno)&&Ultimate_ss>0) + { + AI.SelectCard(CardId.UltimateConductorTytanno); + return true; + } + if (!Util.IsOneEnemyBetter(true)) return false; + IList targets = new[] { + CardId.ElShaddollConstruct, + CardId.DogorantheMadFlameKaiju, + CardId.GamecieltheSeaTurtleKaiju, + CardId.SouleatingOviraptor, + }; + if (!Bot.HasInGraveyard(targets)) + { + return false; + } + AI.SelectCard(targets); + return true; + } + + + private bool PotofAvariceeff() + { + return true; + } + + private bool MaxxC() + { + return Duel.Player == 1; + } + + + private bool SetIsFieldEmpty() + { + return !Bot.IsFieldEmpty(); + } + + + private bool SpellSetZone() + { + return (Bot.GetHandCount()>6 && Duel.Phase==DuelPhase.Main2); + } + + private bool ChargeOfTheLightBrigadeEffect() + { + if (Bot.HasInGraveyard(CardId.Raiden) || Bot.HasInHand(CardId.Raiden)) + AI.SelectCard(CardId.Lumina); + else + AI.SelectCard(CardId.Raiden); + return true; + } + + + // all Shaddoll + private bool SinisterShadowGameseff() + { + if (Bot.HasInGraveyard(CardId.ShaddollFusion)) + AI.SelectCard(CardId.ShaddollCore); + else + AI.SelectCard(new[] + { + CardId.ShaddollBeast, + }); + return true; + } + + + private bool ShaddollCoreeff() + { + if (Card.Location == CardLocation.SpellZone) + { + + if (Duel.Player == 1 && Bot.BattlingMonster == null && Duel.Phase==DuelPhase.BattleStart|| DefaultOnBecomeTarget()) + { + Logger.DebugWriteLine("+++++++++++ShaddollCoreeffdododoo++++++++++"); + AI.SelectPosition(CardPosition.FaceUpDefence); + return true; + } + return false; + } + return true; + } + + + private bool ShaddollFusioneff() + { + List extra_zone_check = Bot.GetMonstersInExtraZone(); + foreach (ClientCard extra_monster in extra_zone_check) + if (extra_monster.HasType(CardType.Xyz) || extra_monster.HasType(CardType.Fusion) || extra_monster.HasType(CardType.Synchro)) return false; + + bool deck_check = false; + List monsters = Enemy.GetMonsters(); + foreach (ClientCard monster in monsters) + { + if (monster.HasType(CardType.Synchro) || monster.HasType(CardType.Fusion) || monster.HasType(CardType.Xyz) || monster.HasType(CardType.Link)) + deck_check = true; + } + + if (deck_check) + { + AI.SelectCard( + CardId.ElShaddollConstruct, + CardId.ElShaddollShekhinaga, + CardId.ElShaddollGrysra, + CardId.ElShaddollWinda + ); + AI.SelectNextCard( + CardId.ShaddollSquamata, + CardId.ShaddollBeast, + CardId.ShaddollHedgehog, + CardId.ShaddollDragon, + CardId.ShaddollFalco, + CardId.FairyTailSnow + ); + AI.SelectPosition(CardPosition.FaceUpAttack); + return true; + } + + if (Enemy.GetMonsterCount() == 0) + { + int dark_count = 0; + IList m0 = Bot.Hand; + IList m1 = Bot.MonsterZone; + IList all = new List(); + foreach (ClientCard monster in m0) + { + if (dark_count == 2) break; + if (monster.HasAttribute(CardAttribute.Dark)) + { + dark_count++; + all.Add(monster); + } + } + foreach (ClientCard monster in m1) + { + if (dark_count == 2) break; + if (monster != null) + { + if (monster.HasAttribute(CardAttribute.Dark)) + { + dark_count++; + all.Add(monster); + } + } + + + } + if (dark_count == 2) + { + AI.SelectCard(CardId.ElShaddollWinda); + AI.SelectMaterials(all); + AI.SelectPosition(CardPosition.FaceUpAttack); + return true; + } + } + if (!Util.IsOneEnemyBetter()) return false; + + + foreach (ClientCard monster in Bot.Hand) + { + if (monster.HasAttribute(CardAttribute.Light)) + { + AI.SelectCard(CardId.ElShaddollConstruct); + AI.SelectPosition(CardPosition.FaceUpAttack); + return true; + } + + } + List material_1 = Bot.GetMonsters(); + foreach (ClientCard monster in material_1) + { + if (monster == null) break; + if (monster.HasAttribute(CardAttribute.Light)) + { + AI.SelectCard(CardId.ElShaddollConstruct); + AI.SelectPosition(CardPosition.FaceUpAttack); + return true; + } + + } + return false; + + } + + + private bool ElShaddollShekhinagaeff() + { + if (Card.Location != CardLocation.MonsterZone) + return true; + else + { + if (DefaultBreakthroughSkill()) + { + AI.SelectCard( + CardId.ShaddollBeast, + CardId.ShaddollSquamata, + CardId.ShaddollHedgehog, + CardId.ShaddollDragon, + CardId.ShaddollFalco + ); + } + else + return false; + } + return true; + } + + + private bool ElShaddollGrysraeff() + { + if (Card.Location != CardLocation.MonsterZone) + return true; + return true; + } + + + private bool ElShaddollConstructeff() + { + + if (!ShaddollBeast_used) + AI.SelectCard(CardId.ShaddollBeast); + else + AI.SelectCard(CardId.ShaddollFalco); + + return true; + } + + + private bool ShaddollSquamataeff() + { + ShaddollSquamata_used = true; + if (Card.Location != CardLocation.MonsterZone) + { + if(Util.ChainContainsCard(CardId.ElShaddollConstruct)) + { + if (!Bot.HasInHand(CardId.ShaddollFusion) && Bot.HasInGraveyard(CardId.ShaddollFusion)) + AI.SelectNextCard(CardId.ShaddollCore); + if (!ShaddollBeast_used) AI.SelectNextCard(CardId.ShaddollBeast); + else if (!ShaddollFalco_used) AI.SelectNextCard(CardId.ShaddollFalco); + else if(!ShaddollHedgehog_used) AI.SelectNextCard(CardId.ShaddollHedgehog); + } + else + { + if (!Bot.HasInHand(CardId.ShaddollFusion) && Bot.HasInGraveyard(CardId.ShaddollFusion)) + AI.SelectCard(CardId.ShaddollCore); + if (!ShaddollBeast_used) AI.SelectCard(CardId.ShaddollBeast); + else if (!ShaddollFalco_used) AI.SelectCard(CardId.ShaddollFalco); + else if (!ShaddollHedgehog_used) AI.SelectCard(CardId.ShaddollHedgehog); + } + + } + else + { + if (Enemy.GetMonsterCount() == 0) return false; + ClientCard target = Util.GetBestEnemyMonster(); + AI.SelectCard(target); + } + return true; + } + + + private bool ShaddollBeasteff() + { + ShaddollBeast_used = true; + return true; + } + + + private bool ShaddollFalcoeff() + { + ShaddollFalco_used = true; + if (Card.Location != CardLocation.MonsterZone) + return true; + else + { + AI.SelectCard( + CardId.ElShaddollConstruct, + CardId.ElShaddollShekhinaga, + CardId.ElShaddollGrysra, + CardId.ElShaddollWinda, + CardId.ShaddollSquamata + ); + + } + return true; + } + + + private bool ShaddollHedgehogeff() + { + ShaddollHedgehog_used = true; + if (Card.Location != CardLocation.MonsterZone) + { + if (Util.ChainContainsCard(CardId.ElShaddollConstruct)) + { + AI.SelectNextCard( + CardId.ShaddollFalco, + CardId.ShaddollSquamata, + CardId.ShaddollDragon + ); + + } + else + { + AI.SelectCard( + CardId.ShaddollSquamata, + CardId.ShaddollDragon + ); + } + + } + else + { + AI.SelectCard( + CardId.ShaddollFusion, + CardId.SinisterShadowGames + ); + } + return true; + } + + + private bool ShaddollDragoneff() + { + ShaddollDragon_used = true; + if (Card.Location == CardLocation.MonsterZone) + { + ClientCard target = Util.GetBestEnemyCard(); + AI.SelectCard(target); + return true; + } + else + { + if (Enemy.GetSpellCount() == 0) return false; + ClientCard target = Util.GetBestEnemySpell(); + AI.SelectCard(target); + return true; + } + } + + + private bool LostWindeff() + { + if (Card.Location == CardLocation.Grave) + return true; + List check = Enemy.GetMonsters(); + foreach (ClientCard m in check) + { + if (m.Attack>=2000) return DefaultBreakthroughSkill(); + } + return false; + } + + private bool FoolishBurialEffect() + { + if (Bot.GetRemainingCount(CardId.DoubleEvolutionPill, 3) > 0) + { + if (!OvertexCoatlseff_used) + { + AI.SelectCard(new[] + { + CardId.OvertexCoatls, + }); + return true; + } + return false; + } + else + { + AI.SelectCard(CardId.ShaddollSquamata, CardId.FairyTailSnow); + } + return true; + } + + + public bool Hand_act_eff() + { + //if (Card.IsCode(CardId.Urara) && Bot.HasInHand(CardId.LockBird) && Bot.HasInSpellZone(CardId.Re)) return false; + if (Card.IsCode(CardId.GhostOgre) && Card.Location == CardLocation.Hand && Bot.HasInMonstersZone(CardId.GhostOgre)) return false; + return (Duel.LastChainPlayer == 1); + } + //other extra + + private bool Michaelsp() + { + IList targets = new[] { + CardId.Raiden, + CardId.Lumina + }; + if (!Bot.HasInMonstersZone(targets)) + return false; + AI.SelectCard(targets); + return true; + } + private bool Michaeleff() + { + if (Card.Location == CardLocation.Grave) + return true; + if (Bot.LifePoints <= 1000) return false; + ClientCard select = Util.GetBestEnemyCard(); + if (select == null) return false; + if(select!=null) + { + + AI.SelectCard(select); + return true; + } + return false; + } + + private bool MinervaTheExaltedEffect() + { + if (Card.Location == CardLocation.MonsterZone) + { + if (Bot.Deck.Count <= 10) return false; + return true; + } + else + { + IList targets = new List(); + + ClientCard target1 = Util.GetBestEnemyMonster(); + if (target1 != null) + targets.Add(target1); + ClientCard target2 = Util.GetBestEnemySpell(); + if (target2 != null) + targets.Add(target2); + + foreach (ClientCard target in Enemy.GetMonsters()) + { + if (targets.Count >= 3) + break; + if (!targets.Contains(target)) + targets.Add(target); + } + foreach (ClientCard target in Enemy.GetSpells()) + { + if (targets.Count >= 3) + break; + if (!targets.Contains(target)) + targets.Add(target); + } + if (targets.Count == 0) + return false; + + AI.SelectCard(0); + AI.SelectNextCard(targets); + return true; + } + } + + + public bool CrystronNeedlefibersp() + { + if (Bot.HasInMonstersZone(CardId.ElShaddollConstruct) || + Bot.HasInMonstersZone(CardId.ElShaddollGrysra) || + Bot.HasInMonstersZone(CardId.ElShaddollShekhinaga) || + Bot.HasInMonstersZone(CardId.ElShaddollWinda)) + return false; + + if (CrystronNeedlefibereff_used) return false; + if (Bot.HasInMonstersZone(CardId.CrystronNeedlefiber)) return false; + IList check = new[] + { + CardId.GlowUpBulb, + CardId.FairyTailSnow, + CardId.KeeperOfDragonicMagic, + CardId.SouleatingOviraptor, + CardId.GiantRex, + CardId.Lumina, + CardId.Raiden, + + }; + int count=0; + foreach (ClientCard monster in Bot.GetMonsters()) + if (monster.IsCode(CardId.GlowUpBulb, CardId.FairyTailSnow, CardId.KeeperOfDragonicMagic, + CardId.SouleatingOviraptor, CardId.GiantRex, CardId.Lumina, CardId.Raiden)) + count++; + if (!Bot.HasInMonstersZone(CardId.GlowUpBulb) || count<2) + return false; + AI.SelectCard(check); + AI.SelectNextCard(check); + + return true; + } + + public bool CrystronNeedlefibereff() + { + bool DarkHole = false; + foreach (ClientCard card in Enemy.GetSpells()) + { + if (card.IsCode(53129443) && card.IsFaceup()) + { + DarkHole = true; + } + } + if (Duel.Player == 0) + { + + CrystronNeedlefibereff_used = true; + AI.SelectCard( + CardId.GhostOgre, + CardId.GlowUpBulb, + CardId.PlaguespreaderZombie, + CardId.ShaddollFalco + ); + return true; + } + + else if (DarkHole || Util.IsChainTarget(Card) || Util.GetProblematicEnemySpell() != null) + { + AI.SelectCard(CardId.TG_WonderMagician); + return true; + } + + else if (Duel.Player == 1 && Duel.Phase == DuelPhase.BattleStart && Util.IsOneEnemyBetterThanValue(1500, true)) + { + AI.SelectCard(CardId.TG_WonderMagician); + if (Util.IsOneEnemyBetterThanValue(1900, true)) + { + AI.SelectPosition(CardPosition.FaceUpDefence); + } + else + { + AI.SelectPosition(CardPosition.FaceUpAttack); + } + return true; + } + return false; + } + + private bool ScarlightRedDragonsp() + { + return false; + } + + private bool ScarlightRedDragoneff() + { + IList targets = new List(); + ClientCard target1 = Util.GetBestEnemyMonster(); + if (target1 != null) + { + targets.Add(target1); + AI.SelectCard(targets); + return true; + } + return false; + } + + + private bool CrystalWingSynchroDragoneff() + { + return Duel.LastChainPlayer != 0; + } + + private bool Sdulldeateff() + { + /* if (snake_four_s) + { + snake_four_s = false; + AI.SelectCard(Useless_List()); + return true; + } + //if (ActivateDescription == Util.GetStringId(CardId.snake, 2)) return true; + if (ActivateDescription == Util.GetStringId(CardId.snake, 1)) + { + foreach (ClientCard hand in Bot.Hand) + { + if (hand.IsCode(CardId.Red, CardId.Pink)) + { + AI.SelectCard(hand); + return true; + } + if (hand.IsCode(CardId.Urara, CardId.Ghost)) + { + if (Tuner_ss()) + { + AI.SelectCard(hand); + return true; + } + } + } + }*/ + return false; + } + + private bool BlackRoseMoonlightDragoneff() + { + IList targets = new List(); + ClientCard target1 = Util.GetBestEnemyMonster(); + if (target1 != null) + { + targets.Add(target1); + AI.SelectCard(targets); + return true; + } + return false; + + } + + private bool RedWyvernsp() + { + return false; + } + + private bool RedWyverneff() + { + IList check = Enemy.GetMonsters(); + ClientCard best = null; + foreach (ClientCard monster in check) + { + if (monster.Attack >= 2400) best = monster; + } + if (best != null) + { + AI.SelectCard(best); + return true; + } + return false; + } + + private bool CoralDragoneff() + { + if (Card.Location != CardLocation.MonsterZone) + return true; + IList targets = new List(); + + ClientCard target1 = Util.GetBestEnemyMonster(); + if (target1 != null) + targets.Add(target1); + ClientCard target2 = Util.GetBestEnemySpell(); + if (target2 != null) + targets.Add(target2); + else if (Util.IsChainTarget(Card) || Util.GetProblematicEnemySpell() != null) + { + AI.SelectCard(targets); + return true; + } + else if (Duel.Player == 1 && Duel.Phase == DuelPhase.BattleStart && Util.IsOneEnemyBetterThanValue(2400, true)) + { + AI.SelectCard(targets); + return true; + } + return false; + } + + public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender) + { + if (!defender.IsMonsterHasPreventActivationEffectInBattle()) + { + if (attacker.IsCode(CardId.ElShaddollConstruct) && !attacker.IsDisabled()) // TODO: && defender.IsSpecialSummoned + attacker.RealPower = 9999; + if (attacker.IsCode(CardId.UltimateConductorTytanno) && !attacker.IsDisabled() && defender.IsDefense()) + attacker.RealPower = 9999; + } + return base.OnPreBattleBetween(attacker, defender); + } + + public override bool OnSelectHand() + { + return true; + } + /* + private bool GoblindberghSummon() + { + foreach (ClientCard card in Bot.Hand.GetMonsters()) + { + if (!card.Equals(Card) && card.Level == 4) + return true; + } + return false; + }*/ + + + } } \ No newline at end of file diff --git a/libWindbot/Game/AI/Decks/LuckyExecutor.cs b/libWindbot/Game/AI/Decks/LuckyExecutor.cs new file mode 100644 index 0000000..452b27d --- /dev/null +++ b/libWindbot/Game/AI/Decks/LuckyExecutor.cs @@ -0,0 +1,242 @@ +using YGOSharp.OCGWrapper.Enums; +using System.Collections.Generic; +using System.Linq; +using WindBot; +using WindBot.Game; +using WindBot.Game.AI; + +namespace WindBot.Game.AI.Decks +{ + [Deck("Lucky", "AI_Test", "Test")] + public class LuckyExecutor : DefaultExecutor + { + public LuckyExecutor(GameAI ai, Duel duel) + : base(ai, duel) + { + AddExecutor(ExecutorType.Activate, ImFeelingLucky); + AddExecutor(ExecutorType.SpSummon, ImFeelingLucky); + + AddExecutor(ExecutorType.SpSummon, ImFeelingUnlucky); + AddExecutor(ExecutorType.Activate, ImFeelingUnlucky); + + AddExecutor(ExecutorType.SummonOrSet, ImFeelingLazy); + AddExecutor(ExecutorType.SpellSet, DefaultSpellSet); + AddExecutor(ExecutorType.Repos, DefaultMonsterRepos); + + AddExecutor(ExecutorType.Activate, _CardId.MysticalSpaceTyphoon, DefaultMysticalSpaceTyphoon); + AddExecutor(ExecutorType.Activate, _CardId.CosmicCyclone, DefaultCosmicCyclone); + AddExecutor(ExecutorType.Activate, _CardId.GalaxyCyclone, DefaultGalaxyCyclone); + AddExecutor(ExecutorType.Activate, _CardId.BookOfMoon, DefaultBookOfMoon); + AddExecutor(ExecutorType.Activate, _CardId.CompulsoryEvacuationDevice, DefaultCompulsoryEvacuationDevice); + AddExecutor(ExecutorType.Activate, _CardId.CallOfTheHaunted, DefaultCallOfTheHaunted); + AddExecutor(ExecutorType.Activate, _CardId.Scapegoat, DefaultScapegoat); + AddExecutor(ExecutorType.Activate, _CardId.MaxxC, DefaultMaxxC); + AddExecutor(ExecutorType.Activate, _CardId.AshBlossom, DefaultAshBlossomAndJoyousSpring); + AddExecutor(ExecutorType.Activate, _CardId.GhostOgreAndSnowRabbit, DefaultGhostOgreAndSnowRabbit); + AddExecutor(ExecutorType.Activate, _CardId.GhostBelle, DefaultGhostBelleAndHauntedMansion); + AddExecutor(ExecutorType.Activate, _CardId.EffectVeiler, DefaultEffectVeiler); + AddExecutor(ExecutorType.Activate, _CardId.CalledByTheGrave, DefaultCalledByTheGrave); + AddExecutor(ExecutorType.Activate, _CardId.InfiniteImpermanence, DefaultInfiniteImpermanence); + AddExecutor(ExecutorType.Activate, _CardId.BreakthroughSkill, DefaultBreakthroughSkill); + AddExecutor(ExecutorType.Activate, _CardId.SolemnJudgment, DefaultSolemnJudgment); + AddExecutor(ExecutorType.Activate, _CardId.SolemnWarning, DefaultSolemnWarning); + AddExecutor(ExecutorType.Activate, _CardId.SolemnStrike, DefaultSolemnStrike); + AddExecutor(ExecutorType.Activate, _CardId.TorrentialTribute, DefaultTorrentialTribute); + AddExecutor(ExecutorType.Activate, _CardId.HeavyStorm, DefaultHeavyStorm); + AddExecutor(ExecutorType.Activate, _CardId.HarpiesFeatherDuster, DefaultHarpiesFeatherDusterFirst); + AddExecutor(ExecutorType.Activate, _CardId.HammerShot, DefaultHammerShot); + AddExecutor(ExecutorType.Activate, _CardId.DarkHole, DefaultDarkHole); + AddExecutor(ExecutorType.Activate, _CardId.Raigeki, DefaultRaigeki); + AddExecutor(ExecutorType.Activate, _CardId.SmashingGround, DefaultSmashingGround); + AddExecutor(ExecutorType.Activate, _CardId.PotOfDesires, DefaultPotOfDesires); + AddExecutor(ExecutorType.Activate, _CardId.AllureofDarkness, DefaultAllureofDarkness); + AddExecutor(ExecutorType.Activate, _CardId.DimensionalBarrier, DefaultDimensionalBarrier); + AddExecutor(ExecutorType.Activate, _CardId.InterruptedKaijuSlumber, DefaultInterruptedKaijuSlumber); + + AddExecutor(ExecutorType.SpSummon, _CardId.JizukirutheStarDestroyingKaiju, DefaultKaijuSpsummon); + AddExecutor(ExecutorType.SpSummon, _CardId.GadarlatheMysteryDustKaiju, DefaultKaijuSpsummon); + AddExecutor(ExecutorType.SpSummon, _CardId.GamecieltheSeaTurtleKaiju, DefaultKaijuSpsummon); + AddExecutor(ExecutorType.SpSummon, _CardId.RadiantheMultidimensionalKaiju, DefaultKaijuSpsummon); + AddExecutor(ExecutorType.SpSummon, _CardId.KumongoustheStickyStringKaiju, DefaultKaijuSpsummon); + AddExecutor(ExecutorType.SpSummon, _CardId.ThunderKingtheLightningstrikeKaiju, DefaultKaijuSpsummon); + AddExecutor(ExecutorType.SpSummon, _CardId.DogorantheMadFlameKaiju, DefaultKaijuSpsummon); + AddExecutor(ExecutorType.SpSummon, _CardId.SuperAntiKaijuWarMachineMechaDogoran, DefaultKaijuSpsummon); + + AddExecutor(ExecutorType.SpSummon, _CardId.EvilswarmExcitonKnight, DefaultEvilswarmExcitonKnightSummon); + AddExecutor(ExecutorType.Activate, _CardId.EvilswarmExcitonKnight, DefaultEvilswarmExcitonKnightEffect); + + AddExecutor(ExecutorType.Summon, _CardId.SandaionTheTimelord, DefaultTimelordSummon); + AddExecutor(ExecutorType.Summon, _CardId.GabrionTheTimelord, DefaultTimelordSummon); + AddExecutor(ExecutorType.Summon, _CardId.MichionTheTimelord, DefaultTimelordSummon); + AddExecutor(ExecutorType.Summon, _CardId.ZaphionTheTimelord, DefaultTimelordSummon); + AddExecutor(ExecutorType.Summon, _CardId.HailonTheTimelord, DefaultTimelordSummon); + AddExecutor(ExecutorType.Summon, _CardId.RaphionTheTimelord, DefaultTimelordSummon); + AddExecutor(ExecutorType.Summon, _CardId.SadionTheTimelord, DefaultTimelordSummon); + AddExecutor(ExecutorType.Summon, _CardId.MetaionTheTimelord, DefaultTimelordSummon); + AddExecutor(ExecutorType.Summon, _CardId.KamionTheTimelord, DefaultTimelordSummon); + AddExecutor(ExecutorType.Summon, _CardId.LazionTheTimelord, DefaultTimelordSummon); + + AddExecutor(ExecutorType.Summon, _CardId.LeftArmofTheForbiddenOne, JustDontIt); + AddExecutor(ExecutorType.Summon, _CardId.RightLegofTheForbiddenOne, JustDontIt); + AddExecutor(ExecutorType.Summon, _CardId.LeftLegofTheForbiddenOne, JustDontIt); + AddExecutor(ExecutorType.Summon, _CardId.RightArmofTheForbiddenOne, JustDontIt); + AddExecutor(ExecutorType.Summon, _CardId.ExodiaTheForbiddenOne, JustDontIt); + } + + private List HintMsgForEnemy = new List + { + HintMsg.Release, HintMsg.Destroy, HintMsg.Remove, HintMsg.ToGrave, HintMsg.ReturnToHand, HintMsg.ToDeck, + HintMsg.FusionMaterial, HintMsg.SynchroMaterial, HintMsg.XyzMaterial, HintMsg.LinkMaterial, HintMsg.Disable + }; + + private List HintMsgForDeck = new List + { + HintMsg.SpSummon, HintMsg.ToGrave, HintMsg.Remove, HintMsg.AddToHand, HintMsg.FusionMaterial + }; + + private List HintMsgForSelf = new List + { + HintMsg.Equip + }; + + private List HintMsgForMaterial = new List + { + HintMsg.FusionMaterial, HintMsg.SynchroMaterial, HintMsg.XyzMaterial, HintMsg.LinkMaterial, HintMsg.Release + }; + + private List HintMsgForMaxSelect = new List + { + HintMsg.SpSummon, HintMsg.ToGrave, HintMsg.AddToHand, HintMsg.FusionMaterial, HintMsg.Destroy + }; + + public override IList OnSelectCard(IList _cards, int min, int max, int hint, bool cancelable) + { + if (Duel.Phase == DuelPhase.BattleStart) + return null; + if (AI.HaveSelectedCards()) + return null; + + IList selected = new List(); + IList cards = new List(_cards); + if (max > cards.Count) + max = cards.Count; + + if (HintMsgForEnemy.Contains(hint)) + { + IList enemyCards = cards.Where(card => card.Controller == 1).ToList(); + + // select enemy's card first + while (enemyCards.Count > 0 && selected.Count < max) + { + ClientCard card = enemyCards[Program.Rand.Next(enemyCards.Count)]; + selected.Add(card); + enemyCards.Remove(card); + cards.Remove(card); + } + } + + if (HintMsgForDeck.Contains(hint)) + { + IList deckCards = cards.Where(card => card.Location == CardLocation.Deck).ToList(); + + // select deck's card first + while (deckCards.Count > 0 && selected.Count < max) + { + ClientCard card = deckCards[Program.Rand.Next(deckCards.Count)]; + selected.Add(card); + deckCards.Remove(card); + cards.Remove(card); + } + } + + if (HintMsgForSelf.Contains(hint)) + { + IList botCards = cards.Where(card => card.Controller == 0).ToList(); + + // select bot's card first + while (botCards.Count > 0 && selected.Count < max) + { + ClientCard card = botCards[Program.Rand.Next(botCards.Count)]; + selected.Add(card); + botCards.Remove(card); + cards.Remove(card); + } + } + + if (HintMsgForMaterial.Contains(hint)) + { + IList materials = cards.OrderBy(card => card.Attack).ToList(); + + // select low attack first + while (materials.Count > 0 && selected.Count < min) + { + ClientCard card = materials[0]; + selected.Add(card); + materials.Remove(card); + cards.Remove(card); + } + } + + // select random cards + while (selected.Count < min) + { + ClientCard card = cards[Program.Rand.Next(cards.Count)]; + selected.Add(card); + cards.Remove(card); + } + + if (HintMsgForMaxSelect.Contains(hint)) + { + // select max cards + while (selected.Count < max) + { + ClientCard card = cards[Program.Rand.Next(cards.Count)]; + selected.Add(card); + cards.Remove(card); + } + } + + return selected; + } + + public override int OnSelectOption(IList options) + { + return Program.Rand.Next(options.Count); + } + + public override CardPosition OnSelectPosition(int cardId, IList positions) + { + YGOSharp.OCGWrapper.NamedCard cardData = YGOSharp.OCGWrapper.NamedCard.Get(cardId); + if (cardData != null) + { + if (cardData.Attack < 0) + return CardPosition.FaceUpAttack; + if (cardData.Attack <= 1000) + return CardPosition.FaceUpDefence; + } + return 0; + } + + private bool ImFeelingLucky() + { + return Program.Rand.Next(10) >= 5 && DefaultDontChainMyself(); + } + + private bool ImFeelingUnlucky() + { + return DefaultDontChainMyself(); + } + + private bool ImFeelingLazy() + { + if (Executors.Any(exec => (exec.Type == ExecutorType.SummonOrSet || exec.Type == ExecutorType.Summon || exec.Type == ExecutorType.MonsterSet) && exec.CardId == Card.Id)) + return false; + return DefaultMonsterSummon(); + } + + private bool JustDontIt() + { + return false; + } + } +} \ No newline at end of file diff --git a/libWindbot/Game/AI/Decks/OldSchoolExecutor.cs b/libWindbot/Game/AI/Decks/OldSchoolExecutor.cs index 25c5c11..87aac00 100644 --- a/libWindbot/Game/AI/Decks/OldSchoolExecutor.cs +++ b/libWindbot/Game/AI/Decks/OldSchoolExecutor.cs @@ -46,8 +46,8 @@ public OldSchoolExecutor(GameAI ai, Duel duel) AddExecutor(ExecutorType.Activate, CardId.SwordsOfRevealingLight, SwordsOfRevealingLight); AddExecutor(ExecutorType.Activate, CardId.DoubleSummon, DoubleSummon); - AddExecutor(ExecutorType.Summon, CardId.AncientGearGolem, DefaultTributeSummon); - AddExecutor(ExecutorType.Summon, CardId.Frostosaurus, DefaultTributeSummon); + AddExecutor(ExecutorType.Summon, CardId.AncientGearGolem, DefaultMonsterSummon); + AddExecutor(ExecutorType.Summon, CardId.Frostosaurus, DefaultMonsterSummon); AddExecutor(ExecutorType.SummonOrSet, CardId.AlexandriteDragon); AddExecutor(ExecutorType.SummonOrSet, CardId.GeneWarpedWarwolf); AddExecutor(ExecutorType.MonsterSet, CardId.GearGolemTheMovingFortress); diff --git a/libWindbot/Game/AI/Decks/OrcustExecutor.cs b/libWindbot/Game/AI/Decks/OrcustExecutor.cs index 86f867b..b852147 100644 --- a/libWindbot/Game/AI/Decks/OrcustExecutor.cs +++ b/libWindbot/Game/AI/Decks/OrcustExecutor.cs @@ -181,7 +181,6 @@ public OrcustExecutor(GameAI ai, Duel duel) private bool CymbalSkeletonUsed = false; private bool BorrelswordDragonUsed = false; private ClientCard RustyBardicheTarget = null; - private int ShootingRiserDragonCount = 0; private int[] HandCosts = new[] { @@ -215,7 +214,6 @@ public override void OnNewTurn() CymbalSkeletonUsed = false; BorrelswordDragonUsed = false; RustyBardicheTarget = null; - ShootingRiserDragonCount = 0; } public override void OnChainEnd() @@ -611,10 +609,7 @@ private bool ShootingRiserDragonEffect() } else { - if (Duel.LastChainPlayer == 0) - return false; - ShootingRiserDragonCount++; - return ShootingRiserDragonCount <= 10; + return Duel.LastChainPlayer != 0; } } @@ -825,8 +820,8 @@ private bool SheorcustDingirsuEffect() if (ActivateDescription == 96) { // TODO: more FogBlade lost target - if ((Duel.Phase == DuelPhase.Main1 || Duel.Phase == DuelPhase.Main2) && Duel.CurrentChain.Count == 0) - return false; + if ((Duel.Phase == DuelPhase.Main1 || Duel.Phase == DuelPhase.Main2) && Duel.CurrentChain.Count == 0) + return false; AI.SelectCard(CardId.OrcustCymbalSkeleton); return true; } @@ -1130,22 +1125,22 @@ private bool ClimaxEffect() { return Duel.LastChainPlayer == 1; } - else if (Duel.Phase == DuelPhase.End) - { - ClientCard target = null; - target = Bot.Banished.GetFirstMatchingFaceupCard(card=>card.IsCode(CardId.OrcustCymbalSkeleton)); - if (target == null) - target = Bot.Banished.GetFirstMatchingFaceupCard(card => card.IsCode(CardId.OrcustHarpHorror)); - if (target != null) - { - AI.SelectCard(target); - return true; - } - if(!Bot.HasInHand(CardId.OrcustHarpHorror) && Bot.GetRemainingCount(CardId.OrcustHarpHorror, 2) > 1) - { - AI.SelectCard(CardId.OrcustHarpHorror); - return true; - } + else if (Duel.Phase == DuelPhase.End) + { + ClientCard target = null; + target = Bot.Banished.GetFirstMatchingFaceupCard(card=>card.IsCode(CardId.OrcustCymbalSkeleton)); + if (target == null) + target = Bot.Banished.GetFirstMatchingFaceupCard(card => card.IsCode(CardId.OrcustHarpHorror)); + if (target != null) + { + AI.SelectCard(target); + return true; + } + if(!Bot.HasInHand(CardId.OrcustHarpHorror) && Bot.GetRemainingCount(CardId.OrcustHarpHorror, 2) > 1) + { + AI.SelectCard(CardId.OrcustHarpHorror); + return true; + } } return false; } diff --git a/libWindbot/Game/AI/Decks/PhantasmExecutor.cs b/libWindbot/Game/AI/Decks/PhantasmExecutor.cs index 124cd9c..6962f3f 100644 --- a/libWindbot/Game/AI/Decks/PhantasmExecutor.cs +++ b/libWindbot/Game/AI/Decks/PhantasmExecutor.cs @@ -117,13 +117,11 @@ public PhantasmExecutor(GameAI ai, Duel duel) bool summon_used = false; bool CardOfDemiseeff_used = false; bool SeaStealthAttackeff_used = false; - int City_count = 0; public override void OnNewTurn() { summon_used = false; CardOfDemiseeff_used = false; SeaStealthAttackeff_used = false; - City_count = 0; base.OnNewTurn(); } private bool PreventFeatherDustereff() @@ -356,9 +354,6 @@ private bool PacifisThePhantasmCityeff() } else { - if (City_count > 10) - return false; - ClientCard target = null; foreach(ClientCard s in Bot.GetSpells()) { @@ -380,7 +375,6 @@ private bool PacifisThePhantasmCityeff() break; } } - City_count++; AI.SelectPlace(Zones.z1 | Zones.z3); AI.SelectCard(CardId.PhantasmSprialBattle); return true; diff --git a/libWindbot/Game/AI/Decks/PureWindsExecutor.cs b/libWindbot/Game/AI/Decks/PureWindsExecutor.cs index fa0290e..a6c4f32 100644 --- a/libWindbot/Game/AI/Decks/PureWindsExecutor.cs +++ b/libWindbot/Game/AI/Decks/PureWindsExecutor.cs @@ -215,8 +215,7 @@ public class CardId private bool Summon_used; private bool Pilica_eff; 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) : base(ai, duel) { @@ -302,7 +301,6 @@ public override void OnNewTurn() Summon_used = false; Pilica_eff = false; plan_A = false; - SnowBell_count = 0; base.OnNewTurn(); } private bool windaset() @@ -770,7 +768,6 @@ private bool SuperTeamBuddyForceUniteeff() private bool WindwitchSnowBellsp() { - if (SnowBell_count >= 5) return false; if ((Bot.HasInMonstersZone(CardId.CrystalWingSynchroDragon) || Bot.HasInMonstersZone(CardId.DaigustoSphreez) || Bot.HasInMonstersZone(CardId.MistWurm)) && @@ -786,7 +783,6 @@ private bool WindwitchSnowBellsp() (Util.GetBotAvailZonesFromExtraDeck() == 0)) return false; AI.SelectPosition(CardPosition.FaceUpDefence); - SnowBell_count++; return true; } private bool DaigustoSphreezsp() diff --git a/libWindbot/Game/AI/Decks/TimeThiefExecutor.cs b/libWindbot/Game/AI/Decks/TimeThiefExecutor.cs index efd28a5..189dc8a 100644 --- a/libWindbot/Game/AI/Decks/TimeThiefExecutor.cs +++ b/libWindbot/Game/AI/Decks/TimeThiefExecutor.cs @@ -1,285 +1,407 @@ -using System; -using YGOSharp.OCGWrapper.Enums; -using System.Collections.Generic; -using System.Diagnostics; -using WindBot; -using WindBot.Game; -using WindBot.Game.AI; -using System.Linq; -using System.Reflection; - -namespace WindBot.Game.AI.Decks -{ - [Deck("TimeThief", "AI_Timethief")] - public class TimeThiefExecutor : DefaultExecutor - { - public class Monsters - { - //monsters - public const int TimeThiefWinder = 56308388; - public const int TimeThiefBezelShip = 82496079; - public const int TimeThiefCronocorder = 74578720; - public const int TimeThiefRegulator = 19891131; - public const int PhotonTrasher = 65367484; - public const int PerformTrickClown = 67696066; - } - - public class Spells - { - // spells - public const int UpstartGoblin = 70368879; - public const int Raigeki = 12580477; - public const int FoolishBurial = 81439173; - public const int TimeThiefStartup = 10877309; - public const int TimeThiefHack = 81670445; - } - public class Traps - { - //traps - public const int XyzReborn = 26708437; - public const int XyzExtreme = 57319935; - public const int TimeThiefRetrograte = 76587747; - public const int PhantomKnightsShade = 98827725; - public const int TimeThiefFlyBack = 18678554; - } - public class XYZs - { - //xyz - public const int TimeThiefRedoer = 55285840; - public const int TimeThiefPerpetua = 59208943; - public const int CrazyBox = 42421606; - } - - - - public TimeThiefExecutor(GameAI ai, Duel duel) - : base(ai, duel) - { - // executors - //Spell activate - AddExecutor(ExecutorType.Activate,Spells.UpstartGoblin); - AddExecutor(ExecutorType.Activate,Spells.FoolishBurial,FoolishBurialTarget); - AddExecutor(ExecutorType.Activate,Spells.TimeThiefStartup,TimeThiefStartupEffect); - AddExecutor(ExecutorType.Activate,Spells.TimeThiefHack); - - // trap executors set - AddExecutor(ExecutorType.SpellSet,Traps.XyzExtreme); - AddExecutor(ExecutorType.SpellSet,Traps.XyzReborn); - AddExecutor(ExecutorType.SpellSet,Traps.PhantomKnightsShade); - AddExecutor(ExecutorType.SpellSet,Traps.TimeThiefRetrograte); - AddExecutor(ExecutorType.SpellSet,Traps.TimeThiefFlyBack); - - //normal summons - AddExecutor(ExecutorType.Summon,Monsters.TimeThiefRegulator ); - AddExecutor(ExecutorType.SpSummon, Monsters.PhotonTrasher, SummonToDef ); - AddExecutor(ExecutorType.Summon,Monsters.TimeThiefWinder ); - AddExecutor(ExecutorType.Summon,Monsters.TimeThiefBezelShip ); - AddExecutor(ExecutorType.Summon,Monsters.PerformTrickClown ); - AddExecutor(ExecutorType.Summon,Monsters.TimeThiefCronocorder ); - //xyz summons - AddExecutor(ExecutorType.SpSummon,XYZs.TimeThiefRedoer); - AddExecutor(ExecutorType.SpSummon,XYZs.TimeThiefPerpetua); - // activate trap - AddExecutor(ExecutorType.Activate,Traps.PhantomKnightsShade); - AddExecutor(ExecutorType.Activate,Traps.XyzExtreme , XyzExtremeEffect); - AddExecutor(ExecutorType.Activate,Traps.XyzReborn , XyzRebornEffect); - AddExecutor(ExecutorType.Activate,Traps.TimeThiefRetrograte , RetrograteEffect); - AddExecutor(ExecutorType.Activate,Traps.TimeThiefFlyBack ); - - //xyz effects - AddExecutor(ExecutorType.Activate,XYZs.TimeThiefRedoer,RedoerEffect); - AddExecutor(ExecutorType.Activate,XYZs.TimeThiefPerpetua , PerpertuaEffect); - - //monster effects - AddExecutor(ExecutorType.Activate,Monsters.TimeThiefRegulator , RegulatorEffect); - AddExecutor(ExecutorType.Activate,Monsters.TimeThiefWinder); - AddExecutor(ExecutorType.Activate,Monsters.TimeThiefCronocorder); - AddExecutor(ExecutorType.Activate,Monsters.PerformTrickClown, TrickClownEffect); - AddExecutor(ExecutorType.Activate,Monsters.TimeThiefBezelShip); - } - - private bool SummonToDef() - { - AI.SelectPosition(CardPosition.Defence); - return true; - } - - - private bool RegulatorEffect() - { - if (Card.Location == CardLocation.MonsterZone) - { - AI.SelectCard(Monsters.TimeThiefCronocorder); - AI.SelectCard(Monsters.TimeThiefWinder); - return true; - } - - if (Card.Location == CardLocation.Grave) - { - return true; - } - - return false; - } - - private bool PerpertuaEffect() - { - if (Bot.HasInGraveyard(XYZs.TimeThiefRedoer)) - { - AI.SelectCard(XYZs.TimeThiefRedoer); - return true; - } - - if (Bot.HasInMonstersZone(XYZs.TimeThiefRedoer)) - { - AI.SelectCard(Monsters.TimeThiefBezelShip); - AI.SelectNextCard(XYZs.TimeThiefRedoer); - return true; - } - - return false; - } - - private int _totalAttack; - private int _totalBotAttack; - private bool RedoerEffect() - { - - List enemy = Enemy.GetMonstersInMainZone(); - List units = Card.Overlays; - if (Duel.Phase == DuelPhase.Standby && (AI.Executor.Util.GetStringId(XYZs.TimeThiefRedoer,0) == - ActivateDescription)) - { - - return true; - } - - try - { - if (Bot.HasInSpellZone(Traps.XyzReborn)) - { - return false; - } - - if (Bot.HasInSpellZone(Traps.XyzExtreme)) - { - return false; - } - - for (int i = 0; i < enemy.Count; i++) - { - _totalAttack += enemy[i].Attack; - } - - foreach (var t in Bot.GetMonsters()) - { - _totalBotAttack += t.Attack; - } - - if (_totalAttack > Bot.LifePoints + _totalBotAttack) - { - return false; - } - - - - foreach (var t in enemy) - { - if (t.Attack < 2400 || !t.IsAttack()) continue; - try - { - AI.SelectCard(t.Id); - AI.SelectCard(t.Id); - } - catch{} - - return true; - } - } - catch{} - - if (Bot.UnderAttack) - { - //AI.SelectCard(Util.GetBestEnemyMonster()); - return true; - } - - return false; - - } - - private bool RetrograteEffect() - { - if (Card.Owner== 1) - { - return true; - } - return false; - - } - - private bool XyzRebornEffect() - { - if (Bot.HasInGraveyard(XYZs.TimeThiefRedoer)) - { - AI.SelectCard(XYZs.TimeThiefRedoer); - return true; - } - return true; - - } - //function - private bool XyzExtremeEffect() - { - AI.SelectCard(XYZs.CrazyBox); - return true; - } - private bool TimeThiefStartupEffect() - { - if (Card.Location == CardLocation.Hand) - { - if (Bot.HasInHand(Monsters.TimeThiefRegulator) && !(Bot.GetMonsterCount() > 0)) - { - AI.SelectCard(Monsters.TimeThiefRegulator); - return true; - } - if(Bot.HasInHand(Monsters.TimeThiefWinder) && Bot.GetMonsterCount()>1) - { - AI.SelectCard(Monsters.TimeThiefWinder); - return true; - } - return true; - - } - if (Card.Location == CardLocation.Grave) - { - AI.SelectCard(Monsters.TimeThiefCronocorder); - AI.SelectCard(Spells.TimeThiefHack); - AI.SelectCard(Traps.TimeThiefFlyBack); - return true; - } - - return false; - - } - private bool FoolishBurialTarget() - { - AI.SelectCard(Monsters.PerformTrickClown); - return true; - } - - private bool TrickClownEffect() - { - if (Bot.LifePoints <= 1000) - { - return false; - } - AI.SelectPosition(CardPosition.FaceUpDefence); - return true; - } - - - - } - -} +using YGOSharp.OCGWrapper; +using YGOSharp.OCGWrapper.Enums; +using System.Collections.Generic; +using WindBot; +using WindBot.Game; +using WindBot.Game.AI; +using System.Linq; + +namespace WindBot.Game.AI.Decks +{ + [Deck("TimeThief", "AI_Timethief")] + public class TimeThiefExecutor : DefaultExecutor + { + public class Monsters + { + //monsters + public const int TimeThiefWinder = 56308388; + public const int TimeThiefBezelShip = 82496079; + public const int TimeThiefCronocorder = 74578720; + public const int TimeThiefRegulator = 19891131; + public const int PhotonTrasher = 65367484; + public const int PerformTrickClown = 67696066; + public const int ThunderKingRaiOh = 71564252; + public const int MaxxC = 23434538; + public const int AshBlossomAndJoyousSpring = 14558127; + } + + public class CardId + { + public const int ImperialOrder = 61740673; + public const int NaturalExterio = 99916754; + public const int NaturalBeast = 33198837; + public const int SwordsmanLV7 = 37267041; + public const int RoyalDecreel = 51452091; + } + + public class Spells + { + // spells + public const int Raigeki = 12580477; + public const int FoolishBurial = 81439173; + public const int TimeThiefStartup = 10877309; + public const int TimeThiefHack = 81670445; + public const int HarpieFeatherDuster = 18144506; + public const int PotOfDesires = 35261759; + public const int PotofExtravagance = 49238328; + } + public class Traps + { + //traps + public const int SolemnWarning = 84749824; + public const int SolemStrike = 40605147; + public const int SolemnJudgment = 41420027; + public const int TimeThiefRetrograte = 76587747; + public const int PhantomKnightsShade = 98827725; + public const int TimeThiefFlyBack = 18678554; + public const int Crackdown = 36975314; + } + public class XYZs + { + //xyz + public const int TimeThiefRedoer = 55285840; + public const int TimeThiefPerpetua = 59208943; + public const int CrazyBox = 42421606; + public const int GagagaCowboy = 12014404; + public const int Number39Utopia = 84013237; + public const int NumberS39UtopiatheLightning = 56832966; + public const int NumberS39UtopiaOne = 86532744; + public const int DarkRebellionXyzDragon = 16195942; + public const int EvilswarmExcitonKnight = 46772449; + } + + + + public TimeThiefExecutor(GameAI ai, Duel duel) + : base(ai, duel) + { + // executors + //Spell activate + AddExecutor(ExecutorType.Activate, Spells.Raigeki, DefaultDarkHole); + AddExecutor(ExecutorType.Activate, Spells.FoolishBurial, FoolishBurialTarget); + AddExecutor(ExecutorType.Activate, Spells.TimeThiefStartup, TimeThiefStartupEffect); + AddExecutor(ExecutorType.Activate, Spells.TimeThiefHack); + AddExecutor(ExecutorType.Activate, Spells.PotofExtravagance, PotofExtravaganceActivate); + AddExecutor(ExecutorType.Activate, Spells.HarpieFeatherDuster, DefaultHarpiesFeatherDusterFirst); + AddExecutor(ExecutorType.Activate, Spells.PotOfDesires, PotOfDesireseff); + // trap executors set + AddExecutor(ExecutorType.SpellSet, Traps.PhantomKnightsShade); + AddExecutor(ExecutorType.SpellSet, Traps.TimeThiefRetrograte); + AddExecutor(ExecutorType.SpellSet, Traps.TimeThiefFlyBack); + AddExecutor(ExecutorType.SpellSet, Traps.SolemnWarning); + AddExecutor(ExecutorType.SpellSet, Traps.SolemStrike); + AddExecutor(ExecutorType.SpellSet, Traps.SolemnJudgment); + AddExecutor(ExecutorType.SpellSet, Traps.Crackdown); + //normal summons + AddExecutor(ExecutorType.Summon, Monsters.TimeThiefRegulator); + AddExecutor(ExecutorType.SpSummon, Monsters.PhotonTrasher, SummonToDef); + AddExecutor(ExecutorType.Summon, Monsters.TimeThiefWinder); + AddExecutor(ExecutorType.Summon, Monsters.TimeThiefBezelShip); + AddExecutor(ExecutorType.Summon, Monsters.PerformTrickClown); + AddExecutor(ExecutorType.Summon, Monsters.TimeThiefCronocorder); + AddExecutor(ExecutorType.Summon, Monsters.ThunderKingRaiOh, ThunderKingRaiOhsummon); + //xyz summons + AddExecutor(ExecutorType.SpSummon, XYZs.TimeThiefRedoer); + AddExecutor(ExecutorType.SpSummon, XYZs.TimeThiefPerpetua); + AddExecutor(ExecutorType.SpSummon, XYZs.EvilswarmExcitonKnight, DefaultEvilswarmExcitonKnightSummon); + AddExecutor(ExecutorType.SpSummon, XYZs.GagagaCowboy, GagagaCowboySummon); + AddExecutor(ExecutorType.SpSummon, XYZs.Number39Utopia, DefaultNumberS39UtopiaTheLightningSummon); + AddExecutor(ExecutorType.SpSummon, XYZs.NumberS39UtopiaOne); + AddExecutor(ExecutorType.SpSummon, XYZs.NumberS39UtopiatheLightning); + AddExecutor(ExecutorType.SpSummon, XYZs.DarkRebellionXyzDragon, DarkRebellionXyzDragonSummon); + //activate trap + AddExecutor(ExecutorType.Activate, Traps.PhantomKnightsShade); + AddExecutor(ExecutorType.Activate, Traps.TimeThiefRetrograte, RetrograteEffect); + AddExecutor(ExecutorType.Activate, Traps.TimeThiefFlyBack); + AddExecutor(ExecutorType.Activate, Traps.SolemnWarning, DefaultSolemnWarning); + AddExecutor(ExecutorType.Activate, Traps.SolemStrike, DefaultSolemnStrike); + AddExecutor(ExecutorType.Activate, Traps.SolemnJudgment, DefaultSolemnJudgment); + AddExecutor(ExecutorType.Activate, Traps.Crackdown, Crackdowneff); + //xyz effects + AddExecutor(ExecutorType.Activate, XYZs.TimeThiefRedoer, RedoerEffect); + AddExecutor(ExecutorType.Activate, XYZs.TimeThiefPerpetua, PerpertuaEffect); + AddExecutor(ExecutorType.Activate, XYZs.EvilswarmExcitonKnight, DefaultEvilswarmExcitonKnightEffect); + AddExecutor(ExecutorType.Activate, XYZs.GagagaCowboy); + AddExecutor(ExecutorType.Activate, XYZs.NumberS39UtopiatheLightning, DefaultNumberS39UtopiaTheLightningEffect); + AddExecutor(ExecutorType.Activate, XYZs.DarkRebellionXyzDragon, DarkRebellionXyzDragonEffect); + + //monster effects + AddExecutor(ExecutorType.Activate, Monsters.TimeThiefRegulator, RegulatorEffect); + AddExecutor(ExecutorType.Activate, Monsters.TimeThiefWinder); + AddExecutor(ExecutorType.Activate, Monsters.TimeThiefCronocorder); + AddExecutor(ExecutorType.Activate, Monsters.PerformTrickClown, TrickClownEffect); + AddExecutor(ExecutorType.Activate, Monsters.TimeThiefBezelShip); + AddExecutor(ExecutorType.Activate, Monsters.ThunderKingRaiOh, ThunderKingRaiOheff); + AddExecutor(ExecutorType.Activate, Monsters.AshBlossomAndJoyousSpring, DefaultAshBlossomAndJoyousSpring); + AddExecutor(ExecutorType.Activate, Monsters.MaxxC, DefaultMaxxC); + } + + public void SelectSTPlace(ClientCard card = null, bool avoid_Impermanence = false, List avoid_list = null) + { + List list = new List { 0, 1, 2, 3, 4 }; + int n = list.Count; + while (n-- > 1) + { + int index = Program.Rand.Next(n + 1); + int temp = list[index]; + list[index] = list[n]; + list[n] = temp; + } + foreach (int seq in list) + { + int zone = (int)System.Math.Pow(2, seq); + if (Bot.SpellZone[seq] == null) + { + if (card != null && card.Location == CardLocation.Hand && avoid_Impermanence) continue; + if (avoid_list != null && avoid_list.Contains(seq)) continue; + AI.SelectPlace(zone); + return; + }; + } + AI.SelectPlace(0); + } + + public bool SpellNegatable(bool isCounter = false, ClientCard target = null) + { + // target default set + if (target == null) target = Card; + // won't negate if not on field + if (target.Location != CardLocation.SpellZone && target.Location != CardLocation.Hand) return false; + + // negate judge + if (Enemy.HasInMonstersZone(CardId.NaturalExterio, true) && !isCounter) return true; + if (target.IsSpell()) + { + if (Enemy.HasInMonstersZone(CardId.NaturalBeast, true)) return true; + if (Enemy.HasInSpellZone(CardId.ImperialOrder, true) || Bot.HasInSpellZone(CardId.ImperialOrder, true)) return true; + if (Enemy.HasInMonstersZone(CardId.SwordsmanLV7, true) || Bot.HasInMonstersZone(CardId.SwordsmanLV7, true)) return true; + } + if (target.IsTrap()) + { + if (Enemy.HasInSpellZone(CardId.RoyalDecreel, true) || Bot.HasInSpellZone(CardId.RoyalDecreel, true)) return true; + } + // how to get here? + return false; + } + private bool SummonToDef() + { + AI.SelectPosition(CardPosition.Defence); + return true; + } + private bool RegulatorEffect() + { + if (Card.Location == CardLocation.MonsterZone) + { + AI.SelectCard(Monsters.TimeThiefCronocorder); + AI.SelectCard(Monsters.TimeThiefWinder); + return true; + } + + if (Card.Location == CardLocation.Grave) + { + return true; + } + + return false; + } + + private bool PerpertuaEffect() + { + if (Bot.HasInGraveyard(XYZs.TimeThiefRedoer)) + { + AI.SelectCard(XYZs.TimeThiefRedoer); + return true; + } + + if (Bot.HasInMonstersZone(XYZs.TimeThiefRedoer)) + { + AI.SelectCard(Monsters.TimeThiefBezelShip); + AI.SelectNextCard(XYZs.TimeThiefRedoer); + return true; + } + + return false; + } + + private int _totalAttack; + private int _totalBotAttack; + private bool RedoerEffect() + { + + List enemy = Enemy.GetMonstersInMainZone(); + List units = Card.Overlays; + if (Duel.Phase == DuelPhase.Standby && (AI.Executor.Util.GetStringId(XYZs.TimeThiefRedoer, 0) == + ActivateDescription)) + { + + return true; + } + + try + { + for (int i = 0; i < enemy.Count; i++) + { + _totalAttack += enemy[i].Attack; + } + + foreach (var t in Bot.GetMonsters()) + { + _totalBotAttack += t.Attack; + } + + if (_totalAttack > Bot.LifePoints + _totalBotAttack) + { + return false; + } + + + + foreach (var t in enemy) + { + if (t.Attack < 2400 || !t.IsAttack()) continue; + try + { + AI.SelectCard(t.Id); + AI.SelectCard(t.Id); + } + catch { } + + return true; + } + } + catch { } + + if (Bot.UnderAttack) + { + //AI.SelectCard(Util.GetBestEnemyMonster()); + return true; + } + + return false; + + } + private bool RetrograteEffect() + { + if (Card.Owner == 1) + { + return true; + } + return false; + + } + private bool TimeThiefStartupEffect() + { + if (Card.Location == CardLocation.Hand) + { + if (Bot.HasInHand(Monsters.TimeThiefRegulator) && !(Bot.GetMonsterCount() > 0)) + { + AI.SelectCard(Monsters.TimeThiefRegulator); + return true; + } + if (Bot.HasInHand(Monsters.TimeThiefWinder) && Bot.GetMonsterCount() > 1) + { + AI.SelectCard(Monsters.TimeThiefWinder); + return true; + } + return true; + + } + if (Card.Location == CardLocation.Grave) + { + AI.SelectCard(Monsters.TimeThiefCronocorder); + AI.SelectCard(Spells.TimeThiefHack); + AI.SelectCard(Traps.TimeThiefFlyBack); + return true; + } + + return false; + + } + private bool FoolishBurialTarget() + { + AI.SelectCard(Monsters.PerformTrickClown); + return true; + } + + private bool TrickClownEffect() + { + if (Bot.LifePoints <= 1000) + { + return false; + } + AI.SelectPosition(CardPosition.FaceUpDefence); + return true; + } + private bool GagagaCowboySummon() + { + if (Enemy.LifePoints <= 800 || (Bot.GetMonsterCount() >= 4 && Enemy.LifePoints <= 1600)) + { + AI.SelectPosition(CardPosition.FaceUpDefence); + return true; + } + return false; + } + + private bool DarkRebellionXyzDragonSummon() + { + int selfBestAttack = Util.GetBestAttack(Bot); + int oppoBestAttack = Util.GetBestAttack(Enemy); + return selfBestAttack <= oppoBestAttack; + } + + private bool DarkRebellionXyzDragonEffect() + { + int oppoBestAttack = Util.GetBestAttack(Enemy); + ClientCard target = Util.GetOneEnemyBetterThanValue(oppoBestAttack, true); + if (target != null) + { + AI.SelectCard(0); + AI.SelectNextCard(target); + } + return true; + } + private bool ThunderKingRaiOhsummon() + { + if (Bot.MonsterZone[0] == null) + AI.SelectPlace(Zones.z0); + else + AI.SelectPlace(Zones.z4); + return true; + } + private bool ThunderKingRaiOheff() + { + if (Duel.SummoningCards.Count > 0) + { + foreach (ClientCard m in Duel.SummoningCards) + { + if (m.Attack >= 1900) + return true; + } + } + return false; + } + private bool Crackdowneff() + { + if (Util.GetOneEnemyBetterThanMyBest(true, true) != null && Bot.UnderAttack) + AI.SelectCard(Util.GetOneEnemyBetterThanMyBest(true, true)); + return Util.GetOneEnemyBetterThanMyBest(true, true) != null && Bot.UnderAttack; + } + private bool PotOfDesireseff() + { + return Bot.Deck.Count > 14 && !DefaultSpellWillBeNegated(); + } + + // activate of PotofExtravagance + public bool PotofExtravaganceActivate() + { + // won't activate if it'll be negate + if (SpellNegatable()) return false; + SelectSTPlace(Card, true); + AI.SelectOption(1); + return true; + } + + + } + +} diff --git a/libWindbot/Game/AI/Decks/TrickstarExecutor.cs b/libWindbot/Game/AI/Decks/TrickstarExecutor.cs index e30e284..ff1d5fb 100644 --- a/libWindbot/Game/AI/Decks/TrickstarExecutor.cs +++ b/libWindbot/Game/AI/Decks/TrickstarExecutor.cs @@ -73,7 +73,6 @@ public int getLinkMarker(int id) bool snake_four_s = false; bool tuner_eff_used = false; bool crystal_eff_used = false; - int red_ss_count = 0; bool white_eff_used = false; bool lockbird_useful = false; bool lockbird_used = false; @@ -758,7 +757,6 @@ public void Red_SelectPos(ClientCard return_card = null) 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 (Duel.LastChainPlayer == 0 && Util.GetLastChainCard().IsCode(CardId.Red)) { @@ -766,7 +764,6 @@ public bool Red_ss() { if (Util.IsChainTarget(m) && IsTrickstar(m.Id)) { - red_ss_count += 1; AI.SelectCard(m); Red_SelectPos(); return true; @@ -789,7 +786,6 @@ public bool Red_ss() { AI.SelectCard(c); Red_SelectPos(c); - red_ss_count += 1; return true; } if (c.IsCode(CardId.Pink)) return false; @@ -800,14 +796,12 @@ public bool Red_ss() if (tosolve_enemy.Attack > 3200) AI.SelectPosition(CardPosition.FaceUpDefence); AI.SelectCard(c); Red_SelectPos(c); - red_ss_count += 1; return true; } if (!Bot.HasInHand(CardId.White) && tosolve_enemy.Attack <= 3200 && c.IsCode(CardId.White)) { AI.SelectCard(c); Red_SelectPos(c); - red_ss_count += 1; return true; } if (!Bot.HasInHand(CardId.White) && c.Attack < tosolve_enemy.Attack) @@ -824,7 +818,6 @@ public bool Red_ss() if (tosolve_enemy.Attack > 1600) AI.SelectPosition(CardPosition.FaceUpDefence); AI.SelectCard(c); Red_SelectPos(c); - red_ss_count += 1; return true; } } @@ -845,7 +838,6 @@ public bool Red_ss() { AI.SelectCard(card); Red_SelectPos(card); - red_ss_count += 1; return true; } } @@ -1710,7 +1702,6 @@ public override void OnNewTurn() pink_ss = false; snake_four_s = false; crystal_eff_used = false; - red_ss_count = 0; white_eff_used = false; lockbird_useful = false; lockbird_used = false; diff --git a/libWindbot/Game/AI/Decks/WitchcraftExecutor.cs b/libWindbot/Game/AI/Decks/WitchcraftExecutor.cs index 55a7416..b977c8a 100644 --- a/libWindbot/Game/AI/Decks/WitchcraftExecutor.cs +++ b/libWindbot/Game/AI/Decks/WitchcraftExecutor.cs @@ -197,7 +197,6 @@ public WitchcraftExecutor(GameAI ai, Duel duel) bool MagicianRightHand_used = false; ClientCard MagiciansLeftHand_negate = null; ClientCard MagicianRightHand_negate = null; - int PSYOmega_count = 0; // go first public override bool OnSelectHand() @@ -271,7 +270,6 @@ public override void OnChaining(int player, ClientCard card) public override void OnNewTurn() { CrossoutDesignatorTarget = 0; - PSYOmega_count = 0; MadameVerreGainedATK = false; summoned = false; enemy_activate_MaxxC = false; @@ -311,8 +309,8 @@ public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender // overwrite OnSelectCard to act normally in SelectUnselect public override IList OnSelectCard(IList cards, int min, int max, int hint, bool cancelable) { - // Patronus HINTMSG_ATOHAND - if (hint == 506) + // Patronus + if (hint == HintMsg.AddToHand) { bool flag = true; foreach(ClientCard card in cards) @@ -336,8 +334,8 @@ public override IList OnSelectCard(IList cards, int min, return selected; } } - // MaxxC HINTMSG_SPSUMMON - if (hint == 509 && enemy_activate_MaxxC) + // MaxxC solution + if (hint == HintMsg.SpSummon && enemy_activate_MaxxC) { // check whether SS from deck while using effect bool flag = true; @@ -394,8 +392,8 @@ public override IList OnSelectCard(IList cards, int min, } } } - // MadameVerre HINTMSG_CONFIRM - if (hint == 526) + // MadameVerre + if (hint == HintMsg.Confirm) { Logger.DebugWriteLine("** min-max: " + min.ToString() + " / " + max.ToString()); foreach (ClientCard card in cards) @@ -2501,20 +2499,15 @@ public bool PSYOmegaActivate() // recycle from grave if (Card.Location == CardLocation.Grave) { - if (PSYOmega_count >= 5){ - return false; - } List enemy_danger = CheckDangerousCardinEnemyGrave(); if (enemy_danger.Count > 0) { AI.SelectCard(enemy_danger); - PSYOmega_count ++; return true; } if (!Bot.HasInHandOrInSpellZoneOrInGraveyard(CardId.Holiday) && Bot.HasInGraveyard(important_witchcraft)) { AI.SelectCard(important_witchcraft); - PSYOmega_count ++; return true; } if (CheckProblematicCards() == null) @@ -2523,7 +2516,6 @@ public bool PSYOmegaActivate() CardId.MaxxC, CardId.AshBlossom_JoyousSpring, CardId.MagicianRightHand, CardId.MagiciansLeftHand, CardId.MagiciansRestage, CardId.Patronus, CardId.LightningStorm, CardId.Reasoning); - PSYOmega_count ++; return true; } } diff --git a/libWindbot/Game/AI/Decks/ZexalWeaponsExecutor.cs b/libWindbot/Game/AI/Decks/ZexalWeaponsExecutor.cs index 54c4006..01fb376 100644 --- a/libWindbot/Game/AI/Decks/ZexalWeaponsExecutor.cs +++ b/libWindbot/Game/AI/Decks/ZexalWeaponsExecutor.cs @@ -100,6 +100,7 @@ public ZexalWeaponsExecutor(GameAI ai, Duel duel) AddExecutor(ExecutorType.Summon, CardId.Goblindbergh); AddExecutor(ExecutorType.Summon, CardId.TinGoldfish); AddExecutor(ExecutorType.Summon, CardId.SummonerMonk); + AddExecutor(ExecutorType.Summon, CardId.Honest); // Summons: Effects AddExecutor(ExecutorType.Activate, CardId.Goblindbergh, GoblindberghEffect); @@ -122,13 +123,6 @@ public ZexalWeaponsExecutor(GameAI ai, Duel duel) AddExecutor(ExecutorType.Activate, CardId.SolemnStrike, DefaultSolemnStrike); } - private int ZwCount = 0; - - public override void OnNewTurn() - { - ZwCount = 0; - } - public override bool OnSelectHand() { return false; @@ -177,8 +171,7 @@ private bool ZwLionArms() private bool ZwWeapon() { - ZwCount++; - return ZwCount < 10; + return true; } private bool ReinforcementOfTheArmy() diff --git a/libWindbot/Game/AI/Decks/ZoodiacExecutor.cs b/libWindbot/Game/AI/Decks/ZoodiacExecutor.cs index 0d36507..469eb03 100644 --- a/libWindbot/Game/AI/Decks/ZoodiacExecutor.cs +++ b/libWindbot/Game/AI/Decks/ZoodiacExecutor.cs @@ -47,7 +47,6 @@ public class CardId bool TigermortarSpsummoned = false; bool ChakanineSpsummoned = false; bool BroadbullSpsummoned = false; - int WhiptailEffectCount = 0; public ZoodiacExecutor(GameAI ai, Duel duel) : base(ai, duel) @@ -128,7 +127,6 @@ public override void OnNewTurn() TigermortarSpsummoned = false; ChakanineSpsummoned = false; BroadbullSpsummoned = false; - WhiptailEffectCount = 0; } public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender) @@ -431,7 +429,7 @@ private bool WhiptailEffect() { if (Duel.Phase == DuelPhase.Main1 || Duel.Phase == DuelPhase.Main2) return false; - if (Card.IsDisabled() || WhiptailEffectCount >= 3) + if (Card.IsDisabled()) return false; ClientCard target = null; List monsters = Bot.GetMonsters(); @@ -461,7 +459,6 @@ private bool WhiptailEffect() CardId.Drident }); } - WhiptailEffectCount++; return true; } diff --git a/libWindbot/Game/AI/DefaultExecutor.cs b/libWindbot/Game/AI/DefaultExecutor.cs index 3eb0b66..826c7c1 100644 --- a/libWindbot/Game/AI/DefaultExecutor.cs +++ b/libWindbot/Game/AI/DefaultExecutor.cs @@ -21,6 +21,23 @@ protected class _CardId public const int GamecieltheSeaTurtleKaiju = 55063751; public const int SuperAntiKaijuWarMachineMechaDogoran = 84769941; + public const int SandaionTheTimelord = 33015627; + public const int GabrionTheTimelord = 6616912; + public const int MichionTheTimelord = 7733560; + public const int ZaphionTheTimelord = 28929131; + public const int HailonTheTimelord = 34137269; + public const int RaphionTheTimelord = 60222213; + public const int SadionTheTimelord = 65314286; + public const int MetaionTheTimelord = 74530899; + public const int KamionTheTimelord = 91712985; + public const int LazionTheTimelord = 92435533; + + public const int LeftArmofTheForbiddenOne = 7902349; + public const int RightLegofTheForbiddenOne = 8124921; + public const int LeftLegofTheForbiddenOne = 44519536; + public const int RightArmofTheForbiddenOne = 70903634; + public const int ExodiaTheForbiddenOne = 33396948; + public const int UltimateConductorTytanno = 18940556; public const int ElShaddollConstruct = 20366274; public const int AllyOfJusticeCatastor = 26593852; @@ -36,8 +53,27 @@ protected class _CardId public const int DarkMagicAttack = 2314238; public const int MysticalSpaceTyphoon = 5318639; public const int CosmicCyclone = 8267140; - public const int ChickenGame = 67616300; + public const int GalaxyCyclone = 5133471; + public const int BookOfMoon = 14087893; + public const int CompulsoryEvacuationDevice = 94192409; + public const int CallOfTheHaunted = 97077563; + public const int Scapegoat = 73915051; + public const int BreakthroughSkill = 78474168; + public const int SolemnJudgment = 41420027; + public const int SolemnWarning = 84749824; + public const int SolemnStrike = 40605147; + public const int TorrentialTribute = 53582587; + public const int HeavyStorm = 19613556; + public const int HammerShot = 26412047; + public const int DarkHole = 53129443; + public const int Raigeki = 12580477; + public const int SmashingGround = 97169186; + public const int PotOfDesires = 35261759; + public const int AllureofDarkness = 1475311; + public const int DimensionalBarrier = 83326048; + public const int InterruptedKaijuSlumber = 99330325; + public const int ChickenGame = 67616300; public const int SantaClaws = 46565218; public const int CastelTheSkyblasterMusketeer = 82633039; @@ -61,7 +97,7 @@ protected class _CardId public const int LockBird = 94145021; public const int GhostOgreAndSnowRabbit = 59438930; public const int GhostBelle = 73642296; - public const int EffectVeiler = 63845230; + public const int EffectVeiler = 97268402; public const int ArtifactLancea = 34267821; public const int CalledByTheGrave = 24224830; @@ -80,12 +116,11 @@ protected class _CardId public const int RedDragonArchfiend = 70902743; public const int ImperialOrder = 61740673; + public const int RoyalDecreel = 51452091; public const int NaturiaBeast = 33198837; public const int AntiSpellFragrance = 58921041; } - int HonestEffectCount = 0; - protected DefaultExecutor(GameAI ai, Duel duel) : base(ai, duel) { @@ -127,9 +162,6 @@ public override BattlePhaseAction OnSelectAttackTarget(ClientCard attacker, ILis /// false if the attack shouldn't be done. public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender) { - if (attacker.RealPower <= 0) - return false; - if (!attacker.IsMonsterHasPreventActivationEffectInBattle()) { if (defender.IsMonsterInvincible() && defender.IsDefense()) @@ -180,6 +212,12 @@ public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender if (attacker.IsCode(_CardId.NumberS39UtopiaTheLightning) && !attacker.IsDisabled() && attacker.HasXyzMaterial(2, _CardId.Number39Utopia)) attacker.RealPower = 5000; + if (attacker.IsCode(_CardId.EaterOfMillions) && !attacker.IsDisabled()) + attacker.RealPower = 9999; + + if (attacker.IsMonsterInvincible()) + attacker.RealPower = 9999; + foreach (ClientCard equip in attacker.EquipCards) { if (equip.IsCode(_CardId.MoonMirrorShield) && !equip.IsDisabled()) @@ -210,6 +248,29 @@ public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender return true; } + public override bool OnPreActivate(ClientCard card) + { + ClientCard LastChainCard = Util.GetLastChainCard(); + if (LastChainCard != null && Duel.Phase == DuelPhase.Standby && + LastChainCard.IsCode( + _CardId.SandaionTheTimelord, + _CardId.GabrionTheTimelord, + _CardId.MichionTheTimelord, + _CardId.ZaphionTheTimelord, + _CardId.HailonTheTimelord, + _CardId.RaphionTheTimelord, + _CardId.SadionTheTimelord, + _CardId.MetaionTheTimelord, + _CardId.KamionTheTimelord, + _CardId.LazionTheTimelord + )) + return false; + if ((card.Location == CardLocation.Hand || card.Location == CardLocation.SpellZone && card.IsFacedown()) && + (card.IsSpell() && DefaultSpellWillBeNegated() || card.IsTrap() && DefaultTrapWillBeNegated())) + return false; + return true; + } + /// /// Called when the AI has to select a card position. /// @@ -242,9 +303,12 @@ public override bool OnSelectBattleReplay() return false; } - public override void OnNewTurn() + /// + /// Set when this card can't beat the enemies + /// + public override bool OnSelectMonsterSummonOrSet(ClientCard card) { - HonestEffectCount = 0; + return card.Level <= 4 && Bot.GetMonsters().Count(m => m.IsFaceup()) == 0 && Util.IsAllEnemyBetterThanValue(card.Attack, true); } /// @@ -622,14 +686,17 @@ protected bool DefaultPotOfDesires() /// protected bool DefaultSpellSet() { - return (Card.IsTrap() || Card.HasType(CardType.QuickPlay)) && Bot.GetSpellCountWithoutField() < 4; + return (Card.IsTrap() || Card.HasType(CardType.QuickPlay) || DefaultSpellMustSetFirst()) && Bot.GetSpellCountWithoutField() < 4; } /// - /// Summon with tributes ATK lower. + /// Summon with no tribute, or with tributes ATK lower. /// - protected bool DefaultTributeSummon() + protected bool DefaultMonsterSummon() { + if (Card.Level <= 4) + return true; + if (!UniqueFaceupMonster()) return false; int tributecount = (int)Math.Ceiling((Card.Level - 4.0d) / 2.0d); @@ -656,8 +723,13 @@ protected bool DefaultField() /// protected bool DefaultMonsterRepos() { - if (Card.IsFaceup() && Card.IsDefense() && Card.Attack == 0) - return false; + if (Card.Attack == 0) + { + if (Card.IsFaceup() && Card.IsAttack()) + return true; + if (Card.IsFaceup() && Card.IsDefense()) + return false; + } if (Enemy.HasInMonstersZone(_CardId.BlueEyesChaosMAXDragon, true) && Card.IsAttack() && (4000 - Card.Defense) * 2 > (4000 - Card.Attack)) @@ -667,10 +739,10 @@ protected bool DefaultMonsterRepos() (4000 - Card.Defense) * 2 > (4000 - Card.Attack)) return true; - bool enemyBetter = Util.IsAllEnemyBetter(true); + bool enemyBetter = Util.IsAllEnemyBetter(); if (Card.IsAttack() && enemyBetter) return true; - if (Card.IsDefense() && !enemyBetter && Card.Attack >= Card.Defense) + if (Card.IsDefense() && !enemyBetter && (Card.Attack >= Card.Defense || Card.Attack >= Util.GetBestPower(Enemy))) return true; return false; @@ -681,7 +753,15 @@ protected bool DefaultMonsterRepos() /// protected bool DefaultSpellWillBeNegated() { - return Bot.HasInSpellZone(_CardId.ImperialOrder, true, true) || Enemy.HasInSpellZone(_CardId.ImperialOrder, true) || Enemy.HasInMonstersZone(_CardId.NaturiaBeast, true); + return (Bot.HasInSpellZone(_CardId.ImperialOrder, true, true) || Enemy.HasInSpellZone(_CardId.ImperialOrder, true)) && !Util.ChainContainsCard(_CardId.ImperialOrder); + } + + /// + /// If trap will be negated + /// + protected bool DefaultTrapWillBeNegated() + { + return (Bot.HasInSpellZone(_CardId.RoyalDecreel, true, true) || Enemy.HasInSpellZone(_CardId.RoyalDecreel, true)) && !Util.ChainContainsCard(_CardId.RoyalDecreel); } /// @@ -689,15 +769,7 @@ protected bool DefaultSpellWillBeNegated() /// protected bool DefaultSpellMustSetFirst() { - ClientCard card = null; - foreach (ClientCard check in Bot.GetSpells()) - { - if (check.IsCode(_CardId.AntiSpellFragrance) && !check.IsDisabled()) - card = check; - } - if (card != null && card.IsFaceup()) - return true; - return Bot.HasInSpellZone(_CardId.AntiSpellFragrance, true, true) || Enemy.HasInSpellZone(_CardId.AntiSpellFragrance, true); + return Bot.HasInSpellZone(_CardId.AntiSpellFragrance, true, true) || Enemy.HasInSpellZone(_CardId.AntiSpellFragrance, true); } /// @@ -764,6 +836,8 @@ protected bool UniqueFaceupMonster() /// protected bool DefaultDontChainMyself() { + if (Type != ExecutorType.Activate) + return true; if (Executors.Any(exec => exec.Type == Type && exec.CardId == Card.Id)) return false; return Duel.LastChainPlayer != 0; @@ -776,6 +850,8 @@ protected bool DefaultChickenGame() { if (Executors.Count(exec => exec.Type == Type && exec.CardId == Card.Id) > 1) return false; + if (Card.IsFacedown()) + return true; if (Bot.LifePoints <= 1000) return false; if (Bot.LifePoints <= Enemy.LifePoints && ActivateDescription == Util.GetStringId(_CardId.ChickenGame, 0)) @@ -1067,6 +1143,11 @@ protected bool DefaultScarlightRedDragonArchfiendSummon() return (selfBestAttack <= oppoBestAttack && oppoBestAttack <= 3000) || DefaultScarlightRedDragonArchfiendEffect(); } + protected bool DefaultTimelordSummon() + { + return Bot.GetMonsterCount() == 0; + } + /// /// Activate when we have less monsters than enemy, or when enemy have more than 3 monsters. /// @@ -1089,13 +1170,7 @@ protected bool DefaultHonestEffect() || ((Bot.BattlingMonster.Attack < Enemy.BattlingMonster.Defense) && (Bot.BattlingMonster.Attack + Enemy.BattlingMonster.Attack > Enemy.BattlingMonster.Defense))); } - if (Util.IsTurn1OrMain2() && HonestEffectCount <= 5) - { - HonestEffectCount++; - return true; - } - - return false; + return Util.IsTurn1OrMain2(); } } } diff --git a/libWindbot/Game/AI/Dialogs.cs b/libWindbot/Game/AI/Dialogs.cs index 02a52d2..478783e 100644 --- a/libWindbot/Game/AI/Dialogs.cs +++ b/libWindbot/Game/AI/Dialogs.cs @@ -59,9 +59,7 @@ public Dialogs(GameClient game) _game = game; DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(DialogsData)); string dialogfilename = game.Dialog; - - //using (Stream fs = WindBot.Program.Assets.Open("Dialogs/" + dialogfilename + ".json")) - using (Stream fs = File.OpenRead(Path.Combine(WindBot.AssetPath, "windbot/Dialogs/", dialogfilename + ".json"))) + using (FileStream fs = Program.ReadFile("Dialogs", dialogfilename, "json")) { DialogsData data = (DialogsData)serializer.ReadObject(fs); _welcome = data.welcome; diff --git a/libWindbot/Game/AI/Enums/InvincibleMonster.cs b/libWindbot/Game/AI/Enums/InvincibleMonster.cs index bd9bc68..c4f4cc9 100644 --- a/libWindbot/Game/AI/Enums/InvincibleMonster.cs +++ b/libWindbot/Game/AI/Enums/InvincibleMonster.cs @@ -1,9 +1,36 @@ namespace WindBot.Game.AI.Enums { + /// + /// Cards that are invincible to battle and should always attack to use effect. + /// + public enum InvincibleBotMonster + { + YubelTheUltimateNightmare = 31764700, + YubelTerrorIncarnate = 4779091, + SandaionTheTimelord = 33015627, + GabrionTheTimelord = 6616912, + MichionTheTimelord = 7733560, + ZaphionTheTimelord = 28929131, + HailonTheTimelord = 34137269, + RaphionTheTimelord = 60222213, + SadionTheTimelord = 65314286, + MetaionTheTimelord = 74530899, + KamionTheTimelord = 91712985, + LazionTheTimelord = 92435533, + TimelordProgenitorVorpgate = 67508932, + RocketWarrior = 30860696, + GoDDDDivineZeroKingRage = 40227329, + BloomDivaTheMelodiousChoir = 84988419, + BlackwingArmorMaster = 69031175, + DaigustoSphreez = 29552709, + Number92HearteartHDragon = 97403510, + NumberC96DarkStorm = 77205367, + Number54LionHeart = 54366836 + } /// /// Cards that are invincible to battle. /// - public enum InvincibleMonster + public enum InvincibleEnemyMonster { SpiritReaper = 23205979, YubelTheUltimateNightmare = 31764700, diff --git a/libWindbot/Game/AI/Executor.cs b/libWindbot/Game/AI/Executor.cs index 59bd1a5..6ef82be 100644 --- a/libWindbot/Game/AI/Executor.cs +++ b/libWindbot/Game/AI/Executor.cs @@ -73,13 +73,19 @@ public virtual ClientCard OnSelectAttacker(IList attackers, IList defenders) { - // Overrided in DefalultExecutor + // Overrided in DefaultExecutor return null; } public virtual bool OnPreBattleBetween(ClientCard attacker, ClientCard defender) { - // Overrided in DefalultExecutor + // Overrided in DefaultExecutor + return true; + } + + public virtual bool OnPreActivate(ClientCard card) + { + // Overrided in DefaultExecutor return true; } @@ -178,13 +184,23 @@ public virtual int OnSelectPlace(int cardId, int player, CardLocation location, public virtual CardPosition OnSelectPosition(int cardId, IList positions) { - // Overrided in DefalultExecutor + // Overrided in DefaultExecutor return 0; } public virtual bool OnSelectBattleReplay() { - // Overrided in DefalultExecutor + // Overrided in DefaultExecutor + return false; + } + + /// + /// Called when the executor type is SummonOrSet + /// + /// True if select to set the monster. + public virtual bool OnSelectMonsterSummonOrSet(ClientCard card) + { + // Overrided in DefaultExecutor return false; } diff --git a/libWindbot/Game/AI/HintMsg.cs b/libWindbot/Game/AI/HintMsg.cs new file mode 100644 index 0000000..65634b4 --- /dev/null +++ b/libWindbot/Game/AI/HintMsg.cs @@ -0,0 +1,62 @@ +namespace WindBot.Game.AI +{ + public static class HintMsg + { + public const int Release = 500, + Discard = 501, + Destroy = 502, + Remove = 503, + ToGrave = 504, + ReturnToHand = 505, + AddToHand = 506, + ToDeck = 507, + Summon = 508, + SpSummon = 509, + Set = 510, + FusionMaterial = 511, + SynchroMaterial = 512, + XyzMaterial = 513, + Faceup = 514, + Facedown = 515, + Attack = 516, + Defense = 517, + Equip = 518, + RemoveXyz = 519, + Control = 520, + DestroyReplace = 521, + FaceupAttack = 522, + FaceupDefense = 523, + FacedownAttack = 524, + FacedownDefense = 525, + Confirm = 526, + ToField = 527, + PosChange = 528, + Self = 529, + Oppo = 530, + Tribute = 531, + DeattachFrom = 532, + LinkMaterial = 533, + AttackTarget = 549, + Effect = 550, + Target = 551, + Coin = 552, + Dice = 553, + CardType = 554, + Option = 555, + ResolveEffect = 556, + Select = 560, + Position = 561, + Attribute = 562, + Race = 563, + Code = 564, + Number = 565, + LvRank = 567, + ResolveCard = 568, + Zone = 569, + DisableZone = 570, + ToZone = 571, + Counter = 572, + Disable = 573, + OperateCard = 574; + } +} \ No newline at end of file diff --git a/libWindbot/Game/ClientCard.cs b/libWindbot/Game/ClientCard.cs index 4a4ece3..1eec6b7 100644 --- a/libWindbot/Game/ClientCard.cs +++ b/libWindbot/Game/ClientCard.cs @@ -32,7 +32,7 @@ public class ClientCard public int RealPower { get; set; } public List Overlays { get; private set; } public int Owner { get; private set; } - public int Controller { get; private set; } + public int Controller { get; set; } public int Disabled { get; private set; } public int ProcCompleted { get; private set; } public int SelectSeq { get; set; } diff --git a/libWindbot/Game/Deck.cs b/libWindbot/Game/Deck.cs index 914c8ed..1753bb0 100644 --- a/libWindbot/Game/Deck.cs +++ b/libWindbot/Game/Deck.cs @@ -43,8 +43,7 @@ public static Deck Load(string name) StreamReader reader = null; try { - reader = new StreamReader(new FileStream(Path.Combine(WindBot.AssetPath, "windbot/Decks/", name + ".ydk"), FileMode.Open, FileAccess.Read)); - //reader = new StreamReader(new FileStream("Decks/" + name + ".ydk", FileMode.Open, FileAccess.Read)); + reader = new StreamReader(Program.ReadFile("Decks", name, "ydk")); Deck deck = new Deck(); bool side = false; @@ -84,8 +83,7 @@ public static Deck Load(string name) } catch (Exception) { - if (reader != null) - reader.Close(); + reader?.Close(); return null; } } diff --git a/libWindbot/Game/Duel.cs b/libWindbot/Game/Duel.cs index 115547b..043aff5 100644 --- a/libWindbot/Game/Duel.cs +++ b/libWindbot/Game/Duel.cs @@ -96,30 +96,8 @@ public ClientCard GetCard(int player, int loc, int seq, int subSeq) public void AddCard(CardLocation loc, int cardId, int player, int seq, int pos) { - switch (loc) - { - case CardLocation.Hand: - Fields[player].Hand.Add(new ClientCard(cardId, loc, -1, pos)); - break; - case CardLocation.Grave: - Fields[player].Graveyard.Add(new ClientCard(cardId, loc,-1, pos)); - break; - case CardLocation.Removed: - Fields[player].Banished.Add(new ClientCard(cardId, loc, -1, pos)); - break; - case CardLocation.MonsterZone: - Fields[player].MonsterZone[seq] = new ClientCard(cardId, loc, seq, pos); - break; - case CardLocation.SpellZone: - Fields[player].SpellZone[seq] = new ClientCard(cardId, loc, seq, pos); - break; - case CardLocation.Deck: - Fields[player].Deck.Add(new ClientCard(cardId, loc, -1, pos)); - break; - case CardLocation.Extra: - Fields[player].ExtraDeck.Add(new ClientCard(cardId, loc, -1, pos)); - break; - } + ClientCard card = new ClientCard(cardId, loc, seq, pos); + AddCard(loc, card, player, seq, pos, cardId); } public void AddCard(CardLocation loc, ClientCard card, int player, int seq, int pos, int id) @@ -127,6 +105,7 @@ public void AddCard(CardLocation loc, ClientCard card, int player, int seq, int card.Location = loc; card.Sequence = seq; card.Position = pos; + card.Controller = player; card.SetId(id); switch (loc) { diff --git a/libWindbot/Game/GameAI.cs b/libWindbot/Game/GameAI.cs index 09862aa..0d14973 100644 --- a/libWindbot/Game/GameAI.cs +++ b/libWindbot/Game/GameAI.cs @@ -13,12 +13,16 @@ public class GameAI private Dialogs _dialogs; + // record activated count to prevent infinite actions + private Dictionary _activatedCards; + public GameAI(GameClient game, Duel duel) { Game = game; Duel = duel; _dialogs = new Dialogs(game); + _activatedCards = new Dictionary(); } /// @@ -81,6 +85,7 @@ public void OnDraw(int player) /// public void OnNewTurn() { + _activatedCards.Clear(); Executor.OnNewTurn(); } @@ -190,12 +195,8 @@ public BattlePhaseAction OnSelectBattleCmd(BattlePhase battle) if (defenders.Count == 0) { // Attack with the monster with the lowest attack first - for (int i = attackers.Count - 1; i >= 0; --i) - { - ClientCard attacker = attackers[i]; - if (attacker.Attack > 0) - return Attack(attacker, null); - } + ClientCard attacker = attackers[attackers.Count - 1]; + return Attack(attacker, null); } else { @@ -226,18 +227,12 @@ public BattlePhaseAction OnSelectBattleCmd(BattlePhase battle) /// A new list containing the selected cards. public IList OnSelectCard(IList cards, int min, int max, int hint, bool cancelable) { - const int HINTMSG_FMATERIAL = 511; - const int HINTMSG_SMATERIAL = 512; - const int HINTMSG_XMATERIAL = 513; - const int HINTMSG_LMATERIAL = 533; - const int HINTMSG_SPSUMMON = 509; - // Check for the executor. IList result = Executor.OnSelectCard(cards, min, max, hint, cancelable); if (result != null) return result; - if (hint == HINTMSG_SPSUMMON && min == 1 && max > min) // pendulum summon + if (hint == HintMsg.SpSummon && min == 1 && max > min) // pendulum summon { result = Executor.OnSelectPendulumSummon(cards, max); if (result != null) @@ -245,7 +240,7 @@ public IList OnSelectCard(IList cards, int min, int max, } CardSelector selector = null; - if (hint == HINTMSG_FMATERIAL || hint == HINTMSG_SMATERIAL || hint == HINTMSG_XMATERIAL || hint == HINTMSG_LMATERIAL) + if (hint == HintMsg.FusionMaterial || hint == HintMsg.SynchroMaterial || hint == HintMsg.XyzMaterial || hint == HintMsg.LinkMaterial) { if (m_materialSelector != null) { @@ -254,13 +249,13 @@ public IList OnSelectCard(IList cards, int min, int max, } else { - if (hint == HINTMSG_FMATERIAL) + if (hint == HintMsg.FusionMaterial) result = Executor.OnSelectFusionMaterial(cards, min, max); - if (hint == HINTMSG_SMATERIAL) + if (hint == HintMsg.SynchroMaterial) result = Executor.OnSelectSynchroMaterial(cards, 0, min, max); - if (hint == HINTMSG_XMATERIAL) + if (hint == HintMsg.XyzMaterial) result = Executor.OnSelectXyzMaterial(cards, min, max); - if (hint == HINTMSG_LMATERIAL) + if (hint == HintMsg.LinkMaterial) result = Executor.OnSelectLinkMaterial(cards, min, max); if (result != null) @@ -439,8 +434,7 @@ public MainPhaseAction OnSelectIdleCmd(MainPhase main) } if (ShouldExecute(exec, card, ExecutorType.SummonOrSet)) { - if (Executor.Util.IsAllEnemyBetter(true) && Executor.Util.IsAllEnemyBetterThanValue(card.Attack + 300, false) && - main.MonsterSetableCards.Contains(card)) + if (main.MonsterSetableCards.Contains(card) && Executor.OnSelectMonsterSummonOrSet(card)) { _dialogs.SendSetMonster(); return new MainPhaseAction(MainPhaseAction.MainAction.SetMonster, card.ActionIndex); @@ -448,7 +442,7 @@ public MainPhaseAction OnSelectIdleCmd(MainPhase main) _dialogs.SendSummon(card.Name); return new MainPhaseAction(MainPhaseAction.MainAction.Summon, card.ActionIndex); } - } + } foreach (ClientCard card in main.SpellSetableCards) { if (ShouldExecute(exec, card, ExecutorType.SpellSet)) @@ -529,16 +523,13 @@ public CardPosition OnSelectPosition(int cardId, IList positions) /// public IList OnSelectSum(IList cards, int sum, int min, int max, int hint, bool mode) { - const int HINTMSG_RELEASE = 500; - const int HINTMSG_SMATERIAL = 512; - IList selected = Executor.OnSelectSum(cards, sum, min, max, hint, mode); if (selected != null) { return selected; } - if (hint == HINTMSG_RELEASE || hint == HINTMSG_SMATERIAL) + if (hint == HintMsg.Release || hint == HintMsg.SynchroMaterial) { if (m_materialSelector != null) { @@ -548,10 +539,10 @@ public IList OnSelectSum(IList cards, int sum, int min, { switch (hint) { - case HINTMSG_SMATERIAL: + case HintMsg.SynchroMaterial: selected = Executor.OnSelectSynchroMaterial(cards, sum, min, max); break; - case HINTMSG_RELEASE: + case HintMsg.Release: selected = Executor.OnSelectRitualTribute(cards, sum, min, max); break; } @@ -951,6 +942,11 @@ public void CleanSelectMaterials() m_materialSelector = null; } + public bool HaveSelectedCards() + { + return m_selector.Count > 0 || m_materialSelector != null; + } + public CardSelector GetSelectedCards() { CardSelector selected = null; @@ -1102,11 +1098,30 @@ public BattlePhaseAction ToMainPhase2() private bool ShouldExecute(CardExecutor exec, ClientCard card, ExecutorType type, int desc = -1) { + if (card.Id != 0 && type == ExecutorType.Activate) + { + if (_activatedCards.ContainsKey(card.Id) && _activatedCards[card.Id] >= 9) + return false; + if (!Executor.OnPreActivate(card)) + return false; + } Executor.SetCard(type, card, desc); - return card != null && - exec.Type == type && - (exec.CardId == -1 || exec.CardId == card.Id) && - (exec.Func == null || exec.Func()); + bool result = card != null && exec.Type == type && + (exec.CardId == -1 || exec.CardId == card.Id) && + (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; } } } diff --git a/libWindbot/Game/GameBehavior.cs b/libWindbot/Game/GameBehavior.cs index 873528c..0784257 100644 --- a/libWindbot/Game/GameBehavior.cs +++ b/libWindbot/Game/GameBehavior.cs @@ -44,7 +44,7 @@ public GameBehavior(GameClient game) _ai = new GameAI(Game, _duel); _ai.Executor = DecksManager.Instantiate(_ai, _duel); - Deck = Deck.Load(_ai.Executor.Deck); + Deck = Deck.Load(Game.DeckFile ?? _ai.Executor.Deck); _select_hint = 0; } @@ -1048,7 +1048,7 @@ private void OnSelectChain(BinaryReader packet) for (int i = 0; i < count; ++i) { packet.ReadByte(); // flag - packet.ReadInt32(); // card id + int id = packet.ReadInt32(); int con = GetLocalPlayer(packet.ReadByte()); int loc = packet.ReadByte(); int seq = packet.ReadByte(); @@ -1059,7 +1059,12 @@ private void OnSelectChain(BinaryReader packet) { desc = 0; } - cards.Add(_duel.GetCard(con, loc, seq, sseq)); + + ClientCard card = _duel.GetCard(con, loc, seq, sseq); + if (card.Id == 0) + card.SetId(id); + + cards.Add(card); descs.Add(desc); } diff --git a/libWindbot/Game/GameClient.cs b/libWindbot/Game/GameClient.cs index ee29920..89e0c5d 100644 --- a/libWindbot/Game/GameClient.cs +++ b/libWindbot/Game/GameClient.cs @@ -1,4 +1,5 @@ using System.IO; +using System.Linq; using System.Net; using System.Text; using YGOSharp.Network; @@ -12,6 +13,7 @@ public class GameClient public YGOClient Connection { get; private set; } public string Username; public string Deck; + public string DeckFile; public string Dialog; public int Hand; public bool Debug; @@ -28,6 +30,7 @@ public GameClient(WindBotInfo Info) { Username = Info.Name; Deck = Info.Deck; + DeckFile = Info.DeckFile; Dialog = Info.Dialog; Hand = Info.Hand; Debug = Info.Debug; @@ -46,7 +49,18 @@ public void Start() Connection.Connected += OnConnected; Connection.PacketReceived += OnPacketReceived; - Connection.Connect(IPAddress.Parse(_serverHost), _serverPort); + IPAddress target_address; + try + { + target_address = IPAddress.Parse(_serverHost); + } + catch (System.Exception) + { + IPHostEntry _hostEntry = Dns.GetHostEntry(_serverHost); + target_address = _hostEntry.AddressList.FirstOrDefault(findIPv4 => findIPv4.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork); + } + + Connection.Connect(target_address, _serverPort); } private void OnConnected() diff --git a/libWindbot/WindBot.cs b/libWindbot/WindBot.cs index f86c525..9a5d6bd 100644 --- a/libWindbot/WindBot.cs +++ b/libWindbot/WindBot.cs @@ -71,6 +71,7 @@ public static void RunAndroid(string arg) p[1] = p[1].Replace("'", ""); if (p[0] == "Name") Info.Name = p[1]; if (p[0] == "Deck") Info.Deck = p[1]; + if (p[0] == "DeckFile") Info.DeckFile = p[1]; if (p[0] == "Dialog") Info.Dialog = p[1]; if (p[0] == "Port") Info.Port = int.Parse(p[1]); if (p[0] == "Hand") Info.Hand = int.Parse(p[1]); @@ -163,5 +164,23 @@ public class BotInfo public class Program { internal static Random Rand; + + public static FileStream ReadFile(string directory, string filename, string extension) + { + string tryfilename = filename + "." + extension; + string trypath = Path.Combine(WindBot.AssetPath, "windbot"); + string fullpath = Path.Combine(trypath, directory, tryfilename); + if (!File.Exists(fullpath)) + fullpath = filename; + if (!File.Exists(fullpath)) + fullpath = Path.Combine(WindBot.AssetPath, filename); + if (!File.Exists(fullpath)) + fullpath = Path.Combine(WindBot.AssetPath, "deck", filename); + if (!File.Exists(fullpath)) + fullpath = Path.Combine(WindBot.AssetPath, tryfilename); + if (!File.Exists(fullpath)) + fullpath = Path.Combine(WindBot.AssetPath, "deck", tryfilename); + return new FileStream(fullpath, FileMode.Open, FileAccess.Read); + } } } diff --git a/libWindbot/WindBotInfo.cs b/libWindbot/WindBotInfo.cs index 34222d9..19293a9 100644 --- a/libWindbot/WindBotInfo.cs +++ b/libWindbot/WindBotInfo.cs @@ -6,6 +6,7 @@ public class WindBotInfo { public string Name { get; set; } public string Deck { get; set; } + public string DeckFile { get; set; } public string Dialog { get; set; } public string Host { get; set; } public int Port { get; set; } @@ -18,6 +19,7 @@ public WindBotInfo() { Name = "WindBot"; Deck = null; + DeckFile = null; Dialog = "default"; Host = "127.0.0.1"; Port = 7911; diff --git a/libWindbot/libWindbot.csproj b/libWindbot/libWindbot.csproj index 75938c0..01d2436 100644 --- a/libWindbot/libWindbot.csproj +++ b/libWindbot/libWindbot.csproj @@ -64,6 +64,7 @@ + @@ -72,6 +73,7 @@ + @@ -107,6 +109,7 @@ +