Commit b225efae authored by mercury233's avatar mercury233

update ai util functions

parent fc10fcec
This diff is collapsed.
......@@ -12,7 +12,7 @@ namespace WindBot.Game.AI
ClientCard selected = null;
foreach (ClientCard card in cards)
{
if (card == null || card.Data == null) continue;
if (card == null || card.Data == null || card.IsFacedown()) continue;
if (card.HasType(CardType.Monster) && card.Attack > highestAtk)
{
highestAtk = card.Attack;
......@@ -28,7 +28,7 @@ namespace WindBot.Game.AI
ClientCard selected = null;
foreach (ClientCard card in cards)
{
if (card == null || card.Data == null) continue;
if (card == null || card.Data == null || card.IsFacedown()) continue;
if (card.HasType(CardType.Monster) && card.Defense > highestDef)
{
highestDef = card.Defense;
......@@ -44,7 +44,7 @@ namespace WindBot.Game.AI
ClientCard selected = null;
foreach (ClientCard card in cards)
{
if (card == null || card.Data == null) continue;
if (card == null || card.Data == null || card.IsFacedown()) continue;
if (lowestAtk == 0 && card.HasType(CardType.Monster) ||
card.HasType(CardType.Monster) && card.Attack < lowestAtk)
{
......@@ -61,7 +61,7 @@ namespace WindBot.Game.AI
ClientCard selected = null;
foreach (ClientCard card in cards)
{
if (card == null || card.Data == null) continue;
if (card == null || card.Data == null || card.IsFacedown()) continue;
if (lowestDef == 0 && card.HasType(CardType.Monster) ||
card.HasType(CardType.Monster) && card.Defense < lowestDef)
{
......@@ -131,36 +131,39 @@ namespace WindBot.Game.AI
continue;
if (card.HasType(CardType.Monster))
cardlist.Add(card);
}
return cardlist;
}
public static ClientCard GetInvincibleMonster(this IEnumerable<ClientCard> cards)
public static IList<ClientCard> GetFaceupPendulumMonsters(this IEnumerable<ClientCard> cards)
{
IList<ClientCard> cardlist = new List<ClientCard>();
foreach (ClientCard card in cards)
{
if (card != null && card.IsMonsterInvincible())
return card;
if (card == null)
continue;
if (card.HasType(CardType.Monster) && card.IsFaceup() && card.HasType(CardType.Pendulum))
cardlist.Add(card);
}
return null;
return cardlist;
}
public static ClientCard GetDangerousMonster(this IEnumerable<ClientCard> cards)
public static ClientCard GetInvincibleMonster(this IEnumerable<ClientCard> cards)
{
foreach (ClientCard card in cards)
{
if (card != null && card.IsMonsterDangerous())
if (card != null && card.IsMonsterInvincible() && card.IsFaceup())
return card;
}
return null;
}
public static ClientCard GetNegateAttackSpell(this IEnumerable<ClientCard> cards)
public static ClientCard GetDangerousMonster(this IEnumerable<ClientCard> cards)
{
foreach (ClientCard card in cards)
{
if (card != null && card.IsSpellNegateAttack())
if (card != null && card.IsMonsterDangerous() && card.IsFaceup())
return card;
}
return null;
......@@ -170,7 +173,7 @@ namespace WindBot.Game.AI
{
foreach (ClientCard card in cards)
{
if (card != null && card.IsFloodgate())
if (card != null && card.IsFloodgate() && card.IsFaceup())
return card;
}
return null;
......
......@@ -5,21 +5,22 @@ namespace WindBot.Game.AI
{
public static class CardExtension
{
/// <summary>
/// Is this monster is invincible to battle?
/// </summary>
public static bool IsMonsterInvincible(this ClientCard card)
{
return Enum.IsDefined(typeof(InvincibleMonster), card.Id);
}
/// <summary>
/// Is this monster is dangerous to attack?
/// </summary>
public static bool IsMonsterDangerous(this ClientCard card)
{
return Enum.IsDefined(typeof(DangerousMonster), card.Id);
}
public static bool IsSpellNegateAttack(this ClientCard card)
{
return Enum.IsDefined(typeof(NegateAttackSpell), card.Id);
}
public static bool IsFloodgate(this ClientCard card)
{
return Enum.IsDefined(typeof(Floodgate), card.Id);
......
......@@ -99,10 +99,10 @@ namespace WindBot.Game.AI.Decks
// special summon from extra
AddExecutor(ExecutorType.SpSummon, (int)CardId.GalaxyEyesCipherDragon, GalaxyEyesCipherDragonSummon);
AddExecutor(ExecutorType.SpSummon, (int)CardId.GalaxyEyesPrimePhotonDragon, GalaxyEyesPrimePhotonDragonSumom);
AddExecutor(ExecutorType.SpSummon, (int)CardId.GalaxyEyesPrimePhotonDragon, GalaxyEyesPrimePhotonDragonSummon);
AddExecutor(ExecutorType.SpSummon, (int)CardId.GalaxyEyesFullArmorPhotonDragon, GalaxyEyesFullArmorPhotonDragonSummon);
AddExecutor(ExecutorType.SpSummon, (int)CardId.GalaxyEyesCipherBladeDragon, GalaxyEyesCipherBladeDragonSummon);
AddExecutor(ExecutorType.SpSummon, (int)CardId.GalaxyEyesDarkMatterDragon, GalaxyEyesDarkMatterDragonSummom);
AddExecutor(ExecutorType.SpSummon, (int)CardId.GalaxyEyesDarkMatterDragon, GalaxyEyesDarkMatterDragonSummon);
AddExecutor(ExecutorType.SpSummon, (int)CardId.Giganticastle, GiganticastleSummon);
AddExecutor(ExecutorType.SpSummon, (int)CardId.BlueEyesSpiritDragon, BlueEyesSpiritDragonSummon);
AddExecutor(ExecutorType.SpSummon, (int)CardId.HopeHarbingerDragonTitanicGalaxy, HopeHarbingerDragonTitanicGalaxySummon);
......@@ -332,28 +332,7 @@ namespace WindBot.Game.AI.Decks
private bool AlternativeWhiteDragonEffect()
{
ClientCard card = Enemy.MonsterZone.GetFloodgate();
if (card != null)
{
AI.SelectCard(card);
UsedAlternativeWhiteDragon.Add(Card);
return true;
}
card = Enemy.MonsterZone.GetInvincibleMonster();
if (card != null)
{
AI.SelectCard(card);
UsedAlternativeWhiteDragon.Add(Card);
return true;
}
card = Enemy.MonsterZone.GetDangerousMonster();
if (card != null)
{
AI.SelectCard(card);
UsedAlternativeWhiteDragon.Add(Card);
return true;
}
card = AI.Utils.GetOneEnemyBetterThanValue(Card.GetDefensePower(), false);
ClientCard card = AI.Utils.GetProblematicEnemyMonster(Card.GetDefensePower());
if (card != null)
{
AI.SelectCard(card);
......@@ -362,6 +341,8 @@ namespace WindBot.Game.AI.Decks
}
if (CanDealWithUsedAlternativeWhiteDragon())
{
card = AI.Utils.GetBestEnemyMonster();
AI.SelectCard(card);
UsedAlternativeWhiteDragon.Add(Card);
return true;
}
......@@ -487,7 +468,7 @@ namespace WindBot.Game.AI.Decks
{
if (ActivateDescription == -1)
{
ClientCard target = Enemy.SpellZone.GetFloodgate();
ClientCard target = AI.Utils.GetBestEnemySpell();
AI.SelectCard(target);
return true;
}
......@@ -504,12 +485,9 @@ namespace WindBot.Game.AI.Decks
&& !Bot.HasInGraveyard((int)CardId.DragonSpiritOfWhite)
&& !Bot.HasInGraveyard((int)CardId.WhiteDragon);
}
foreach (ClientCard card in Duel.ChainTargets)
if (AI.Utils.IsChainTarget(Card))
{
if (Card.Equals(card))
{
return HaveEnoughWhiteDragonInHand();
}
return HaveEnoughWhiteDragonInHand();
}
return false;
}
......@@ -528,13 +506,10 @@ namespace WindBot.Game.AI.Decks
}
else
{
foreach (ClientCard card in Duel.ChainTargets)
if (AI.Utils.IsChainTarget(Card))
{
if (Card.Equals(card))
{
AI.SelectCard((int)CardId.AzureEyesSilverDragon);
return true;
}
AI.SelectCard((int)CardId.AzureEyesSilverDragon);
return true;
}
return false;
}
......@@ -638,7 +613,7 @@ namespace WindBot.Game.AI.Decks
return false;
}
private bool GalaxyEyesPrimePhotonDragonSumom()
private bool GalaxyEyesPrimePhotonDragonSummon()
{
if (Duel.Turn == 1)
{
......@@ -679,7 +654,7 @@ namespace WindBot.Game.AI.Decks
private bool GalaxyEyesCipherBladeDragonSummon()
{
if (Bot.HasInMonstersZone((int)CardId.GalaxyEyesFullArmorPhotonDragon) && AI.Utils.GetProblematicCard() != null)
if (Bot.HasInMonstersZone((int)CardId.GalaxyEyesFullArmorPhotonDragon) && AI.Utils.GetProblematicEnemyCard() != null)
{
AI.SelectCard((int)CardId.GalaxyEyesFullArmorPhotonDragon);
return true;
......@@ -687,7 +662,7 @@ namespace WindBot.Game.AI.Decks
return false;
}
private bool GalaxyEyesDarkMatterDragonSummom()
private bool GalaxyEyesDarkMatterDragonSummon()
{
if (Bot.HasInMonstersZone((int)CardId.GalaxyEyesFullArmorPhotonDragon))
{
......@@ -729,22 +704,22 @@ namespace WindBot.Game.AI.Decks
private bool GalaxyEyesFullArmorPhotonDragonEffect()
{
ClientCard floodgate = Enemy.SpellZone.GetFloodgate();
if (floodgate != null)
ClientCard target = AI.Utils.GetProblematicEnemySpell();
if (target != null)
{
AI.SelectCard(floodgate);
AI.SelectCard(target);
return true;
}
floodgate = Enemy.MonsterZone.GetFloodgate();
if (floodgate != null)
target = AI.Utils.GetProblematicEnemyMonster();
if (target != null)
{
AI.SelectCard(floodgate);
AI.SelectCard(target);
return true;
}
List<ClientCard> spells = Enemy.GetSpells();
foreach (ClientCard spell in spells)
{
if (!spell.IsFacedown())
if (spell.IsFaceup())
{
AI.SelectCard(spell);
return true;
......@@ -787,7 +762,7 @@ namespace WindBot.Game.AI.Decks
{
return true;
}
ClientCard target = AI.Utils.GetProblematicCard();
ClientCard target = AI.Utils.GetProblematicEnemyCard();
if (target != null)
{
AI.SelectCard(target);
......@@ -847,8 +822,8 @@ namespace WindBot.Game.AI.Decks
{
if (Duel.Phase != DuelPhase.Main1 || Duel.Turn == 1 || SoulChargeUsed)
return false;
int bestSelfAttack = AI.Utils.GetBestAttack(Bot, false);
int bestEnemyAttack = AI.Utils.GetBestAttack(Enemy, false);
int bestSelfAttack = AI.Utils.GetBestAttack(Bot);
int bestEnemyAttack = AI.Utils.GetBestPower(Enemy);
return bestSelfAttack <= bestEnemyAttack && bestEnemyAttack > 2500 && bestEnemyAttack <= 3100;
}
......@@ -973,7 +948,7 @@ namespace WindBot.Game.AI.Decks
private bool Repos()
{
bool enemyBetter = AI.Utils.IsEnemyBetter(true, true);
bool enemyBetter = AI.Utils.IsAllEnemyBetter(true);
if (Card.IsAttack() && enemyBetter)
return true;
......
......@@ -344,32 +344,30 @@ namespace WindBot.Game.AI.Decks
{
//if (AI.Utils.IsOneEnemyBetterThanValue(2500, true))
// return true;
ClientCard invincible = AI.Utils.GetProblematicCard();
ClientCard invincible = AI.Utils.GetProblematicEnemyCard();
return invincible != null;
}
private bool ScrapDragonEffect()
{
ClientCard invincible = AI.Utils.GetProblematicCard();
ClientCard invincible = AI.Utils.GetProblematicEnemyCard();
if (invincible == null && !AI.Utils.IsOneEnemyBetterThanValue(2800 - 1, false))
return false;
ClientField field = Bot;
int tributeId = -1;
if (field.HasInSpellZone((int)CardId.FireFormationTenki))
if (Bot.HasInSpellZone((int)CardId.FireFormationTenki))
tributeId = (int)CardId.FireFormationTenki;
else if (field.HasInSpellZone((int)CardId.Terraforming))
else if (Bot.HasInSpellZone((int)CardId.Terraforming))
tributeId = (int)CardId.Terraforming;
else if (field.HasInSpellZone((int)CardId.DragonsMirror))
else if (Bot.HasInSpellZone((int)CardId.DragonsMirror))
tributeId = (int)CardId.DragonsMirror;
else if (field.HasInSpellZone((int)CardId.CardsOfConsonance))
else if (Bot.HasInSpellZone((int)CardId.CardsOfConsonance))
tributeId = (int)CardId.CardsOfConsonance;
else if (field.HasInSpellZone((int)CardId.AssaultTeleport))
else if (Bot.HasInSpellZone((int)CardId.AssaultTeleport))
tributeId = (int)CardId.AssaultTeleport;
else if (field.HasInSpellZone((int)CardId.AssaultModeActivate))
else if (Bot.HasInSpellZone((int)CardId.AssaultModeActivate))
tributeId = (int)CardId.AssaultModeActivate;
else if (field.HasInSpellZone((int)CardId.DragonRavine))
else if (Bot.HasInSpellZone((int)CardId.DragonRavine))
tributeId = (int)CardId.DragonRavine;
List<ClientCard> monsters = Enemy.GetMonsters();
......
......@@ -165,7 +165,7 @@ namespace WindBot.Game.AI.Decks
{
List<int> cards = new List<int>();
if (AI.Utils.IsEnemyBetter(false, false))
if (AI.Utils.IsOneEnemyBetter())
{
cards.Add((int)CardId.FlipFlopFrog);
}
......
......@@ -74,7 +74,7 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.SpSummon, (int)CardId.EvilswarmExcitonKnight, EvilswarmExcitonKnightSummon);
AddExecutor(ExecutorType.Activate, (int)CardId.EvilswarmExcitonKnight, EvilswarmExcitonKnightEffect);
AddExecutor(ExecutorType.SpSummon, (int)CardId.CastelTheSkyblasterMusketeer, CastelTheSkyblasterMusketeerSummom);
AddExecutor(ExecutorType.SpSummon, (int)CardId.CastelTheSkyblasterMusketeer, CastelTheSkyblasterMusketeerSummon);
AddExecutor(ExecutorType.Activate, (int)CardId.CastelTheSkyblasterMusketeer, CastelTheSkyblasterMusketeerEffect);
AddExecutor(ExecutorType.SpSummon, (int)CardId.ScarlightRedDragonArchfiend, ScarlightRedDragonArchfiendSummon);
AddExecutor(ExecutorType.Activate, (int)CardId.ScarlightRedDragonArchfiend, ScarlightRedDragonArchfiendEffect);
......@@ -249,8 +249,8 @@ namespace WindBot.Game.AI.Decks
private bool ScarlightRedDragonArchfiendSummon()
{
int selfBestAttack = AI.Utils.GetBestAttack(Bot, true);
int oppoBestAttack = AI.Utils.GetBestAttack(Enemy, false);
int selfBestAttack = AI.Utils.GetBestAttack(Bot);
int oppoBestAttack = AI.Utils.GetBestPower(Enemy);
return (selfBestAttack <= oppoBestAttack && oppoBestAttack <= 3000) || ScarlightRedDragonArchfiendEffect();
}
......@@ -275,22 +275,22 @@ namespace WindBot.Game.AI.Decks
return (oppoCount > 0 && selfCount <= oppoCount) || oppoCount > 2;
}
private bool CastelTheSkyblasterMusketeerSummom()
private bool CastelTheSkyblasterMusketeerSummon()
{
return AI.Utils.GetProblematicCard() != null;
return AI.Utils.GetProblematicEnemyCard() != null;
}
private bool CastelTheSkyblasterMusketeerEffect()
{
if (ActivateDescription == AI.Utils.GetStringId((int)CardId.CastelTheSkyblasterMusketeer, 0))
return false;
AI.SelectNextCard(AI.Utils.GetProblematicCard());
AI.SelectNextCard(AI.Utils.GetProblematicEnemyCard());
return true;
}
private bool NumberS39UtopiatheLightningSummon()
{
return AI.Utils.IsEnemyBetter(false, false);
return AI.Utils.IsOneEnemyBetter();
}
}
}
\ No newline at end of file
......@@ -72,7 +72,7 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.SummonOrSet, (int)CardId.DancePrincess, DancePrincessSummon);
AddExecutor(ExecutorType.MonsterSet, (int)CardId.Shurit, ShuritSet);
AddExecutor(ExecutorType.Summon, (int)CardId.ThousandHands, ThousandHandsSummom);
AddExecutor(ExecutorType.Summon, (int)CardId.ThousandHands, ThousandHandsSummon);
AddExecutor(ExecutorType.Summon, (int)CardId.TenThousandHands, TenThousandHandsSummon);
AddExecutor(ExecutorType.Summon, (int)CardId.PhantomOfChaos, PhantomOfChaosSummon);
......@@ -101,7 +101,7 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.SpSummon, (int)CardId.EvilswarmExcitonKnight, EvilswarmExcitonKnightSummon);
}
private bool ThousandHandsSummom()
private bool ThousandHandsSummon()
{
if (!Bot.HasInHand(NekrozRituelCard) || Bot.HasInHand((int)CardId.Shurit) || !Bot.HasInHand(NekrozSpellCard))
return true;
......@@ -190,7 +190,7 @@ namespace WindBot.Game.AI.Decks
private bool GungnirEffect()
{
if (AI.Utils.IsEnemyBetter(true, false) && Duel.Phase == DuelPhase.Main1)
if (AI.Utils.IsOneEnemyBetter(true) && Duel.Phase == DuelPhase.Main1)
{
AI.SelectCard(Enemy.GetMonsters().GetHighestAttackMonster());
return true;
......
......@@ -91,7 +91,7 @@ namespace WindBot.Game.AI.Decks
if (handCard.IsFacedown())
return true;
}
return AI.Utils.IsEnemyBetter(true, false);
return AI.Utils.IsOneEnemyBetter(true);
}
}
}
\ No newline at end of file
......@@ -244,10 +244,9 @@ namespace WindBot.Game.AI.Decks
if (!Card.Equals(card))
count++;
}
foreach (ClientCard card in Bot.ExtraDeck.GetMonsters())
foreach (ClientCard card in Bot.ExtraDeck.GetFaceupPendulumMonsters())
{
if (card.HasType(CardType.Pendulum) && card.IsFaceup())
count++;
count++;
}
ClientCard l = AI.Utils.GetPZone(0, 0);
ClientCard r = AI.Utils.GetPZone(0, 1);
......@@ -290,10 +289,9 @@ namespace WindBot.Game.AI.Decks
{
fieldcount++;
}
foreach (ClientCard card in Bot.ExtraDeck.GetMonsters())
foreach (ClientCard card in Bot.ExtraDeck.GetFaceupPendulumMonsters())
{
if (card.HasType(CardType.Pendulum) && card.IsFaceup())
count++;
count++;
}
if (count>0 && !Bot.HasInHand(LowScaleCards))
{
......@@ -319,32 +317,12 @@ namespace WindBot.Game.AI.Decks
{
if (Card.Location == CardLocation.Hand)
return false;
ClientCard target = AI.Utils.GetProblematicCard();
ClientCard target = AI.Utils.GetBestEnemyCard();
if (target != null)
{
AI.SelectCard(target);
return true;
}
List<ClientCard> monsters = Enemy.GetMonsters();
foreach (ClientCard monster in monsters)
{
AI.SelectCard(monster);
return true;
}
List<ClientCard> spells = Enemy.GetSpells();
foreach (ClientCard spell in spells)
{
if (spell.IsFacedown())
{
AI.SelectCard(spell);
return true;
}
}
foreach (ClientCard spell in spells)
{
AI.SelectCard(spell);
return true;
}
return false;
}
......@@ -352,18 +330,12 @@ namespace WindBot.Game.AI.Decks
{
if (Card.Location == CardLocation.Hand)
return false;
ClientCard target = AI.Utils.GetProblematicMonsterCard();
ClientCard target = AI.Utils.GetBestEnemyMonster();
if (target != null)
{
AI.SelectCard(target);
return true;
}
List<ClientCard> monsters = Enemy.GetMonsters();
foreach (ClientCard monster in monsters)
{
AI.SelectCard(monster);
return true;
}
return false;
}
......@@ -371,26 +343,12 @@ namespace WindBot.Game.AI.Decks
{
if (Card.Location == CardLocation.Hand)
return false;
ClientCard target = AI.Utils.GetProblematicSpellCard();
ClientCard target = AI.Utils.GetBestEnemySpell();
if (target != null)
{
AI.SelectCard(target);
return true;
}
List<ClientCard> spells = Enemy.GetSpells();
foreach (ClientCard spell in spells)
{
if (spell.IsFacedown())
{
AI.SelectCard(spell);
return true;
}
}
foreach (ClientCard spell in spells)
{
AI.SelectCard(spell);
return true;
}
return false;
}
......@@ -405,10 +363,9 @@ namespace WindBot.Game.AI.Decks
{
count++;
}
foreach (ClientCard card in Bot.ExtraDeck.GetMonsters())
foreach (ClientCard card in Bot.ExtraDeck.GetFaceupPendulumMonsters())
{
if (card.HasType(CardType.Pendulum) && card.IsFaceup())
count++;
count++;
}
return count > 1;
}
......
......@@ -290,8 +290,8 @@ namespace WindBot.Game.AI.Decks
private bool ScarlightRedDragonArchfiendSummon()
{
int selfBestAttack = AI.Utils.GetBestAttack(Bot, true);
int oppoBestAttack = AI.Utils.GetBestAttack(Enemy, false);
int selfBestAttack = AI.Utils.GetBestAttack(Bot);
int oppoBestAttack = AI.Utils.GetBestPower(Enemy);
return (selfBestAttack <= oppoBestAttack && oppoBestAttack <= 3000) || ScarlightRedDragonArchfiendEffect();
}
......@@ -319,20 +319,20 @@ namespace WindBot.Game.AI.Decks
private bool CastelTheSkyblasterMusketeerSummon()
{
return AI.Utils.GetProblematicCard() != null;
return AI.Utils.GetProblematicEnemyCard() != null;
}
private bool CastelTheSkyblasterMusketeerEffect()
{
if (ActivateDescription == AI.Utils.GetStringId((int)CardId.CastelTheSkyblasterMusketeer, 0))
return false;
AI.SelectNextCard(AI.Utils.GetProblematicCard());
AI.SelectNextCard(AI.Utils.GetProblematicEnemyCard());
return true;
}
private bool IgnisterProminenceTheBlastingDracoslayerSummon()
{
return AI.Utils.GetProblematicCard() != null;
return AI.Utils.GetProblematicEnemyCard() != null;
}
private bool IgnisterProminenceTheBlastingDracoslayerEffect()
......@@ -340,7 +340,7 @@ namespace WindBot.Game.AI.Decks
if (ActivateDescription == AI.Utils.GetStringId((int)CardId.IgnisterProminenceTheBlastingDracoslayer, 1))
return true;
ClientCard target1 = null;
ClientCard target2 = AI.Utils.GetProblematicCard();
ClientCard target2 = AI.Utils.GetProblematicEnemyCard();
List<ClientCard> spells = Enemy.GetSpells();
foreach (ClientCard spell in spells)
{
......@@ -409,19 +409,19 @@ namespace WindBot.Game.AI.Decks
}
}
return AI.Utils.GetProblematicCard() != null;
return AI.Utils.GetProblematicEnemyCard() != null;
}
private bool LightningChidoriEffect()
{
ClientCard problematicCard = AI.Utils.GetProblematicCard();
ClientCard problematicCard = AI.Utils.GetProblematicEnemyCard();
AI.SelectNextCard(problematicCard);
return true;
}
private bool StardustDragonSummon()
{
return (AI.Utils.IsEnemyBetter(false, false) && !AI.Utils.IsOneEnemyBetterThanValue(2400, true)) || AI.Utils.IsTurn1OrMain2();
return (AI.Utils.IsOneEnemyBetter() && !AI.Utils.IsOneEnemyBetterThanValue(2400, true)) || AI.Utils.IsTurn1OrMain2();
}
private bool StardustDragonEffect()
......@@ -457,18 +457,15 @@ namespace WindBot.Game.AI.Decks
private bool Number59CrookedCookSummon()
{
return ((Bot.GetMonsterCount() + Bot.GetSpellCount() - 2) <= 1) &&
((AI.Utils.IsEnemyBetter(false, false) && !AI.Utils.IsOneEnemyBetterThanValue(2300, true)) || AI.Utils.IsTurn1OrMain2());
((AI.Utils.IsOneEnemyBetter() && !AI.Utils.IsOneEnemyBetterThanValue(2300, true)) || AI.Utils.IsTurn1OrMain2());
}
private bool Number59CrookedCookEffect()
{
if (Duel.Player == 0)
{
foreach (ClientCard card in Duel.ChainTargets)
{
if (Card.Equals(card))
return true;
}
if (AI.Utils.IsChainTarget(Card))
return true;
}
else
{
......@@ -501,7 +498,7 @@ namespace WindBot.Game.AI.Decks
private bool NumberS39UtopiatheLightningSummon()
{
return AI.Utils.IsEnemyBetter(false, false);
return AI.Utils.IsOneEnemyBetter(true);
}
private bool TrapSet()
......
......@@ -276,9 +276,7 @@ namespace WindBot.Game.AI.Decks
private bool Number61VolcasaurusEffect()
{
ClientCard target = Enemy.MonsterZone.GetFloodgate();
if (target == null)
target = AI.Utils.GetOneEnemyBetterThanValue(2000, false);
ClientCard target = AI.Utils.GetProblematicEnemyMonster(2000);
if (target != null)
{
AI.SelectCard((int)CardId.CyberDragon);
......@@ -291,7 +289,7 @@ namespace WindBot.Game.AI.Decks
private bool TirasKeeperOfGenesisEffect()
{
ClientCard target = AI.Utils.GetProblematicCard();
ClientCard target = AI.Utils.GetProblematicEnemyCard();
if (target != null)
{
AI.SelectCard(target);
......@@ -346,32 +344,12 @@ namespace WindBot.Game.AI.Decks
private bool PanzerDragonEffect()
{
ClientCard target = AI.Utils.GetProblematicCard();
ClientCard target = AI.Utils.GetBestEnemyCard();
if (target != null)
{
AI.SelectCard(target);
return true;
}
List<ClientCard> monsters = Enemy.GetMonsters();
foreach (ClientCard monster in monsters)
{
AI.SelectCard(monster);
return true;
}
List<ClientCard> spells = Enemy.GetSpells();
foreach (ClientCard spell in spells)
{
if (spell.IsFacedown())
{
AI.SelectCard(spell);
return true;
}
}
foreach (ClientCard spell in spells)
{
AI.SelectCard(spell);
return true;
}
return false;
}
......
......@@ -189,7 +189,7 @@ namespace WindBot.Game.AI.Decks
private bool MindControlEffect()
{
ClientCard target = AI.Utils.GetAnyEnemyMonster();
ClientCard target = AI.Utils.GetBestEnemyMonster();
if (target != null)
{
AI.SelectCard(target);
......@@ -470,8 +470,8 @@ namespace WindBot.Game.AI.Decks
private bool LinkSummon()
{
return (AI.Utils.IsTurn1OrMain2() || AI.Utils.IsEnemyBetter(false, false))
&& AI.Utils.GetBestAttack(Bot, true) < Card.Attack;
return (AI.Utils.IsTurn1OrMain2() || AI.Utils.IsOneEnemyBetter())
&& AI.Utils.GetBestAttack(Bot) < Card.Attack;
}
}
}
\ No newline at end of file
......@@ -426,7 +426,7 @@ namespace WindBot.Game.AI.Decks
private bool CatSharkSummon()
{
bool should = Bot.HasInMonstersZone((int)CardId.ToadallyAwesome)
&& ((AI.Utils.IsEnemyBetter(true, false)
&& ((AI.Utils.IsOneEnemyBetter(true)
&& !Bot.HasInMonstersZone(new List<int>
{
(int)CardId.CatShark,
......@@ -485,8 +485,8 @@ namespace WindBot.Game.AI.Decks
num++;
}
}
return AI.Utils.IsEnemyBetter(true, false)
&& AI.Utils.GetBestAttack(Enemy, true) > 2200
return AI.Utils.IsOneEnemyBetter(true)
&& AI.Utils.GetBestAttack(Enemy) > 2200
&& num < 4
&& !Bot.HasInMonstersZone(new List<int>
{
......@@ -513,7 +513,7 @@ namespace WindBot.Game.AI.Decks
{
defence += monster.GetDefensePower();
}
if (attack - 2000 - defence > Duel.LifePoints[1] && !AI.Utils.IsEnemyBetter(true, false))
if (attack - 2000 - defence > Duel.LifePoints[1] && !AI.Utils.IsOneEnemyBetter(true))
return true;
}
return false;
......@@ -527,7 +527,7 @@ namespace WindBot.Game.AI.Decks
private bool Repos()
{
bool enemyBetter = AI.Utils.IsEnemyBetter(true, true);
bool enemyBetter = AI.Utils.IsAllEnemyBetter(true);
if (Card.IsFacedown())
return true;
......
......@@ -314,14 +314,14 @@ namespace WindBot.Game.AI.Decks
private bool DarkRebellionXyzDragonSummon()
{
int selfBestAttack = AI.Utils.GetBestAttack(Bot, true);
int oppoBestAttack = AI.Utils.GetBestAttack(Enemy, true);
int selfBestAttack = AI.Utils.GetBestAttack(Bot);
int oppoBestAttack = AI.Utils.GetBestAttack(Enemy);
return selfBestAttack <= oppoBestAttack;
}
private bool DarkRebellionXyzDragonEffect()
{
int oppoBestAttack = AI.Utils.GetBestAttack(Enemy, true);
int oppoBestAttack = AI.Utils.GetBestAttack(Enemy);
ClientCard target = AI.Utils.GetOneEnemyBetterThanValue(oppoBestAttack, true);
if (target != null)
{
......@@ -332,8 +332,8 @@ namespace WindBot.Game.AI.Decks
private bool NumberS39UtopiatheLightningSummon()
{
int selfBestAttack = AI.Utils.GetBestAttack(Bot, true);
int oppoBestAttack = AI.Utils.GetBestAttack(Enemy, false);
int selfBestAttack = AI.Utils.GetBestAttack(Bot);
int oppoBestAttack = AI.Utils.GetBestPower(Enemy);
return selfBestAttack <= oppoBestAttack;
}
......
......@@ -90,9 +90,9 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.SpSummon, (int)CardId.Drident, DridentSummon);
AddExecutor(ExecutorType.Summon, (int)CardId.Ratpier);
AddExecutor(ExecutorType.Activate, (int)CardId.Ratpier, Ratpier);
AddExecutor(ExecutorType.Activate, (int)CardId.Ratpier, RatpierEffect);
AddExecutor(ExecutorType.Summon, (int)CardId.Thoroughblade);
AddExecutor(ExecutorType.Activate, (int)CardId.Thoroughblade, Ratpier);
AddExecutor(ExecutorType.Activate, (int)CardId.Thoroughblade, RatpierEffect);
AddExecutor(ExecutorType.Summon, (int)CardId.AleisterTheInvoker);
AddExecutor(ExecutorType.Activate, (int)CardId.AleisterTheInvoker, AleisterTheInvokerEffect);
......@@ -151,8 +151,8 @@ namespace WindBot.Game.AI.Decks
private bool NumberS39UtopiatheLightningSummon()
{
int selfBestAttack = AI.Utils.GetBestAttack(Bot, true);
int oppoBestAttack = AI.Utils.GetBestAttack(Enemy, false);
int selfBestAttack = AI.Utils.GetBestAttack(Bot);
int oppoBestAttack = AI.Utils.GetBestPower(Enemy);
return selfBestAttack < oppoBestAttack;
}
......@@ -172,7 +172,7 @@ namespace WindBot.Game.AI.Decks
|| Duel.Phase == DuelPhase.Damage))
return false;
return Duel.Player==0
|| AI.Utils.IsEnemyBetter(false, false);
|| AI.Utils.IsOneEnemyBetter();
}
return true;
}
......@@ -486,7 +486,7 @@ namespace WindBot.Game.AI.Decks
return true;
}
private bool Ratpier()
private bool RatpierEffect()
{
AI.SelectCard(new[]
{
......@@ -501,46 +501,7 @@ namespace WindBot.Game.AI.Decks
{
if (LastChainPlayer == 0)
return false;
ClientCard target = AI.Utils.GetProblematicCard();
if (target == null)
{
List<ClientCard> monsters = Enemy.GetMonsters();
foreach (ClientCard monster in monsters)
{
if (monster.IsFaceup())
{
target=monster;
break;
}
}
}
if (target == null)
{
List<ClientCard> spells = Enemy.GetSpells();
foreach (ClientCard spell in spells)
{
if (spell.IsFaceup() && spell.IsSpellNegateAttack())
{
target = spell;
break;
}
}
}
if (target == null)
{
List<ClientCard> spells = Enemy.GetSpells();
foreach (ClientCard spell in spells)
{
if (spell.IsFaceup() && (spell.HasType(CardType.Continuous)
|| spell.HasType(CardType.Equip)
|| spell.HasType(CardType.Field)
|| spell.HasType(CardType.Pendulum)))
{
target = spell;
break;
}
}
}
ClientCard target = AI.Utils.GetBestEnemyCard(true);
if (target == null)
return false;
AI.SelectCard(new[]
......
......@@ -124,7 +124,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultBookOfMoon()
{
if (AI.Utils.IsEnemyBetter(true, true))
if (AI.Utils.IsAllEnemyBetter(true))
{
ClientCard monster = Enemy.GetMonsters().GetHighestAttackMonster();
if (monster != null && monster.HasType(CardType.Effect) && (monster.HasType(CardType.Xyz) || monster.Level > 4))
......@@ -141,22 +141,19 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultCompulsoryEvacuationDevice()
{
ClientCard target = AI.Utils.GetProblematicMonsterCard();
ClientCard target = AI.Utils.GetProblematicEnemyMonster();
if (target != null)
{
AI.SelectCard(target);
return true;
}
foreach (ClientCard card in Duel.ChainTargets)
if (AI.Utils.IsChainTarget(Card))
{
if (Card.Equals(card))
ClientCard monster = AI.Utils.GetBestEnemyMonster();
if (monster != null)
{
ClientCard monster = AI.Utils.GetAnyEnemyMonster();
if (monster != null)
{
AI.SelectCard(monster);
return true;
}
AI.SelectCard(monster);
return true;
}
}
return false;
......@@ -167,7 +164,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultCallOfTheHaunted()
{
if (!AI.Utils.IsEnemyBetter(true, true))
if (!AI.Utils.IsAllEnemyBetter(true))
return false;
ClientCard selected = null;
int BestAtk = 0;
......@@ -201,7 +198,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultSolemnJudgment()
{
return !(Duel.ChainTargets.Count == 1 && Card.Equals(Duel.ChainTargets[0])) && !(Duel.Player == 0 && LastChainPlayer == -1) && DefaultTrap();
return !AI.Utils.IsChainTargetOnly(Card) && !(Duel.Player == 0 && LastChainPlayer == -1) && DefaultTrap();
}
/// <summary>
......@@ -225,7 +222,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultTorrentialTribute()
{
return !HasChainedTrap(0) && AI.Utils.IsEnemyBetter(true, true);
return !HasChainedTrap(0) && AI.Utils.IsAllEnemyBetter(true);
}
/// <summary>
......@@ -249,7 +246,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultHammerShot()
{
return AI.Utils.IsEnemyBetter(true, false);
return AI.Utils.IsOneEnemyBetter(true);
}
/// <summary>
......@@ -257,7 +254,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultDarkHole()
{
return AI.Utils.IsEnemyBetter(false, false);
return AI.Utils.IsOneEnemyBetter();
}
/// <summary>
......@@ -265,7 +262,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultRaigeki()
{
return AI.Utils.IsEnemyBetter(false, false);
return AI.Utils.IsOneEnemyBetter();
}
/// <summary>
......@@ -273,7 +270,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultSmashingGround()
{
return AI.Utils.IsEnemyBetter(false, false);
return AI.Utils.IsOneEnemyBetter();
}
/// <summary>
......@@ -328,7 +325,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultMonsterRepos()
{
bool enemyBetter = AI.Utils.IsEnemyBetter(true, true);
bool enemyBetter = AI.Utils.IsAllEnemyBetter(true);
if (Card.IsAttack() && enemyBetter)
return true;
......@@ -476,13 +473,10 @@ namespace WindBot.Game.AI
return true;
}
}
foreach (ClientCard card in Duel.ChainTargets)
if (AI.Utils.IsChainTarget(Card))
{
if (Card.Equals(card))
{
AI.SelectOption(XYZ);
return true;
}
AI.SelectOption(XYZ);
return true;
}
return false;
}
......@@ -552,7 +546,7 @@ namespace WindBot.Game.AI
AI.SelectCard(card);
return true;
}
card = AI.Utils.GetOneEnemyBetterThanValue(Card.GetDefensePower(), false);
card = AI.Utils.GetOneEnemyBetterThanValue(Card.GetDefensePower());
if (card != null)
{
AI.SelectCard(card);
......
namespace WindBot.Game.AI.Enums
{
/// <summary>
/// Cards that are dangerous to attack.
/// </summary>
public enum DangerousMonster
{
LionHeart = 54366836,
Yubel = 78371393,
YubelIncarnate = 4779091,
YubelNightmare = 31764700,
MetaionTheTimelord = 74530899,
Number39Utopia = 84013237,
NumberS39UtopiatheLightning = 56832966
MetaionTheTimelord = 74530899
}
}
namespace WindBot.Game.AI.Enums
{
/// <summary>
/// Cards that restrict player from performing some action. Bot will preferentially destroy them.
/// </summary>
public enum Floodgate
{
BarrierStatueoftheTorrent = 10963799,
......@@ -24,11 +27,13 @@
LevelLimitAreaB = 3136426,
DimensionalFissure = 81674782,
Necrovalley = 47355498,
SavageColosseum = 32391631,
SecretVillageoftheSpellcasters = 68462976,
SwordsofRevealingLight = 72302403,
MessengerofPeace = 44656491,
KaiserColosseum = 35059553,
DomainoftheTrueMonarchs = 84171830,
ZombieWorld = 4064256,
ImperialOrder = 61740673,
MacroCosmos = 30241314,
MindDrain = 68937720,
......@@ -41,6 +46,7 @@
LightImprisoningMirror = 53341729,
ShadowImprisoningMirror = 99735427,
WallofRevealingLight = 17078030,
GravityBind = 85742772,
VanitysEmptiness = 5851097,
Lose1Turn = 24348804,
Reqliate = 20426907,
......
namespace WindBot.Game.AI.Enums
{
/// <summary>
/// Cards that are invincible to battle.
/// </summary>
public enum InvincibleMonster
{
SpiritReaper = 23205979,
......
namespace WindBot.Game.AI.Enums
{
public enum NegateAttackSpell
{
MessengerOfPeace = 44656491,
SavageColosseum = 32391631,
GravityBind = 85742772,
LevelLimitAreaB = 3136426
}
}
namespace WindBot.Game.AI.Enums
{
public enum NegatesEffects
{
SkillDrain = 82732705,
SoulDrain = 73599290
}
}
namespace WindBot.Game.AI.Enums
{
public enum NegatesSpells
{
HorusLv6 = 11224103,
HorusLv8 = 48229808
}
}
namespace WindBot.Game.AI.Enums
{
public enum NegatesSummons
{
Necrovalley = 47355498,
ImperialIronWall = 30459350,
ZombieWorld = 4064256,
DnaSurgery = 74701381,
MacroCosmos = 30241314,
DimensionalFissure = 81674782
}
}
namespace WindBot.Game.AI.Enums
{
public enum NegatesTraps
{
Jinzo = 77585513,
RoyalDecree = 51452091
}
}
......@@ -304,7 +304,7 @@ namespace WindBot.Game
}
if (ShouldExecute(exec, card, ExecutorType.SummonOrSet))
{
if (Utils.IsEnemyBetter(true, true) && Utils.IsAllEnemyBetterThanValue(card.Attack + 300, false) &&
if (Utils.IsAllEnemyBetter(true) && Utils.IsAllEnemyBetterThanValue(card.Attack + 300, false) &&
main.MonsterSetableCards.Contains(card))
{
_dialogs.SendSetMonster();
......
......@@ -125,4 +125,6 @@ The parameters are same as commandlines, but low cased.
* Better new master rule support
* Update the known card enums
* More default common cards executor
......@@ -114,11 +114,6 @@
<Compile Include="Game\AI\Enums\OneForXyz.cs" />
<Compile Include="Game\AI\Enums\InvincibleMonster.cs" />
<Compile Include="Game\AI\Enums\Floodgate.cs" />
<Compile Include="Game\AI\Enums\NegateAttackSpell.cs" />
<Compile Include="Game\AI\Enums\NegatesEffects.cs" />
<Compile Include="Game\AI\Enums\NegatesSpells.cs" />
<Compile Include="Game\AI\Enums\NegatesSummons.cs" />
<Compile Include="Game\AI\Enums\NegatesTraps.cs" />
<Compile Include="Game\AI\Executor.cs" />
<Compile Include="Game\AI\ExecutorType.cs" />
<Compile Include="Game\BattlePhase.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