Commit b2427bbd authored by mercury233's avatar mercury233

add LuckyExecutor

parent 1348ee44
using YGOSharp.OCGWrapper.Enums;
using System.Collections.Generic;
using WindBot;
using WindBot.Game;
using WindBot.Game.AI;
namespace WindBot.Game.AI.Decks
{
[Deck("Lucky", "AI_Test", "Test")]
public class LuckyExecutor : DefaultExecutor
{
public LuckyExecutor(GameAI ai, Duel duel)
: base(ai, duel)
{
AddExecutor(ExecutorType.SpSummon, ImFeelingLucky);
AddExecutor(ExecutorType.Activate, ImFeelingLucky);
AddExecutor(ExecutorType.SummonOrSet, ImFeelingLucky);
AddExecutor(ExecutorType.SpellSet, ImFeelingLucky);
AddExecutor(ExecutorType.Repos, DefaultMonsterRepos);
}
public override IList<ClientCard> OnSelectCard(IList<ClientCard> _cards, int min, int max, int hint, bool cancelable)
{
if (Duel.Phase == DuelPhase.BattleStart)
return null;
if (AI.HaveSelectedCards())
return null;
IList<ClientCard> cards = new List<ClientCard>(_cards);
IList<ClientCard> selected = new List<ClientCard>();
if (max > cards.Count)
max = cards.Count;
// select random cards
while (selected.Count < max)
{
ClientCard card = cards[Program.Rand.Next(cards.Count)];
selected.Add(card);
cards.Remove(card);
}
return selected;
}
public override int OnSelectOption(IList<int> options)
{
return Program.Rand.Next(options.Count);
}
private bool ImFeelingLucky()
{
return Program.Rand.Next(9) >= 3 && DefaultDontChainMyself();
}
}
}
\ No newline at end of file
......@@ -951,6 +951,11 @@ namespace WindBot.Game
m_materialSelector = null;
}
public bool HaveSelectedCards()
{
return m_selector.Count > 0 || m_materialSelector != null;
}
public CardSelector GetSelectedCards()
{
CardSelector selected = null;
......
......@@ -72,6 +72,7 @@
<Compile Include="Game\AI\Decks\AltergeistExecutor.cs" />
<Compile Include="Game\AI\Decks\FamiliarPossessedExecutor.cs" />
<Compile Include="Game\AI\Decks\BlackwingExecutor.cs" />
<Compile Include="Game\AI\Decks\LuckyExecutor.cs" />
<Compile Include="Game\AI\Decks\MathMechExecutor.cs" />
<Compile Include="Game\AI\Decks\PureWindsExecutor.cs" />
<Compile Include="Game\AI\Decks\DragunExecutor.cs" />
......
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