Commit 47f5ca86 authored by mercury233's avatar mercury233 Committed by GitHub

refactor DefaultExecutor (#92)

parent 07a0649a
......@@ -280,6 +280,11 @@ namespace WindBot.Game.AI
return Duel.CurrentChain.Any(card => card.Id == id);
}
public bool ChainContainsCard(int[] ids)
{
return Duel.CurrentChain.Any(card => ids.Contains(card.Id));
}
public int ChainCountPlayer(int player)
{
return Duel.CurrentChain.Count(card => card.Controller == player);
......
......@@ -91,6 +91,7 @@ namespace WindBot.Game.AI.Decks
public override void OnNewTurn()
{
ClownUsed = false;
base.OnNewTurn();
}
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
......
This diff is collapsed.
......@@ -198,24 +198,24 @@ namespace WindBot.Game
return GetMonsters().Any(card => card.IsDefense());
}
public bool HasInMonstersZone(int cardId, bool notDisabled = false, bool hasXyzMaterial = false)
public bool HasInMonstersZone(int cardId, bool notDisabled = false, bool hasXyzMaterial = false, bool faceUp = false)
{
return HasInCards(MonsterZone, cardId, notDisabled, hasXyzMaterial);
return HasInCards(MonsterZone, cardId, notDisabled, hasXyzMaterial, faceUp);
}
public bool HasInMonstersZone(IList<int> cardId, bool notDisabled = false, bool hasXyzMaterial = false)
public bool HasInMonstersZone(IList<int> cardId, bool notDisabled = false, bool hasXyzMaterial = false, bool faceUp = false)
{
return HasInCards(MonsterZone, cardId, notDisabled, hasXyzMaterial);
return HasInCards(MonsterZone, cardId, notDisabled, hasXyzMaterial, faceUp);
}
public bool HasInSpellZone(int cardId, bool notDisabled = false)
public bool HasInSpellZone(int cardId, bool notDisabled = false, bool faceUp = false)
{
return HasInCards(SpellZone, cardId, notDisabled);
return HasInCards(SpellZone, cardId, notDisabled, false, faceUp);
}
public bool HasInSpellZone(IList<int> cardId, bool notDisabled = false)
public bool HasInSpellZone(IList<int> cardId, bool notDisabled = false, bool faceUp = false)
{
return HasInCards(SpellZone, cardId, notDisabled);
return HasInCards(SpellZone, cardId, notDisabled, false, faceUp);
}
public bool HasInHandOrInSpellZone(int cardId)
......@@ -323,14 +323,14 @@ namespace WindBot.Game
return cards.Where(card => card != null).ToList();
}
private static bool HasInCards(IEnumerable<ClientCard> cards, int cardId, bool notDisabled = false, bool hasXyzMaterial = false)
private static bool HasInCards(IEnumerable<ClientCard> cards, int cardId, bool notDisabled = false, bool hasXyzMaterial = false, bool faceUp = false)
{
return cards.Any(card => card != null && card.Id == cardId && !(notDisabled && card.IsDisabled()) && !(hasXyzMaterial && !card.HasXyzMaterial()));
return cards.Any(card => card != null && card.Id == cardId && !(notDisabled && card.IsDisabled()) && !(hasXyzMaterial && !card.HasXyzMaterial()) && !(faceUp && card.IsFacedown()));
}
private static bool HasInCards(IEnumerable<ClientCard> cards, IList<int> cardId, bool notDisabled = false, bool hasXyzMaterial = false)
private static bool HasInCards(IEnumerable<ClientCard> cards, IList<int> cardId, bool notDisabled = false, bool hasXyzMaterial = false, bool faceUp = false)
{
return cards.Any(card => card != null && cardId.Contains(card.Id) && !(notDisabled && card.IsDisabled()) && !(hasXyzMaterial && !card.HasXyzMaterial()));
return cards.Any(card => card != null && cardId.Contains(card.Id) && !(notDisabled && card.IsDisabled()) && !(hasXyzMaterial && !card.HasXyzMaterial()) && !(faceUp && card.IsFacedown()));
}
}
}
\ No newline at end of file
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