Skip to content

Commit

Permalink
Add AI.GetAttacker() and AI.GetDefender() (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wind2009-Louse authored and mercury233 committed Mar 1, 2018
1 parent 81235d3 commit 258990b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
30 changes: 25 additions & 5 deletions Game/GameAI.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using System.Collections.Generic;
using WindBot.Game.AI;
using YGOSharp.OCGWrapper.Enums;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -167,9 +169,9 @@ public IList<ClientCard> OnSelectCard(IList<ClientCard> 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<ClientCard> result = Executor.OnSelectCard(cards, min, max, hint, cancelable);
Expand Down Expand Up @@ -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<CardAttribute> m_attributes = new List<CardAttribute>();
private IList<CardRace> m_races = new List<CardRace>();

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);
Expand Down Expand Up @@ -894,4 +914,4 @@ private bool ShouldExecute(CardExecutor exec, ClientCard card, ExecutorType type
return false;
}
}
}
}
9 changes: 5 additions & 4 deletions Game/GameBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 258990b

Please sign in to comment.