Commit d2925f39 authored by mercury233's avatar mercury233

add OnSelectBattleReplay

parent 98f7c3e1
......@@ -127,6 +127,21 @@ namespace WindBot.Game.AI
return true;
}
public override bool OnSelectBattleReplay()
{
if (Bot.BattlingMonster == null)
return false;
List<ClientCard> defenders = new List<ClientCard>(Duel.Fields[1].GetMonsters());
defenders.Sort(AIFunctions.CompareDefensePower);
defenders.Reverse();
BattlePhaseAction result = OnSelectAttackTarget(Bot.BattlingMonster, defenders);
if (result != null && result.Action == BattlePhaseAction.BattleAction.Attack)
{
return true;
}
return false;
}
/// <summary>
/// Destroy face-down cards first, in our turn.
/// </summary>
......
......@@ -153,6 +153,12 @@ namespace WindBot.Game.AI
return -1;
}
public virtual bool OnSelectBattleReplay()
{
// Overrided in DefalultExecutor
return false;
}
public void SetMain(MainPhase main)
{
Main = main;
......
......@@ -647,6 +647,15 @@ namespace WindBot.Game
return Executor.OnSelectYesNo(desc);
}
/// <summary>
/// Called when the AI has to select if to continue attacking when replay.
/// </summary>
/// <returns>True for yes, false for no.</returns>
public bool OnSelectBattleReplay()
{
return Executor.OnSelectBattleReplay();
}
/// <summary>
/// Called when the AI has to declare a card.
/// </summary>
......
......@@ -1180,7 +1180,12 @@ namespace WindBot.Game
private void OnSelectYesNo(BinaryReader packet)
{
packet.ReadByte(); // player
int reply = _ai.OnSelectYesNo(packet.ReadInt32()) ? (1) : (0);
int desc = packet.ReadInt32();
int reply;
if (desc == 30)
reply = _ai.OnSelectBattleReplay() ? 1 : 0;
else
reply = _ai.OnSelectYesNo(desc) ? 1 : 0;
Connection.Send(CtosMessage.Response, reply);
}
......
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