From 6446ca9943b1423cfba04d4fc170c60c33b10be5 Mon Sep 17 00:00:00 2001 From: handsomekiwi Date: Thu, 23 Aug 2018 19:55:37 +0800 Subject: [PATCH 1/3] add position in one chain --- Game/GameAI.cs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Game/GameAI.cs b/Game/GameAI.cs index b70e1d84..ac3f6a0a 100644 --- a/Game/GameAI.cs +++ b/Game/GameAI.cs @@ -92,11 +92,12 @@ public void OnNewTurn() public void OnNewPhase() { m_selector.Clear(); + m_position.Clear(); m_selector_pointer = -1; m_materialSelector = null; m_option = -1; m_yesno = -1; - m_position = CardPosition.FaceUpAttack; + m_place = 0; if (Duel.Player == 0 && Duel.Phase == DuelPhase.Draw) { @@ -508,8 +509,7 @@ public int OnSelectPlace(int cardId, int player, int location, int available) /// Selected position. public CardPosition OnSelectPosition(int cardId, IList positions) { - CardPosition selector_selected = m_position; - m_position = CardPosition.FaceUpAttack; + CardPosition selector_selected = GetSelectedPosition(); CardPosition executor_selected = Executor.OnSelectPosition(cardId, positions); @@ -746,8 +746,7 @@ public int OnAnnounceCard() // Those functions are used by the AI behavior. - private CardSelector m_materialSelector; - private CardPosition m_position = CardPosition.FaceUpAttack; + private CardSelector m_materialSelector; private int m_place; private int m_option; private int m_number; @@ -755,6 +754,7 @@ public int OnAnnounceCard() private int m_yesno; private IList m_attributes = new List(); private IList m_selector = new List(); + private IList m_position = new List(); private int m_selector_pointer = -1; private IList m_races = new List(); @@ -929,9 +929,20 @@ public CardSelector GetSelectedCards() return selected; } + public CardPosition GetSelectedPosition() + { + CardPosition selected = CardPosition.FaceUpAttack; + if (m_position.Count > 0) + { + selected = m_position[0]; + m_position.RemoveAt(0); + } + return selected; + } + public void SelectPosition(CardPosition pos) { - m_position = pos; + m_position.Add(pos); } public void SelectPlace(int zones) From b6085ce1b1ec6fb9691338cef857512e402a788f Mon Sep 17 00:00:00 2001 From: Mercury233 Date: Fri, 24 Aug 2018 16:00:28 +0800 Subject: [PATCH 2/3] format --- Game/GameAI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Game/GameAI.cs b/Game/GameAI.cs index ac3f6a0a..576806c0 100644 --- a/Game/GameAI.cs +++ b/Game/GameAI.cs @@ -746,7 +746,7 @@ public int OnAnnounceCard() // Those functions are used by the AI behavior. - private CardSelector m_materialSelector; + private CardSelector m_materialSelector; private int m_place; private int m_option; private int m_number; From 2264bcf300810c61f5dce040b82e4bf751d3f203 Mon Sep 17 00:00:00 2001 From: handsomekiwi Date: Fri, 24 Aug 2018 16:39:17 +0800 Subject: [PATCH 3/3] add some default functon --- Game/AI/DefaultExecutor.cs | 69 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/Game/AI/DefaultExecutor.cs b/Game/AI/DefaultExecutor.cs index 71b3475d..e9e462be 100644 --- a/Game/AI/DefaultExecutor.cs +++ b/Game/AI/DefaultExecutor.cs @@ -55,6 +55,14 @@ protected class _CardId public const int MacroCosmos = 30241314; public const int UpstartGoblin = 70368879; public const int EaterOfMillions = 63845230; + + public const int InvokedPurgatrio = 12307878; + public const int ChaosAncientGearGiant = 51788412; + public const int UltimateAncientGearGolem = 12652643; + + public const int ImperialOrder = 61740673; + public const int NaturiaBeast = 33198837; + public const int AntiSpellFragrance = 58921041; } protected DefaultExecutor(GameAI ai, Duel duel) @@ -325,6 +333,31 @@ protected bool DefaultCallOfTheHaunted() return true; } + /// + /// Default Scapegoat effect + /// + protected bool DefaultScapegoat() + { + if (DefaultSpellWillBeNegated()) return false; + if (Duel.Player == 0) return false; + if (Duel.Phase == DuelPhase.End) return true; + if (DefaultOnBecomeTarget()) return true; + if (Duel.Phase > DuelPhase.Main1 && Duel.Phase < DuelPhase.Main2) + { + if (Enemy.HasInMonstersZone(_CardId.UltimateConductorTytanno, true)) return false; + if (Enemy.HasInMonstersZone(_CardId.InvokedPurgatrio, true)) return false; + if (Enemy.HasInMonstersZone(_CardId.ChaosAncientGearGiant, true)) return false; + if (Enemy.HasInMonstersZone(_CardId.UltimateAncientGearGolem, true)) return false; + int total_atk = 0; + List enemy_monster = Enemy.GetMonsters(); + foreach (ClientCard m in enemy_monster) + { + if (m.IsAttack()) total_atk += m.Attack; + } + if (total_atk >= Bot.LifePoints) return true; + } + return false; + } /// /// Always active in opponent's turn. /// @@ -624,6 +657,42 @@ protected bool DefaultMonsterRepos() return false; } + /// + /// If spell will be negated + /// + protected bool DefaultSpellWillBeNegated() + { + ClientCard card = null; + foreach (ClientCard check in Bot.GetSpells()) + { + if (check.Id == _CardId.ImperialOrder && !check.IsDisabled()) + card = check; + } + if (card != null && card.IsFaceup()) + return true; + if (Enemy.HasInSpellZone(_CardId.ImperialOrder, true) || Enemy.HasInMonstersZone(_CardId.NaturiaBeast, true)) + return true; + return false; + } + + /// + /// If spell must set first to activate + /// + protected bool DefaultSpellMustSetFirst() + { + ClientCard card = null; + foreach (ClientCard check in Bot.GetSpells()) + { + if (check.Id == _CardId.AntiSpellFragrance && !check.IsDisabled()) + card = check; + } + if (card != null && card.IsFaceup()) + return true; + if (Enemy.HasInSpellZone(_CardId.AntiSpellFragrance, true)) + return true; + return false; + } + /// /// if spell/trap is the target or enermy activate HarpiesFeatherDuster ///