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
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()
{
if (Bot.BattlingMonster == null)
......
......@@ -156,6 +156,12 @@ namespace WindBot.Game.AI
return -1;
}
public virtual CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions)
{
// Overrided in DefalultExecutor
return 0;
}
public virtual bool OnSelectBattleReplay()
{
// Overrided in DefalultExecutor
......
......@@ -443,13 +443,17 @@ namespace WindBot.Game
/// <returns>Selected position.</returns>
public CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions)
{
// Selects the selected position if available, the first available otherwise.
if (positions.Contains(m_position))
{
CardPosition old = m_position;
CardPosition selector_selected = m_position;
m_position = CardPosition.FaceUpAttack;
return old;
}
CardPosition executor_selected = Executor.OnSelectPosition(cardId, positions);
// Selects the selected position if available, the first available otherwise.
if (positions.Contains(executor_selected))
return executor_selected;
if (positions.Contains(selector_selected))
return selector_selected;
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