Commit 43086945 authored by mercury233's avatar mercury233

Merge branch 'master' of https://github.com/IceYGO/windbot

parents 8880a1d5 73314e40
using System; using System;
using System.IO; using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Linq; using System.Linq;
namespace BotWrapper namespace BotWrapper
{ {
class BotWrapper class BotWrapper
{ {
[DllImport("User32.dll", CharSet = CharSet.Unicode)] [DllImport("User32.dll", CharSet = CharSet.Unicode)]
public static extern int MessageBox(IntPtr hWnd, string lpText, string lpCaption, int uType); public static extern int MessageBox(IntPtr hWnd, string lpText, string lpCaption, int uType);
const int MB_ICONERROR = 0x00000010; const int MB_ICONERROR = 0x00000010;
static void Main(string[] args) static void Main(string[] args)
{ {
ProcessStartInfo startInfo = new ProcessStartInfo(); ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.UseShellExecute = false; startInfo.UseShellExecute = false;
startInfo.WorkingDirectory = Path.GetFullPath("WindBot"); startInfo.WorkingDirectory = Path.GetFullPath("WindBot");
startInfo.FileName = startInfo.WorkingDirectory + "\\WindBot.exe"; startInfo.FileName = startInfo.WorkingDirectory + "\\WindBot.exe";
if (args.Length == 3) if (args.Length == 3)
{ {
startInfo.CreateNoWindow = true; startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.WindowStyle = ProcessWindowStyle.Hidden;
string arg = args[0]; string arg = args[0];
Match match = Regex.Match(arg, "Random=(.*)"); Match match = Regex.Match(arg, "Random=(.*)");
if (match.Success) if (match.Success)
{ {
string randomFlag = match.Groups[1].Value; string randomFlag = match.Groups[1].Value;
...@@ -39,42 +39,42 @@ namespace BotWrapper ...@@ -39,42 +39,42 @@ namespace BotWrapper
{ {
MessageBox((IntPtr)0, "Can't find random bot with this flag!\n\nA totally random bot will appear instead.", "WindBot", MB_ICONERROR); MessageBox((IntPtr)0, "Can't find random bot with this flag!\n\nA totally random bot will appear instead.", "WindBot", MB_ICONERROR);
} }
} }
arg = arg.Replace("'", "\""); arg = arg.Replace("'", "\"");
if (int.Parse(args[1]) == 1) if (int.Parse(args[1]) == 1)
{ {
arg += " Hand=1"; arg += " Hand=1";
} }
arg += " Port=" + args[2]; arg += " Port=" + args[2];
startInfo.Arguments = arg; startInfo.Arguments = arg;
} }
try try
{ {
Process.Start(startInfo); Process.Start(startInfo);
} }
catch catch
{ {
MessageBox((IntPtr)0, "WindBot can't be started!", "WindBot", MB_ICONERROR); MessageBox((IntPtr)0, "WindBot can't be started!", "WindBot", MB_ICONERROR);
} }
} }
public class BotInfo public class BotInfo
{ {
public string name; public string name;
public string command; public string command;
public string desc; public string desc;
public string[] flags; public string[] flags;
} }
static public IList<BotInfo> Bots = new List<BotInfo>(); static public IList<BotInfo> Bots = new List<BotInfo>();
static void ReadBots() static void ReadBots()
{ {
using (StreamReader reader = new StreamReader("bot.conf")) using (StreamReader reader = new StreamReader("bot.conf"))
{ {
while (!reader.EndOfStream) while (!reader.EndOfStream)
{ {
string line = reader.ReadLine().Trim(); string line = reader.ReadLine().Trim();
if (line.Length > 0 && line[0] == '!') if (line.Length > 0 && line[0] == '!')
{ {
...@@ -88,8 +88,8 @@ namespace BotWrapper ...@@ -88,8 +88,8 @@ namespace BotWrapper
} }
} }
} }
} }
static string GetRandomBot(string flag) static string GetRandomBot(string flag)
{ {
IList<BotInfo> foundBots = Bots.Where(bot => bot.flags.Contains(flag)).ToList(); IList<BotInfo> foundBots = Bots.Where(bot => bot.flags.Contains(flag)).ToList();
...@@ -100,6 +100,6 @@ namespace BotWrapper ...@@ -100,6 +100,6 @@ namespace BotWrapper
return bot.command; return bot.command;
} }
return ""; return "";
} }
} }
} }
This diff is collapsed.
This diff is collapsed.
...@@ -68,13 +68,13 @@ namespace WindBot.Game.AI ...@@ -68,13 +68,13 @@ namespace WindBot.Game.AI
break; break;
case SelectType.Id: case SelectType.Id:
foreach (ClientCard card in cards) foreach (ClientCard card in cards)
if (card.Id == _id) if (card.IsCode(_id))
result.Add(card); result.Add(card);
break; break;
case SelectType.Ids: case SelectType.Ids:
foreach (int id in _ids) foreach (int id in _ids)
foreach (ClientCard card in cards) foreach (ClientCard card in cards)
if (card.Id == id && !result.Contains(card)) if (card.IsCode(id) && !result.Contains(card))
result.Add(card); result.Add(card);
break; break;
case SelectType.Location: case SelectType.Location:
......
This diff is collapsed.
...@@ -111,7 +111,7 @@ namespace WindBot.Game.AI.Decks ...@@ -111,7 +111,7 @@ namespace WindBot.Game.AI.Decks
{ {
List<ClientCard> monster = Bot.GetMonsters(); List<ClientCard> monster = Bot.GetMonsters();
foreach (ClientCard card in monster) foreach (ClientCard card in monster)
if (card != null && card.Id == CardId.KrisTheCrackOfDawn || card.Id == CardId.KalutTheMoonShadow || card.Id == CardId.GaleTheWhirlwind || card.Id == CardId.BoraTheSpear || card.Id == CardId.SiroccoTheDawn || card.Id == CardId.ShuraTheBlueFlame || card.Id == CardId.BlizzardTheFarNorth) if (card != null && card.IsCode(CardId.KrisTheCrackOfDawn, CardId.KalutTheMoonShadow, CardId.GaleTheWhirlwind, CardId.BoraTheSpear, CardId.SiroccoTheDawn, CardId.ShuraTheBlueFlame, CardId.BlizzardTheFarNorth))
return true; return true;
return false; return false;
} }
...@@ -119,7 +119,7 @@ namespace WindBot.Game.AI.Decks ...@@ -119,7 +119,7 @@ namespace WindBot.Game.AI.Decks
private bool KalutTheMoonShadowSummon() private bool KalutTheMoonShadowSummon()
{ {
foreach (ClientCard card in Bot.Hand) foreach (ClientCard card in Bot.Hand)
if (card != null && card.Id == CardId.KrisTheCrackOfDawn || card.Id == CardId.GaleTheWhirlwind || card.Id == CardId.BoraTheSpear || card.Id == CardId.SiroccoTheDawn || card.Id == CardId.ShuraTheBlueFlame || card.Id == CardId.BlizzardTheFarNorth) if (card != null && card.IsCode(CardId.KrisTheCrackOfDawn, CardId.GaleTheWhirlwind, CardId.BoraTheSpear, CardId.SiroccoTheDawn, CardId.ShuraTheBlueFlame, CardId.BlizzardTheFarNorth))
return false; return false;
return true; return true;
} }
...@@ -127,7 +127,7 @@ namespace WindBot.Game.AI.Decks ...@@ -127,7 +127,7 @@ namespace WindBot.Game.AI.Decks
private bool BlizzardTheFarNorthSummon() private bool BlizzardTheFarNorthSummon()
{ {
foreach (ClientCard card in Bot.Graveyard) foreach (ClientCard card in Bot.Graveyard)
if (card != null && card.Id == CardId.KalutTheMoonShadow || card.Id == CardId.BoraTheSpear || card.Id == CardId.ShuraTheBlueFlame || card.Id == CardId.KrisTheCrackOfDawn) if (card != null && card.IsCode(CardId.KalutTheMoonShadow, CardId.BoraTheSpear, CardId.ShuraTheBlueFlame, CardId.KrisTheCrackOfDawn))
return true; return true;
return false; return false;
} }
...@@ -138,7 +138,7 @@ namespace WindBot.Game.AI.Decks ...@@ -138,7 +138,7 @@ namespace WindBot.Game.AI.Decks
List<ClientCard> monster = Bot.GetMonsters(); List<ClientCard> monster = Bot.GetMonsters();
foreach (ClientCard card in monster) foreach (ClientCard card in monster)
if (card != null && card.Id == CardId.KrisTheCrackOfDawn || card.Id == CardId.KalutTheMoonShadow || card.Id == CardId.GaleTheWhirlwind || card.Id == CardId.BoraTheSpear || card.Id == CardId.SiroccoTheDawn || card.Id == CardId.ShuraTheBlueFlame || card.Id == CardId.BlizzardTheFarNorth) if (card != null && card.IsCode(CardId.KrisTheCrackOfDawn, CardId.KalutTheMoonShadow, CardId.GaleTheWhirlwind, CardId.BoraTheSpear, CardId.SiroccoTheDawn, CardId.ShuraTheBlueFlame, CardId.BlizzardTheFarNorth))
Count++; Count++;
if (Count == 3) if (Count == 3)
......
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using WindBot; using WindBot;
using WindBot.Game; using WindBot.Game;
using WindBot.Game.AI; using WindBot.Game.AI;
...@@ -138,27 +139,11 @@ namespace WindBot.Game.AI.Decks ...@@ -138,27 +139,11 @@ namespace WindBot.Game.AI.Decks
if (max == 2 && cards[0].Location == CardLocation.Deck) if (max == 2 && cards[0].Location == CardLocation.Deck)
{ {
Logger.DebugWriteLine("OnSelectCard MelodyOfAwakeningDragon"); Logger.DebugWriteLine("OnSelectCard MelodyOfAwakeningDragon");
IList<ClientCard> result = new List<ClientCard>(); List<ClientCard> result = new List<ClientCard>();
if (!Bot.HasInHand(CardId.WhiteDragon)) if (!Bot.HasInHand(CardId.WhiteDragon))
{ result.AddRange(cards.Where(card => card.IsCode(CardId.WhiteDragon)).Take(1));
foreach (ClientCard card in cards) result.AddRange(cards.Where(card => card.IsCode(CardId.AlternativeWhiteDragon)));
{ return AI.Utils.CheckSelectCount(result, cards, min, max);
if (card.Id == CardId.WhiteDragon)
{
result.Add(card);
break;
}
}
}
foreach (ClientCard card in cards)
{
if (card.Id == CardId.AlternativeWhiteDragon && result.Count < max)
{
result.Add(card);
}
}
AI.Utils.CheckSelectCount(result, cards, min, max);
return result;
} }
Logger.DebugWriteLine("Use default."); Logger.DebugWriteLine("Use default.");
return null; return null;
...@@ -167,10 +152,8 @@ namespace WindBot.Game.AI.Decks ...@@ -167,10 +152,8 @@ namespace WindBot.Game.AI.Decks
public override IList<ClientCard> OnSelectXyzMaterial(IList<ClientCard> cards, int min, int max) public override IList<ClientCard> OnSelectXyzMaterial(IList<ClientCard> cards, int min, int max)
{ {
Logger.DebugWriteLine("OnSelectXyzMaterial " + cards.Count + " " + min + " " + max); Logger.DebugWriteLine("OnSelectXyzMaterial " + cards.Count + " " + min + " " + max);
IList<ClientCard> result = new List<ClientCard>(); IList<ClientCard> result = AI.Utils.SelectPreferredCards(UsedAlternativeWhiteDragon, cards, min, max);
AI.Utils.SelectPreferredCards(result, UsedAlternativeWhiteDragon, cards, min, max); return AI.Utils.CheckSelectCount(result, cards, min, max);
AI.Utils.CheckSelectCount(result, cards, min, max);
return result;
} }
public override IList<ClientCard> OnSelectSynchroMaterial(IList<ClientCard> cards, int sum, int min, int max) public override IList<ClientCard> OnSelectSynchroMaterial(IList<ClientCard> cards, int sum, int min, int max)
...@@ -900,23 +883,16 @@ namespace WindBot.Game.AI.Decks ...@@ -900,23 +883,16 @@ namespace WindBot.Game.AI.Decks
return true; return true;
if (Card.IsDefense() && !enemyBetter && Card.Attack >= Card.Defense) if (Card.IsDefense() && !enemyBetter && Card.Attack >= Card.Defense)
return true; return true;
if (Card.IsDefense() && ( if (Card.IsDefense() && Card.IsCode(CardId.BlueEyesSpiritDragon, CardId.AzureEyesSilverDragon))
Card.Id == CardId.BlueEyesSpiritDragon
|| Card.Id == CardId.AzureEyesSilverDragon
))
return true; return true;
if (Card.IsAttack() && ( if (Card.IsAttack() && Card.IsCode(CardId.SageWithEyesOfBlue, CardId.WhiteStoneOfAncients, CardId.WhiteStoneOfLegend))
Card.Id == CardId.SageWithEyesOfBlue
|| Card.Id == CardId.WhiteStoneOfAncients
|| Card.Id == CardId.WhiteStoneOfLegend
))
return true; return true;
return false; return false;
} }
private bool SpellSet() private bool SpellSet()
{ {
return (Card.IsTrap() || (Card.Id==CardId.SilversCry)) && Bot.GetSpellCountWithoutField() < 4; return (Card.IsTrap() || Card.IsCode(CardId.SilversCry)) && Bot.GetSpellCountWithoutField() < 4;
} }
private bool HasTwoInHand(int id) private bool HasTwoInHand(int id)
...@@ -924,7 +900,7 @@ namespace WindBot.Game.AI.Decks ...@@ -924,7 +900,7 @@ namespace WindBot.Game.AI.Decks
int num = 0; int num = 0;
foreach (ClientCard card in Bot.Hand) foreach (ClientCard card in Bot.Hand)
{ {
if (card != null && card.Id == id) if (card != null && card.IsCode(id))
num++; num++;
} }
return num >= 2; return num >= 2;
......
This diff is collapsed.
...@@ -108,7 +108,7 @@ namespace WindBot.Game.AI.Decks ...@@ -108,7 +108,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard card in Bot.GetMonsters()) foreach (ClientCard card in Bot.GetMonsters())
{ {
if (card.Id == CardId.Marshmallon || card.Id == CardId.SpiritReaper) if (card.IsCode(CardId.Marshmallon, CardId.SpiritReaper))
{ {
return false; return false;
} }
...@@ -134,9 +134,9 @@ namespace WindBot.Game.AI.Decks ...@@ -134,9 +134,9 @@ namespace WindBot.Game.AI.Decks
private bool ReposEverything() private bool ReposEverything()
{ {
if (Card.Id == CardId.ReflectBounder) if (Card.IsCode(CardId.ReflectBounder))
return Card.IsDefense(); return Card.IsDefense();
if (Card.Id == CardId.FencingFireFerret) if (Card.IsCode(CardId.FencingFireFerret))
return DefaultMonsterRepos(); return DefaultMonsterRepos();
if (Card.IsAttack()) if (Card.IsAttack())
return true; return true;
......
...@@ -227,7 +227,7 @@ namespace WindBot.Game.AI.Decks ...@@ -227,7 +227,7 @@ namespace WindBot.Game.AI.Decks
{ {
return (id == CardId.SandaionTheTimelord || return (id == CardId.SandaionTheTimelord ||
id == CardId.BattleFader || id == CardId.BattleFader ||
id ==CardId.MichionTimelord id == CardId.MichionTimelord
); );
} }
bool no_sp = false; bool no_sp = false;
...@@ -322,49 +322,49 @@ namespace WindBot.Game.AI.Decks ...@@ -322,49 +322,49 @@ namespace WindBot.Game.AI.Decks
IList<ClientCard> check = Bot.GetSpells(); IList<ClientCard> check = Bot.GetSpells();
foreach (ClientCard card in check) foreach (ClientCard card in check)
{ {
if (card.Id == CardId.AccuulatedFortune) if (card.IsCode(CardId.AccuulatedFortune))
HasAccuulatedFortune++; HasAccuulatedFortune++;
} }
foreach (ClientCard card in check) foreach (ClientCard card in check)
{ {
if (card.Id == CardId.SecretBlast) if (card.IsCode(CardId.SecretBlast))
blast_count++; blast_count++;
} }
foreach (ClientCard card in check) foreach (ClientCard card in check)
{ {
if (card.Id == CardId.SectetBarrel) if (card.IsCode(CardId.SectetBarrel))
barrel_count++; barrel_count++;
} }
foreach (ClientCard card in check) foreach (ClientCard card in check)
{ {
if (card.Id == CardId.JustDesserts) if (card.IsCode(CardId.JustDesserts))
just_count++; just_count++;
} }
foreach (ClientCard card in check) foreach (ClientCard card in check)
{ {
if (card.Id == CardId.ChainStrike) if (card.IsCode(CardId.ChainStrike))
strike_count++; strike_count++;
} }
foreach (ClientCard card in Bot.GetSpells()) foreach (ClientCard card in Bot.GetSpells())
{ {
if (card.Id == CardId.RecklessGreed) if (card.IsCode(CardId.RecklessGreed))
greed_count++; greed_count++;
} }
foreach (ClientCard card in check) foreach (ClientCard card in check)
{ {
if (card.Id == CardId.Waboku) if (card.IsCode(CardId.Waboku))
Waboku_count++; Waboku_count++;
} }
foreach (ClientCard card in check) foreach (ClientCard card in check)
{ {
if (card.Id == CardId.ThreateningRoar) if (card.IsCode(CardId.ThreateningRoar))
Roar_count++; Roar_count++;
} }
...@@ -418,7 +418,7 @@ namespace WindBot.Game.AI.Decks ...@@ -418,7 +418,7 @@ namespace WindBot.Game.AI.Decks
if (AI.Utils.IsChainTarget(Card)) return true; if (AI.Utils.IsChainTarget(Card)) return true;
foreach (ClientCard card in Enemy.GetSpells()) foreach (ClientCard card in Enemy.GetSpells())
{ {
if (card.Id == CardId.HarpiesFeatherDuster&&card.IsFaceup()) if (card.IsCode(CardId.HarpiesFeatherDuster)&&card.IsFaceup())
{ {
return true; return true;
} }
...@@ -432,7 +432,7 @@ namespace WindBot.Game.AI.Decks ...@@ -432,7 +432,7 @@ namespace WindBot.Game.AI.Decks
} }
private bool BrunSpellSet() private bool BrunSpellSet()
{ {
if (Card.Id == CardId.OjamaTrio && Bot.HasInSpellZone(CardId.OjamaTrio))return false; if (Card.IsCode(CardId.OjamaTrio) && Bot.HasInSpellZone(CardId.OjamaTrio))return false;
return (Card.IsTrap() || Card.HasType(CardType.QuickPlay)) && Bot.GetSpellCountWithoutField() < 5; return (Card.IsTrap() || Card.HasType(CardType.QuickPlay)) && Bot.GetSpellCountWithoutField() < 5;
} }
private bool MichionTimelordsummon() private bool MichionTimelordsummon()
...@@ -565,7 +565,7 @@ namespace WindBot.Game.AI.Decks ...@@ -565,7 +565,7 @@ namespace WindBot.Game.AI.Decks
int count=0; int count=0;
foreach (ClientCard card in Bot.GetSpells()) foreach (ClientCard card in Bot.GetSpells())
{ {
if (card.Id == CardId.RecklessGreed) if (card.IsCode(CardId.RecklessGreed))
count++; count++;
} }
...@@ -668,7 +668,7 @@ namespace WindBot.Game.AI.Decks ...@@ -668,7 +668,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard card in Bot.GetMonsters()) foreach (ClientCard card in Bot.GetMonsters())
{ {
if (card.Id == CardId.CardcarD && card.IsFaceup()) if (card.IsCode(CardId.CardcarD) && card.IsFaceup())
return false; return false;
} }
if (Bot.GetHandCount() == 1 && Bot.GetSpellCountWithoutField() <= 3) if (Bot.GetHandCount() == 1 && Bot.GetSpellCountWithoutField() <= 3)
...@@ -694,7 +694,7 @@ namespace WindBot.Game.AI.Decks ...@@ -694,7 +694,7 @@ namespace WindBot.Game.AI.Decks
foreach (ClientCard card in Bot.GetMonsters()) foreach (ClientCard card in Bot.GetMonsters())
{ {
if (card.Id == CardId.DiceJar && card.IsFacedown()) if (card.IsCode(CardId.DiceJar) && card.IsFacedown())
return true; return true;
break; break;
} }
...@@ -725,24 +725,24 @@ namespace WindBot.Game.AI.Decks ...@@ -725,24 +725,24 @@ namespace WindBot.Game.AI.Decks
if (GetTotalATK(newlist) / 2 >= Enemy.LifePoints && Bot.HasInSpellZone(CardId.BlazingMirrorForce)) if (GetTotalATK(newlist) / 2 >= Enemy.LifePoints && Bot.HasInSpellZone(CardId.BlazingMirrorForce))
return false; return false;
if (AI.Utils.GetLastChainCard() == null) return true; if (AI.Utils.GetLastChainCard() == null) return true;
if (AI.Utils.GetLastChainCard().Id == CardId.Linkuriboh) return false; if (AI.Utils.GetLastChainCard().IsCode(CardId.Linkuriboh)) return false;
return true; return true;
} }
public bool MonsterRepos() public bool MonsterRepos()
{ {
if (Card.IsFacedown() && Card.Id!=CardId.DiceJar) if (Card.IsFacedown() && !Card.IsCode(CardId.DiceJar))
return true; return true;
return base.DefaultMonsterRepos(); return base.DefaultMonsterRepos();
} }
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender) public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
{ {
if (attacker.Id == CardId.Linkuriboh && defender.IsFacedown()) return false; if (attacker.IsCode(CardId.Linkuriboh) && defender.IsFacedown()) return false;
if (attacker.Id == CardId.SandaionTheTimelord && !attacker.IsDisabled()) if (attacker.IsCode(CardId.SandaionTheTimelord) && !attacker.IsDisabled())
{ {
attacker.RealPower = 9999; attacker.RealPower = 9999;
return true; return true;
} }
if(attacker.Id==CardId.MichionTimelord && !attacker.IsDisabled()) if(attacker.IsCode(CardId.MichionTimelord) && !attacker.IsDisabled())
{ {
attacker.RealPower = 9999; attacker.RealPower = 9999;
return true; return true;
...@@ -771,49 +771,49 @@ namespace WindBot.Game.AI.Decks ...@@ -771,49 +771,49 @@ namespace WindBot.Game.AI.Decks
IList<ClientCard> check = Bot.GetSpells(); IList<ClientCard> check = Bot.GetSpells();
foreach (ClientCard card1 in check) foreach (ClientCard card1 in check)
{ {
if (card1.Id == CardId.AccuulatedFortune) if (card1.IsCode(CardId.AccuulatedFortune))
HasAccuulatedFortune++; HasAccuulatedFortune++;
} }
foreach (ClientCard card1 in check) foreach (ClientCard card1 in check)
{ {
if (card1.Id == CardId.SecretBlast) if (card1.IsCode(CardId.SecretBlast))
blast_count++; blast_count++;
} }
foreach (ClientCard card1 in check) foreach (ClientCard card1 in check)
{ {
if (card1.Id == CardId.SectetBarrel) if (card1.IsCode(CardId.SectetBarrel))
barrel_count++; barrel_count++;
} }
foreach (ClientCard card1 in check) foreach (ClientCard card1 in check)
{ {
if (card1.Id == CardId.JustDesserts) if (card1.IsCode(CardId.JustDesserts))
just_count++; just_count++;
} }
foreach (ClientCard card1 in check) foreach (ClientCard card1 in check)
{ {
if (card1.Id == CardId.ChainStrike) if (card1.IsCode(CardId.ChainStrike))
strike_count++; strike_count++;
} }
foreach (ClientCard card1 in Bot.GetSpells()) foreach (ClientCard card1 in Bot.GetSpells())
{ {
if (card1.Id == CardId.RecklessGreed) if (card1.IsCode(CardId.RecklessGreed))
greed_count++; greed_count++;
} }
foreach (ClientCard card1 in check) foreach (ClientCard card1 in check)
{ {
if (card1.Id == CardId.Waboku) if (card1.IsCode(CardId.Waboku))
Waboku_count++; Waboku_count++;
} }
foreach (ClientCard card1 in check) foreach (ClientCard card1 in check)
{ {
if (card1.Id == CardId.ThreateningRoar) if (card1.IsCode(CardId.ThreateningRoar))
Roar_count++; Roar_count++;
} }
......
This diff is collapsed.
...@@ -136,7 +136,7 @@ namespace WindBot.Game.AI.Decks ...@@ -136,7 +136,7 @@ namespace WindBot.Game.AI.Decks
int count = 0; int count = 0;
foreach (ClientCard card in Bot.Hand) foreach (ClientCard card in Bot.Hand)
{ {
if (card.Id == CardId.DragunityDux) if (card.IsCode(CardId.DragunityDux))
++count; ++count;
} }
if (count >= 2) if (count >= 2)
...@@ -164,7 +164,7 @@ namespace WindBot.Game.AI.Decks ...@@ -164,7 +164,7 @@ namespace WindBot.Game.AI.Decks
/*bool hasRealMonster = false; /*bool hasRealMonster = false;
foreach (ClientCard card in Bot.GetMonsters()) foreach (ClientCard card in Bot.GetMonsters())
{ {
if (card.Id != CardId.AssaultBeast) if (!card.IsCode(CardId.AssaultBeast))
{ {
hasRealMonster = true; hasRealMonster = true;
break; break;
...@@ -184,13 +184,13 @@ namespace WindBot.Game.AI.Decks ...@@ -184,13 +184,13 @@ namespace WindBot.Game.AI.Decks
int remaining = 3; int remaining = 3;
foreach (ClientCard card in Bot.Hand) foreach (ClientCard card in Bot.Hand)
if (card.Id == needId) if (card.IsCode(needId))
remaining--; remaining--;
foreach (ClientCard card in Bot.Graveyard) foreach (ClientCard card in Bot.Graveyard)
if (card.Id == needId) if (card.IsCode(needId))
remaining--; remaining--;
foreach (ClientCard card in Bot.Banished) foreach (ClientCard card in Bot.Banished)
if (card.Id == needId) if (card.IsCode(needId))
remaining--; remaining--;
if (remaining <= 0) if (remaining <= 0)
return false; return false;
...@@ -262,8 +262,7 @@ namespace WindBot.Game.AI.Decks ...@@ -262,8 +262,7 @@ namespace WindBot.Game.AI.Decks
ClientCard card = cards[i]; ClientCard card = cards[i];
if (card.Attack < 2000) if (card.Attack < 2000)
break; break;
if (card.Id == (int) CardId.StardustDragonAssaultMode || if (card.IsCode(CardId.StardustDragonAssaultMode, CardId.FiveHeadedDragon))
card.Id == (int) CardId.FiveHeadedDragon)
continue; continue;
if (card.IsMonster()) if (card.IsMonster())
{ {
...@@ -298,7 +297,7 @@ namespace WindBot.Game.AI.Decks ...@@ -298,7 +297,7 @@ namespace WindBot.Game.AI.Decks
int phalanxCount = 0; int phalanxCount = 0;
foreach (ClientCard card in Bot.Graveyard) foreach (ClientCard card in Bot.Graveyard)
{ {
if (card.Id == (int) CardId.DragunityPhalanx) if (card.IsCode(CardId.DragunityPhalanx))
{ {
phalanxCount++; phalanxCount++;
break; break;
...@@ -315,7 +314,7 @@ namespace WindBot.Game.AI.Decks ...@@ -315,7 +314,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard card in Bot.Graveyard) foreach (ClientCard card in Bot.Graveyard)
{ {
if (card.Id == (int) CardId.DragunityPhalanx) if (card.IsCode(CardId.DragunityPhalanx))
{ {
phalanxCount--; phalanxCount--;
tributes.Add(card); tributes.Add(card);
...@@ -462,7 +461,7 @@ namespace WindBot.Game.AI.Decks ...@@ -462,7 +461,7 @@ namespace WindBot.Game.AI.Decks
List<ClientCard> monsters = Bot.GetMonsters(); List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters) foreach (ClientCard monster in monsters)
{ {
if (monster.Id == CardId.StardustDragon && monster.Attacked) if (monster.IsCode(CardId.StardustDragon) && monster.Attacked)
{ {
AI.SelectCard(monster); AI.SelectCard(monster);
return true; return true;
......
...@@ -147,7 +147,7 @@ namespace WindBot.Game.AI.Decks ...@@ -147,7 +147,7 @@ namespace WindBot.Game.AI.Decks
if (AI.Utils.IsOneEnemyBetterThanValue(atk, true)) if (AI.Utils.IsOneEnemyBetterThanValue(atk, true))
return false; return false;
if (Card.Id == CardId.SwapFrog) if (Card.IsCode(CardId.SwapFrog))
m_swapFrogSummoned = Duel.Turn; m_swapFrogSummoned = Duel.Turn;
return true; return true;
} }
...@@ -200,7 +200,7 @@ namespace WindBot.Game.AI.Decks ...@@ -200,7 +200,7 @@ namespace WindBot.Game.AI.Decks
List<ClientCard> spells = Bot.GetSpells(); List<ClientCard> spells = Bot.GetSpells();
foreach (ClientCard spell in spells) foreach (ClientCard spell in spells)
{ {
if (spell.Id == CardId.GravityBind && !spell.IsFacedown()) if (spell.IsCode(CardId.GravityBind) && !spell.IsFacedown())
return false; return false;
} }
return true; return true;
...@@ -208,9 +208,9 @@ namespace WindBot.Game.AI.Decks ...@@ -208,9 +208,9 @@ namespace WindBot.Game.AI.Decks
private bool FrogMonsterRepos() private bool FrogMonsterRepos()
{ {
if (Card.Id == CardId.Unifrog) if (Card.IsCode(CardId.Unifrog))
return Card.IsDefense(); return Card.IsDefense();
if (Card.Id == CardId.DewdarkOfTheIceBarrier) if (Card.IsCode(CardId.DewdarkOfTheIceBarrier))
return Card.IsDefense(); return Card.IsDefense();
bool enemyBetter = AI.Utils.IsOneEnemyBetterThanValue(Card.Attack + (Card.IsFacedown() ? GetSpellBonus() : 0), true); bool enemyBetter = AI.Utils.IsOneEnemyBetterThanValue(Card.Attack + (Card.IsFacedown() ? GetSpellBonus() : 0), true);
...@@ -222,10 +222,10 @@ namespace WindBot.Game.AI.Decks ...@@ -222,10 +222,10 @@ namespace WindBot.Game.AI.Decks
if (Card.IsDefense() && !enemyBetter) if (Card.IsDefense() && !enemyBetter)
result = true; result = true;
if (!result && Card.Id == CardId.FlipFlopFrog && Enemy.GetMonsterCount() > 0 && Card.IsFacedown()) if (!result && Card.IsCode(CardId.FlipFlopFrog) && Enemy.GetMonsterCount() > 0 && Card.IsFacedown())
result = true; result = true;
if (Card.Id == CardId.FlipFlopFrog && Card.IsFacedown() && result) if (Card.IsCode(CardId.FlipFlopFrog) && Card.IsFacedown() && result)
m_flipFlopFrogSummoned = Duel.Turn; m_flipFlopFrogSummoned = Duel.Turn;
return result; return result;
...@@ -242,7 +242,7 @@ namespace WindBot.Game.AI.Decks ...@@ -242,7 +242,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard card in Bot.GetSpells()) foreach (ClientCard card in Bot.GetSpells())
{ {
if (card.Id == CardId.Solidarity) if (card.IsCode(CardId.Solidarity))
atk += 800; atk += 800;
} }
} }
......
...@@ -251,21 +251,21 @@ namespace WindBot.Game.AI.Decks ...@@ -251,21 +251,21 @@ namespace WindBot.Game.AI.Decks
private bool DarkBribeeff() private bool DarkBribeeff()
{ {
if (AI.Utils.GetLastChainCard()!=null && AI.Utils.GetLastChainCard().Id == CardId.UpstartGoblin) if (AI.Utils.GetLastChainCard()!=null && AI.Utils.GetLastChainCard().IsCode(CardId.UpstartGoblin))
return false; return false;
return true; return true;
} }
private bool ImperialOrderfirst() private bool ImperialOrderfirst()
{ {
if (AI.Utils.GetLastChainCard() != null && AI.Utils.GetLastChainCard().Id == CardId.UpstartGoblin) if (AI.Utils.GetLastChainCard() != null && AI.Utils.GetLastChainCard().IsCode(CardId.UpstartGoblin))
return false; return false;
return DefaultOnBecomeTarget() && AI.Utils.GetLastChainCard().HasType(CardType.Spell); return DefaultOnBecomeTarget() && AI.Utils.GetLastChainCard().HasType(CardType.Spell);
} }
private bool ImperialOrdereff() private bool ImperialOrdereff()
{ {
if (AI.Utils.GetLastChainCard() != null && AI.Utils.GetLastChainCard().Id == CardId.UpstartGoblin) if (AI.Utils.GetLastChainCard() != null && AI.Utils.GetLastChainCard().IsCode(CardId.UpstartGoblin))
return false; return false;
if (Duel.LastChainPlayer == 1) if (Duel.LastChainPlayer == 1)
{ {
...@@ -437,7 +437,7 @@ namespace WindBot.Game.AI.Decks ...@@ -437,7 +437,7 @@ namespace WindBot.Game.AI.Decks
IList<ClientCard> material_list = new List<ClientCard>(); IList<ClientCard> material_list = new List<ClientCard>();
foreach (ClientCard monster in Bot.GetMonsters()) foreach (ClientCard monster in Bot.GetMonsters())
{ {
if (monster.Id ==CardId.MissusRadiant || monster.Id==CardId.LinkSpider || monster.Id==CardId.Linkuriboh) if (monster.IsCode(CardId.MissusRadiant, CardId.LinkSpider, CardId.Linkuriboh))
material_list.Add(monster); material_list.Add(monster);
if (material_list.Count == 3) break; if (material_list.Count == 3) break;
} }
...@@ -454,10 +454,7 @@ namespace WindBot.Game.AI.Decks ...@@ -454,10 +454,7 @@ namespace WindBot.Game.AI.Decks
IList<ClientCard> material_list = new List<ClientCard>(); IList<ClientCard> material_list = new List<ClientCard>();
foreach (ClientCard monster in Bot.GetMonsters()) foreach (ClientCard monster in Bot.GetMonsters())
{ {
if ((monster.Id == CardId.MissusRadiant || if (monster.IsCode(CardId.MissusRadiant, CardId.LinkSpider, CardId.Linkuriboh))
monster.Id == CardId.LinkSpider ||
monster.Id == CardId.Linkuriboh )&&
monster.Id!=CardId.EaterOfMillions)
material_list.Add(monster); material_list.Add(monster);
if (material_list.Count == 3) break; if (material_list.Count == 3) break;
} }
...@@ -559,7 +556,7 @@ namespace WindBot.Game.AI.Decks ...@@ -559,7 +556,7 @@ namespace WindBot.Game.AI.Decks
IList<ClientCard> material_list = new List<ClientCard>(); IList<ClientCard> material_list = new List<ClientCard>();
foreach (ClientCard monster in Bot.GetMonsters()) foreach (ClientCard monster in Bot.GetMonsters())
{ {
if (monster.HasAttribute(CardAttribute.Earth) && monster.Level==1 && monster.Id!=CardId.EaterOfMillions) if (monster.HasAttribute(CardAttribute.Earth) && monster.Level==1 && !monster.IsCode(CardId.EaterOfMillions))
material_list.Add(monster); material_list.Add(monster);
if (material_list.Count == 2) break; if (material_list.Count == 2) break;
} }
...@@ -587,7 +584,7 @@ namespace WindBot.Game.AI.Decks ...@@ -587,7 +584,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard c in Bot.GetMonsters()) foreach (ClientCard c in Bot.GetMonsters())
{ {
if (c.Id != CardId.EaterOfMillions && c.Id != CardId.Linkuriboh && c.Level==1 ) if (!c.IsCode(CardId.EaterOfMillions, CardId.Linkuriboh) && c.Level==1)
{ {
AI.SelectMaterials(c); AI.SelectMaterials(c);
return true; return true;
...@@ -598,12 +595,12 @@ namespace WindBot.Game.AI.Decks ...@@ -598,12 +595,12 @@ namespace WindBot.Game.AI.Decks
private bool Linkuriboheff() private bool Linkuriboheff()
{ {
if (Duel.LastChainPlayer == 0 && AI.Utils.GetLastChainCard().Id == CardId.Linkuriboh) return false; if (Duel.LastChainPlayer == 0 && AI.Utils.GetLastChainCard().IsCode(CardId.Linkuriboh)) return false;
return true; return true;
} }
private bool MonsterRepos() private bool MonsterRepos()
{ {
if (Card.Id == CardId.EaterOfMillions && Card.IsAttack()) return false; if (Card.IsCode(CardId.EaterOfMillions) && Card.IsAttack()) return false;
return DefaultMonsterRepos(); return DefaultMonsterRepos();
} }
...@@ -612,29 +609,29 @@ namespace WindBot.Game.AI.Decks ...@@ -612,29 +609,29 @@ namespace WindBot.Game.AI.Decks
int count = 0; int count = 0;
foreach(ClientCard check in Bot.Hand) foreach(ClientCard check in Bot.Hand)
{ {
if (check.Id == CardId.CardOfDemise) if (check.IsCode(CardId.CardOfDemise))
count++; count++;
} }
if (count == 2 && Bot.Hand.Count == 2 && Bot.GetSpellCountWithoutField() <= 2) if (count == 2 && Bot.Hand.Count == 2 && Bot.GetSpellCountWithoutField() <= 2)
return true; return true;
if (Card.Id == CardId.MacroCosmos && Bot.HasInSpellZone(CardId.MacroCosmos)) return false; if (Card.IsCode(CardId.MacroCosmos) && Bot.HasInSpellZone(CardId.MacroCosmos)) return false;
if (Card.Id == CardId.AntiSpellFragrance && Bot.HasInSpellZone(CardId.AntiSpellFragrance)) return false; if (Card.IsCode(CardId.AntiSpellFragrance) && Bot.HasInSpellZone(CardId.AntiSpellFragrance)) return false;
if (CardOfDemiseeff_used)return true; if (CardOfDemiseeff_used)return true;
if (Card.Id == CardId.EvenlyMatched && (Enemy.GetFieldCount() - Bot.GetFieldCount()) < 0) return false; if (Card.IsCode(CardId.EvenlyMatched) && (Enemy.GetFieldCount() - Bot.GetFieldCount()) < 0) return false;
if (Card.Id == CardId.AntiSpellFragrance && Bot.HasInSpellZone(CardId.AntiSpellFragrance)) return false; if (Card.IsCode(CardId.AntiSpellFragrance) && Bot.HasInSpellZone(CardId.AntiSpellFragrance)) return false;
if (Card.Id == CardId.MacroCosmos && Bot.HasInSpellZone(CardId.MacroCosmos)) return false; if (Card.IsCode(CardId.MacroCosmos) && Bot.HasInSpellZone(CardId.MacroCosmos)) return false;
if (Duel.Turn > 1 && Duel.Phase == DuelPhase.Main1 && Bot.HasAttackingMonster()) if (Duel.Turn > 1 && Duel.Phase == DuelPhase.Main1 && Bot.HasAttackingMonster())
return false; return false;
if (Card.Id == CardId.InfiniteImpermanence) if (Card.IsCode(CardId.InfiniteImpermanence))
return Bot.GetFieldCount() > 0 && Bot.GetSpellCountWithoutField() < 4; return Bot.GetFieldCount() > 0 && Bot.GetSpellCountWithoutField() < 4;
if (Card.Id == CardId.Scapegoat) if (Card.IsCode(CardId.Scapegoat))
return true; return true;
if (Card.HasType(CardType.Trap)) if (Card.HasType(CardType.Trap))
return Bot.GetSpellCountWithoutField() < 4; return Bot.GetSpellCountWithoutField() < 4;
if(Bot.HasInSpellZone(CardId.AntiSpellFragrance,true)) if(Bot.HasInSpellZone(CardId.AntiSpellFragrance,true))
{ {
if (Card.Id == CardId.UpstartGoblin || Card.Id == CardId.PotOfDesires || Card.Id==CardId.PotOfDuality) return true; if (Card.IsCode(CardId.UpstartGoblin, CardId.PotOfDesires, CardId.PotOfDuality)) return true;
if (Card.Id == CardId.CardOfDemise && Bot.HasInSpellZone(CardId.CardOfDemise)) return false; if (Card.IsCode(CardId.CardOfDemise) && Bot.HasInSpellZone(CardId.CardOfDemise)) return false;
if (Card.HasType(CardType.Spell)) if (Card.HasType(CardType.Spell))
return Bot.GetSpellCountWithoutField() < 4; return Bot.GetSpellCountWithoutField() < 4;
} }
...@@ -642,12 +639,12 @@ namespace WindBot.Game.AI.Decks ...@@ -642,12 +639,12 @@ namespace WindBot.Game.AI.Decks
} }
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender) public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
{ {
if (attacker.Id == _CardId.EaterOfMillions && (Bot.HasInMonstersZone(CardId.InspectBoarder) && eater_eff) && !attacker.IsDisabled()) if (attacker.IsCode(_CardId.EaterOfMillions) && (Bot.HasInMonstersZone(CardId.InspectBoarder) && eater_eff) && !attacker.IsDisabled())
{ {
attacker.RealPower = 9999; attacker.RealPower = 9999;
return true; return true;
} }
if (attacker.Id == _CardId.EaterOfMillions && !Bot.HasInMonstersZone(CardId.InspectBoarder) && !attacker.IsDisabled()) if (attacker.IsCode(_CardId.EaterOfMillions) && !Bot.HasInMonstersZone(CardId.InspectBoarder) && !attacker.IsDisabled())
{ {
attacker.RealPower = 9999; attacker.RealPower = 9999;
return true; return true;
...@@ -659,7 +656,7 @@ namespace WindBot.Game.AI.Decks ...@@ -659,7 +656,7 @@ namespace WindBot.Game.AI.Decks
for (int i = 0; i < attackers.Count; ++i) for (int i = 0; i < attackers.Count; ++i)
{ {
ClientCard attacker = attackers[i]; ClientCard attacker = attackers[i];
if (attacker.Id == CardId.BirrelswordDragon || attacker.Id == CardId.EaterOfMillions) return attacker; if (attacker.IsCode(CardId.BirrelswordDragon, CardId.EaterOfMillions)) return attacker;
} }
return null; return null;
} }
......
...@@ -79,7 +79,7 @@ namespace WindBot.Game.AI.Decks ...@@ -79,7 +79,7 @@ namespace WindBot.Game.AI.Decks
return false; return false;
int remaining = 2; int remaining = 2;
foreach (ClientCard card in Bot.Banished) foreach (ClientCard card in Bot.Banished)
if (card.Id == CardId.WhiteNightDragon) if (card.IsCode(CardId.WhiteNightDragon))
remaining--; remaining--;
if (remaining > 0) if (remaining > 0)
{ {
...@@ -154,7 +154,7 @@ namespace WindBot.Game.AI.Decks ...@@ -154,7 +154,7 @@ namespace WindBot.Game.AI.Decks
// We should summon Horus the Black Flame Dragon LV6 if he can lvlup. // We should summon Horus the Black Flame Dragon LV6 if he can lvlup.
if (Enemy.GetMonsterCount() != 0 && !AI.Utils.IsAllEnemyBetterThanValue(2300 - 1, false)) if (Enemy.GetMonsterCount() != 0 && !AI.Utils.IsAllEnemyBetterThanValue(2300 - 1, false))
foreach (ClientCard card in Main.SummonableCards) foreach (ClientCard card in Main.SummonableCards)
if (card.Id == 11224103) if (card.IsCode(11224103))
return false; return false;
return DefaultTributeSummon(); return DefaultTributeSummon();
...@@ -197,7 +197,7 @@ namespace WindBot.Game.AI.Decks ...@@ -197,7 +197,7 @@ namespace WindBot.Game.AI.Decks
ClientCard monster = cards[i]; ClientCard monster = cards[i];
if (monster.Attack < 2300) if (monster.Attack < 2300)
return false; return false;
if (monster.Race == (int)CardRace.Dragon && monster.Id != CardId.HorusTheBlackFlameDragonLv8) if (monster.Race == (int)CardRace.Dragon && !monster.IsCode(CardId.HorusTheBlackFlameDragonLv8))
{ {
summonCard = monster; summonCard = monster;
break; break;
......
...@@ -91,6 +91,7 @@ namespace WindBot.Game.AI.Decks ...@@ -91,6 +91,7 @@ namespace WindBot.Game.AI.Decks
public override void OnNewTurn() public override void OnNewTurn()
{ {
ClownUsed = false; ClownUsed = false;
base.OnNewTurn();
} }
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender) public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
...@@ -109,13 +110,13 @@ namespace WindBot.Game.AI.Decks ...@@ -109,13 +110,13 @@ namespace WindBot.Game.AI.Decks
IList<ClientCard> result = new List<ClientCard>(); IList<ClientCard> result = new List<ClientCard>();
foreach (ClientCard card in cards) foreach (ClientCard card in cards)
{ {
if (!result.Contains(card) && (!ClownUsed || card.Id != CardId.PerformageTrickClown)) if (!result.Contains(card) && (!ClownUsed || !card.IsCode(CardId.PerformageTrickClown)))
result.Add(card); result.Add(card);
if (result.Count >= max) if (result.Count >= max)
break; break;
} }
AI.Utils.CheckSelectCount(result, cards, min, max);
return result; return AI.Utils.CheckSelectCount(result, cards, min, max);
} }
private bool ReinforcementOfTheArmyEffect() private bool ReinforcementOfTheArmyEffect()
......
...@@ -353,13 +353,13 @@ namespace WindBot.Game.AI.Decks ...@@ -353,13 +353,13 @@ namespace WindBot.Game.AI.Decks
} }
return false; return false;
} }
private bool GamecieltheSeaTurtleKaijusp() private bool GamecieltheSeaTurtleKaijusp()
{ {
if (!Bot.HasInMonstersZone(CardId.UltimateConductorTytanno)) if (!Bot.HasInMonstersZone(CardId.UltimateConductorTytanno))
return DefaultKaijuSpsummon(); return DefaultKaijuSpsummon();
return false; return false;
} }
private bool RadiantheMultidimensionalKaijusp() private bool RadiantheMultidimensionalKaijusp()
...@@ -390,7 +390,7 @@ namespace WindBot.Game.AI.Decks ...@@ -390,7 +390,7 @@ namespace WindBot.Game.AI.Decks
Pillused = true; Pillused = true;
foreach (ClientCard card in Bot.GetMonsters()) foreach (ClientCard card in Bot.GetMonsters())
{ {
if (card.Id == CardId.UltimateConductorTytanno && card.IsFaceup()) if (card.IsCode(CardId.UltimateConductorTytanno) && card.IsFaceup())
return false; return false;
} }
Ultimate_ss++; Ultimate_ss++;
...@@ -409,13 +409,13 @@ namespace WindBot.Game.AI.Decks ...@@ -409,13 +409,13 @@ namespace WindBot.Game.AI.Decks
} }
private bool MonsterRepos() private bool MonsterRepos()
{ {
if (Card.Id == CardId.UltimateConductorTytanno && Card.IsFacedown()) return true; if (Card.IsCode(CardId.UltimateConductorTytanno) && Card.IsFacedown()) return true;
if (Card.Id == CardId.ElShaddollConstruct && Card.IsFacedown()) return true; if (Card.IsCode(CardId.ElShaddollConstruct) && Card.IsFacedown()) return true;
if (Card.Id == CardId.ElShaddollConstruct && Card.IsAttack()) return false; if (Card.IsCode(CardId.ElShaddollConstruct) && Card.IsAttack()) return false;
if (Card.Id == CardId.GlowUpBulb && Card.IsDefense()) return false; if (Card.IsCode(CardId.GlowUpBulb) && Card.IsDefense()) return false;
if (Card.Id == CardId.ShaddollDragon && Card.IsFacedown() && Enemy.GetMonsterCount() >= 0) return true; if (Card.IsCode(CardId.ShaddollDragon) && Card.IsFacedown() && Enemy.GetMonsterCount() >= 0) return true;
if (Card.Id == CardId.ShaddollSquamata && Card.IsFacedown() && Enemy.GetMonsterCount() >= 0) return true; if (Card.IsCode(CardId.ShaddollSquamata) && Card.IsFacedown() && Enemy.GetMonsterCount() >= 0) return true;
return base.DefaultMonsterRepos(); return base.DefaultMonsterRepos();
} }
...@@ -430,7 +430,7 @@ namespace WindBot.Game.AI.Decks ...@@ -430,7 +430,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard card in Bot.GetMonsters()) foreach (ClientCard card in Bot.GetMonsters())
{ {
if (card.Id == CardId.UltimateConductorTytanno && card.IsFaceup()) if (card.IsCode(CardId.UltimateConductorTytanno) && card.IsFaceup())
return false; return false;
} }
if (Pillused == true) return false; if (Pillused == true) return false;
...@@ -526,8 +526,8 @@ namespace WindBot.Game.AI.Decks ...@@ -526,8 +526,8 @@ namespace WindBot.Game.AI.Decks
private bool FairyTailSnowsummon() private bool FairyTailSnowsummon()
{ {
ClientCard target = AI.Utils.GetBestEnemyMonster(true, true); ClientCard target = AI.Utils.GetBestEnemyMonster(true, true);
if(target != null) if(target != null)
{ {
return true; return true;
...@@ -549,13 +549,13 @@ namespace WindBot.Game.AI.Decks ...@@ -549,13 +549,13 @@ namespace WindBot.Game.AI.Decks
int spell_count = 0; int spell_count = 0;
IList<ClientCard> grave = Bot.Graveyard; IList<ClientCard> grave = Bot.Graveyard;
IList<ClientCard> all = new List<ClientCard>(); IList<ClientCard> all = new List<ClientCard>();
foreach (ClientCard check in grave) foreach (ClientCard check in grave)
{ {
if (check.Id == CardId.GiantRex) if (check.IsCode(CardId.GiantRex))
{ {
all.Add(check); all.Add(check);
} }
} }
foreach (ClientCard check in grave) foreach (ClientCard check in grave)
{ {
...@@ -572,8 +572,8 @@ namespace WindBot.Game.AI.Decks ...@@ -572,8 +572,8 @@ namespace WindBot.Game.AI.Decks
all.Add(check); all.Add(check);
} }
} }
if (AI.Utils.ChainContainsCard(CardId.FairyTailSnow)) return false; if (AI.Utils.ChainContainsCard(CardId.FairyTailSnow)) return false;
if ( Duel.Player == 1 && Duel.Phase == DuelPhase.BattleStart && Bot.BattlingMonster == null && Enemy_atk >=Bot.LifePoints || if ( Duel.Player == 1 && Duel.Phase == DuelPhase.BattleStart && Bot.BattlingMonster == null && Enemy_atk >=Bot.LifePoints ||
Duel.Player == 0 && Duel.Phase==DuelPhase.BattleStart && Enemy.BattlingMonster == null && Enemy.LifePoints<=1850 Duel.Player == 0 && Duel.Phase==DuelPhase.BattleStart && Enemy.BattlingMonster == null && Enemy.LifePoints<=1850
) )
...@@ -590,9 +590,9 @@ namespace WindBot.Game.AI.Decks ...@@ -590,9 +590,9 @@ namespace WindBot.Game.AI.Decks
private bool SouleatingOviraptoreff() private bool SouleatingOviraptoreff()
{ {
if (!OvertexCoatlseff_used && Bot.GetRemainingCount(CardId.OvertexCoatls, 3) > 0) if (!OvertexCoatlseff_used && Bot.GetRemainingCount(CardId.OvertexCoatls, 3) > 0)
{ {
AI.SelectCard(CardId.OvertexCoatls); AI.SelectCard(CardId.OvertexCoatls);
AI.SelectOption(0); AI.SelectOption(0);
} }
else else
{ {
...@@ -992,7 +992,7 @@ namespace WindBot.Game.AI.Decks ...@@ -992,7 +992,7 @@ namespace WindBot.Game.AI.Decks
private bool LostWindeff() private bool LostWindeff()
{ {
if (Card.Location == CardLocation.Grave) if (Card.Location == CardLocation.Grave)
return true; return true;
List<ClientCard> check = Enemy.GetMonsters(); List<ClientCard> check = Enemy.GetMonsters();
foreach (ClientCard m in check) foreach (ClientCard m in check)
...@@ -1030,8 +1030,8 @@ namespace WindBot.Game.AI.Decks ...@@ -1030,8 +1030,8 @@ namespace WindBot.Game.AI.Decks
public bool Hand_act_eff() public bool Hand_act_eff()
{ {
//if (Card.Id == CardId.Urara && Bot.HasInHand(CardId.LockBird) && Bot.HasInSpellZone(CardId.Re)) return false; //if (Card.IsCode(CardId.Urara) && Bot.HasInHand(CardId.LockBird) && Bot.HasInSpellZone(CardId.Re)) return false;
if (Card.Id == CardId.GhostOgre && Card.Location == CardLocation.Hand && Bot.HasInMonstersZone(CardId.GhostOgre)) return false; if (Card.IsCode(CardId.GhostOgre) && Card.Location == CardLocation.Hand && Bot.HasInMonstersZone(CardId.GhostOgre)) return false;
return (Duel.LastChainPlayer == 1); return (Duel.LastChainPlayer == 1);
} }
//other extra //other extra
...@@ -1128,14 +1128,8 @@ namespace WindBot.Game.AI.Decks ...@@ -1128,14 +1128,8 @@ namespace WindBot.Game.AI.Decks
}; };
int count=0; int count=0;
foreach (ClientCard monster in Bot.GetMonsters()) foreach (ClientCard monster in Bot.GetMonsters())
if (monster.Id == CardId.GlowUpBulb || if (monster.IsCode(CardId.GlowUpBulb, CardId.FairyTailSnow, CardId.KeeperOfDragonicMagic,
monster.Id == CardId.FairyTailSnow || CardId.SouleatingOviraptor, CardId.GiantRex, CardId.Lumina, CardId.Raiden))
monster.Id == CardId.KeeperOfDragonicMagic ||
monster.Id == CardId.SouleatingOviraptor||
monster.Id == CardId.GiantRex||
monster.Id == CardId.Lumina||
monster.Id == CardId.Raiden
)
count++; count++;
if (!Bot.HasInMonstersZone(CardId.GlowUpBulb) || count<2) if (!Bot.HasInMonstersZone(CardId.GlowUpBulb) || count<2)
return false; return false;
...@@ -1150,7 +1144,7 @@ namespace WindBot.Game.AI.Decks ...@@ -1150,7 +1144,7 @@ namespace WindBot.Game.AI.Decks
bool DarkHole = false; bool DarkHole = false;
foreach (ClientCard card in Enemy.GetSpells()) foreach (ClientCard card in Enemy.GetSpells())
{ {
if (card.Id == 53129443 && card.IsFaceup()) if (card.IsCode(53129443) && card.IsFaceup())
{ {
DarkHole = true; DarkHole = true;
} }
...@@ -1222,12 +1216,12 @@ namespace WindBot.Game.AI.Decks ...@@ -1222,12 +1216,12 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard hand in Bot.Hand) foreach (ClientCard hand in Bot.Hand)
{ {
if (hand.Id == CardId.Red || hand.Id == CardId.Pink) if (hand.IsCode(CardId.Red, CardId.Pink))
{ {
AI.SelectCard(hand); AI.SelectCard(hand);
return true; return true;
} }
if (hand.Id == CardId.Urara || hand.Id == CardId.Ghost) if (hand.IsCode(CardId.Urara, CardId.Ghost))
{ {
if (Tuner_ss()) if (Tuner_ss())
{ {
...@@ -1261,7 +1255,7 @@ namespace WindBot.Game.AI.Decks ...@@ -1261,7 +1255,7 @@ namespace WindBot.Game.AI.Decks
private bool RedWyverneff() private bool RedWyverneff()
{ {
IList<ClientCard> check = Enemy.MonsterZone; IList<ClientCard> check = Enemy.GetMonsters();
ClientCard best = null; ClientCard best = null;
foreach (ClientCard monster in check) foreach (ClientCard monster in check)
{ {
...@@ -1304,9 +1298,9 @@ namespace WindBot.Game.AI.Decks ...@@ -1304,9 +1298,9 @@ namespace WindBot.Game.AI.Decks
{ {
if (!defender.IsMonsterHasPreventActivationEffectInBattle()) if (!defender.IsMonsterHasPreventActivationEffectInBattle())
{ {
if (attacker.Id == CardId.ElShaddollConstruct && !attacker.IsDisabled()) // TODO: && defender.IsSpecialSummoned if (attacker.IsCode(CardId.ElShaddollConstruct) && !attacker.IsDisabled()) // TODO: && defender.IsSpecialSummoned
attacker.RealPower = 9999; attacker.RealPower = 9999;
if (attacker.Id == CardId.UltimateConductorTytanno && !attacker.IsDisabled() && defender.IsDefense()) if (attacker.IsCode(CardId.UltimateConductorTytanno) && !attacker.IsDisabled() && defender.IsDefense())
attacker.RealPower = 9999; attacker.RealPower = 9999;
} }
return base.OnPreBattleBetween(attacker, defender); return base.OnPreBattleBetween(attacker, defender);
......
...@@ -106,9 +106,9 @@ namespace WindBot.Game.AI.Decks ...@@ -106,9 +106,9 @@ namespace WindBot.Game.AI.Decks
if (!Bot.HasInHand(NekrozRituelCard) || Bot.HasInHand(CardId.Shurit) || !Bot.HasInHand(NekrozSpellCard)) if (!Bot.HasInHand(NekrozRituelCard) || Bot.HasInHand(CardId.Shurit) || !Bot.HasInHand(NekrozSpellCard))
return true; return true;
foreach (ClientCard Card in Bot.Hand) foreach (ClientCard Card in Bot.Hand)
if (Card != null && Card.Id == CardId.Kaleidoscope && !Bot.HasInHand(CardId.Unicore)) if (Card != null && Card.IsCode(CardId.Kaleidoscope) && !Bot.HasInHand(CardId.Unicore))
return true; return true;
else if (Card.Id == CardId.Trishula || Card.Id == CardId.DecisiveArmor && !Bot.HasInHand(CardId.Mirror) || !Bot.HasInHand(CardId.Shurit)) else if (Card.IsCode(CardId.Trishula) || Card.IsCode(CardId.DecisiveArmor) && !Bot.HasInHand(CardId.Mirror) || !Bot.HasInHand(CardId.Shurit))
return true; return true;
return false; return false;
} }
...@@ -271,9 +271,9 @@ namespace WindBot.Game.AI.Decks ...@@ -271,9 +271,9 @@ namespace WindBot.Game.AI.Decks
List<int> NekrozCard = new List<int>(); List<int> NekrozCard = new List<int>();
try try
{ {
foreach (ClientCard Card in Bot.Hand) foreach (ClientCard card in Bot.Hand)
if (Card != null && NekrozRituelCard.Contains((int)Card.Id)) if (card != null && card.IsCode(NekrozRituelCard))
NekrozCard.Add(Card.Id); NekrozCard.Add(card.Id);
foreach (int Id in NekrozCard) foreach (int Id in NekrozCard)
{ {
......
...@@ -162,7 +162,7 @@ namespace WindBot.Game.AI.Decks ...@@ -162,7 +162,7 @@ namespace WindBot.Game.AI.Decks
} }
if (AI.Utils.GetProblematicEnemyCard(9999,true)!=null) if (AI.Utils.GetProblematicEnemyCard(9999,true)!=null)
{ {
if (AI.Utils.GetProblematicEnemyCard(9999, true).Id == CardId.ElShaddollWinda && if (AI.Utils.GetProblematicEnemyCard(9999, true).IsCode(CardId.ElShaddollWinda) &&
!AI.Utils.GetProblematicEnemyCard(9999, true).IsDisabled()) !AI.Utils.GetProblematicEnemyCard(9999, true).IsDisabled())
return false; return false;
AI.SelectCard(AI.Utils.GetProblematicEnemyCard(9999, true)); AI.SelectCard(AI.Utils.GetProblematicEnemyCard(9999, true));
...@@ -349,7 +349,7 @@ namespace WindBot.Game.AI.Decks ...@@ -349,7 +349,7 @@ namespace WindBot.Game.AI.Decks
ClientCard target = null; ClientCard target = null;
foreach(ClientCard s in Bot.GetSpells()) foreach(ClientCard s in Bot.GetSpells())
{ {
if(s.Id==CardId.SeaStealthAttack && Card.IsFaceup()) if(s.IsCode(CardId.SeaStealthAttack) && Card.IsFaceup())
{ {
target = s; target = s;
break; break;
...@@ -388,7 +388,7 @@ namespace WindBot.Game.AI.Decks ...@@ -388,7 +388,7 @@ namespace WindBot.Game.AI.Decks
IList<ClientCard> material_list = new List<ClientCard>(); IList<ClientCard> material_list = new List<ClientCard>();
foreach (ClientCard m in Bot.GetMonsters()) foreach (ClientCard m in Bot.GetMonsters())
{ {
if (m.Id == CardId.MissusRadiant) if (m.IsCode(CardId.MissusRadiant))
{ {
material_list.Add(m); material_list.Add(m);
break; break;
...@@ -396,7 +396,7 @@ namespace WindBot.Game.AI.Decks ...@@ -396,7 +396,7 @@ namespace WindBot.Game.AI.Decks
} }
foreach (ClientCard m in Bot.GetMonsters()) foreach (ClientCard m in Bot.GetMonsters())
{ {
if (m.Id == CardId.Linkuriboh || m.Id == CardId.LinkSpider) if (m.IsCode(CardId.Linkuriboh, CardId.LinkSpider))
{ {
material_list.Add(m); material_list.Add(m);
if (material_list.Count == 3) if (material_list.Count == 3)
...@@ -489,7 +489,7 @@ namespace WindBot.Game.AI.Decks ...@@ -489,7 +489,7 @@ namespace WindBot.Game.AI.Decks
IList<ClientCard> material_list = new List<ClientCard>(); IList<ClientCard> material_list = new List<ClientCard>();
foreach (ClientCard monster in Bot.GetMonsters()) foreach (ClientCard monster in Bot.GetMonsters())
{ {
if (monster.HasAttribute(CardAttribute.Earth) && monster.Level == 1 && monster.Id != CardId.EaterOfMillions) if (monster.HasAttribute(CardAttribute.Earth) && monster.Level == 1 && !monster.IsCode(CardId.EaterOfMillions))
material_list.Add(monster); material_list.Add(monster);
if (material_list.Count == 2) break; if (material_list.Count == 2) break;
} }
...@@ -518,7 +518,7 @@ namespace WindBot.Game.AI.Decks ...@@ -518,7 +518,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard c in Bot.GetMonsters()) foreach (ClientCard c in Bot.GetMonsters())
{ {
if (c.Id != CardId.EaterOfMillions && c.Id != CardId.Linkuriboh && c.Level == 1) if (!c.IsCode(CardId.EaterOfMillions, CardId.Linkuriboh) && c.Level == 1)
{ {
AI.SelectMaterials(c); AI.SelectMaterials(c);
return true; return true;
...@@ -529,7 +529,7 @@ namespace WindBot.Game.AI.Decks ...@@ -529,7 +529,7 @@ namespace WindBot.Game.AI.Decks
private bool Linkuriboheff() private bool Linkuriboheff()
{ {
if (Duel.LastChainPlayer == 0 && AI.Utils.GetLastChainCard().Id == CardId.Linkuriboh) return false; if (Duel.LastChainPlayer == 0 && AI.Utils.GetLastChainCard().IsCode(CardId.Linkuriboh)) return false;
return true; return true;
} }
private bool SeaStealthAttackeff() private bool SeaStealthAttackeff()
...@@ -548,7 +548,7 @@ namespace WindBot.Game.AI.Decks ...@@ -548,7 +548,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard s in Bot.GetGraveyardSpells()) foreach (ClientCard s in Bot.GetGraveyardSpells())
{ {
if (s.Id == CardId.PacifisThePhantasmCity) if (s.IsCode(CardId.PacifisThePhantasmCity))
{ {
AI.SelectYesNo(true); AI.SelectYesNo(true);
AI.SelectCard(s); AI.SelectCard(s);
...@@ -560,7 +560,7 @@ namespace WindBot.Game.AI.Decks ...@@ -560,7 +560,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard s in Bot.Hand) foreach (ClientCard s in Bot.Hand)
{ {
if (s.Id == CardId.PacifisThePhantasmCity) if (s.IsCode(CardId.PacifisThePhantasmCity))
{ {
AI.SelectYesNo(true); AI.SelectYesNo(true);
AI.SelectCard(s); AI.SelectCard(s);
...@@ -579,7 +579,7 @@ namespace WindBot.Game.AI.Decks ...@@ -579,7 +579,7 @@ namespace WindBot.Game.AI.Decks
ClientCard target = null; ClientCard target = null;
foreach(ClientCard s in Bot.GetSpells()) foreach(ClientCard s in Bot.GetSpells())
{ {
if (s.Id == CardId.PacifisThePhantasmCity) if (s.IsCode(CardId.PacifisThePhantasmCity))
target = s; target = s;
} }
if (target != null && AI.Utils.IsChainTarget(target)) if (target != null && AI.Utils.IsChainTarget(target))
...@@ -590,13 +590,13 @@ namespace WindBot.Game.AI.Decks ...@@ -590,13 +590,13 @@ namespace WindBot.Game.AI.Decks
target = AI.Utils.GetLastChainCard(); target = AI.Utils.GetLastChainCard();
if(target!=null) if(target!=null)
{ {
if(target.Id==CardId.BrandishSkillAfterburner) if(target.IsCode(CardId.BrandishSkillAfterburner))
{ {
AI.SelectCard(CardId.MegalosmasherX); AI.SelectCard(CardId.MegalosmasherX);
SeaStealthAttackeff_used = true; SeaStealthAttackeff_used = true;
return true; return true;
} }
if(Enemy.GetGraveyardSpells().Count>=3 && target.Id==CardId.BrandishSkillJammingWave) if(Enemy.GetGraveyardSpells().Count>=3 && target.IsCode(CardId.BrandishSkillJammingWave))
{ {
AI.SelectCard(CardId.MegalosmasherX); AI.SelectCard(CardId.MegalosmasherX);
SeaStealthAttackeff_used = true; SeaStealthAttackeff_used = true;
...@@ -675,7 +675,7 @@ namespace WindBot.Game.AI.Decks ...@@ -675,7 +675,7 @@ namespace WindBot.Game.AI.Decks
int zone_count = 5 - Bot.GetSpellCountWithoutField(); int zone_count = 5 - Bot.GetSpellCountWithoutField();
return zone_count- hand_spell_count >= 1; return zone_count- hand_spell_count >= 1;
} }
if(Card.Id==CardId.PhantasmSprialBattle || Card.Id==CardId.PhantasmSpiralPower) if(Card.IsCode(CardId.PhantasmSprialBattle, CardId.PhantasmSpiralPower))
{ {
if (Bot.HasInMonstersZone(CardId.MegalosmasherX) && if (Bot.HasInMonstersZone(CardId.MegalosmasherX) &&
!Bot.HasInHandOrInSpellZone(CardId.PacifisThePhantasmCity) && !Bot.HasInHandOrInSpellZone(CardId.PacifisThePhantasmCity) &&
...@@ -691,20 +691,20 @@ namespace WindBot.Game.AI.Decks ...@@ -691,20 +691,20 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard s in Bot.GetSpells()) foreach (ClientCard s in Bot.GetSpells())
{ {
if (s.IsFaceup() && s.Id == CardId.SeaStealthAttack && if (s.IsFaceup() && s.IsCode(CardId.SeaStealthAttack) &&
Bot.HasInSpellZone(CardId.PacifisThePhantasmCity) && Bot.HasInSpellZone(CardId.PacifisThePhantasmCity) &&
Card.IsAttack()) Card.IsAttack())
return false; return false;
} }
} }
if (Card.Id == CardId.EaterOfMillions && !Card.IsDisabled() && Card.IsAttack()) if (Card.IsCode(CardId.EaterOfMillions) && !Card.IsDisabled() && Card.IsAttack())
return false; return false;
return DefaultMonsterRepos(); return DefaultMonsterRepos();
} }
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender) public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
{ {
if(attacker.Id==CardId.PacifisThePhantasmCity+1 && defender.Id==CardId.EaterOfMillions) if(attacker.IsCode(CardId.PacifisThePhantasmCity+1) && defender.IsCode(CardId.EaterOfMillions))
{ {
if (attacker.RealPower >= defender.RealPower) return true; if (attacker.RealPower >= defender.RealPower) return true;
} }
...@@ -712,10 +712,10 @@ namespace WindBot.Game.AI.Decks ...@@ -712,10 +712,10 @@ namespace WindBot.Game.AI.Decks
{ {
foreach(ClientCard s in Bot.GetSpells()) foreach(ClientCard s in Bot.GetSpells())
{ {
if (s.IsFaceup() && s.Id == CardId.SeaStealthAttack && Bot.HasInSpellZone(CardId.PacifisThePhantasmCity)) if (s.IsFaceup() && s.IsCode(CardId.SeaStealthAttack) && Bot.HasInSpellZone(CardId.PacifisThePhantasmCity))
{ {
attacker.RealPower = 9999; attacker.RealPower = 9999;
if (defender.Id == CardId.EaterOfMillions) return true; if (defender.IsCode(CardId.EaterOfMillions)) return true;
} }
} }
...@@ -728,7 +728,7 @@ namespace WindBot.Game.AI.Decks ...@@ -728,7 +728,7 @@ namespace WindBot.Game.AI.Decks
for (int i = 0; i < attackers.Count; ++i) for (int i = 0; i < attackers.Count; ++i)
{ {
ClientCard attacker = attackers[i]; ClientCard attacker = attackers[i];
if (attacker.Id == CardId.EaterOfMillions) return attacker; if (attacker.IsCode(CardId.EaterOfMillions)) return attacker;
} }
return null; return null;
} }
......
...@@ -141,7 +141,7 @@ namespace WindBot.Game.AI.Decks ...@@ -141,7 +141,7 @@ namespace WindBot.Game.AI.Decks
for (int i = 1; i <= max; ++i) for (int i = 1; i <= max; ++i)
{ {
ClientCard card = cards[cards.Count - i]; ClientCard card = cards[cards.Count - i];
if (card.Id != CardId.Scout || (card.Location == CardLocation.Extra && !Duel.IsNewRule)) if (!card.IsCode(CardId.Scout) || (card.Location == CardLocation.Extra && !Duel.IsNewRule))
selected.Add(card); selected.Add(card);
} }
if (selected.Count == 0) if (selected.Count == 0)
...@@ -152,7 +152,7 @@ namespace WindBot.Game.AI.Decks ...@@ -152,7 +152,7 @@ namespace WindBot.Game.AI.Decks
private bool NormalSummon() private bool NormalSummon()
{ {
if (Card.Id == CardId.Scout) if (Card.IsCode(CardId.Scout))
return false; return false;
if (Card.Level < 8) if (Card.Level < 8)
AI.SelectOption(1); AI.SelectOption(1);
...@@ -196,7 +196,7 @@ namespace WindBot.Game.AI.Decks ...@@ -196,7 +196,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard card in Bot.GetSpells()) foreach (ClientCard card in Bot.GetSpells())
{ {
if (card.Id == Card.Id) if (card.IsCode(Card.Id))
return false; return false;
} }
return TrapSetWhenZoneFree(); return TrapSetWhenZoneFree();
......
...@@ -162,7 +162,7 @@ namespace WindBot.Game.AI.Decks ...@@ -162,7 +162,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard card2 in cards) foreach (ClientCard card2 in cards)
{ {
if (card1.Id == card2.Id && !card1.Equals(card2)) if (card1.IsCode(card2.Id) && !card1.Equals(card2))
{ {
result.Add(card1); result.Add(card1);
result.Add(card2); result.Add(card2);
...@@ -172,8 +172,8 @@ namespace WindBot.Game.AI.Decks ...@@ -172,8 +172,8 @@ namespace WindBot.Game.AI.Decks
if (result.Count > 0) if (result.Count > 0)
break; break;
} }
AI.Utils.CheckSelectCount(result, cards, min, max);
return result; return AI.Utils.CheckSelectCount(result, cards, min, max);
} }
private bool UnexpectedDaiEffect() private bool UnexpectedDaiEffect()
......
...@@ -120,15 +120,13 @@ namespace WindBot.Game.AI.Decks ...@@ -120,15 +120,13 @@ namespace WindBot.Game.AI.Decks
public override IList<ClientCard> OnSelectXyzMaterial(IList<ClientCard> cards, int min, int max) public override IList<ClientCard> OnSelectXyzMaterial(IList<ClientCard> cards, int min, int max)
{ {
IList<ClientCard> result = new List<ClientCard>(); IList<ClientCard> result = AI.Utils.SelectPreferredCards(new[] {
AI.Utils.SelectPreferredCards(result, new[] {
CardId.MistArchfiend, CardId.MistArchfiend,
CardId.PanzerDragon, CardId.PanzerDragon,
CardId.SolarWindJammer, CardId.SolarWindJammer,
CardId.StarDrawing CardId.StarDrawing
}, cards, min, max); }, cards, min, max);
AI.Utils.CheckSelectCount(result, cards, min, max); return AI.Utils.CheckSelectCount(result, cards, min, max);
return result;
} }
private bool NormalSummon() private bool NormalSummon()
...@@ -187,15 +185,15 @@ namespace WindBot.Game.AI.Decks ...@@ -187,15 +185,15 @@ namespace WindBot.Game.AI.Decks
int lv5Count = 0; int lv5Count = 0;
foreach (ClientCard card in Bot.Hand) foreach (ClientCard card in Bot.Hand)
{ {
if (card.Id == CardId.SolarWindJammer && Bot.GetMonsterCount() == 0) if (card.IsCode(CardId.SolarWindJammer) && Bot.GetMonsterCount() == 0)
++lv5Count; ++lv5Count;
if (card.Id == CardId.InstantFusion && !InstantFusionUsed) if (card.IsCode(CardId.InstantFusion) && !InstantFusionUsed)
++lv5Count; ++lv5Count;
if (card.Id == CardId.QuickdrawSynchron && Bot.Hand.ContainsMonsterWithLevel(4)) if (card.IsCode(CardId.QuickdrawSynchron) && Bot.Hand.ContainsMonsterWithLevel(4))
++lv5Count; ++lv5Count;
if (card.Id == CardId.MistArchfiend && !NormalSummoned) if (card.IsCode(CardId.MistArchfiend) && !NormalSummoned)
++lv5Count; ++lv5Count;
if (card.Id == CardId.DoubleSummon && DoubleSummonEffect()) if (card.IsCode(CardId.DoubleSummon) && DoubleSummonEffect())
++lv5Count; ++lv5Count;
} }
if (lv5Count >= 2) if (lv5Count >= 2)
...@@ -389,8 +387,8 @@ namespace WindBot.Game.AI.Decks ...@@ -389,8 +387,8 @@ namespace WindBot.Game.AI.Decks
if (monster.HasType(CardType.Monster) && if (monster.HasType(CardType.Monster) &&
!monster.HasType(CardType.Xyz) && !monster.HasType(CardType.Xyz) &&
(monster.Level == 5 (monster.Level == 5
|| monster.Id == CardId.StarDrawing || monster.IsCode(CardId.StarDrawing)
|| (monster.Id == CardId.WindUpSoldier) && !monster.Equals(Card))) || (monster.IsCode(CardId.WindUpSoldier)) && !monster.Equals(Card)))
return true; return true;
} }
return false; return false;
......
...@@ -284,7 +284,7 @@ namespace WindBot.Game.AI.Decks ...@@ -284,7 +284,7 @@ namespace WindBot.Game.AI.Decks
List<ClientCard> monsters = Bot.GetMonsters(); List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters) foreach (ClientCard monster in monsters)
{ {
if (monster.Id == CardId.BalancerLord) if (monster.IsCode(CardId.BalancerLord))
{ {
AI.SelectCard(monster); AI.SelectCard(monster);
selected = true; selected = true;
...@@ -404,7 +404,7 @@ namespace WindBot.Game.AI.Decks ...@@ -404,7 +404,7 @@ namespace WindBot.Game.AI.Decks
}; };
foreach (ClientCard monster in Bot.Hand) foreach (ClientCard monster in Bot.Hand)
{ {
if (targets.Contains(monster.Id)) if (monster.IsCode(targets))
{ {
AI.SelectCard(targets); AI.SelectCard(targets);
return true; return true;
...@@ -418,7 +418,7 @@ namespace WindBot.Game.AI.Decks ...@@ -418,7 +418,7 @@ namespace WindBot.Game.AI.Decks
}; };
foreach (ClientCard monster in Bot.GetMonsters()) foreach (ClientCard monster in Bot.GetMonsters())
{ {
if (targets2.Contains(monster.Id)) if (monster.IsCode(targets2))
{ {
AI.SelectCard(targets2); AI.SelectCard(targets2);
return true; return true;
......
...@@ -152,7 +152,7 @@ namespace WindBot.Game.AI.Decks ...@@ -152,7 +152,7 @@ namespace WindBot.Game.AI.Decks
{ {
if (!defender.IsMonsterHasPreventActivationEffectInBattle()) if (!defender.IsMonsterHasPreventActivationEffectInBattle())
{ {
if (attacker.Id == CardId.HiSpeedroidChanbara && !attacker.IsDisabled()) if (attacker.IsCode(CardId.HiSpeedroidChanbara) && !attacker.IsDisabled())
attacker.RealPower = attacker.RealPower + 200; attacker.RealPower = attacker.RealPower + 200;
} }
return base.OnPreBattleBetween(attacker, defender); return base.OnPreBattleBetween(attacker, defender);
...@@ -399,7 +399,7 @@ namespace WindBot.Game.AI.Decks ...@@ -399,7 +399,7 @@ namespace WindBot.Game.AI.Decks
IList<ClientCard> targets = new List<ClientCard>(); IList<ClientCard> targets = new List<ClientCard>();
foreach(ClientCard card in Bot.GetGraveyardMonsters()) foreach(ClientCard card in Bot.GetGraveyardMonsters())
{ {
if (card.Id == CardId.Hayate || card.Id == CardId.Kagari || card.Id == CardId.Shizuku) if (card.IsCode(CardId.Hayate, CardId.Kagari, CardId.Shizuku))
targets.Add(card); targets.Add(card);
} }
if (targets.Count > 0) if (targets.Count > 0)
...@@ -451,7 +451,7 @@ namespace WindBot.Game.AI.Decks ...@@ -451,7 +451,7 @@ namespace WindBot.Game.AI.Decks
} }
foreach (ClientCard target in Bot.GetMonsters()) foreach (ClientCard target in Bot.GetMonsters())
{ {
if (target.Id == CardId.Raye && Bot.GetMonstersExtraZoneCount() == 0) if (target.IsCode(CardId.Raye) && Bot.GetMonstersExtraZoneCount() == 0)
{ {
AI.SelectCard(target); AI.SelectCard(target);
return true; return true;
...@@ -459,7 +459,7 @@ namespace WindBot.Game.AI.Decks ...@@ -459,7 +459,7 @@ namespace WindBot.Game.AI.Decks
} }
foreach (ClientCard target in Bot.GetSpells()) foreach (ClientCard target in Bot.GetSpells())
{ {
if (target.Id != CardId.AreaZero && target.Id != CardId.Multirole && target.Id != CardId.WidowAnchor && target.IsSpell()) if (!target.IsCode(CardId.AreaZero, CardId.Multirole, CardId.WidowAnchor) && target.IsSpell())
{ {
AI.SelectCard(target); AI.SelectCard(target);
return true; return true;
...@@ -482,7 +482,7 @@ namespace WindBot.Game.AI.Decks ...@@ -482,7 +482,7 @@ namespace WindBot.Game.AI.Decks
} }
foreach (ClientCard target in Bot.GetMonsters()) foreach (ClientCard target in Bot.GetMonsters())
{ {
if (target.Id == CardId.Raye && Bot.GetMonstersExtraZoneCount() == 0) if (target.IsCode(CardId.Raye) && Bot.GetMonstersExtraZoneCount() == 0)
{ {
AI.SelectCard(target); AI.SelectCard(target);
return true; return true;
...@@ -490,7 +490,7 @@ namespace WindBot.Game.AI.Decks ...@@ -490,7 +490,7 @@ namespace WindBot.Game.AI.Decks
} }
foreach (ClientCard target in Bot.GetSpells()) foreach (ClientCard target in Bot.GetSpells())
{ {
if (target.Id == CardId.AreaZero) if (target.IsCode(CardId.AreaZero))
{ {
AI.SelectCard(target); AI.SelectCard(target);
return true; return true;
...@@ -498,7 +498,7 @@ namespace WindBot.Game.AI.Decks ...@@ -498,7 +498,7 @@ namespace WindBot.Game.AI.Decks
} }
foreach (ClientCard target in Bot.GetSpells()) foreach (ClientCard target in Bot.GetSpells())
{ {
if (target.Id != CardId.Multirole && target.Id != CardId.WidowAnchor && target.IsSpell()) if (!target.IsCode(CardId.Multirole, CardId.WidowAnchor) && target.IsSpell())
{ {
AI.SelectCard(target); AI.SelectCard(target);
return true; return true;
......
...@@ -116,7 +116,7 @@ namespace WindBot.Game.AI.Decks ...@@ -116,7 +116,7 @@ namespace WindBot.Game.AI.Decks
{ {
if (!defender.IsMonsterHasPreventActivationEffectInBattle()) if (!defender.IsMonsterHasPreventActivationEffectInBattle())
{ {
if (attacker.Id == CardId.SkyCavalryCentaurea && !attacker.IsDisabled() && attacker.HasXyzMaterial()) if (attacker.IsCode(CardId.SkyCavalryCentaurea) && !attacker.IsDisabled() && attacker.HasXyzMaterial())
attacker.RealPower = Bot.LifePoints + attacker.Attack; attacker.RealPower = Bot.LifePoints + attacker.Attack;
} }
return base.OnPreBattleBetween(attacker, defender); return base.OnPreBattleBetween(attacker, defender);
...@@ -315,7 +315,7 @@ namespace WindBot.Game.AI.Decks ...@@ -315,7 +315,7 @@ namespace WindBot.Game.AI.Decks
}; };
foreach (ClientCard monster in monsters) foreach (ClientCard monster in monsters)
{ {
if (suitableCost.Contains(monster.Id)) if (monster.IsCode(suitableCost))
{ {
AI.SelectCard(monster); AI.SelectCard(monster);
return true; return true;
...@@ -325,7 +325,7 @@ namespace WindBot.Game.AI.Decks ...@@ -325,7 +325,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard monster in monsters) foreach (ClientCard monster in monsters)
{ {
if (monster.Id == CardId.DupeFrog) if (monster.IsCode(CardId.DupeFrog))
{ {
AI.SelectCard(monster); AI.SelectCard(monster);
return true; return true;
...@@ -337,7 +337,7 @@ namespace WindBot.Game.AI.Decks ...@@ -337,7 +337,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard monster in hands) foreach (ClientCard monster in hands)
{ {
if (monster.Id == CardId.GraydleSlimeJr) if (monster.IsCode(CardId.GraydleSlimeJr))
{ {
AI.SelectCard(monster); AI.SelectCard(monster);
return true; return true;
...@@ -348,7 +348,7 @@ namespace WindBot.Game.AI.Decks ...@@ -348,7 +348,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard monster in hands) foreach (ClientCard monster in hands)
{ {
if (monster.Id == CardId.DupeFrog) if (monster.IsCode(CardId.DupeFrog))
{ {
AI.SelectCard(monster); AI.SelectCard(monster);
return true; return true;
...@@ -357,7 +357,7 @@ namespace WindBot.Game.AI.Decks ...@@ -357,7 +357,7 @@ namespace WindBot.Game.AI.Decks
} }
foreach (ClientCard monster in hands) foreach (ClientCard monster in hands)
{ {
if (monster.Id == CardId.Ronintoadin || monster.Id == CardId.DupeFrog) if (monster.IsCode(CardId.Ronintoadin, CardId.DupeFrog))
{ {
AI.SelectCard(monster); AI.SelectCard(monster);
return true; return true;
...@@ -442,7 +442,7 @@ namespace WindBot.Game.AI.Decks ...@@ -442,7 +442,7 @@ namespace WindBot.Game.AI.Decks
List<ClientCard> monsters = Bot.GetMonsters(); List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters) foreach (ClientCard monster in monsters)
{ {
if (monster.Id == CardId.ToadallyAwesome && monster.Attack <= 2200) if (monster.IsCode(CardId.ToadallyAwesome) && monster.Attack <= 2200)
{ {
SelectXYZDetach(Card.Overlays); SelectXYZDetach(Card.Overlays);
AI.SelectNextCard(monster); AI.SelectNextCard(monster);
...@@ -451,7 +451,7 @@ namespace WindBot.Game.AI.Decks ...@@ -451,7 +451,7 @@ namespace WindBot.Game.AI.Decks
} }
foreach (ClientCard monster in monsters) foreach (ClientCard monster in monsters)
{ {
if (monster.Id == CardId.SkyCavalryCentaurea && monster.Attack <= 2000) if (monster.IsCode(CardId.SkyCavalryCentaurea) && monster.Attack <= 2000)
{ {
SelectXYZDetach(Card.Overlays); SelectXYZDetach(Card.Overlays);
AI.SelectNextCard(monster); AI.SelectNextCard(monster);
...@@ -460,7 +460,7 @@ namespace WindBot.Game.AI.Decks ...@@ -460,7 +460,7 @@ namespace WindBot.Game.AI.Decks
} }
foreach (ClientCard monster in monsters) foreach (ClientCard monster in monsters)
{ {
if (monster.Id == CardId.DaigustoPhoenix && monster.Attack <= 1500) if (monster.IsCode(CardId.DaigustoPhoenix) && monster.Attack <= 1500)
{ {
SelectXYZDetach(Card.Overlays); SelectXYZDetach(Card.Overlays);
AI.SelectNextCard(monster); AI.SelectNextCard(monster);
......
This diff is collapsed.
...@@ -163,7 +163,7 @@ namespace WindBot.Game.AI.Decks ...@@ -163,7 +163,7 @@ namespace WindBot.Game.AI.Decks
if (Card == null) if (Card == null)
return true; return true;
// Logger.DebugWriteLine(Card.Name); // Logger.DebugWriteLine(Card.Name);
if (Card.Id == CardId.YosenjuKama2) if (Card.IsCode(CardId.YosenjuKama2))
return Card.ShouldDirectAttack; return Card.ShouldDirectAttack;
else else
return true; return true;
...@@ -181,10 +181,8 @@ namespace WindBot.Game.AI.Decks ...@@ -181,10 +181,8 @@ namespace WindBot.Game.AI.Decks
public override IList<ClientCard> OnSelectXyzMaterial(IList<ClientCard> cards, int min, int max) public override IList<ClientCard> OnSelectXyzMaterial(IList<ClientCard> cards, int min, int max)
{ {
IList<ClientCard> result = new List<ClientCard>(); IList<ClientCard> result = AI.Utils.SelectPreferredCards(CardId.YosenjuTsujik, cards, min, max);
AI.Utils.SelectPreferredCards(result, CardId.YosenjuTsujik, cards, min, max); return AI.Utils.CheckSelectCount(result, cards, min, max);
AI.Utils.CheckSelectCount(result, cards, min, max);
return result;
} }
private bool PotOfDualityEffect() private bool PotOfDualityEffect()
...@@ -243,7 +241,7 @@ namespace WindBot.Game.AI.Decks ...@@ -243,7 +241,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard card in Bot.Hand.GetMonsters()) foreach (ClientCard card in Bot.Hand.GetMonsters())
{ {
if (!card.Equals(Card) && card.Id == Card.Id) if (!card.Equals(Card) && card.IsCode(Card.Id))
return true; return true;
} }
return false; return false;
...@@ -253,7 +251,7 @@ namespace WindBot.Game.AI.Decks ...@@ -253,7 +251,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard card in Bot.GetSpells()) foreach (ClientCard card in Bot.GetSpells())
{ {
if (card.Id == Card.Id) if (card.IsCode(Card.Id))
return false; return false;
} }
return TrapSetWhenZoneFree(); return TrapSetWhenZoneFree();
......
using System.Collections.Generic; using System;
using System.Collections.Generic;
using WindBot; using WindBot;
using WindBot.Game; using WindBot.Game;
using WindBot.Game.AI; using WindBot.Game.AI;
...@@ -103,7 +104,7 @@ namespace WindBot.Game.AI.Decks ...@@ -103,7 +104,7 @@ namespace WindBot.Game.AI.Decks
// Summons: Effects // Summons: Effects
AddExecutor(ExecutorType.Activate, CardId.Goblindbergh, GoblindberghEffect); AddExecutor(ExecutorType.Activate, CardId.Goblindbergh, GoblindberghEffect);
AddExecutor(ExecutorType.Activate, CardId.TinGoldfish, GoblindberghEffect); AddExecutor(ExecutorType.Activate, CardId.TinGoldfish, GoblindberghEffect);
AddExecutor(ExecutorType.Activate, CardId.Kagetokage); AddExecutor(ExecutorType.Activate, CardId.Kagetokage, KagetokageEffect);
AddExecutor(ExecutorType.Activate, CardId.SummonerMonk, SummonerMonkEffect); AddExecutor(ExecutorType.Activate, CardId.SummonerMonk, SummonerMonkEffect);
AddExecutor(ExecutorType.Activate, CardId.Honest, DefaultHonestEffect); AddExecutor(ExecutorType.Activate, CardId.Honest, DefaultHonestEffect);
...@@ -138,14 +139,12 @@ namespace WindBot.Game.AI.Decks ...@@ -138,14 +139,12 @@ namespace WindBot.Game.AI.Decks
public override IList<ClientCard> OnSelectXyzMaterial(IList<ClientCard> cards, int min, int max) public override IList<ClientCard> OnSelectXyzMaterial(IList<ClientCard> cards, int min, int max)
{ {
IList<ClientCard> result = new List<ClientCard>(); IList<ClientCard> result = AI.Utils.SelectPreferredCards(new[] {
AI.Utils.SelectPreferredCards(result, new[] {
CardId.StarDrawing, CardId.StarDrawing,
CardId.SolarWindJammer, CardId.SolarWindJammer,
CardId.Goblindbergh CardId.Goblindbergh
}, cards, min, max); }, cards, min, max);
AI.Utils.CheckSelectCount(result, cards, min, max); return AI.Utils.CheckSelectCount(result, cards, min, max);
return result;
} }
private bool Number39Utopia() private bool Number39Utopia()
...@@ -235,6 +234,13 @@ namespace WindBot.Game.AI.Decks ...@@ -235,6 +234,13 @@ namespace WindBot.Game.AI.Decks
return true; return true;
} }
private bool KagetokageEffect()
{
var lastChainCard = AI.Utils.GetLastChainCard();
if (lastChainCard == null) return true;
return !lastChainCard.IsCode(CardId.Goblindbergh, CardId.TinGoldfish);
}
private bool SummonerMonkEffect() private bool SummonerMonkEffect()
{ {
IList<int> costs = new[] IList<int> costs = new[]
...@@ -273,7 +279,7 @@ namespace WindBot.Game.AI.Decks ...@@ -273,7 +279,7 @@ namespace WindBot.Game.AI.Decks
private bool MonsterRepos() private bool MonsterRepos()
{ {
if (Card.Id == CardId.NumberS39UtopiatheLightning && Card.IsAttack()) if (Card.IsCode(CardId.NumberS39UtopiatheLightning) && Card.IsAttack())
return false; return false;
return base.DefaultMonsterRepos(); return base.DefaultMonsterRepos();
} }
......
...@@ -230,14 +230,14 @@ namespace WindBot.Game.AI.Decks ...@@ -230,14 +230,14 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard card in Enemy.Graveyard) foreach (ClientCard card in Enemy.Graveyard)
{ {
if (card.Id == CardId.AleisterTheInvoker) if (card.IsCode(CardId.AleisterTheInvoker))
{ {
return card; return card;
} }
} }
foreach (ClientCard card in Bot.Graveyard) foreach (ClientCard card in Bot.Graveyard)
{ {
if (card.Id == CardId.AleisterTheInvoker) if (card.IsCode(CardId.AleisterTheInvoker))
{ {
return card; return card;
} }
...@@ -445,7 +445,7 @@ namespace WindBot.Game.AI.Decks ...@@ -445,7 +445,7 @@ namespace WindBot.Game.AI.Decks
List<ClientCard> monsters = Bot.GetMonsters(); List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters) foreach (ClientCard monster in monsters)
{ {
if (monster.IsFaceup() && monster.Id == CardId.Drident && !monster.HasXyzMaterial()) if (monster.IsFaceup() && monster.IsCode(CardId.Drident) && !monster.HasXyzMaterial())
{ {
target = monster; target = monster;
break; break;
...@@ -455,7 +455,7 @@ namespace WindBot.Game.AI.Decks ...@@ -455,7 +455,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard monster in monsters) foreach (ClientCard monster in monsters)
{ {
if (monster.IsFaceup() && monster.Type == (int)CardType.Xyz && monster.Id != CardId.DaigustoEmeral && !monster.HasXyzMaterial()) if (monster.IsFaceup() && monster.Type == (int)CardType.Xyz && !monster.IsCode(CardId.DaigustoEmeral) && !monster.HasXyzMaterial())
{ {
target = monster; target = monster;
break; break;
...@@ -550,7 +550,7 @@ namespace WindBot.Game.AI.Decks ...@@ -550,7 +550,7 @@ namespace WindBot.Game.AI.Decks
{ {
foreach (ClientCard spell in Bot.GetSpells()) foreach (ClientCard spell in Bot.GetSpells())
{ {
if (spell.Id == CardId.ZoodiacBarrage && !Card.Equals(spell)) if (spell.IsCode(CardId.ZoodiacBarrage) && !Card.Equals(spell))
return false; return false;
} }
AI.SelectCard(new[] AI.SelectCard(new[]
...@@ -604,7 +604,7 @@ namespace WindBot.Game.AI.Decks ...@@ -604,7 +604,7 @@ namespace WindBot.Game.AI.Decks
private bool MonsterRepos() private bool MonsterRepos()
{ {
if (Card.Id == CardId.NumberS39UtopiatheLightning && Card.IsAttack()) if (Card.IsCode(CardId.NumberS39UtopiatheLightning) && Card.IsAttack())
return false; return false;
return base.DefaultMonsterRepos(); return base.DefaultMonsterRepos();
} }
......
This diff is collapsed.
...@@ -127,7 +127,7 @@ namespace WindBot.Game.AI ...@@ -127,7 +127,7 @@ namespace WindBot.Game.AI
public void SendOnDirectAttack(string attacker) public void SendOnDirectAttack(string attacker)
{ {
if (attacker == "" || attacker == null) if (string.IsNullOrEmpty(attacker))
{ {
attacker = _facedownmonstername; attacker = _facedownmonstername;
} }
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
using WindBot; using WindBot;
using WindBot.Game; using WindBot.Game;
...@@ -82,12 +83,12 @@ namespace WindBot.Game.AI ...@@ -82,12 +83,12 @@ namespace WindBot.Game.AI
public virtual void OnChaining(int player, ClientCard card) public virtual void OnChaining(int player, ClientCard card)
{ {
// For overriding
} }
public virtual void OnChainEnd() public virtual void OnChainEnd()
{ {
// For overriding
} }
public virtual void OnNewPhase() public virtual void OnNewPhase()
{ {
...@@ -239,12 +240,7 @@ namespace WindBot.Game.AI ...@@ -239,12 +240,7 @@ namespace WindBot.Game.AI
private bool DefaultNoExecutor() private bool DefaultNoExecutor()
{ {
foreach (CardExecutor exec in Executors) return Executors.All(exec => exec.Type != Type || exec.CardId != Card.Id);
{
if (exec.Type == Type && exec.CardId == Card.Id)
return false;
}
return true;
} }
} }
} }
\ No newline at end of file
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using YGOSharp.OCGWrapper; using YGOSharp.OCGWrapper;
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
...@@ -39,6 +40,8 @@ namespace WindBot.Game ...@@ -39,6 +40,8 @@ namespace WindBot.Game
public List<ClientCard> EquipCards { get; set; } public List<ClientCard> EquipCards { get; set; }
public ClientCard EquipTarget; public ClientCard EquipTarget;
public List<ClientCard> OwnTargets { get; set; }
public List<ClientCard> TargetCards { get; set; }
public bool CanDirectAttack { get; set; } public bool CanDirectAttack { get; set; }
public bool ShouldDirectAttack { get; set; } public bool ShouldDirectAttack { get; set; }
...@@ -61,6 +64,8 @@ namespace WindBot.Game ...@@ -61,6 +64,8 @@ namespace WindBot.Game
Position = position; Position = position;
Overlays = new List<int>(); Overlays = new List<int>();
EquipCards = new List<ClientCard>(); EquipCards = new List<ClientCard>();
OwnTargets = new List<ClientCard>();
TargetCards = new List<ClientCard>();
ActionIndex = new int[16]; ActionIndex = new int[16];
ActionActivateIndex = new Dictionary<int, int>(); ActionActivateIndex = new Dictionary<int, int>();
Location = loc; Location = loc;
...@@ -72,7 +77,11 @@ namespace WindBot.Game ...@@ -72,7 +77,11 @@ namespace WindBot.Game
Id = id; Id = id;
Data = NamedCard.Get(Id); Data = NamedCard.Get(Id);
if (Data != null) if (Data != null)
{
Name = Data.Name; Name = Data.Name;
if (Data.Alias != 0)
Alias = Data.Alias;
}
} }
public void Update(BinaryReader packet, Duel duel) public void Update(BinaryReader packet, Duel duel)
...@@ -83,8 +92,8 @@ namespace WindBot.Game ...@@ -83,8 +92,8 @@ namespace WindBot.Game
if ((flag & (int)Query.Position) != 0) if ((flag & (int)Query.Position) != 0)
{ {
Controller = duel.GetLocalPlayer(packet.ReadByte()); Controller = duel.GetLocalPlayer(packet.ReadByte());
packet.ReadByte(); Location = (CardLocation)packet.ReadByte();
packet.ReadByte(); Sequence = packet.ReadByte();
Position = packet.ReadByte(); Position = packet.ReadByte();
} }
if ((flag & (int)Query.Alias) != 0) if ((flag & (int)Query.Alias) != 0)
...@@ -149,29 +158,93 @@ namespace WindBot.Game ...@@ -149,29 +158,93 @@ namespace WindBot.Game
} }
} }
public void ClearCardTargets()
{
foreach (ClientCard card in TargetCards)
{
card.OwnTargets.Remove(this);
}
foreach (ClientCard card in OwnTargets)
{
card.TargetCards.Remove(this);
}
OwnTargets.Clear();
TargetCards.Clear();
}
public bool HasLinkMarker(int dir) public bool HasLinkMarker(int dir)
{ {
return ((LinkMarker & dir) != 0); return (LinkMarker & dir) != 0;
} }
public bool HasLinkMarker(LinkMarker dir) public bool HasLinkMarker(CardLinkMarker dir)
{ {
return ((LinkMarker & (int)dir) != 0); return (LinkMarker & (int)dir) != 0;
}
public int GetLinkedZones()
{
if (!HasType(CardType.Link) || Location != CardLocation.MonsterZone)
return 0;
int zones = 0;
if (Sequence > 0 && Sequence <= 4 && HasLinkMarker(CardLinkMarker.Left))
zones |= 1 << (Sequence - 1);
if (Sequence <= 3 && HasLinkMarker(CardLinkMarker.Right))
zones |= 1 << (Sequence + 1);
if (Sequence == 0 && HasLinkMarker(CardLinkMarker.TopRight)
|| Sequence == 1 && HasLinkMarker(CardLinkMarker.Top)
|| Sequence == 2 && HasLinkMarker(CardLinkMarker.TopLeft))
zones |= (1 << 5) | (1 << (16 + 6));
if (Sequence == 2 && HasLinkMarker(CardLinkMarker.TopRight)
|| Sequence == 3 && HasLinkMarker(CardLinkMarker.Top)
|| Sequence == 4 && HasLinkMarker(CardLinkMarker.TopLeft))
zones |= (1 << 6) | (1 << (16 + 5));
if (Sequence == 5)
{
if (HasLinkMarker(CardLinkMarker.BottomLeft))
zones |= 1 << 0;
if (HasLinkMarker(CardLinkMarker.Bottom))
zones |= 1 << 1;
if (HasLinkMarker(CardLinkMarker.BottomRight))
zones |= 1 << 2;
if (HasLinkMarker(CardLinkMarker.TopLeft))
zones |= 1 << (16 + 4);
if (HasLinkMarker(CardLinkMarker.Top))
zones |= 1 << (16 + 3);
if (HasLinkMarker(CardLinkMarker.TopRight))
zones |= 1 << (16 + 2);
}
if (Sequence == 6)
{
if (HasLinkMarker(CardLinkMarker.BottomLeft))
zones |= 1 << 2;
if (HasLinkMarker(CardLinkMarker.Bottom))
zones |= 1 << 3;
if (HasLinkMarker(CardLinkMarker.BottomRight))
zones |= 1 << 4;
if (HasLinkMarker(CardLinkMarker.TopLeft))
zones |= 1 << (16 + 2);
if (HasLinkMarker(CardLinkMarker.Top))
zones |= 1 << (16 + 1);
if (HasLinkMarker(CardLinkMarker.TopRight))
zones |= 1 << (16 + 0);
}
return zones;
} }
public bool HasType(CardType type) public bool HasType(CardType type)
{ {
return ((Type & (int)type) != 0); return (Type & (int)type) != 0;
} }
public bool HasPosition(CardPosition position) public bool HasPosition(CardPosition position)
{ {
return ((Position & (int)position) != 0); return (Position & (int)position) != 0;
} }
public bool HasAttribute(CardAttribute attribute) public bool HasAttribute(CardAttribute attribute)
{ {
return ((Attribute & (int)attribute) != 0); return (Attribute & (int)attribute) != 0;
} }
public bool IsMonster() public bool IsMonster()
...@@ -221,7 +294,22 @@ namespace WindBot.Game ...@@ -221,7 +294,22 @@ namespace WindBot.Game
public bool IsDisabled() public bool IsDisabled()
{ {
return (Disabled != 0); return Disabled != 0;
}
public bool IsCode(int id)
{
return Id == id || Alias != 0 && Alias == id;
}
public bool IsCode(IList<int> ids)
{
return ids.Contains(Id) || Alias != 0 && ids.Contains(Alias);
}
public bool IsCode(params int[] ids)
{
return ids.Contains(Id) || Alias != 0 && ids.Contains(Alias);
} }
public bool HasXyzMaterial() public bool HasXyzMaterial()
......
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using WindBot.Game.AI;
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
namespace WindBot.Game namespace WindBot.Game
...@@ -94,30 +96,36 @@ namespace WindBot.Game ...@@ -94,30 +96,36 @@ namespace WindBot.Game
} }
return count; return count;
} }
public int GetFieldCount() public int GetFieldCount()
{ {
return GetSpellCount() + GetMonsterCount(); return GetSpellCount() + GetMonsterCount();
} }
public int GetFieldHandCount() public int GetFieldHandCount()
{ {
return GetSpellCount() + GetMonsterCount() + GetHandCount(); return GetSpellCount() + GetMonsterCount() + GetHandCount();
} }
public bool IsFieldEmpty() public bool IsFieldEmpty()
{ {
return GetMonsters().Count == 0 && GetSpells().Count == 0; return GetMonsters().Count == 0 && GetSpells().Count == 0;
} }
public int GetLinkedZones()
{
int zones = 0;
for (int i = 0; i < 7; i++)
{
zones |= MonsterZone[i]?.GetLinkedZones() ?? 0;
}
return zones;
}
public List<ClientCard> GetMonsters() public List<ClientCard> GetMonsters()
{ {
return GetCards(MonsterZone); return GetCards(MonsterZone);
} }
public List<ClientCard> GetGraveyardMonsters() public List<ClientCard> GetGraveyardMonsters()
{ {
...@@ -141,23 +149,12 @@ namespace WindBot.Game ...@@ -141,23 +149,12 @@ namespace WindBot.Game
public List<ClientCard> GetMonstersInExtraZone() public List<ClientCard> GetMonstersInExtraZone()
{ {
List<ClientCard> cards = new List<ClientCard>(); return GetMonsters().Where((card, i) => i >= 5).ToList();
if (MonsterZone[5] != null)
cards.Add(MonsterZone[5]);
if (MonsterZone[6] != null)
cards.Add(MonsterZone[6]);
return cards;
} }
public List<ClientCard> GetMonstersInMainZone() public List<ClientCard> GetMonstersInMainZone()
{ {
List<ClientCard> cards = new List<ClientCard>(); return GetMonsters().Where((card, i) => i < 5).ToList();
for (int i = 0; i < 5; i++)
{
if (MonsterZone[i] != null)
cards.Add(MonsterZone[i]);
}
return cards;
} }
public bool HasInHand(int cardId) public bool HasInHand(int cardId)
...@@ -202,44 +199,32 @@ namespace WindBot.Game ...@@ -202,44 +199,32 @@ namespace WindBot.Game
public bool HasAttackingMonster() public bool HasAttackingMonster()
{ {
IList<ClientCard> monsters = GetMonsters(); return GetMonsters().Any(card => card.IsAttack());
foreach (ClientCard card in monsters)
{
if (card.IsAttack())
return true;
}
return false;
} }
public bool HasDefendingMonster() public bool HasDefendingMonster()
{ {
IList<ClientCard> monsters = GetMonsters(); return GetMonsters().Any(card => card.IsDefense());
foreach (ClientCard card in monsters)
{
if (card.IsDefense())
return true;
}
return false;
} }
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) public bool HasInHandOrInSpellZone(int cardId)
...@@ -315,94 +300,46 @@ namespace WindBot.Game ...@@ -315,94 +300,46 @@ namespace WindBot.Game
public int GetRemainingCount(int cardId, int initialCount) public int GetRemainingCount(int cardId, int initialCount)
{ {
int remaining = initialCount; int remaining = initialCount;
foreach (ClientCard card in Hand) remaining = remaining - Hand.Count(card => card != null && card.IsCode(cardId));
if (card != null && card.Id == cardId) remaining = remaining - SpellZone.Count(card => card != null && card.IsCode(cardId));
remaining--; remaining = remaining - Graveyard.Count(card => card != null && card.IsCode(cardId));
foreach (ClientCard card in SpellZone) remaining = remaining - Banished.Count(card => card != null && card.IsCode(cardId));
if (card != null && card.Id == cardId)
remaining--;
foreach (ClientCard card in Graveyard)
if (card != null && card.Id == cardId)
remaining--;
foreach (ClientCard card in Banished)
if (card != null && card.Id == cardId)
remaining--;
return (remaining < 0) ? 0 : remaining; return (remaining < 0) ? 0 : remaining;
} }
private static int GetCount(IEnumerable<ClientCard> cards) private static int GetCount(IEnumerable<ClientCard> cards)
{ {
int count = 0; return cards.Count(card => card != null);
foreach (ClientCard card in cards)
{
if (card != null)
count++;
}
return count;
} }
public int GetCountCardInZone(IEnumerable<ClientCard> cards, int cardId) public int GetCountCardInZone(IEnumerable<ClientCard> cards, int cardId)
{ {
int count = 0; return cards.Count(card => card != null && card.IsCode(cardId));
foreach (ClientCard card in cards)
{
if (card != null && card.Id == cardId)
count++;
}
return count;
} }
public int GetCountCardInZone(IEnumerable<ClientCard> cards, List<int> cardId) public int GetCountCardInZone(IEnumerable<ClientCard> cards, List<int> cardId)
{ {
int count = 0; return cards.Count(card => card != null && card.IsCode(cardId));
foreach (ClientCard card in cards)
{
if (card != null && cardId.Contains(card.Id))
count++;
}
return count;
} }
private static List<ClientCard> GetCards(IEnumerable<ClientCard> cards, CardType type) private static List<ClientCard> GetCards(IEnumerable<ClientCard> cards, CardType type)
{ {
List<ClientCard> nCards = new List<ClientCard>(); return cards.Where(card => card != null && card.HasType(type)).ToList();
foreach (ClientCard card in cards)
{
if (card != null && card.HasType(type))
nCards.Add(card);
}
return nCards;
} }
private static List<ClientCard> GetCards(IEnumerable<ClientCard> cards) private static List<ClientCard> GetCards(IEnumerable<ClientCard> cards)
{ {
List<ClientCard> nCards = new List<ClientCard>(); return cards.Where(card => card != null).ToList();
foreach (ClientCard card in cards)
{
if (card != null)
nCards.Add(card);
}
return nCards;
} }
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)
{ {
foreach (ClientCard card in cards) return cards.Any(card => card != null && card.IsCode(cardId) && !(notDisabled && card.IsDisabled()) && !(hasXyzMaterial && !card.HasXyzMaterial()) && !(faceUp && card.IsFacedown()));
{
if (card != null && card.Id == cardId && !(notDisabled && card.IsDisabled()) && !(hasXyzMaterial && !card.HasXyzMaterial()))
return true;
}
return false;
} }
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)
{ {
foreach (ClientCard card in cards) return cards.Any(card => card != null && card.IsCode(cardId) && !(notDisabled && card.IsDisabled()) && !(hasXyzMaterial && !card.HasXyzMaterial()) && !(faceUp && card.IsFacedown()));
{
if (card != null && cardId.Contains(card.Id) && !(notDisabled && card.IsDisabled()) && !(hasXyzMaterial && !card.HasXyzMaterial()))
return true;
}
return false;
} }
} }
} }
\ No newline at end of file
...@@ -83,8 +83,7 @@ namespace WindBot.Game ...@@ -83,8 +83,7 @@ namespace WindBot.Game
} }
catch (Exception) catch (Exception)
{ {
if (reader != null) reader?.Close();
reader.Close();
return null; return null;
} }
} }
......
...@@ -360,10 +360,7 @@ namespace WindBot.Game ...@@ -360,10 +360,7 @@ namespace WindBot.Game
return result; return result;
result = new List<ClientCard>(); result = new List<ClientCard>();
// TODO: use selector // TODO: use selector
for (int i = 0; i < cards.Count; i++) result = cards.ToList();
{
result.Add(cards[i]);
}
return result; return result;
} }
...@@ -550,10 +547,15 @@ namespace WindBot.Game ...@@ -550,10 +547,15 @@ namespace WindBot.Game
} }
else else
{ {
if (hint == HINTMSG_SMATERIAL) switch (hint)
selected = Executor.OnSelectSynchroMaterial(cards, sum, min, max); {
if (hint == HINTMSG_RELEASE) case HINTMSG_SMATERIAL:
selected = Executor.OnSelectRitualTribute(cards, sum, min, max); selected = Executor.OnSelectSynchroMaterial(cards, sum, min, max);
break;
case HINTMSG_RELEASE:
selected = Executor.OnSelectRitualTribute(cards, sum, min, max);
break;
}
} }
if (selected != null) if (selected != null)
{ {
...@@ -1017,12 +1019,7 @@ namespace WindBot.Game ...@@ -1017,12 +1019,7 @@ namespace WindBot.Game
/// <returns>A list of the selected attributes.</returns> /// <returns>A list of the selected attributes.</returns>
public virtual IList<CardAttribute> OnAnnounceAttrib(int count, IList<CardAttribute> attributes) public virtual IList<CardAttribute> OnAnnounceAttrib(int count, IList<CardAttribute> attributes)
{ {
IList<CardAttribute> foundAttributes = new List<CardAttribute>(); IList<CardAttribute> foundAttributes = m_attributes.Where(attributes.Contains).ToList();
foreach (CardAttribute attribute in m_attributes)
{
if(attributes.Contains(attribute))
foundAttributes.Add(attribute);
}
if (foundAttributes.Count > 0) if (foundAttributes.Count > 0)
return foundAttributes; return foundAttributes;
...@@ -1037,12 +1034,7 @@ namespace WindBot.Game ...@@ -1037,12 +1034,7 @@ namespace WindBot.Game
/// <returns>A list of the selected races.</returns> /// <returns>A list of the selected races.</returns>
public virtual IList<CardRace> OnAnnounceRace(int count, IList<CardRace> races) public virtual IList<CardRace> OnAnnounceRace(int count, IList<CardRace> races)
{ {
IList<CardRace> foundRaces = new List<CardRace>(); IList<CardRace> foundRaces = m_races.Where(races.Contains).ToList();
foreach (CardRace race in m_races)
{
if (races.Contains(race))
foundRaces.Add(race);
}
if (foundRaces.Count > 0) if (foundRaces.Count > 0)
return foundRaces; return foundRaces;
...@@ -1080,12 +1072,10 @@ namespace WindBot.Game ...@@ -1080,12 +1072,10 @@ namespace WindBot.Game
private bool ShouldExecute(CardExecutor exec, ClientCard card, ExecutorType type, int desc = -1) private bool ShouldExecute(CardExecutor exec, ClientCard card, ExecutorType type, int desc = -1)
{ {
Executor.SetCard(type, card, desc); Executor.SetCard(type, card, desc);
if (card != null && return card != null &&
exec.Type == type && exec.Type == type &&
(exec.CardId == -1 || exec.CardId == card.Id) && (exec.CardId == -1 || exec.CardId == card.Id) &&
(exec.Func == null || exec.Func())) (exec.Func == null || exec.Func());
return true;
return false;
} }
} }
} }
This diff is collapsed.
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