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 ...@@ -271,6 +271,7 @@ namespace WindBot.Game.AI.Decks
public override void OnNewTurn() public override void OnNewTurn()
{ {
CrossoutDesignatorTarget = 0; CrossoutDesignatorTarget = 0;
PSYOmega_count = 0;
MadameVerreGainedATK = false; MadameVerreGainedATK = false;
summoned = false; summoned = false;
enemy_activate_MaxxC = false; enemy_activate_MaxxC = false;
...@@ -283,8 +284,7 @@ namespace WindBot.Game.AI.Decks ...@@ -283,8 +284,7 @@ namespace WindBot.Game.AI.Decks
FirstCheckSS.Clear(); FirstCheckSS.Clear();
UseSSEffect.Clear(); UseSSEffect.Clear();
ActivatedCards.Clear(); ActivatedCards.Clear();
int PSYOmega_count = 0; // CalledbytheGrave refresh
// CalledbytheGrave refrest
List<int> key_list = CalledbytheGraveCount.Keys.ToList(); List<int> key_list = CalledbytheGraveCount.Keys.ToList();
foreach (int dic in key_list) foreach (int dic in key_list)
{ {
...@@ -438,6 +438,17 @@ namespace WindBot.Game.AI.Decks ...@@ -438,6 +438,17 @@ namespace WindBot.Game.AI.Decks
return base.OnSelectPosition(cardId, positions); 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> // shuffle List<ClientCard>
public List<ClientCard> CardListShuffle(List<ClientCard> list) public List<ClientCard> CardListShuffle(List<ClientCard> list)
{ {
...@@ -976,8 +987,6 @@ namespace WindBot.Game.AI.Decks ...@@ -976,8 +987,6 @@ namespace WindBot.Game.AI.Decks
// check // check
bool have_FiveRainbow = false; bool have_FiveRainbow = false;
List<ClientCard> list = new List<ClientCard>(); List<ClientCard> list = new List<ClientCard>();
ClientCard l = null;
ClientCard r = null;
if (Duel.IsNewRule || Duel.IsNewRule2020) if (Duel.IsNewRule || Duel.IsNewRule2020)
{ {
list.Add(Enemy.SpellZone[0]); list.Add(Enemy.SpellZone[0]);
......
...@@ -188,6 +188,19 @@ namespace WindBot.Game.AI ...@@ -188,6 +188,19 @@ namespace WindBot.Game.AI
return false; 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) public void SetMain(MainPhase main)
{ {
Main = main; Main = main;
......
...@@ -734,12 +734,14 @@ namespace WindBot.Game ...@@ -734,12 +734,14 @@ namespace WindBot.Game
/// <summary> /// <summary>
/// Called when the AI has to declare a card. /// Called when the AI has to declare a card.
/// </summary> /// </summary>
/// <param name="opcodes">Operation lists.</param>
/// <returns>Id of the selected card.</returns> /// <returns>Id of the selected card.</returns>
public int OnAnnounceCard() public int OnAnnounceCard(IList<int> opcodes)
{ {
if (m_announce == 0) if (m_announce == 0)
return 89631139; // Blue-eyes white dragon m_announce = 89631139; // Blue-eyes white dragon
return m_announce;
return Executor.OnAnnounceCard(opcodes, m_announce);
} }
// _ Others functions _ // _ Others functions _
......
...@@ -1441,8 +1441,15 @@ namespace WindBot.Game ...@@ -1441,8 +1441,15 @@ namespace WindBot.Game
private void OnAnnounceCard(BinaryReader packet) 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 // not fully implemented
Connection.Send(CtosMessage.Response, _ai.OnAnnounceCard()); Connection.Send(CtosMessage.Response, _ai.OnAnnounceCard(opcodes));
} }
private void OnAnnounceNumber(BinaryReader packet) 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