Commit eb222c82 authored by wind2009's avatar wind2009 Committed by mercury233

Make OnAnnounceCard overrideable

parent 87e802b1
......@@ -271,6 +271,7 @@ namespace WindBot.Game.AI.Decks
public override void OnNewTurn()
{
CrossoutDesignatorTarget = 0;
PSYOmega_count = 0;
MadameVerreGainedATK = false;
summoned = false;
enemy_activate_MaxxC = false;
......@@ -283,8 +284,7 @@ namespace WindBot.Game.AI.Decks
FirstCheckSS.Clear();
UseSSEffect.Clear();
ActivatedCards.Clear();
int PSYOmega_count = 0;
// CalledbytheGrave refrest
// CalledbytheGrave refresh
List<int> key_list = CalledbytheGraveCount.Keys.ToList();
foreach (int dic in key_list)
{
......@@ -438,6 +438,17 @@ namespace WindBot.Game.AI.Decks
return base.OnSelectPosition(cardId, positions);
}
/// <summary>
/// Override for CrossoutDesignator
/// </summary>
/// <param name="opcodes">Operation codes for limitation.</param>
/// <param name="preAnnouced">Card's id prepared to annouce.</param>
/// <returns>Card's id to annouce.</returns>
public override int OnAnnounceCard(IList<int> opcodes, int preAnnouced)
{
return base.OnAnnounceCard(opcodes, preAnnouced);
}
// shuffle List<ClientCard>
public List<ClientCard> CardListShuffle(List<ClientCard> list)
{
......@@ -976,8 +987,6 @@ namespace WindBot.Game.AI.Decks
// check
bool have_FiveRainbow = false;
List<ClientCard> list = new List<ClientCard>();
ClientCard l = null;
ClientCard r = null;
if (Duel.IsNewRule || Duel.IsNewRule2020)
{
list.Add(Enemy.SpellZone[0]);
......
......@@ -188,6 +188,19 @@ namespace WindBot.Game.AI
return false;
}
/// <summary>
/// Called when bot is going to annouce a card, to check whether it's legel(to avoid error)
/// For full implement of opcodes, see ygopro-core/playerop.cpp#is_declarable
/// </summary>
/// <param name="opcodes">Operation codes for limitation.</param>
/// <param name="preAnnouced">Card's id prepared to annouce.</param>
/// <returns>Card's id to annouce.</returns>
public virtual int OnAnnounceCard(IList<int> opcodes, int preAnnouced)
{
// For overriding
return preAnnouced;
}
public void SetMain(MainPhase main)
{
Main = main;
......
......@@ -734,12 +734,14 @@ namespace WindBot.Game
/// <summary>
/// Called when the AI has to declare a card.
/// </summary>
/// <param name="opcodes">Operation lists.</param>
/// <returns>Id of the selected card.</returns>
public int OnAnnounceCard()
public int OnAnnounceCard(IList<int> opcodes)
{
if (m_announce == 0)
return 89631139; // Blue-eyes white dragon
return m_announce;
m_announce = 89631139; // Blue-eyes white dragon
return Executor.OnAnnounceCard(opcodes, m_announce);
}
// _ Others functions _
......
......@@ -1441,8 +1441,15 @@ namespace WindBot.Game
private void OnAnnounceCard(BinaryReader packet)
{
IList<int> opcodes = new List<int>();
packet.ReadByte(); // player
int count = packet.ReadByte();
for (int i = 0; i < count; ++i)
{
opcodes.Add(packet.ReadInt32());
}
// not fully implemented
Connection.Send(CtosMessage.Response, _ai.OnAnnounceCard());
Connection.Send(CtosMessage.Response, _ai.OnAnnounceCard(opcodes));
}
private void OnAnnounceNumber(BinaryReader packet)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment