From 4b7885b0981a00bb4411ed5249a8c2c2fac10b5b Mon Sep 17 00:00:00 2001 From: Wind2009-Louse Date: Wed, 21 Jun 2023 15:20:30 +0800 Subject: [PATCH 1/2] Add custom dialogues --- Dialogs/verre.zh-CN.json | 13 ++ Game/AI/Decks/ExosisterExecutor.cs | 64 +++++++++ Game/AI/Decks/WitchcraftExecutor.cs | 196 +++++++++++++++++++------- Game/AI/Decks/ZefraExecutor.cs | 6 +- Game/AI/Dialogs.cs | 62 +++++++- Game/AI/Enums/Dialogs/VerreDialogs.cs | 20 +++ Game/AI/Executor.cs | 72 ++++++++++ Game/GameAI.cs | 44 +++--- WindBot.csproj | 1 + 9 files changed, 404 insertions(+), 74 deletions(-) create mode 100644 Game/AI/Enums/Dialogs/VerreDialogs.cs diff --git a/Dialogs/verre.zh-CN.json b/Dialogs/verre.zh-CN.json index e43ee104..7d35b7be 100644 --- a/Dialogs/verre.zh-CN.json +++ b/Dialogs/verre.zh-CN.json @@ -50,5 +50,18 @@ "发动{0}!", "等一下,我发动{0}。", "要不是有{0},我都快睡着了。" + ], + "custom": [ + "臣服于本小姐的伟大吧!", + "{0},最后一击!", + "该跑路咯~", + "可爱而无敌的本小姐,降临!", + "海涅,先来帮我顶着!", + "……来帮我一把,海涅!", + "发动本小姐的强大效果,封印你的所有怪兽!", + "发动本小姐的强大效果,提升攻击力!", + "魔力再生!", + "{0},变身!", + "噫,是蟑螂!" ] } diff --git a/Game/AI/Decks/ExosisterExecutor.cs b/Game/AI/Decks/ExosisterExecutor.cs index 03f1517f..0f54d5d2 100644 --- a/Game/AI/Decks/ExosisterExecutor.cs +++ b/Game/AI/Decks/ExosisterExecutor.cs @@ -4,6 +4,7 @@ using WindBot; using WindBot.Game; using WindBot.Game.AI; +using WindBot.Game.AI.Enums.Dialogs; using System.Linq; using System; @@ -170,6 +171,7 @@ public ExosisterExecutor(GameAI ai, Duel duel) bool enemyMoveGrave = false; bool paxCallToField = false; List infiniteImpermanenceList = new List(); + bool customDialogFlag = false; bool summoned = false; bool elisEffect1Activated = false; @@ -728,6 +730,7 @@ public override void OnChaining(int player, ClientCard card) { if (card.IsCode(_CardId.MaxxC) && CheckCalledbytheGrave(_CardId.MaxxC) == 0) { + AI.Dialogs.SendCustomChat((int)VerreDialogs.MaxxCResponse); enemyActivateMaxxC = true; } if (card.IsCode(_CardId.LockBird) && CheckCalledbytheGrave(_CardId.LockBird) == 0) @@ -1105,6 +1108,55 @@ public override int OnSelectOption(IList options) return base.OnSelectOption(options); } + public override void SendActivateDialog(ClientCard card) + { + if (customDialogFlag) + { + customDialogFlag = false; + return; + } + base.SendActivateDialog(card); + } + + public override void SendChainingDialog(ClientCard card) + { + if (customDialogFlag) + { + customDialogFlag = false; + return; + } + base.SendChainingDialog(card); + } + + public override void SendDirectAttackDialog(ClientCard card) + { + if (card.Attack >= Enemy.LifePoints) + { + AI.Dialogs.SendCustomDirectAttack((int)VerreDialogs.LastAttack, card.Name); + return; + } + base.SendDirectAttackDialog(card); + } + + public override void SendEndTurnDialog() + { + // check whether duel going to end + if (Duel.Turn > 1) + { + if (Bot.GetMonsterCount() > 0 && Enemy.GetMonsterCount() == 0 && Bot.LifePoints > Enemy.LifePoints) + { + AI.Dialogs.SendCustomChat((int)VerreDialogs.DuelNearEnd); + return; + } + if (Bot.GetMonsterCount() == 0 && Enemy.GetMonsterCount() > 0 && Bot.LifePoints < Enemy.LifePoints) + { + AI.Dialogs.SendCustomChat((int)VerreDialogs.DuelNearEnd); + return; + } + } + base.SendEndTurnDialog(); + } + public bool AshBlossomActivate() { if (CheckWhetherNegated(true) || !CheckLastChainShouldNegated()) return false; @@ -1647,6 +1699,17 @@ public bool ExosisterMarthaActivate() } public bool DefaultExosisterTransform() + { + if (DefaultExosisterTransformInner()) + { + AI.Dialogs.SendCustomChat((int)VerreDialogs.ExosisterTransformActivate, Card.Name); + customDialogFlag = true; + return true; + } + return false; + } + + public bool DefaultExosisterTransformInner() { List canTransformList = new List { @@ -1716,6 +1779,7 @@ public bool DefaultExosisterTransform() return false; } + public bool ExosisterMikailisActivate() { // banish diff --git a/Game/AI/Decks/WitchcraftExecutor.cs b/Game/AI/Decks/WitchcraftExecutor.cs index b977c8ac..5712a983 100644 --- a/Game/AI/Decks/WitchcraftExecutor.cs +++ b/Game/AI/Decks/WitchcraftExecutor.cs @@ -4,9 +4,9 @@ using WindBot; using WindBot.Game; using WindBot.Game.AI; +using WindBot.Game.AI.Enums.Dialogs; using System.Linq; - namespace WindBot.Game.AI.Decks { [Deck("Witchcraft", "AI_Witchcraft")] @@ -197,6 +197,7 @@ public WitchcraftExecutor(GameAI ai, Duel duel) bool MagicianRightHand_used = false; ClientCard MagiciansLeftHand_negate = null; ClientCard MagicianRightHand_negate = null; + bool customDialogFlag = false; // go first public override bool OnSelectHand() @@ -246,6 +247,7 @@ public override void OnChaining(int player, ClientCard card) if (player == 1 && card.Id == CardId.MaxxC && CheckCalledbytheGrave(CardId.MaxxC) == 0) { + AI.Dialogs.SendCustomChat((int)VerreDialogs.MaxxCResponse); enemy_activate_MaxxC = true; } if (player == 1 && card.Id == CardId.DimensionShifter && CheckCalledbytheGrave(CardId.DimensionShifter) == 0) @@ -422,6 +424,19 @@ public override CardPosition OnSelectPosition(int cardId, IList po { return base.OnSelectPosition(cardId, positions); } + if (cardId == CardId.MadameVerre) + { + AI.Dialogs.SendCustomChat((int)VerreDialogs.VerreSpSummon); + } + if (cardId == CardId.Haine) { + if (Bot.HasInMonstersZone(CardId.MadameVerre, false, false, true)) + { + AI.Dialogs.SendCustomChat((int)VerreDialogs.HaineSpSummonWithVerre); + } else + { + AI.Dialogs.SendCustomChat((int)VerreDialogs.HaineSpSummonWithoutVerre); + } + } if (!Enemy.HasInMonstersZone(_CardId.BlueEyesChaosMAXDragon) && (Duel.Player == 1 && (cardId == CardId.MadameVerre || Util.GetOneEnemyBetterThanValue(Data.Attack + 1) != null)) @@ -436,6 +451,70 @@ public override CardPosition OnSelectPosition(int cardId, IList po return base.OnSelectPosition(cardId, positions); } + public override void SendActivateDialog(ClientCard card) + { + if (customDialogFlag) + { + customDialogFlag = false; + return; + } + if (Duel.Phase == DuelPhase.End && card.HasSetcode(Witchcraft_setcode) && card.Location == CardLocation.Grave) + { + AI.Dialogs.SendCustomChat((int)VerreDialogs.SpellRecycleActivate); + return; + } + base.SendActivateDialog(card); + } + + public override void SendChainingDialog(ClientCard card) + { + if (customDialogFlag) + { + customDialogFlag = false; + return; + } + if (Duel.Phase == DuelPhase.End && card.HasSetcode(Witchcraft_setcode) && card.Location == CardLocation.Grave) + { + AI.Dialogs.SendCustomChat((int)VerreDialogs.SpellRecycleActivate); + return; + } + base.SendChainingDialog(card); + } + + public override void SendDirectAttackDialog(ClientCard card) + { + if (card.Id == CardId.MadameVerre) + { + AI.Dialogs.SendCustomDirectAttack((int)VerreDialogs.VerreDirectAttack, null); + return; + } + if (card.Attack >= Enemy.LifePoints) + { + AI.Dialogs.SendCustomDirectAttack((int)VerreDialogs.LastAttack, card.Name); + return; + } + base.SendDirectAttackDialog(card); + } + + public override void SendEndTurnDialog() + { + // check whether duel going to end + if (Duel.Turn > 1) + { + if (Bot.GetMonsterCount() > 0 && Enemy.GetMonsterCount() == 0 && Bot.LifePoints > Enemy.LifePoints) + { + AI.Dialogs.SendCustomChat((int)VerreDialogs.DuelNearEnd); + return; + } + if (Bot.GetMonsterCount() == 0 && Enemy.GetMonsterCount() > 0 && Bot.LifePoints < Enemy.LifePoints) + { + AI.Dialogs.SendCustomChat((int)VerreDialogs.DuelNearEnd); + return; + } + } + base.SendEndTurnDialog(); + } + // shuffle List public List CardListShuffle(List list) { @@ -1352,71 +1431,92 @@ public bool MadameVerreActivate() // negate if (ActivateDescription == Util.GetStringId(CardId.MadameVerre, 1)) { - if (Card.IsDisabled()) return false; - if (CheckLastChainNegated()) return false; - - // negate before activate - if (Enemy.MonsterZone.GetFirstMatchingCard(card => card.IsMonsterShouldBeDisabledBeforeItUseEffect() && !card.IsDisabled()) != null) + if (MadameVerreActivateForNegate()) { - SelectDiscardSpell(); + AI.Dialogs.SendCustomActivate((int)VerreDialogs.VerreNegateActivate, null); + customDialogFlag = true; return true; } - - // chain check - ClientCard LastChainCard = Util.GetLastChainCard(); - if ((LastChainCard != null && LastChainCard.Controller == 1 && LastChainCard.Location == CardLocation.MonsterZone)) + } + // gain ATK + else + { + if (MadameVerreActivateForGainAttack()) { - // negate monsters' activate - SelectDiscardSpell(); + AI.Dialogs.SendCustomActivate((int)VerreDialogs.VerreGainAttackActivate, null); + customDialogFlag = true; return true; } + } + return false; + } + + public bool MadameVerreActivateForNegate() + { + if (Card.IsDisabled()) return false; + if (CheckLastChainNegated()) return false; + + // negate before activate + if (Enemy.MonsterZone.GetFirstMatchingCard(card => card.IsMonsterShouldBeDisabledBeforeItUseEffect() && !card.IsDisabled()) != null) + { + SelectDiscardSpell(); + return true; + } - // negate battle related effect - if (Duel.Phase > DuelPhase.Main1 && Duel.Phase < DuelPhase.Main2) + // chain check + ClientCard LastChainCard = Util.GetLastChainCard(); + if ((LastChainCard != null && LastChainCard.Controller == 1 && LastChainCard.Location == CardLocation.MonsterZone)) + { + // negate monsters' activate + SelectDiscardSpell(); + return true; + } + + // negate battle related effect + if (Duel.Phase > DuelPhase.Main1 && Duel.Phase < DuelPhase.Main2) + { + if (Enemy.MonsterZone.GetFirstMatchingCard(card => + card.IsMonsterDangerous() || (Duel.Player == 0) && card.IsMonsterInvincible()) != null) { - if (Enemy.MonsterZone.GetFirstMatchingCard(card => - card.IsMonsterDangerous() || (Duel.Player == 0) && card.IsMonsterInvincible()) != null) - { - SelectDiscardSpell(); - return true; - } + SelectDiscardSpell(); + return true; } - - return false; } - // gain ATK - else + + return false; + } + + public bool MadameVerreActivateForGainAttack() + { + ClientCard self_card = Bot.BattlingMonster; + ClientCard enemy_card = Enemy.BattlingMonster; + if (self_card != null && enemy_card != null) { - ClientCard self_card = Bot.BattlingMonster; - ClientCard enemy_card = Enemy.BattlingMonster; - if (self_card != null && enemy_card != null) + int power_cangain = CheckPlusAttackforMadameVerre(); + int diff = enemy_card.GetDefensePower() - self_card.GetDefensePower(); + Logger.DebugWriteLine("power: " + power_cangain.ToString()); + Logger.DebugWriteLine("diff: " + diff.ToString()); + if (diff > 0) { - int power_cangain = CheckPlusAttackforMadameVerre(); - int diff = enemy_card.GetDefensePower() - self_card.GetDefensePower(); - Logger.DebugWriteLine("power: " + power_cangain.ToString()); - Logger.DebugWriteLine("diff: " + diff.ToString()); - if (diff > 0) + // avoid useless effect + if (self_card.IsDefense() && power_cangain < diff) { - // avoid useless effect - if (self_card.IsDefense() && power_cangain < diff) - { - return false; - } - AI.SelectCard(Bot.Hand.GetMatchingCards(card => card.IsSpell())); - MadameVerreGainedATK = true; - return true; - } - else if (Enemy.GetMonsterCount() == 1 || (enemy_card.IsAttack() && Enemy.LifePoints <= diff + power_cangain)) - { - AI.SelectCard(Bot.Hand.GetMatchingCards(card => card.IsSpell())); - MadameVerreGainedATK = true; - return true; + return false; } + AI.SelectCard(Bot.Hand.GetMatchingCards(card => card.IsSpell())); + MadameVerreGainedATK = true; + return true; + } + else if (Enemy.GetMonsterCount() == 1 || (enemy_card.IsAttack() && Enemy.LifePoints <= diff + power_cangain)) + { + AI.SelectCard(Bot.Hand.GetMatchingCards(card => card.IsSpell())); + MadameVerreGainedATK = true; + return true; } } return false; } - + // activate of Haine public bool HaineActivate() { diff --git a/Game/AI/Decks/ZefraExecutor.cs b/Game/AI/Decks/ZefraExecutor.cs index 40bef73a..f65fa489 100644 --- a/Game/AI/Decks/ZefraExecutor.cs +++ b/Game/AI/Decks/ZefraExecutor.cs @@ -547,7 +547,7 @@ public override void OnNewTurn() if (duel_start) { duel_start = false; - AI.SendCustomChat((int)CustomMessage.Happy); + AI.Dialogs.SendCustomChat((int)CustomMessage.Happy); } activate_SupremeKingDragonDarkwurm_1 = false; activate_SupremeKingDragonDarkwurm_2 = false; @@ -725,7 +725,7 @@ private bool GoToEndPhase() && activate_count + summon_count < 5 && !enemy_activate) { - AI.SendCustomChat((int)CustomMessage.Angry); + AI.Dialogs.SendCustomChat((int)CustomMessage.Angry); return true; } return false; @@ -1405,7 +1405,7 @@ private bool CrystronHalqifibraxSummon() AI.SelectMaterials(materials); if (materials.Distinct().Count() <= 3) { - AI.SendCustomChat((int)CustomMessage.Surprise); + AI.Dialogs.SendCustomChat((int)CustomMessage.Surprise); } return true; } diff --git a/Game/AI/Dialogs.cs b/Game/AI/Dialogs.cs index 00835649..790e6956 100644 --- a/Game/AI/Dialogs.cs +++ b/Game/AI/Dialogs.cs @@ -110,16 +110,31 @@ public void SendNewTurn() InternalSendMessage(_newturn); } + public void SendCustomNewTurn(int index, params object[] opts) + { + SendCustomChatWithDefaultMessages(index, _newturn, opts); + } + public void SendEndTurn() { InternalSendMessage(_endturn); } + public void SendCustomEndTurn(int index, params object[] opts) + { + SendCustomChatWithDefaultMessages(index, _endturn, opts); + } + public void SendDirectAttack(string attacker) { InternalSendMessage(_directattack, attacker); } + public void SendCustomDirectAttack(int index, string attacker) + { + SendCustomChatWithDefaultMessages(index, _directattack, attacker); + } + public void SendAttack(string attacker, string defender) { if (defender=="monster") @@ -129,6 +144,11 @@ public void SendAttack(string attacker, string defender) InternalSendMessage(_attack, attacker, defender); } + public void SendCustomAttack(int index, string attacker, string defender) + { + SendCustomChatWithDefaultMessages(index, _attack, attacker, defender); + } + public void SendOnDirectAttack(string attacker) { if (string.IsNullOrEmpty(attacker)) @@ -137,6 +157,12 @@ public void SendOnDirectAttack(string attacker) } InternalSendMessage(_ondirectattack, attacker); } + + public void SendCustomOnDirectAttack(int index, string attacker) + { + SendCustomChatWithDefaultMessages(index, _ondirectattack, attacker); + } + public void SendOnDirectAttack() { InternalSendMessage(_ondirectattack); @@ -147,21 +173,41 @@ public void SendActivate(string spell) InternalSendMessage(_activate, spell); } + public void SendCustomActivate(int index, string spell) + { + SendCustomChatWithDefaultMessages(index, _activate, spell); + } + public void SendSummon(string monster) { InternalSendMessage(_summon, monster); } + public void SendCustomSummon(int index, string spell) + { + SendCustomChatWithDefaultMessages(index, _summon, spell); + } + public void SendSetMonster() { InternalSendMessage(_setmonster); } + public void SendCustomSetMonster(int index) + { + SendCustomChatWithDefaultMessages(index, _setmonster); + } + public void SendChaining(string card) { InternalSendMessage(_chaining, card); } + public void SendCustomChaining(int index, string card) + { + SendCustomChatWithDefaultMessages(index, _chaining, card); + } + private void InternalSendMessage(IList array, params object[] opts) { if (!_game._chat) @@ -180,11 +226,25 @@ private void InternalSendMessageForced(IList array, params object[] opts public void SendCustomChat(int index, params object[] opts) { - if (!_game._chat || _custom == null) + if (!_game._chat || _custom == null || _custom.Length <= index) return; string message = string.Format(_custom[index], opts); if (message != "") _game.Chat(message); } + + public void SendCustomChatWithDefaultMessages(int index, String[] defaultMessages, params object[] opts) + { + if (!_game._chat) + return; + if (_custom == null || _custom.Length <= index) + { + InternalSendMessage(defaultMessages, opts); + return; + } + string message = string.Format(_custom[index], opts); + if (message != "") + _game.Chat(message); + } } } diff --git a/Game/AI/Enums/Dialogs/VerreDialogs.cs b/Game/AI/Enums/Dialogs/VerreDialogs.cs new file mode 100644 index 00000000..6abb6fb8 --- /dev/null +++ b/Game/AI/Enums/Dialogs/VerreDialogs.cs @@ -0,0 +1,20 @@ +namespace WindBot.Game.AI.Enums.Dialogs +{ + /// + /// Verre's dialogs + /// + public enum VerreDialogs + { + VerreDirectAttack, + LastAttack, + DuelNearEnd, + VerreSpSummon, + HaineSpSummonWithoutVerre, + HaineSpSummonWithVerre, + VerreNegateActivate, + VerreGainAttackActivate, + SpellRecycleActivate, + ExosisterTransformActivate, + MaxxCResponse + } +} diff --git a/Game/AI/Executor.cs b/Game/AI/Executor.cs index d2a43e1c..75c6282d 100644 --- a/Game/AI/Executor.cs +++ b/Game/AI/Executor.cs @@ -220,6 +220,78 @@ public virtual int OnAnnounceCard(IList avail) return 0; } + /// + /// Called when bot send new turn dialog + /// + public virtual void SendNewTurnDialog() + { + AI.Dialogs.SendNewTurn(); + } + + /// + /// Called when bot send end turn dialog + /// + public virtual void SendEndTurnDialog() + { + AI.Dialogs.SendEndTurn(); + } + + /// + /// Called when bot send direct attack dialog + /// + public virtual void SendDirectAttackDialog(ClientCard card) + { + AI.Dialogs.SendDirectAttack(card.Name); + } + + /// + /// Called when bot send attack dialog + /// + public virtual void SendAttackDialog(ClientCard attacker, string defender) + { + AI.Dialogs.SendAttack(attacker.Name, defender); + } + + /// + /// Called when bot send under direct attack dialog + /// + public virtual void SendOnDirectAttackDialog(ClientCard card) + { + AI.Dialogs.SendOnDirectAttack(card.Name); + } + + /// + /// Called when bot send activate dialog + /// + public virtual void SendActivateDialog(ClientCard card) + { + AI.Dialogs.SendActivate(card.Name); + } + + /// + /// Called when bot send summon dialog + /// + public virtual void SendSummonDialog(ClientCard card) + { + AI.Dialogs.SendSummon(card.Name); + } + + /// + /// Called when bot send set monster dialog + /// + public virtual void SendSetMonsterDialog() + { + AI.Dialogs.SendSetMonster(); + } + + /// + /// Called when bot send chaining dialog + /// + public virtual void SendChainingDialog(ClientCard card) + { + AI.Dialogs.SendChaining(card.Name); + } + public void SetMain(MainPhase main) { Main = main; diff --git a/Game/GameAI.cs b/Game/GameAI.cs index 1c120915..fade3b97 100644 --- a/Game/GameAI.cs +++ b/Game/GameAI.cs @@ -11,7 +11,7 @@ public class GameAI public Duel Duel { get; private set; } public Executor Executor { get; set; } - private Dialogs _dialogs; + public Dialogs Dialogs { get; private set; } // record activated count to prevent infinite actions private Dictionary _activatedCards; @@ -21,7 +21,7 @@ public GameAI(GameClient game, Duel duel) Game = game; Duel = duel; - _dialogs = new Dialogs(game); + Dialogs = new Dialogs(game); _activatedCards = new Dictionary(); } @@ -30,12 +30,12 @@ public GameAI(GameClient game, Duel duel) /// public void OnRetry() { - _dialogs.SendSorry(); + Dialogs.SendSorry(); } public void OnDeckError(string card) { - _dialogs.SendDeckSorry(card); + Dialogs.SendDeckSorry(card); } /// @@ -43,7 +43,7 @@ public void OnDeckError(string card) /// public void OnJoinGame() { - _dialogs.SendWelcome(); + Dialogs.SendWelcome(); } /// @@ -51,7 +51,7 @@ public void OnJoinGame() /// public void OnStart() { - _dialogs.SendDuelStart(); + Dialogs.SendDuelStart(); } /// @@ -59,7 +59,7 @@ public void OnStart() /// public void SendCustomChat(int index, params object[] opts) { - _dialogs.SendCustomChat(index, opts); + Dialogs.SendCustomChat(index, opts); } /// @@ -114,7 +114,7 @@ public void OnNewPhase() m_place = 0; if (Duel.Player == 0 && Duel.Phase == DuelPhase.Draw) { - _dialogs.SendNewTurn(); + Executor.SendNewTurnDialog(); } Executor.OnNewPhase(); } @@ -124,7 +124,7 @@ public void OnNewPhase() /// public void OnDirectAttack(ClientCard card) { - _dialogs.SendOnDirectAttack(card.Name); + Executor.SendOnDirectAttackDialog(card); } /// @@ -170,7 +170,7 @@ public BattlePhaseAction OnSelectBattleCmd(BattlePhase battle) ClientCard card = battle.ActivableCards[i]; if (ShouldExecute(exec, card, ExecutorType.Activate, battle.ActivableDescs[i])) { - _dialogs.SendChaining(card.Name); + Executor.SendChainingDialog(card); return new BattlePhaseAction(BattlePhaseAction.BattleAction.Activate, card.ActionIndex); } } @@ -320,7 +320,7 @@ public int OnSelectChain(IList cards, IList descs, bool forced) ClientCard card = cards[i]; if (ShouldExecute(exec, card, ExecutorType.Activate, descs[i])) { - _dialogs.SendChaining(card.Name); + Executor.SendChainingDialog(card); return i; } } @@ -403,7 +403,7 @@ public MainPhaseAction OnSelectIdleCmd(MainPhase main) { if (exec.Type == ExecutorType.GoToEndPhase && main.CanEndPhase && exec.Func()) // check if should enter end phase directly { - _dialogs.SendEndTurn(); + Executor.SendEndTurnDialog(); return new MainPhaseAction(MainPhaseAction.MainAction.ToEndPhase); } if (exec.Type==ExecutorType.GoToBattlePhase && main.CanBattlePhase && exec.Func()) // check if should enter battle phase directly @@ -418,7 +418,7 @@ public MainPhaseAction OnSelectIdleCmd(MainPhase main) ClientCard card = main.ActivableCards[i]; if (ShouldExecute(exec, card, ExecutorType.Activate, main.ActivableDescs[i])) { - _dialogs.SendActivate(card.Name); + Executor.SendActivateDialog(card); return new MainPhaseAction(MainPhaseAction.MainAction.Activate, card.ActionActivateIndex[main.ActivableDescs[i]]); } } @@ -426,7 +426,7 @@ public MainPhaseAction OnSelectIdleCmd(MainPhase main) { if (ShouldExecute(exec, card, ExecutorType.MonsterSet)) { - _dialogs.SendSetMonster(); + Executor.SendSetMonsterDialog(); return new MainPhaseAction(MainPhaseAction.MainAction.SetMonster, card.ActionIndex); } } @@ -439,7 +439,7 @@ public MainPhaseAction OnSelectIdleCmd(MainPhase main) { if (ShouldExecute(exec, card, ExecutorType.SpSummon)) { - _dialogs.SendSummon(card.Name); + Executor.SendSummonDialog(card); return new MainPhaseAction(MainPhaseAction.MainAction.SpSummon, card.ActionIndex); } } @@ -447,17 +447,17 @@ public MainPhaseAction OnSelectIdleCmd(MainPhase main) { if (ShouldExecute(exec, card, ExecutorType.Summon)) { - _dialogs.SendSummon(card.Name); + Executor.SendSummonDialog(card); return new MainPhaseAction(MainPhaseAction.MainAction.Summon, card.ActionIndex); } if (ShouldExecute(exec, card, ExecutorType.SummonOrSet)) { if (main.MonsterSetableCards.Contains(card) && Executor.OnSelectMonsterSummonOrSet(card)) { - _dialogs.SendSetMonster(); + Executor.SendSetMonsterDialog(); return new MainPhaseAction(MainPhaseAction.MainAction.SetMonster, card.ActionIndex); } - _dialogs.SendSummon(card.Name); + Executor.SendSummonDialog(card); return new MainPhaseAction(MainPhaseAction.MainAction.Summon, card.ActionIndex); } } @@ -471,7 +471,7 @@ public MainPhaseAction OnSelectIdleCmd(MainPhase main) if (main.CanBattlePhase && Duel.Fields[0].HasAttackingMonster()) return new MainPhaseAction(MainPhaseAction.MainAction.ToBattlePhase); - _dialogs.SendEndTurn(); + Executor.SendEndTurnDialog(); return new MainPhaseAction(MainPhaseAction.MainAction.ToEndPhase); } @@ -1100,20 +1100,20 @@ public BattlePhaseAction Attack(ClientCard attacker, ClientCard defender) { string cardName = defender.Name ?? "monster"; attacker.ShouldDirectAttack = false; - _dialogs.SendAttack(attacker.Name, cardName); + Executor.SendAttackDialog(attacker, cardName); SelectCard(defender); } else { attacker.ShouldDirectAttack = true; - _dialogs.SendDirectAttack(attacker.Name); + Executor.SendDirectAttackDialog(attacker); } return new BattlePhaseAction(BattlePhaseAction.BattleAction.Attack, attacker.ActionIndex); } public BattlePhaseAction ToEndPhase() { - _dialogs.SendEndTurn(); + Executor.SendEndTurnDialog(); return new BattlePhaseAction(BattlePhaseAction.BattleAction.ToEndPhase); } public BattlePhaseAction ToMainPhase2() diff --git a/WindBot.csproj b/WindBot.csproj index c40a8c76..f151e997 100644 --- a/WindBot.csproj +++ b/WindBot.csproj @@ -132,6 +132,7 @@ + From c4c6480757c13e801cbe081c073a1eb10aac0be2 Mon Sep 17 00:00:00 2001 From: Wind2009-Louse Date: Wed, 21 Jun 2023 15:32:33 +0800 Subject: [PATCH 2/2] Fix improper dialog call --- Game/AI/Decks/ExosisterExecutor.cs | 6 +++--- Game/AI/Decks/WitchcraftExecutor.cs | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Game/AI/Decks/ExosisterExecutor.cs b/Game/AI/Decks/ExosisterExecutor.cs index 0f54d5d2..1d05c5b5 100644 --- a/Game/AI/Decks/ExosisterExecutor.cs +++ b/Game/AI/Decks/ExosisterExecutor.cs @@ -1145,12 +1145,12 @@ public override void SendEndTurnDialog() { if (Bot.GetMonsterCount() > 0 && Enemy.GetMonsterCount() == 0 && Bot.LifePoints > Enemy.LifePoints) { - AI.Dialogs.SendCustomChat((int)VerreDialogs.DuelNearEnd); + AI.Dialogs.SendCustomEndTurn((int)VerreDialogs.DuelNearEnd); return; } if (Bot.GetMonsterCount() == 0 && Enemy.GetMonsterCount() > 0 && Bot.LifePoints < Enemy.LifePoints) { - AI.Dialogs.SendCustomChat((int)VerreDialogs.DuelNearEnd); + AI.Dialogs.SendCustomEndTurn((int)VerreDialogs.DuelNearEnd); return; } } @@ -1702,7 +1702,7 @@ public bool DefaultExosisterTransform() { if (DefaultExosisterTransformInner()) { - AI.Dialogs.SendCustomChat((int)VerreDialogs.ExosisterTransformActivate, Card.Name); + AI.Dialogs.SendCustomActivate((int)VerreDialogs.ExosisterTransformActivate, Card.Name); customDialogFlag = true; return true; } diff --git a/Game/AI/Decks/WitchcraftExecutor.cs b/Game/AI/Decks/WitchcraftExecutor.cs index 5712a983..5fe51492 100644 --- a/Game/AI/Decks/WitchcraftExecutor.cs +++ b/Game/AI/Decks/WitchcraftExecutor.cs @@ -460,7 +460,7 @@ public override void SendActivateDialog(ClientCard card) } if (Duel.Phase == DuelPhase.End && card.HasSetcode(Witchcraft_setcode) && card.Location == CardLocation.Grave) { - AI.Dialogs.SendCustomChat((int)VerreDialogs.SpellRecycleActivate); + AI.Dialogs.SendCustomActivate((int)VerreDialogs.SpellRecycleActivate, card.Name); return; } base.SendActivateDialog(card); @@ -475,7 +475,7 @@ public override void SendChainingDialog(ClientCard card) } if (Duel.Phase == DuelPhase.End && card.HasSetcode(Witchcraft_setcode) && card.Location == CardLocation.Grave) { - AI.Dialogs.SendCustomChat((int)VerreDialogs.SpellRecycleActivate); + AI.Dialogs.SendCustomChaining((int)VerreDialogs.SpellRecycleActivate, card.Name); return; } base.SendChainingDialog(card); @@ -485,7 +485,7 @@ public override void SendDirectAttackDialog(ClientCard card) { if (card.Id == CardId.MadameVerre) { - AI.Dialogs.SendCustomDirectAttack((int)VerreDialogs.VerreDirectAttack, null); + AI.Dialogs.SendCustomDirectAttack((int)VerreDialogs.VerreDirectAttack, card.Name); return; } if (card.Attack >= Enemy.LifePoints) @@ -503,12 +503,12 @@ public override void SendEndTurnDialog() { if (Bot.GetMonsterCount() > 0 && Enemy.GetMonsterCount() == 0 && Bot.LifePoints > Enemy.LifePoints) { - AI.Dialogs.SendCustomChat((int)VerreDialogs.DuelNearEnd); + AI.Dialogs.SendCustomEndTurn((int)VerreDialogs.DuelNearEnd); return; } if (Bot.GetMonsterCount() == 0 && Enemy.GetMonsterCount() > 0 && Bot.LifePoints < Enemy.LifePoints) { - AI.Dialogs.SendCustomChat((int)VerreDialogs.DuelNearEnd); + AI.Dialogs.SendCustomEndTurn((int)VerreDialogs.DuelNearEnd); return; } } @@ -1433,7 +1433,7 @@ public bool MadameVerreActivate() { if (MadameVerreActivateForNegate()) { - AI.Dialogs.SendCustomActivate((int)VerreDialogs.VerreNegateActivate, null); + AI.Dialogs.SendCustomActivate((int)VerreDialogs.VerreNegateActivate, Card.Name); customDialogFlag = true; return true; } @@ -1443,7 +1443,7 @@ public bool MadameVerreActivate() { if (MadameVerreActivateForGainAttack()) { - AI.Dialogs.SendCustomActivate((int)VerreDialogs.VerreGainAttackActivate, null); + AI.Dialogs.SendCustomActivate((int)VerreDialogs.VerreGainAttackActivate, Card.Name); customDialogFlag = true; return true; }