From 258990b944be0a32a19b3cd2707023f046e5d11c Mon Sep 17 00:00:00 2001 From: Wind2009-Louse Date: Thu, 1 Mar 2018 21:58:42 +0800 Subject: [PATCH] Add AI.GetAttacker() and AI.GetDefender() (#3) --- Game/GameAI.cs | 30 +++++++++++++++++++++++++----- Game/GameBehavior.cs | 9 +++++---- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Game/GameAI.cs b/Game/GameAI.cs index b52d729f..8ef45be4 100644 --- a/Game/GameAI.cs +++ b/Game/GameAI.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using System.Collections.Generic; using WindBot.Game.AI; using YGOSharp.OCGWrapper.Enums; @@ -90,6 +90,8 @@ public void OnNewPhase() m_option = -1; m_yesno = -1; m_position = CardPosition.FaceUpAttack; + m_attacker = null; + m_defender = null; Duel.LastSummonPlayer = -1; if (Duel.Player == 0 && Duel.Phase == DuelPhase.Draw) { @@ -167,9 +169,9 @@ public IList OnSelectCard(IList cards, int min, int max, { 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; + 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); @@ -626,9 +628,27 @@ public int OnAnnounceCard() private int m_number; private int m_announce; private int m_yesno; + private ClientCard m_attacker; + private ClientCard m_defender; private IList m_attributes = new List(); private IList m_races = new List(); + public void SendBattleMsg(ClientCard attackcard, ClientCard defendcard) + { + m_attacker = attackcard; + m_defender = defendcard; + } + + public ClientCard GetAttacker() + { + return m_attacker; + } + + public ClientCard GetDefender() + { + return m_defender; + } + public void SelectCard(ClientCard card) { m_selector = new CardSelector(card); @@ -894,4 +914,4 @@ private bool ShouldExecute(CardExecutor exec, ClientCard card, ExecutorType type return false; } } -} \ No newline at end of file +} diff --git a/Game/GameBehavior.cs b/Game/GameBehavior.cs index 1ca34d43..c232aae3 100644 --- a/Game/GameBehavior.cs +++ b/Game/GameBehavior.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Text.RegularExpressions; @@ -494,12 +494,13 @@ private void OnAttack(BinaryReader packet) int la = packet.ReadByte(); int sa = packet.ReadByte(); packet.ReadByte(); // - packet.ReadByte(); // cd + int cd = GetLocalPlayer(packet.ReadByte()); // cd int ld = packet.ReadByte(); - packet.ReadByte(); // sd + int sd = packet.ReadByte(); // sd packet.ReadByte(); // - ClientCard attackcard = _duel.GetCard(ca, (CardLocation)la, sa); + ClientCard defendcard = _duel.GetCard(cd, (CardLocation)ld, sd); + _ai.SendBattleMsg(attackcard, defendcard); if (ld == 0 && (attackcard != null) && (ca != 0)) { _ai.OnDirectAttack(attackcard);