Commit b56e66dc authored by mercury233's avatar mercury233

move GetMatchingCards, add GetMatchingCardsCount

parent c2a94e8e
......@@ -219,11 +219,6 @@ namespace WindBot.Game.AI
return null;
}
public IList<ClientCard> GetMatchingCards(IList<ClientCard> cards, Func<ClientCard, bool> filter)
{
return cards.Where(card => card != null && filter(card)).ToList();
}
public ClientCard GetPZone(int player, int id)
{
if (Duel.IsNewRule)
......
......@@ -116,6 +116,21 @@ namespace WindBot.Game.AI
return cards.FirstOrDefault(card => card?.Data != null && card.IsFaceup() && filter.Invoke(card));
}
public static IList<ClientCard> GetMatchingCards(this IEnumerable<ClientCard> cards, Func<ClientCard, bool> filter)
{
return cards.Where(card => card?.Data != null && filter.Invoke(card)).ToList();
}
public static int GetMatchingCardsCount(this IEnumerable<ClientCard> cards, Func<ClientCard, bool> filter)
{
return cards.Count(card => card?.Data != null && filter.Invoke(card));
}
public static bool IsExistingMatchingCard(this IEnumerable<ClientCard> cards, Func<ClientCard, bool> filter, int count = 1)
{
return cards.GetMatchingCardsCount(filter) >= count;
}
public static ClientCard GetShouldBeDisabledBeforeItUseEffectMonster(this IEnumerable<ClientCard> cards, bool canBeTarget = true)
{
return cards.FirstOrDefault(card => card?.Data != null && card.IsMonsterShouldBeDisabledBeforeItUseEffect() && card.IsFaceup() && (!canBeTarget || !card.IsShouldNotBeTarget()));
......
using System;
using System;
using YGOSharp.OCGWrapper.Enums;
using System.Collections.Generic;
using WindBot;
using WindBot.Game;
using WindBot.Game.AI;
namespace WindBot.Game.AI.Decks
{
[Deck("Rainbow", "AI_Rainbow")]
......@@ -137,8 +137,8 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.Activate, CardId.TraptrixTrapHoleNightmare, DefaultUniqueTrap);
AddExecutor(ExecutorType.Repos, DefaultMonsterRepos);
}
}
public override void OnNewTurn()
{
NormalSummoned = false;
......@@ -207,13 +207,13 @@ namespace WindBot.Game.AI.Decks
}
return true;
}
private bool RescueRabbitSummon()
{
return Util.GetBotAvailZonesFromExtraDeck() > 0
|| Util.GetMatchingCards(Enemy.MonsterZone, card => card.GetDefensePower() >= 1900).Count == 0
|| Util.GetMatchingCards(Enemy.MonsterZone, card => card.GetDefensePower() < 1900).Count > Util.GetMatchingCards(Bot.MonsterZone, card => card.Attack >= 1900).Count;
}
private bool RescueRabbitSummon()
{
return Util.GetBotAvailZonesFromExtraDeck() > 0
|| !Enemy.MonsterZone.IsExistingMatchingCard(card => card.GetDefensePower() >= 1900)
|| Enemy.MonsterZone.GetMatchingCardsCount(card => card.GetDefensePower() < 1900) > Bot.MonsterZone.GetMatchingCardsCount(card => card.Attack >= 1900);
}
private bool RescueRabbitEffect()
{
......
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