Commit 5cf720d1 authored by mercury233's avatar mercury233

add Executor.OnSelectPosition, make 0 atk monster go defense at default

parent dd752335
...@@ -127,6 +127,20 @@ namespace WindBot.Game.AI ...@@ -127,6 +127,20 @@ namespace WindBot.Game.AI
return true; return true;
} }
/// <summary>
/// Called when the AI has to select a card position.
/// </summary>
/// <param name="cardId">Id of the card to position on the field.</param>
/// <param name="positions">List of available positions.</param>
/// <returns>Selected position, or 0 if no position is set for this card.</returns>
public override CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions)
{
YGOSharp.OCGWrapper.NamedCard cardData = YGOSharp.OCGWrapper.NamedCard.Get(cardId);
if (cardData.Attack == 0)
return CardPosition.FaceUpDefence;
return base.OnSelectPosition(cardId, positions);
}
public override bool OnSelectBattleReplay() public override bool OnSelectBattleReplay()
{ {
if (Bot.BattlingMonster == null) if (Bot.BattlingMonster == null)
......
...@@ -156,6 +156,12 @@ namespace WindBot.Game.AI ...@@ -156,6 +156,12 @@ namespace WindBot.Game.AI
return -1; return -1;
} }
public virtual CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions)
{
// Overrided in DefalultExecutor
return 0;
}
public virtual bool OnSelectBattleReplay() public virtual bool OnSelectBattleReplay()
{ {
// Overrided in DefalultExecutor // Overrided in DefalultExecutor
......
...@@ -443,13 +443,17 @@ namespace WindBot.Game ...@@ -443,13 +443,17 @@ namespace WindBot.Game
/// <returns>Selected position.</returns> /// <returns>Selected position.</returns>
public CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions) public CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions)
{ {
CardPosition selector_selected = m_position;
m_position = CardPosition.FaceUpAttack;
CardPosition executor_selected = Executor.OnSelectPosition(cardId, positions);
// Selects the selected position if available, the first available otherwise. // Selects the selected position if available, the first available otherwise.
if (positions.Contains(m_position)) if (positions.Contains(executor_selected))
{ return executor_selected;
CardPosition old = m_position; if (positions.Contains(selector_selected))
m_position = CardPosition.FaceUpAttack; return selector_selected;
return old;
}
return positions[0]; return positions[0];
} }
......
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