Commit bf22e2d0 authored by nanahira's avatar nanahira

mg

parents 8667065b f92f918b
......@@ -2,8 +2,10 @@
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Linq;
namespace BotWrapper
{
......@@ -12,6 +14,8 @@ namespace BotWrapper
[DllImport("User32.dll", CharSet = CharSet.Unicode)]
public static extern int MessageBox(IntPtr hWnd, string lpText, string lpCaption, int uType);
const int MB_ICONERROR = 0x00000010;
static void Main(string[] args)
{
ProcessStartInfo startInfo = new ProcessStartInfo();
......@@ -24,7 +28,19 @@ namespace BotWrapper
startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
string arg = args[0].Replace("'","\"");
string arg = args[0];
Match match = Regex.Match(arg, "Random=(.*)");
if (match.Success)
{
string randomFlag = match.Groups[1].Value;
ReadBots();
arg = GetRandomBot(randomFlag);
if (arg == "")
{
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("'", "\"");
if (int.Parse(args[1]) == 1)
{
arg += " Hand=1";
......@@ -39,8 +55,51 @@ namespace BotWrapper
}
catch
{
MessageBox((IntPtr)0, "WindBot can't be started!", "WindBot", 0x00000010); // MB_ICONERROR
MessageBox((IntPtr)0, "WindBot can't be started!", "WindBot", MB_ICONERROR);
}
}
public class BotInfo
{
public string name;
public string command;
public string desc;
public string[] flags;
}
static public IList<BotInfo> Bots = new List<BotInfo>();
static void ReadBots()
{
using (StreamReader reader = new StreamReader("bot.conf"))
{
while (!reader.EndOfStream)
{
string line = reader.ReadLine().Trim();
if (line.Length > 0 && line[0] == '!')
{
BotInfo newBot = new BotInfo();
newBot.name = line;
newBot.command = reader.ReadLine().Trim();
newBot.desc = reader.ReadLine().Trim();
line = reader.ReadLine().Trim();
newBot.flags = line.Split(' ');
Bots.Add(newBot);
}
}
}
}
static string GetRandomBot(string flag)
{
IList<BotInfo> foundBots = Bots.Where(bot => bot.flags.Contains(flag)).ToList();
if (foundBots.Count > 0)
{
Random rand = new Random();
BotInfo bot = foundBots[rand.Next(foundBots.Count)];
return bot.command;
}
return "";
}
}
}
......@@ -4,25 +4,40 @@
# description
# flags (avail flags: SUPPORT_MASTER_RULE_3, SUPPORT_NEW_MASTER_RULE)
!随机-非常简单
Random=AI_LV1
主要是一些沙包。
SUPPORT_NEW_MASTER_RULE
!随机-简单
Random=AI_LV2
一些比较弱的卡组。
SUPPORT_NEW_MASTER_RULE
!随机-普通
Random=AI_LV3
一些环境里可以看到的卡组。
SUPPORT_NEW_MASTER_RULE
!谜之剑士LV4-龙骑星爆
Name=谜之剑士LV4 Deck=Dragunity Dialog=swordsman.zh-CN
龙骑轴星尘龙爆裂体卡组。
SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
!谜之剑士LV4-R5
Name=谜之剑士LV4 Deck='Rank V' Dialog=swordsman.zh-CN
5阶超量卡组。
SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
!谜之剑士LV4-异热同心武器
Name=谜之剑士LV4 Deck='Zexal Weapons' Dialog=swordsman.zh-CN
神装电光皇卡组。
SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
!琪露诺-彩虹
Name=琪露诺 Deck=Rainbow Dialog=cirno.zh-CN
全属性凡骨卡组。
SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
!琪露诺-饼蛙
Name=琪露诺 Deck='Toadally Awesome' Dialog=cirno.zh-CN
......@@ -32,7 +47,7 @@ SUPPORT_MASTER_RULE_3
!复制植物-青眼
Name=复制植物 Deck=Blue-Eyes Dialog=copy.zh-CN
青眼卡组。
SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
!复制植物-十二兽
Name=复制植物 Deck=Zoodiac Dialog=copy.zh-CN
......@@ -42,17 +57,22 @@ SUPPORT_MASTER_RULE_3
!尼亚-妖仙兽
Name=尼亚 Deck=Yosenju Dialog=near.zh-CN
妖仙兽卡组。
SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
!尼亚-机壳
Name=尼亚 Deck=Qliphort Dialog=near.zh-CN
机壳卡组。
SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
!尼亚-淘气仙星
Name=尼亚 Deck=Trickstar Dialog=near.zh-CN
淘气仙星卡组。
SUPPORT_NEW_MASTER_RULE
AI_LV3 SUPPORT_NEW_MASTER_RULE
!尼亚-幻变骚灵
Name=尼亚 Deck=Altergeist Dialog=near.zh-CN
幻变骚灵卡组。
AI_LV3 SUPPORT_NEW_MASTER_RULE
!永远之魂-削血
Name=永远之魂 Deck=Burn Dialog=soul.zh-CN
......@@ -62,44 +82,59 @@ SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
!永远之魂-青蛙
Name=永远之魂 Deck=Frog Dialog=soul.zh-CN
老式青蛙卡组。
SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
AI_LV1 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
!永远之魂-荷鲁斯
Name=永远之魂 Deck=Horus Dialog=soul.zh-CN
老式龙族卡组。
SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
AI_LV1 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
!悠悠
Name=悠悠 Deck=MokeyMokey Dialog=mokey.zh-CN
沙包。
SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
AI_LV1 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
!悠悠王
Name=悠悠王 Deck=MokeyMokeyKing Dialog=mokey.zh-CN
大沙包。
SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
AI_LV1 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
!试作型机器人1732
Name=试作型机器人1732 Deck=ST1732 Dialog=zh-CN
由三盒ST17和三盒SD32组成的卡组。
SUPPORT_NEW_MASTER_RULE
AI_LV2 SUPPORT_NEW_MASTER_RULE
!奇異果
Name=奇異果 Deck=LightswornShaddoldinosour Dialog=kiwi.zh-TW
光道影依恐龙卡组。
SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
!奇魔果
Name=奇魔果 Deck=DarkMagician Dialog=kiwi.zh-TW
黑魔术师卡组。
SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
!MAX龍果
Name=MAX龍果 Deck=BlueEyesMaxDragon Dialog=kiwi.zh-TW
青眼混沌极龙卡组。
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
!幻煌果
Name=幻煌果 Deck=Phantasm Dialog=kiwi.zh-TW
幻煌龙卡组。
AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
!燃血鬥士
Name=燃血鬥士 Deck=ChainBurn Dialog=kiwi.zh-TW
连锁烧卡组。
SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE
!報社鬥士
Name=報社鬥士 Deck=GrenMajuThunderBoarder Dialog=kiwi.zh-TW
红莲雷王滑板卡组。
AI_LV3 SUPPORT_NEW_MASTER_RULE
!复制梁龙-闪刀姬
Name=复制梁龙 Deck=SkyStriker Dialog=anothercopy.zh-CN
纯闪刀姬卡组。
SUPPORT_NEW_MASTER_RULE
AI_LV3 SUPPORT_NEW_MASTER_RULE
#created by ...
#main
52927340
53143898
53143898
53143898
42790071
42790071
14558127
14558127
59438930
62015408
62015408
89538537
89538537
23434538
23434538
23434538
25533642
25533642
25533642
2295440
18144506
35261759
68462976
68462976
10045474
10045474
10045474
10813327
23924608
35146019
35146019
27541563
27541563
53936268
53936268
53936268
61740673
40605147
40605147
41420027
41420027
#extra
99916754
86221741
85289965
5043010
49725936
24094258
59934749
1508649
1508649
1508649
50588353
63288573
90673288
41999284
94259633
!side
#created by ...
#main
89631139
55410871
89631139
80701178
31036355
38517737
80701178
80701178
95492061
95492061
95492061
53303460
53303460
53303460
14558127
14558127
23434538
55410871
55410871
31036355
31036355
48800175
48800175
48800175
70368879
70368879
70368879
21082832
46052429
46052429
46052429
24224830
24224830
24224830
73915051
10045474
10045474
37576645
37576645
37576645
#extra
31833038
85289965
74997493
5043010
65330383
38342335
2857636
28776350
75452921
3987233
3987233
99111753
98978921
41999284
41999284
!side
75732622
15397015
15397015
73642296
23434538
5821478
77058170
3679218
25774450
43898403
23002292
23002292
84749824
84749824
#created by ...
#main
15397015
15397015
15397015
71564252
71564252
71564252
14558127
14558127
36584821
36584821
36584821
23434538
23434538
63845230
63845230
63845230
18144506
35261759
35261759
35261759
59750328
59750328
98645731
98645731
98645731
73915051
73915051
10045474
10045474
10813327
15693423
23924608
47475363
47475363
30241314
30241314
58921041
58921041
61740673
61936647
69452756
40605147
40605147
77538567
77538567
#extra
86221741
31833038
85289965
5043010
30194529
38342335
2857636
24094258
50588353
3987233
3987233
63288573
98978921
41999284
41999284
!side
10000080
86937530
62015408
9742784
70368879
19508728
10045474
15693423
24207889
69452756
23002292
41420027
41420027
#created by ...
#main
81823360
81823360
81823360
14558127
14558127
63845230
18144506
35261759
35261759
47325505
47325505
59750328
59750328
59750328
73628505
98645731
98645731
98645731
73915051
73915051
2819435
2819435
2819435
10045474
34302287
34302287
34302287
47475363
58120309
61397885
61397885
89208725
89208725
19089195
19089195
19089195
53334471
53334471
82732705
99188141
#extra
44508094
5821478
31833038
85289965
65330383
72529749
61665245
38342335
2857636
75452921
50588353
3987233
98978921
41999284
41999284
!side
24094258
47475363
61397885
30241314
30241314
82732705
using System.Collections.Generic;
using System.Linq;
using YGOSharp.OCGWrapper.Enums;
namespace WindBot.Game.AI
{
......@@ -41,6 +42,13 @@ namespace WindBot.Game.AI
return 1;
}
/// <summary>
/// Get the total ATK Monster of the player.
/// </summary>
public int GetTotalAttackingMonsterAttack(int player)
{
return Duel.Fields[player].GetMonsters().Where(m => m.IsAttack()).Sum(m => (int?)m.Attack) ?? 0;
}
/// <summary>
/// Get the best ATK or DEF power of the field.
/// </summary>
......@@ -48,17 +56,9 @@ namespace WindBot.Game.AI
/// <param name="onlyATK">Only calculate attack.</param>
public int GetBestPower(ClientField field, bool onlyATK = false)
{
int bestPower = -1;
for (int i = 0; i < 7; ++i)
{
ClientCard card = field.MonsterZone[i];
if (card == null || card.Data == null) continue;
if (onlyATK && card.IsDefense()) continue;
int newPower = card.GetDefensePower();
if (newPower > bestPower)
bestPower = newPower;
}
return bestPower;
return field.MonsterZone.GetMonsters()
.Where(card => !onlyATK || card.IsAttack())
.Max(card => (int?)card.GetDefensePower()) ?? -1;
}
public int GetBestAttack(ClientField field)
......@@ -68,36 +68,15 @@ namespace WindBot.Game.AI
public bool IsOneEnemyBetterThanValue(int value, bool onlyATK)
{
int bestValue = -1;
bool nomonster = true;
for (int i = 0; i < 7; ++i)
{
ClientCard card = Enemy.MonsterZone[i];
if (card == null || card.Data == null) continue;
if (onlyATK && card.IsDefense()) continue;
nomonster = false;
int enemyValue = card.GetDefensePower();
if (enemyValue > bestValue)
bestValue = enemyValue;
}
if (nomonster) return false;
return bestValue > value;
return Enemy.MonsterZone.GetMonsters()
.Any(card => card.GetDefensePower() > value && (!onlyATK || card.IsAttack()));
}
public bool IsAllEnemyBetterThanValue(int value, bool onlyATK)
{
bool nomonster = true;
for (int i = 0; i < 7; ++i)
{
ClientCard card = Enemy.MonsterZone[i];
if (card == null || card.Data == null) continue;
if (onlyATK && card.IsDefense()) continue;
nomonster = false;
int enemyValue = card.GetDefensePower();
if (enemyValue <= value)
return false;
}
return !nomonster;
List<ClientCard> monsters = Enemy.MonsterZone.GetMonsters();
return monsters.Count > 0 && monsters
.All(card => card.GetDefensePower() > value && (!onlyATK || card.IsAttack()));
}
/// <summary>
......@@ -133,59 +112,24 @@ namespace WindBot.Game.AI
public ClientCard GetBestBotMonster(bool onlyATK = false)
{
int bestPower = -1;
ClientCard bestMonster = null;
for (int i = 0; i < 7; ++i)
{
ClientCard card = Bot.MonsterZone[i];
if (card == null || card.Data == null) continue;
if (onlyATK && card.IsDefense()) continue;
int newPower = card.GetDefensePower();
if (newPower > bestPower)
{
bestPower = newPower;
bestMonster = card;
}
}
return bestMonster;
return Bot.MonsterZone.GetMonsters()
.Where(card => !onlyATK || card.IsAttack())
.OrderByDescending(card => card.GetDefensePower())
.FirstOrDefault();
}
public ClientCard GetWorstBotMonster(bool onlyATK = false)
{
int WorstPower = -1;
ClientCard WorstMonster = null;
for (int i = 0; i < 7; ++i)
{
ClientCard card = Bot.MonsterZone[i];
if (card == null || card.Data == null) continue;
if (onlyATK && card.IsDefense()) continue;
int newPower = card.GetDefensePower();
if (newPower < WorstPower)
{
WorstPower = newPower;
WorstMonster = card;
}
}
return WorstMonster;
return Bot.MonsterZone.GetMonsters()
.Where(card => !onlyATK || card.IsAttack())
.OrderBy(card => card.GetDefensePower())
.FirstOrDefault();
}
public ClientCard GetOneEnemyBetterThanValue(int value, bool onlyATK = false, bool canBeTarget = false)
{
ClientCard bestCard = null;
int bestValue = value;
for (int i = 0; i < 7; ++i)
{
ClientCard card = Enemy.MonsterZone[i];
if (card == null || card.Data == null || (canBeTarget && card.IsShouldNotBeTarget())) continue;
if (onlyATK && card.IsDefense()) continue;
int enemyValue = card.GetDefensePower();
if (enemyValue >= bestValue)
{
bestCard = card;
bestValue = enemyValue;
}
}
return bestCard;
return Enemy.MonsterZone.GetMonsters()
.FirstOrDefault(card => card.GetDefensePower() > value && (!onlyATK || card.IsAttack()) && (!canBeTarget || !card.IsShouldNotBeTarget()));
}
public ClientCard GetOneEnemyBetterThanMyBest(bool onlyATK = false, bool canBeTarget = false)
......@@ -276,21 +220,10 @@ namespace WindBot.Game.AI
public ClientCard GetWorstEnemyMonster(bool onlyATK = false)
{
int WorstPower = -1;
ClientCard WorstMonster = null;
for (int i = 0; i < 7; ++i)
{
ClientCard card = Enemy.MonsterZone[i];
if (card == null || card.Data == null) continue;
if (onlyATK && card.IsDefense()) continue;
int newPower = card.GetDefensePower();
if (newPower < WorstPower)
{
WorstPower = newPower;
WorstMonster = card;
}
}
return WorstMonster;
return Enemy.MonsterZone.GetMonsters()
.Where(card => !onlyATK || card.IsAttack())
.OrderBy(card => card.GetDefensePower())
.FirstOrDefault();
}
public ClientCard GetBestEnemySpell(bool onlyFaceup = false)
......@@ -299,14 +232,11 @@ namespace WindBot.Game.AI
if (card != null)
return card;
List<ClientCard> spells = Enemy.GetSpells();
var spells = Enemy.GetSpells();
foreach (ClientCard ecard in spells)
{
if (ecard.IsFaceup() && ecard.HasType(CardType.Continuous)||
ecard.IsFaceup() && ecard.HasType(CardType.Field))
return ecard;
}
card = spells.FirstOrDefault(ecard => ecard.IsFaceup() && (ecard.HasType(CardType.Continuous) || ecard.HasType(CardType.Field)));
if (card != null)
return card;
if (spells.Count > 0 && !onlyFaceup)
return spells[0];
......@@ -336,105 +266,140 @@ namespace WindBot.Game.AI
return Duel.Turn == 1 || Duel.Phase == DuelPhase.Main2;
}
public bool IsChainTarget(ClientCard card)
internal bool inListOrNull(ClientCard card, IList<ClientCard> list)
{
foreach (ClientCard target in Duel.ChainTargets)
return card == null || list.Contains(card);
}
public int GetBotAvailZonesFromExtraDeck(IList<ClientCard> remove)
{
if (card.Equals(target))
if (!Duel.IsNewRule)
return Zones.MainMonsterZones;
int result = 0;
if (inListOrNull(Bot.MonsterZone[5], remove) && inListOrNull(Bot.MonsterZone[6], remove) &&
(inListOrNull(Enemy.MonsterZone[5], remove) || inListOrNull(Enemy.MonsterZone[6], remove)))
result |= Zones.ExtraMonsterZones;
if (inListOrNull(Bot.MonsterZone[0], remove) &&
(!inListOrNull(Bot.MonsterZone[1], remove) && Bot.MonsterZone[1].HasLinkMarker(CardLinkMarker.Left) ||
!inListOrNull(Bot.MonsterZone[5], remove) && Bot.MonsterZone[5].HasLinkMarker(CardLinkMarker.BottomLeft) ||
!inListOrNull(Enemy.MonsterZone[6], remove) && Enemy.MonsterZone[6].HasLinkMarker(CardLinkMarker.TopRight)))
result += Zones.z0;
if (inListOrNull(Bot.MonsterZone[1], remove) &&
(!inListOrNull(Bot.MonsterZone[0], remove) && Bot.MonsterZone[0].HasLinkMarker(CardLinkMarker.Right) ||
!inListOrNull(Bot.MonsterZone[2], remove) && Bot.MonsterZone[2].HasLinkMarker(CardLinkMarker.Left) ||
!inListOrNull(Bot.MonsterZone[5], remove) && Bot.MonsterZone[5].HasLinkMarker(CardLinkMarker.Bottom) ||
!inListOrNull(Enemy.MonsterZone[6], remove) && Enemy.MonsterZone[6].HasLinkMarker(CardLinkMarker.Top)))
result += Zones.z1;
if (inListOrNull(Bot.MonsterZone[2], remove) &&
(!inListOrNull(Bot.MonsterZone[1], remove) && Bot.MonsterZone[1].HasLinkMarker(CardLinkMarker.Right) ||
!inListOrNull(Bot.MonsterZone[3], remove) && Bot.MonsterZone[3].HasLinkMarker(CardLinkMarker.Left) ||
!inListOrNull(Bot.MonsterZone[5], remove) && Bot.MonsterZone[5].HasLinkMarker(CardLinkMarker.BottomRight) ||
!inListOrNull(Enemy.MonsterZone[6], remove) && Enemy.MonsterZone[6].HasLinkMarker(CardLinkMarker.TopLeft) ||
!inListOrNull(Bot.MonsterZone[6], remove) && Bot.MonsterZone[6].HasLinkMarker(CardLinkMarker.BottomLeft) ||
!inListOrNull(Enemy.MonsterZone[5], remove) && Enemy.MonsterZone[5].HasLinkMarker(CardLinkMarker.TopRight)))
result += Zones.z2;
if (inListOrNull(Bot.MonsterZone[3], remove) &&
(!inListOrNull(Bot.MonsterZone[2], remove) && Bot.MonsterZone[2].HasLinkMarker(CardLinkMarker.Right) ||
!inListOrNull(Bot.MonsterZone[4], remove) && Bot.MonsterZone[4].HasLinkMarker(CardLinkMarker.Left) ||
!inListOrNull(Bot.MonsterZone[6], remove) && Bot.MonsterZone[6].HasLinkMarker(CardLinkMarker.Bottom) ||
!inListOrNull(Enemy.MonsterZone[5], remove) && Enemy.MonsterZone[5].HasLinkMarker(CardLinkMarker.Top)))
result += Zones.z3;
if (inListOrNull(Bot.MonsterZone[4], remove) &&
(!inListOrNull(Bot.MonsterZone[3], remove) && Bot.MonsterZone[3].HasLinkMarker(CardLinkMarker.Right) ||
!inListOrNull(Bot.MonsterZone[6], remove) && Bot.MonsterZone[6].HasLinkMarker(CardLinkMarker.BottomRight) ||
!inListOrNull(Enemy.MonsterZone[5], remove) && Enemy.MonsterZone[5].HasLinkMarker(CardLinkMarker.TopLeft)))
result += Zones.z4;
return result;
}
public int GetBotAvailZonesFromExtraDeck(ClientCard remove)
{
return true;
return GetBotAvailZonesFromExtraDeck(new [] { remove });
}
public int GetBotAvailZonesFromExtraDeck()
{
return GetBotAvailZonesFromExtraDeck(new List<ClientCard>());
}
return false;
public bool IsChainTarget(ClientCard card)
{
return Duel.ChainTargets.Any(card.Equals);
}
public bool IsChainTargetOnly(ClientCard card)
{
return Duel.ChainTargets.Count == 1 && card.Equals(Duel.ChainTargets[0]);
return Duel.ChainTargetOnly.Count == 1 && card.Equals(Duel.ChainTargetOnly[0]);
}
public bool ChainContainsCard(int id)
{
foreach (ClientCard card in Duel.CurrentChain)
{
if (card.Id == id)
return true;
return Duel.CurrentChain.Any(card => card.IsCode(id));
}
return false;
public bool ChainContainsCard(int[] ids)
{
return Duel.CurrentChain.Any(card => card.IsCode(ids));
}
public int ChainCountPlayer(int player)
{
int count = 0;
foreach (ClientCard card in Duel.CurrentChain)
{
if (card.Controller == player)
count++;
}
return count;
return Duel.CurrentChain.Count(card => card.Controller == player);
}
public bool ChainContainPlayer(int player)
{
foreach (ClientCard card in Duel.CurrentChain)
{
if (card.Controller == player)
return true;
}
return false;
return Duel.CurrentChain.Any(card => card.Controller == player);
}
public bool HasChainedTrap(int player)
{
foreach (ClientCard card in Duel.CurrentChain)
{
if (card.Controller == player && card.HasType(CardType.Trap))
return true;
}
return false;
return Duel.CurrentChain.Any(card => card.Controller == player && card.HasType(CardType.Trap));
}
public ClientCard GetLastChainCard()
{
if (Duel.CurrentChain.Count > 0)
return Duel.CurrentChain[Duel.CurrentChain.Count - 1];
return null;
return Duel.CurrentChain.LastOrDefault();
}
/// <summary>
/// Select cards listed in preferred.
/// </summary>
public void SelectPreferredCards(IList<ClientCard> selected, ClientCard preferred, IList<ClientCard> cards, int min, int max)
public IList<ClientCard> SelectPreferredCards(ClientCard preferred, IList<ClientCard> cards, int min, int max)
{
IList<ClientCard> selected = new List<ClientCard>();
if (cards.IndexOf(preferred) > 0 && selected.Count < max)
{
selected.Add(preferred);
}
return selected;
}
/// <summary>
/// Select cards listed in preferred.
/// </summary>
public void SelectPreferredCards(IList<ClientCard> selected, int preferred, IList<ClientCard> cards, int min, int max)
public IList<ClientCard> SelectPreferredCards(int preferred, IList<ClientCard> cards, int min, int max)
{
IList<ClientCard> selected = new List<ClientCard>();
foreach (ClientCard card in cards)
{
if (card.Id== preferred && selected.Count < max)
if (card.IsCode(preferred) && selected.Count < max)
selected.Add(card);
}
return selected;
}
/// <summary>
/// Select cards listed in preferred.
/// </summary>
public void SelectPreferredCards(IList<ClientCard> selected, IList<ClientCard> preferred, IList<ClientCard> cards, int min, int max)
{
IList<ClientCard> avail = new List<ClientCard>();
foreach (ClientCard card in cards)
public IList<ClientCard> SelectPreferredCards(IList<ClientCard> preferred, IList<ClientCard> cards, int min, int max)
{
// clone
avail.Add(card);
}
IList<ClientCard> selected = new List<ClientCard>();
IList<ClientCard> avail = cards.ToList(); // clone
while (preferred.Count > 0 && avail.IndexOf(preferred[0]) > 0 && selected.Count < max)
{
ClientCard card = preferred[0];
......@@ -442,30 +407,36 @@ namespace WindBot.Game.AI
avail.Remove(card);
selected.Add(card);
}
return selected;
}
/// <summary>
/// Select cards listed in preferred.
/// </summary>
public void SelectPreferredCards(IList<ClientCard> selected, IList<int> preferred, IList<ClientCard> cards, int min, int max)
public IList<ClientCard> SelectPreferredCards(IList<int> preferred, IList<ClientCard> cards, int min, int max)
{
for (int i = 0; i < preferred.Count; i++)
IList<ClientCard> selected = new List<ClientCard>();
foreach (int id in preferred)
{
foreach (ClientCard card in cards)
{
if (card.Id == preferred[i] && selected.Count < max && selected.IndexOf(card) <= 0)
if (card.IsCode(id) && selected.Count < max && selected.IndexOf(card) <= 0)
selected.Add(card);
}
if (selected.Count >= max)
break;
}
return selected;
}
/// <summary>
/// Check and fix selected to make sure it meet the count requirement.
/// </summary>
public void CheckSelectCount(IList<ClientCard> selected, IList<ClientCard> cards, int min, int max)
public IList<ClientCard> CheckSelectCount(IList<ClientCard> _selected, IList<ClientCard> cards, int min, int max)
{
var selected = _selected.ToList();
if (selected.Count < min)
{
foreach (ClientCard card in cards)
......@@ -480,6 +451,8 @@ namespace WindBot.Game.AI
{
selected.RemoveAt(selected.Count - 1);
}
return selected;
}
}
}
\ No newline at end of file
using System.Collections.Generic;
using YGOSharp.OCGWrapper.Enums;
using System;
using System.Linq;
namespace WindBot.Game.AI
......@@ -8,175 +9,90 @@ namespace WindBot.Game.AI
{
public static ClientCard GetHighestAttackMonster(this IEnumerable<ClientCard> cards, bool canBeTarget = false)
{
int highestAtk = 0;
ClientCard selected = null;
foreach (ClientCard card in cards)
{
if (card == null || card.Data == null || card.IsFacedown() || (canBeTarget && card.IsShouldNotBeTarget())) continue;
if (card.HasType(CardType.Monster) && card.Attack > highestAtk)
{
highestAtk = card.Attack;
selected = card;
}
}
return selected;
return cards
.Where(card => card?.Data != null && card.HasType(CardType.Monster) && card.IsFaceup() && !(canBeTarget && card.IsShouldNotBeTarget()))
.OrderBy(card => card.Attack).FirstOrDefault();
}
public static ClientCard GetHighestDefenseMonster(this IEnumerable<ClientCard> cards, bool canBeTarget = false)
{
int highestDef = 0;
ClientCard selected = null;
foreach (ClientCard card in cards)
{
if (card == null || card.Data == null || card.IsFacedown() || (canBeTarget && card.IsShouldNotBeTarget())) continue;
if (card.HasType(CardType.Monster) && card.Defense > highestDef)
{
highestDef = card.Defense;
selected = card;
}
}
return selected;
return cards
.Where(card => card?.Data != null && card.HasType(CardType.Monster) && card.IsFaceup() && !(canBeTarget && card.IsShouldNotBeTarget()))
.OrderBy(card => card.Defense).FirstOrDefault();
}
public static ClientCard GetLowestAttackMonster(this IEnumerable<ClientCard> cards, bool canBeTarget = false)
{
int lowestAtk = 0;
ClientCard selected = null;
foreach (ClientCard card in cards)
{
if (card == null || card.Data == null || card.IsFacedown() || (canBeTarget && card.IsShouldNotBeTarget())) continue;
if (lowestAtk == 0 && card.HasType(CardType.Monster) ||
card.HasType(CardType.Monster) && card.Attack < lowestAtk)
{
lowestAtk = card.Attack;
selected = card;
}
}
return selected;
return cards
.Where(card => card?.Data != null && card.HasType(CardType.Monster) && card.IsFaceup() && !(canBeTarget && card.IsShouldNotBeTarget()))
.OrderByDescending(card => card.Attack).FirstOrDefault();
}
public static ClientCard GetLowestDefenseMonster(this IEnumerable<ClientCard> cards, bool canBeTarget = false)
{
int lowestDef = 0;
ClientCard selected = null;
foreach (ClientCard card in cards)
{
if (card == null || card.Data == null || card.IsFacedown() || (canBeTarget && card.IsShouldNotBeTarget())) continue;
if (lowestDef == 0 && card.HasType(CardType.Monster) ||
card.HasType(CardType.Monster) && card.Defense < lowestDef)
{
lowestDef = card.Defense;
selected = card;
}
}
return selected;
return cards
.Where(card => card?.Data != null && card.HasType(CardType.Monster) && card.IsFaceup() && !(canBeTarget && card.IsShouldNotBeTarget()))
.OrderByDescending(card => card.Defense).FirstOrDefault();
}
public static bool ContainsMonsterWithLevel(this IEnumerable<ClientCard> cards, int level)
{
foreach (ClientCard card in cards)
{
if (card == null)
continue;
if (!card.HasType(CardType.Xyz) && card.Level == level)
return true;
}
return false;
return cards.Where(card => card?.Data != null).Any(card => !card.HasType(CardType.Xyz) && card.Level == level);
}
public static bool ContainsMonsterWithRank(this IEnumerable<ClientCard> cards, int rank)
{
foreach (ClientCard card in cards)
{
if (card == null)
continue;
if (card.HasType(CardType.Xyz) && card.Rank == rank)
return true;
}
return false;
return cards.Where(card => card?.Data != null).Any(card => card.HasType(CardType.Xyz) && card.Rank == rank);
}
public static bool ContainsCardWithId(this IEnumerable<ClientCard> cards, int id)
{
foreach (ClientCard card in cards)
{
if (card == null)
continue;
if (card.Id == id)
return true;
}
return false;
return cards.Where(card => card?.Data != null).Any(card => card.IsCode(id));
}
public static int GetCardCount(this IEnumerable<ClientCard> cards, int id)
{
int count = 0;
foreach (ClientCard card in cards)
{
if (card == null)
continue;
if (card.Id == id)
count++;
}
return count;
return cards.Where(card => card?.Data != null).Count(card => card.IsCode(id));
}
public static List<ClientCard> GetMonsters(this IEnumerable<ClientCard> cards)
{
List<ClientCard> cardlist = new List<ClientCard>();
foreach (ClientCard card in cards)
{
if (card == null)
continue;
if (card.HasType(CardType.Monster))
cardlist.Add(card);
}
return cardlist;
return cards.Where(card => card?.Data != null && card.HasType(CardType.Monster)).ToList();
}
public static List<ClientCard> GetFaceupPendulumMonsters(this IEnumerable<ClientCard> cards)
{
List<ClientCard> cardlist = new List<ClientCard>();
foreach (ClientCard card in cards)
{
if (card == null)
continue;
if (card.HasType(CardType.Monster) && card.IsFaceup() && card.HasType(CardType.Pendulum))
cardlist.Add(card);
}
return cardlist;
return cards.Where(card => card?.Data != null && card.HasType(CardType.Monster) && card.IsFaceup() && card.HasType(CardType.Pendulum)).ToList();
}
public static ClientCard GetInvincibleMonster(this IEnumerable<ClientCard> cards, bool canBeTarget = false)
{
foreach (ClientCard card in cards)
{
if (card != null && card.IsMonsterInvincible() && card.IsFaceup() && (!canBeTarget || !card.IsShouldNotBeTarget()))
return card;
}
return null;
return cards.FirstOrDefault(card => card?.Data != null && card.IsMonsterInvincible() && card.IsFaceup() && (!canBeTarget || !card.IsShouldNotBeTarget()));
}
public static ClientCard GetDangerousMonster(this IEnumerable<ClientCard> cards, bool canBeTarget = false)
{
foreach (ClientCard card in cards)
{
if (card != null && card.IsMonsterDangerous() && card.IsFaceup() && (!canBeTarget || !card.IsShouldNotBeTarget()))
return card;
}
return null;
return cards.FirstOrDefault(card => card?.Data != null && card.IsMonsterDangerous() && card.IsFaceup() && (!canBeTarget || !card.IsShouldNotBeTarget()));
}
public static ClientCard GetFloodgate(this IEnumerable<ClientCard> cards, bool canBeTarget = false)
{
foreach (ClientCard card in cards)
return cards.FirstOrDefault(card => card?.Data != null && card.IsFloodgate() && card.IsFaceup() && (!canBeTarget || !card.IsShouldNotBeTarget()));
}
public static ClientCard GetFirstMatchingCard(this IEnumerable<ClientCard> cards, Func<ClientCard, bool> filter)
{
return cards.FirstOrDefault(card => card?.Data != null && filter.Invoke(card));
}
public static ClientCard GetFirstMatchingFaceupCard(this IEnumerable<ClientCard> cards, Func<ClientCard, bool> filter)
{
if (card != null && card.IsFloodgate() && card.IsFaceup() && (!canBeTarget || !card.IsShouldNotBeTarget()))
return card;
return cards.FirstOrDefault(card => card?.Data != null && card.IsFaceup() && filter.Invoke(card));
}
return null;
public static ClientCard GetShouldBeDisabledBeforeItUseEffectMonster(this IEnumerable<ClientCard> cards, bool canBeTarget = true)
{
return cards.FirstOrDefault(card => card?.Data != null && card.IsMonsterShouldBeDisabledBeforeItUseEffect() && card.IsFaceup() && (!canBeTarget || !card.IsShouldNotBeTarget()));
}
public static IEnumerable<IEnumerable<T>> GetCombinations<T>(this IEnumerable<T> elements, int k)
......
......@@ -63,18 +63,18 @@ namespace WindBot.Game.AI
break;
case SelectType.Cards:
foreach (ClientCard card in _cards)
if (cards.Contains(card))
if (cards.Contains(card) && !result.Contains(card))
result.Add(card);
break;
case SelectType.Id:
foreach (ClientCard card in cards)
if (card.Id == _id)
if (card.IsCode(_id))
result.Add(card);
break;
case SelectType.Ids:
foreach (int id in _ids)
foreach (ClientCard card in cards)
if (card.Id == id)
if (card.IsCode(id) && !result.Contains(card))
result.Add(card);
break;
case SelectType.Location:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -111,7 +111,7 @@ namespace WindBot.Game.AI.Decks
{
List<ClientCard> monster = Bot.GetMonsters();
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 false;
}
......@@ -119,7 +119,7 @@ namespace WindBot.Game.AI.Decks
private bool KalutTheMoonShadowSummon()
{
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 true;
}
......@@ -127,7 +127,7 @@ namespace WindBot.Game.AI.Decks
private bool BlizzardTheFarNorthSummon()
{
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 false;
}
......@@ -138,7 +138,7 @@ namespace WindBot.Game.AI.Decks
List<ClientCard> monster = Bot.GetMonsters();
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++;
if (Count == 3)
......
using YGOSharp.OCGWrapper.Enums;
using System.Collections.Generic;
using System.Linq;
using WindBot;
using WindBot.Game;
using WindBot.Game.AI;
......@@ -138,27 +139,11 @@ namespace WindBot.Game.AI.Decks
if (max == 2 && cards[0].Location == CardLocation.Deck)
{
Logger.DebugWriteLine("OnSelectCard MelodyOfAwakeningDragon");
IList<ClientCard> result = new List<ClientCard>();
List<ClientCard> result = new List<ClientCard>();
if (!Bot.HasInHand(CardId.WhiteDragon))
{
foreach (ClientCard card in cards)
{
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;
result.AddRange(cards.Where(card => card.IsCode(CardId.WhiteDragon)).Take(1));
result.AddRange(cards.Where(card => card.IsCode(CardId.AlternativeWhiteDragon)));
return AI.Utils.CheckSelectCount(result, cards, min, max);
}
Logger.DebugWriteLine("Use default.");
return null;
......@@ -167,10 +152,8 @@ namespace WindBot.Game.AI.Decks
public override IList<ClientCard> OnSelectXyzMaterial(IList<ClientCard> cards, int min, int max)
{
Logger.DebugWriteLine("OnSelectXyzMaterial " + cards.Count + " " + min + " " + max);
IList<ClientCard> result = new List<ClientCard>();
AI.Utils.SelectPreferredCards(result, UsedAlternativeWhiteDragon, cards, min, max);
AI.Utils.CheckSelectCount(result, cards, min, max);
return result;
IList<ClientCard> result = AI.Utils.SelectPreferredCards(UsedAlternativeWhiteDragon, cards, min, max);
return AI.Utils.CheckSelectCount(result, cards, min, max);
}
public override IList<ClientCard> OnSelectSynchroMaterial(IList<ClientCard> cards, int sum, int min, int max)
......@@ -194,33 +177,30 @@ namespace WindBot.Game.AI.Decks
private bool DragonShrineEffect()
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.DragonSpiritOfWhite,
CardId.WhiteDragon,
CardId.WhiteStoneOfAncients,
CardId.WhiteStoneOfLegend
});
);
if (!Bot.HasInHand(CardId.WhiteDragon))
{
AI.SelectNextCard(CardId.WhiteStoneOfLegend);
}
else
{
AI.SelectNextCard(new[]
{
AI.SelectNextCard(
CardId.WhiteStoneOfAncients,
CardId.DragonSpiritOfWhite,
CardId.WhiteStoneOfLegend
});
);
}
return true;
}
private bool MelodyOfAwakeningDragonEffect()
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.WhiteStoneOfAncients,
CardId.DragonSpiritOfWhite,
CardId.WhiteStoneOfLegend,
......@@ -228,7 +208,7 @@ namespace WindBot.Game.AI.Decks
CardId.EffectVeiler,
CardId.TradeIn,
CardId.SageWithEyesOfBlue
});
);
return true;
}
......@@ -268,11 +248,7 @@ namespace WindBot.Game.AI.Decks
}
else if (!Bot.HasInHand(CardId.WhiteDragon) || !Bot.HasInHand(CardId.AlternativeWhiteDragon))
{
AI.SelectCard(new[]
{
CardId.WhiteDragon,
CardId.AlternativeWhiteDragon
});
AI.SelectCard(CardId.WhiteDragon, CardId.AlternativeWhiteDragon);
return true;
}
else
......@@ -365,12 +341,11 @@ namespace WindBot.Game.AI.Decks
{
return false;
}
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.WhiteStoneOfAncients,
CardId.EffectVeiler,
CardId.WhiteStoneOfLegend
});
);
return true;
}
......@@ -398,11 +373,7 @@ namespace WindBot.Game.AI.Decks
{
return false;
}
AI.SelectCard(new[]
{
CardId.WhiteStoneOfLegend,
CardId.WhiteStoneOfAncients
});
AI.SelectCard(CardId.WhiteStoneOfLegend, CardId.WhiteStoneOfAncients);
if (Enemy.GetSpellCount() > 0)
{
AI.SelectNextCard(CardId.DragonSpiritOfWhite);
......@@ -747,20 +718,18 @@ namespace WindBot.Game.AI.Decks
private bool GalaxyEyesDarkMatterDragonEffect()
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.WhiteStoneOfAncients,
CardId.WhiteStoneOfLegend,
CardId.DragonSpiritOfWhite,
CardId.WhiteDragon
});
AI.SelectNextCard(new[]
{
);
AI.SelectNextCard(
CardId.WhiteStoneOfAncients,
CardId.WhiteStoneOfLegend,
CardId.DragonSpiritOfWhite,
CardId.WhiteDragon
});
);
return true;
}
......@@ -839,11 +808,7 @@ namespace WindBot.Game.AI.Decks
private bool SylvanPrincesspriteEffect()
{
AI.SelectCard(new[]
{
CardId.WhiteStoneOfLegend,
CardId.WhiteStoneOfAncients
});
AI.SelectCard(CardId.WhiteStoneOfLegend, CardId.WhiteStoneOfAncients);
return true;
}
......@@ -875,8 +840,7 @@ namespace WindBot.Game.AI.Decks
if (attack - defence > Enemy.LifePoints)
return false;
}
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.BlueEyesSpiritDragon,
CardId.HopeHarbingerDragonTitanicGalaxy,
CardId.AlternativeWhiteDragon,
......@@ -885,7 +849,7 @@ namespace WindBot.Game.AI.Decks
CardId.AzureEyesSilverDragon,
CardId.WhiteStoneOfAncients,
CardId.WhiteStoneOfLegend
});
);
SoulChargeUsed = true;
return true;
}
......@@ -900,23 +864,16 @@ namespace WindBot.Game.AI.Decks
return true;
if (Card.IsDefense() && !enemyBetter && Card.Attack >= Card.Defense)
return true;
if (Card.IsDefense() && (
Card.Id == CardId.BlueEyesSpiritDragon
|| Card.Id == CardId.AzureEyesSilverDragon
))
if (Card.IsDefense() && Card.IsCode(CardId.BlueEyesSpiritDragon, CardId.AzureEyesSilverDragon))
return true;
if (Card.IsAttack() && (
Card.Id == CardId.SageWithEyesOfBlue
|| Card.Id == CardId.WhiteStoneOfAncients
|| Card.Id == CardId.WhiteStoneOfLegend
))
if (Card.IsAttack() && Card.IsCode(CardId.SageWithEyesOfBlue, CardId.WhiteStoneOfAncients, CardId.WhiteStoneOfLegend))
return true;
return false;
}
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)
......@@ -924,7 +881,7 @@ namespace WindBot.Game.AI.Decks
int num = 0;
foreach (ClientCard card in Bot.Hand)
{
if (card != null && card.Id == id)
if (card != null && card.IsCode(id))
num++;
}
return num >= 2;
......
using YGOSharp.OCGWrapper.Enums;
using System.Collections.Generic;
using WindBot;
using WindBot.Game;
using WindBot.Game.AI;
namespace WindBot.Game.AI.Decks
{
[Deck("BlueEyesMaxDragon", "AI_BlueEyesMaxDragon", "Normal")]
public class BlueEyesMaxDragonExecutor : DefaultExecutor
{
public class CardId
{
public const int BlueEyesWhiteDragon = 89631139;
public const int BlueEyesAlternativeWhiteDragon = 38517737;
public const int DeviritualTalismandra = 80701178;
public const int ManguOfTheTenTousandHands = 95492061;
public const int DevirrtualCandoll = 53303460;
public const int AshBlossom = 14558127;
public const int MaxxC = 23434538;
public const int BlueEyesChaosMaxDragon = 55410871;
public const int CreatureSwap= 31036355;
public const int TheMelodyOfAwakeningDragon = 48800175;
public const int UpstartGoblin = 70368879;
public const int ChaosForm = 21082832;
public const int AdvancedRitualArt = 46052429;
public const int CalledByTheGrave = 24224830;
public const int Scapegoat = 73915051;
public const int InfiniteImpermanence = 10045474;
public const int RecklessGreed = 37576645;
public const int BorreloadDragon = 31833038;
public const int BirrelswordDragon = 85289965;
public const int KnightmareGryphon = 65330383;
public const int MissusRadiant = 3987233;
public const int LinkSpider = 98978921;
public const int Linkuriboh = 41999284;
public const int LockBird = 94145021;
public const int Ghost = 59438930;
}
public BlueEyesMaxDragonExecutor(GameAI ai, Duel duel)
: base(ai, duel)
{
//counter
AddExecutor(ExecutorType.Activate, CardId.AshBlossom, DefaultAshBlossomAndJoyousSpring);
AddExecutor(ExecutorType.Activate, CardId.MaxxC, MaxxCeff);
AddExecutor(ExecutorType.Activate, CardId.InfiniteImpermanence, DefaultInfiniteImpermanence);
AddExecutor(ExecutorType.Activate, CardId.CalledByTheGrave, CalledByTheGraveeff);
//first
AddExecutor(ExecutorType.Activate, CardId.UpstartGoblin);
AddExecutor(ExecutorType.Activate, CardId.BlueEyesAlternativeWhiteDragon, BlueEyesAlternativeWhiteDragoneff);
AddExecutor(ExecutorType.Activate, CardId.CreatureSwap, CreatureSwapeff);
AddExecutor(ExecutorType.Activate, CardId.TheMelodyOfAwakeningDragon, TheMelodyOfAwakeningDragoneff);
//summon
AddExecutor(ExecutorType.Summon, CardId.ManguOfTheTenTousandHands);
AddExecutor(ExecutorType.Activate, CardId.ManguOfTheTenTousandHands, TenTousandHandseff);
AddExecutor(ExecutorType.Activate, DeviritualCheck);
//ritual summon
AddExecutor(ExecutorType.Activate, CardId.AdvancedRitualArt);
AddExecutor(ExecutorType.Activate, CardId.ChaosForm, ChaosFormeff);
//sp summon
AddExecutor(ExecutorType.SpSummon, CardId.MissusRadiant, MissusRadiantsp);
AddExecutor(ExecutorType.Activate, CardId.MissusRadiant, MissusRadianteff);
AddExecutor(ExecutorType.Activate, CardId.Linkuriboh, Linkuriboheff);
AddExecutor(ExecutorType.SpSummon, CardId.Linkuriboh, Linkuribohsp);
AddExecutor(ExecutorType.SpSummon, CardId.LinkSpider);
AddExecutor(ExecutorType.SpSummon, CardId.BirrelswordDragon, BirrelswordDragonsp);
AddExecutor(ExecutorType.Activate, CardId.BirrelswordDragon, BirrelswordDragoneff);
//set
AddExecutor(ExecutorType.Activate, CardId.TheMelodyOfAwakeningDragon, TheMelodyOfAwakeningDragoneffsecond);
AddExecutor(ExecutorType.SpellSet, SpellSet);
AddExecutor(ExecutorType.Repos, DefaultMonsterRepos);
//
AddExecutor(ExecutorType.Activate, CardId.RecklessGreed, RecklessGreedeff);
AddExecutor(ExecutorType.Activate, CardId.Scapegoat, Scapegoateff);
}
int Talismandra_count = 0;
int Candoll_count = 0;
bool Talismandra_used = false;
bool Candoll_used = false;
int RitualArt_count = 0;
int ChaosForm_count = 0;
int MaxDragon_count = 0;
int TheMelody_count = 0;
public override void OnNewTurn()
{
Talismandra_used = false;
Candoll_used = false;
base.OnNewTurn();
}
private void Count_check()
{
TheMelody_count = 0;
Talismandra_count = 0;
Candoll_count = 0;
RitualArt_count = 0;
ChaosForm_count = 0;
MaxDragon_count = 0;
foreach (ClientCard check in Bot.Hand)
{
if (check.IsCode(CardId.AdvancedRitualArt))
RitualArt_count++;
if (check.IsCode(CardId.ChaosForm))
ChaosForm_count++;
if (check.IsCode(CardId.DevirrtualCandoll))
Candoll_count++;
if (check.IsCode(CardId.DeviritualTalismandra))
Talismandra_count++;
if (check.IsCode(CardId.BlueEyesChaosMaxDragon))
MaxDragon_count++;
if (check.IsCode(CardId.TheMelodyOfAwakeningDragon))
TheMelody_count++;
}
}
private bool MaxxCeff()
{
return Duel.Player == 1;
}
private bool CalledByTheGraveeff()
{
if(Duel.LastChainPlayer==1)
{
ClientCard lastCard = AI.Utils.GetLastChainCard();
if (lastCard.IsCode(CardId.MaxxC))
{
AI.SelectCard(CardId.MaxxC);
if(AI.Utils.ChainContainsCard(CardId.TheMelodyOfAwakeningDragon))
AI.SelectNextCard(CardId.BlueEyesChaosMaxDragon, CardId.BlueEyesChaosMaxDragon, CardId.BlueEyesAlternativeWhiteDragon);
return UniqueFaceupSpell();
}
if (lastCard.IsCode(CardId.LockBird))
{
AI.SelectCard(CardId.LockBird);
if (AI.Utils.ChainContainsCard(CardId.TheMelodyOfAwakeningDragon))
AI.SelectNextCard(CardId.BlueEyesChaosMaxDragon, CardId.BlueEyesChaosMaxDragon, CardId.BlueEyesAlternativeWhiteDragon);
return UniqueFaceupSpell();
}
if (lastCard.IsCode(CardId.Ghost))
{
AI.SelectCard(CardId.Ghost);
if (AI.Utils.ChainContainsCard(CardId.TheMelodyOfAwakeningDragon))
AI.SelectNextCard(CardId.BlueEyesChaosMaxDragon, CardId.BlueEyesChaosMaxDragon, CardId.BlueEyesAlternativeWhiteDragon);
return UniqueFaceupSpell();
}
if (lastCard.IsCode(CardId.AshBlossom))
{
AI.SelectCard(CardId.AshBlossom);
if (AI.Utils.ChainContainsCard(CardId.TheMelodyOfAwakeningDragon))
AI.SelectNextCard(CardId.BlueEyesChaosMaxDragon, CardId.BlueEyesChaosMaxDragon, CardId.BlueEyesAlternativeWhiteDragon);
return UniqueFaceupSpell();
}
}
return false;
}
private bool BlueEyesAlternativeWhiteDragoneff()
{
if(Card.Location==CardLocation.Hand)
{
if (Duel.Turn == 1)
return false;
return true;
}
else
{
if(AI.Utils.GetProblematicEnemyMonster(3000,true)!=null)
{
AI.SelectCard(AI.Utils.GetProblematicEnemyMonster(3000, true));
return true;
}
}
return false;
}
private bool CreatureSwapeff()
{
if(Bot.HasInMonstersZone(CardId.BlueEyesChaosMaxDragon,true) && Duel.Phase==DuelPhase.Main1 &&
(Bot.HasInMonstersZone(CardId.DeviritualTalismandra) || Bot.HasInMonstersZone(CardId.DevirrtualCandoll)))
{
AI.SelectCard(CardId.DevirrtualCandoll, CardId.DeviritualTalismandra);
return true;
}
return false;
}
private bool TheMelodyOfAwakeningDragoneff()
{
Count_check();
if(TheMelody_count>=2 && Bot.GetRemainingCount(CardId.BlueEyesChaosMaxDragon,3)>0)
{
AI.SelectCard(CardId.TheMelodyOfAwakeningDragon);
AI.SelectNextCard(CardId.BlueEyesChaosMaxDragon, CardId.BlueEyesChaosMaxDragon, CardId.BlueEyesAlternativeWhiteDragon);
return true;
}
if(Bot.HasInHand(CardId.BlueEyesWhiteDragon) && Bot.GetRemainingCount(CardId.BlueEyesChaosMaxDragon, 3) > 0)
{
AI.SelectCard(CardId.BlueEyesWhiteDragon);
AI.SelectNextCard(CardId.BlueEyesChaosMaxDragon, CardId.BlueEyesChaosMaxDragon, CardId.BlueEyesAlternativeWhiteDragon);
return true;
}
return false;
}
private bool TheMelodyOfAwakeningDragoneffsecond()
{
Count_check();
if (RitualArtCanUse() && Bot.GetRemainingCount(CardId.BlueEyesChaosMaxDragon, 3) > 0 &&
!Bot.HasInHand(CardId.BlueEyesChaosMaxDragon) && Bot.Hand.Count>=3)
{
if(RitualArt_count>=2)
{
foreach (ClientCard m in Bot.Hand)
{
if (m.IsCode(CardId.AdvancedRitualArt))
AI.SelectCard(m);
}
}
foreach(ClientCard m in Bot.Hand)
{
if (!m.IsCode(CardId.AdvancedRitualArt))
AI.SelectCard(m);
}
AI.SelectNextCard(CardId.BlueEyesChaosMaxDragon, CardId.BlueEyesChaosMaxDragon, CardId.BlueEyesAlternativeWhiteDragon);
return true;
}
return false;
}
private bool TenTousandHandseff()
{
Count_check();
if(Talismandra_count>=2 && Bot.GetRemainingCount(CardId.BlueEyesChaosMaxDragon,3)>0)
{
AI.SelectCard(CardId.BlueEyesChaosMaxDragon);
return true;
}
if(Candoll_count>=2 || MaxDragon_count >= 2)
{
if(RitualArtCanUse() && Bot.GetRemainingCount(CardId.AdvancedRitualArt,3)>0)
{
AI.SelectCard(CardId.AdvancedRitualArt);
return true;
}
if(ChaosFormCanUse() && Bot.GetRemainingCount(CardId.ChaosForm,1)>0)
{
AI.SelectCard(CardId.ChaosForm);
return true;
}
}
if(RitualArt_count+ChaosForm_count>=2)
{
AI.SelectCard(CardId.BlueEyesChaosMaxDragon);
return true;
}
if(Candoll_count+Talismandra_count>1)
{
if (MaxDragon_count >= 1)
{
if (RitualArtCanUse() && Bot.GetRemainingCount(CardId.AdvancedRitualArt, 3) > 0)
{
AI.SelectCard(CardId.AdvancedRitualArt);
return true;
}
if (ChaosFormCanUse() && Bot.GetRemainingCount(CardId.ChaosForm, 1) > 0)
{
AI.SelectCard(CardId.ChaosForm);
return true;
}
}
if(Bot.HasInHand(CardId.AdvancedRitualArt) || Bot.HasInHand(CardId.ChaosForm))
{
AI.SelectCard(CardId.BlueEyesChaosMaxDragon);
return true;
}
}
if (ChaosForm_count >= 1)
{
if (RitualArtCanUse() && Bot.GetRemainingCount(CardId.AdvancedRitualArt, 3) > 0)
{
AI.SelectCard(CardId.AdvancedRitualArt);
return true;
}
if (ChaosFormCanUse() && Bot.GetRemainingCount(CardId.ChaosForm, 1) > 0)
{
AI.SelectCard(CardId.ChaosForm);
return true;
}
}
if (Talismandra_count>=1)
{
AI.SelectCard(CardId.BlueEyesChaosMaxDragon);
return true;
}
if(MaxDragon_count>=1)
{
if (RitualArtCanUse() && Bot.GetRemainingCount(CardId.AdvancedRitualArt, 3) > 0)
{
AI.SelectCard(CardId.AdvancedRitualArt);
return true;
}
if (ChaosFormCanUse() && Bot.GetRemainingCount(CardId.ChaosForm, 1) > 0)
{
AI.SelectCard(CardId.ChaosForm);
return true;
}
}
if (RitualArtCanUse() && Bot.GetRemainingCount(CardId.AdvancedRitualArt, 3) > 0)
{
AI.SelectCard(CardId.AdvancedRitualArt);
}
if (ChaosFormCanUse() && Bot.GetRemainingCount(CardId.ChaosForm, 1) > 0)
{
AI.SelectCard(CardId.ChaosForm);
}
return true;
}
private bool RitualArtCanUse()
{
return Bot.GetRemainingCount(CardId.BlueEyesWhiteDragon,2)>0;
}
private bool ChaosFormCanUse()
{
ClientCard check = null;
foreach (ClientCard m in Bot.GetGraveyardMonsters())
{
if (m.IsCode(CardId.BlueEyesAlternativeWhiteDragon, CardId.BlueEyesChaosMaxDragon, CardId.BlueEyesWhiteDragon))
check = m;
}
foreach (ClientCard m in Bot.Hand)
{
if (m.IsCode(CardId.BlueEyesWhiteDragon))
check = m;
}
if (check != null)
{
return true;
}
return false;
}
private bool DeviritualCheck()
{
Count_check();
if(Card.IsCode(CardId.DeviritualTalismandra, CardId.DevirrtualCandoll))
{
if (Card.Location == CardLocation.MonsterZone)
{
if(RitualArtCanUse())
{
AI.SelectCard(CardId.AdvancedRitualArt);
}
else
{
AI.SelectCard(CardId.ChaosForm);
}
return true;
}
if(Card.Location==CardLocation.Hand)
{
if(Card.IsCode(CardId.DevirrtualCandoll))
{
if (MaxDragon_count >= 2 && Talismandra_count >= 1 || Candoll_used)
return false;
}
if(Card.IsCode(CardId.DeviritualTalismandra))
{
if (RitualArt_count + ChaosForm_count >= 2 && Candoll_count >= 1 || Talismandra_used)
return false;
Talismandra_used = true;
return true;
}
if(RitualArtCanUse())
{
Candoll_used = true;
AI.SelectCard(CardId.AdvancedRitualArt);
return true;
}
if (ChaosFormCanUse())
{
Candoll_used = true;
AI.SelectCard(CardId.ChaosForm);
return true;
}
return true;
}
}
return false;
}
private bool ChaosFormeff()
{
ClientCard check = null;
foreach(ClientCard m in Bot.Graveyard)
{
if (m.IsCode(CardId.BlueEyesAlternativeWhiteDragon, CardId.BlueEyesChaosMaxDragon, CardId.BlueEyesWhiteDragon))
check = m;
}
if(check != null)
{
AI.SelectCard(CardId.BlueEyesChaosMaxDragon);
AI.SelectNextCard(check);
return true;
}
foreach(ClientCard m in Bot.Hand)
{
if (m.IsCode(CardId.BlueEyesWhiteDragon))
check = m;
}
if (check != null)
{
AI.SelectCard(CardId.BlueEyesChaosMaxDragon);
AI.SelectNextCard(check);
return true;
}
return false;
}
private bool MissusRadiantsp()
{
IList<ClientCard> material_list = new List<ClientCard>();
foreach (ClientCard monster in Bot.GetMonsters())
{
if (monster.HasAttribute(CardAttribute.Earth) && monster.Level == 1)
material_list.Add(monster);
if (material_list.Count == 2) break;
}
if (material_list.Count < 2) return false;
if (Bot.HasInMonstersZone(CardId.MissusRadiant)) return false;
AI.SelectMaterials(material_list);
if (Bot.MonsterZone[0] == null && Bot.MonsterZone[2] == null && Bot.MonsterZone[5] == null)
AI.SelectPlace(Zones.z5);
else
AI.SelectPlace(Zones.z6);
return true;
}
private bool MissusRadianteff()
{
AI.SelectCard(CardId.MaxxC, CardId.MissusRadiant);
return true;
}
private bool Linkuribohsp()
{
foreach (ClientCard c in Bot.GetMonsters())
{
if (!c.IsCode(CardId.Linkuriboh) && c.Level == 1)
{
AI.SelectMaterials(c);
return true;
}
}
return false;
}
private bool Linkuriboheff()
{
if (Duel.LastChainPlayer == 0 && AI.Utils.GetLastChainCard().IsCode(CardId.Linkuriboh)) return false;
return true;
}
private bool BirrelswordDragonsp()
{
IList<ClientCard> material_list = new List<ClientCard>();
foreach (ClientCard m in Bot.GetMonsters())
{
if (m.IsCode(CardId.MissusRadiant))
{
material_list.Add(m);
break;
}
}
foreach (ClientCard m in Bot.GetMonsters())
{
if (m.IsCode(CardId.Linkuriboh) || m.Level==1)
{
material_list.Add(m);
if (material_list.Count == 3)
break;
}
}
if (material_list.Count == 3)
{
AI.SelectMaterials(material_list);
return true;
}
return false;
}
private bool BirrelswordDragoneff()
{
if (ActivateDescription == AI.Utils.GetStringId(CardId.BirrelswordDragon, 0))
{
if (AI.Utils.IsChainTarget(Card) && AI.Utils.GetBestEnemyMonster(true, true) != null)
{
AI.SelectCard(AI.Utils.GetBestEnemyMonster(true, true));
return true;
}
if (Duel.Player == 1 && Bot.BattlingMonster == Card)
{
AI.SelectCard(Enemy.BattlingMonster);
return true;
}
if (Duel.Player == 1 && Bot.BattlingMonster != null &&
(Enemy.BattlingMonster.Attack - Bot.BattlingMonster.Attack) >= Bot.LifePoints)
{
AI.SelectCard(Enemy.BattlingMonster);
return true;
}
if (Duel.Player == 0 && Duel.Phase == DuelPhase.BattleStart)
{
foreach (ClientCard check in Enemy.GetMonsters())
{
if (check.IsAttack())
{
AI.SelectCard(check);
return true;
}
}
}
return false;
}
return true;
}
private bool SpellSet()
{
if (Card.IsCode(CardId.InfiniteImpermanence))
return !Bot.IsFieldEmpty();
if (Card.IsCode(CardId.RecklessGreed))
return true;
if (Card.IsCode(CardId.Scapegoat))
return true;
return false;
}
private bool RecklessGreedeff()
{
int count = 0;
foreach (ClientCard card in Bot.GetSpells())
{
if (card.IsCode(CardId.RecklessGreed))
count++;
}
if (DefaultOnBecomeTarget()) return true;
if(Duel.Player==0 && Duel.Phase>=DuelPhase.Main1)
{
if (Bot.LifePoints <= 4000 || count>=2)
return true;
}
return false;
}
private bool Scapegoateff()
{
if (Duel.Player == 0) return false;
if (Duel.Phase == DuelPhase.End) return true;
if (Duel.LastChainPlayer == 1 && DefaultOnBecomeTarget()) return true;
if (Duel.Phase > DuelPhase.Main1 && Duel.Phase < DuelPhase.Main2)
{
int total_atk = 0;
List<ClientCard> enemy_monster = Enemy.GetMonsters();
foreach (ClientCard m in enemy_monster)
{
if (m.IsAttack() && !m.Attacked) total_atk += m.Attack;
}
if (total_atk >= Bot.LifePoints) return true;
}
return false;
}
public override ClientCard OnSelectAttacker(IList<ClientCard> attackers, IList<ClientCard> defenders)
{
for (int i = 0; i < attackers.Count; ++i)
{
ClientCard attacker = attackers[i];
if (attacker.IsCode(CardId.BlueEyesChaosMaxDragon))
{
Logger.DebugWriteLine(attacker.Name);
return attacker;
}
}
return base.OnSelectAttacker(attackers, defenders);
}
public override BattlePhaseAction OnSelectAttackTarget(ClientCard attacker, IList<ClientCard> defenders)
{
if(attacker.IsCode(CardId.BlueEyesChaosMaxDragon) && !attacker.IsDisabled() &&
Enemy.HasInMonstersZone(new[] {CardId.DeviritualTalismandra,CardId.DevirrtualCandoll }))
{
for (int i = 0; i < defenders.Count; i++)
{
ClientCard defender = defenders[i];
attacker.RealPower = attacker.Attack;
defender.RealPower = defender.GetDefensePower();
if (!OnPreBattleBetween(attacker, defender))
continue;
if (defender.IsCode(CardId.DevirrtualCandoll, CardId.DeviritualTalismandra))
{
return AI.Attack(attacker, defender);
}
}
}
return base.OnSelectAttackTarget(attacker, defenders);
}
public override bool OnSelectHand()
{
return false;
}
}
}
......@@ -108,7 +108,7 @@ namespace WindBot.Game.AI.Decks
{
foreach (ClientCard card in Bot.GetMonsters())
{
if (card.Id == CardId.Marshmallon || card.Id == CardId.SpiritReaper)
if (card.IsCode(CardId.Marshmallon, CardId.SpiritReaper))
{
return false;
}
......@@ -134,9 +134,9 @@ namespace WindBot.Game.AI.Decks
private bool ReposEverything()
{
if (Card.Id == CardId.ReflectBounder)
if (Card.IsCode(CardId.ReflectBounder))
return Card.IsDefense();
if (Card.Id == CardId.FencingFireFerret)
if (Card.IsCode(CardId.FencingFireFerret))
return DefaultMonsterRepos();
if (Card.IsAttack())
return true;
......
......@@ -227,7 +227,7 @@ namespace WindBot.Game.AI.Decks
{
return (id == CardId.SandaionTheTimelord ||
id == CardId.BattleFader ||
id ==CardId.MichionTimelord
id == CardId.MichionTimelord
);
}
bool no_sp = false;
......@@ -322,49 +322,49 @@ namespace WindBot.Game.AI.Decks
IList<ClientCard> check = Bot.GetSpells();
foreach (ClientCard card in check)
{
if (card.Id == CardId.AccuulatedFortune)
if (card.IsCode(CardId.AccuulatedFortune))
HasAccuulatedFortune++;
}
foreach (ClientCard card in check)
{
if (card.Id == CardId.SecretBlast)
if (card.IsCode(CardId.SecretBlast))
blast_count++;
}
foreach (ClientCard card in check)
{
if (card.Id == CardId.SectetBarrel)
if (card.IsCode(CardId.SectetBarrel))
barrel_count++;
}
foreach (ClientCard card in check)
{
if (card.Id == CardId.JustDesserts)
if (card.IsCode(CardId.JustDesserts))
just_count++;
}
foreach (ClientCard card in check)
{
if (card.Id == CardId.ChainStrike)
if (card.IsCode(CardId.ChainStrike))
strike_count++;
}
foreach (ClientCard card in Bot.GetSpells())
{
if (card.Id == CardId.RecklessGreed)
if (card.IsCode(CardId.RecklessGreed))
greed_count++;
}
foreach (ClientCard card in check)
{
if (card.Id == CardId.Waboku)
if (card.IsCode(CardId.Waboku))
Waboku_count++;
}
foreach (ClientCard card in check)
{
if (card.Id == CardId.ThreateningRoar)
if (card.IsCode(CardId.ThreateningRoar))
Roar_count++;
}
......@@ -418,7 +418,7 @@ namespace WindBot.Game.AI.Decks
if (AI.Utils.IsChainTarget(Card)) return true;
foreach (ClientCard card in Enemy.GetSpells())
{
if (card.Id == CardId.HarpiesFeatherDuster&&card.IsFaceup())
if (card.IsCode(CardId.HarpiesFeatherDuster)&&card.IsFaceup())
{
return true;
}
......@@ -432,7 +432,7 @@ namespace WindBot.Game.AI.Decks
}
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;
}
private bool MichionTimelordsummon()
......@@ -565,7 +565,7 @@ namespace WindBot.Game.AI.Decks
int count=0;
foreach (ClientCard card in Bot.GetSpells())
{
if (card.Id == CardId.RecklessGreed)
if (card.IsCode(CardId.RecklessGreed))
count++;
}
......@@ -668,7 +668,7 @@ namespace WindBot.Game.AI.Decks
{
foreach (ClientCard card in Bot.GetMonsters())
{
if (card.Id == CardId.CardcarD && card.IsFaceup())
if (card.IsCode(CardId.CardcarD) && card.IsFaceup())
return false;
}
if (Bot.GetHandCount() == 1 && Bot.GetSpellCountWithoutField() <= 3)
......@@ -694,7 +694,7 @@ namespace WindBot.Game.AI.Decks
foreach (ClientCard card in Bot.GetMonsters())
{
if (card.Id == CardId.DiceJar && card.IsFacedown())
if (card.IsCode(CardId.DiceJar) && card.IsFacedown())
return true;
break;
}
......@@ -725,24 +725,24 @@ namespace WindBot.Game.AI.Decks
if (GetTotalATK(newlist) / 2 >= Enemy.LifePoints && Bot.HasInSpellZone(CardId.BlazingMirrorForce))
return false;
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;
}
public bool MonsterRepos()
{
if (Card.IsFacedown() && Card.Id!=CardId.DiceJar)
if (Card.IsFacedown() && !Card.IsCode(CardId.DiceJar))
return true;
return base.DefaultMonsterRepos();
}
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
{
if (attacker.Id == CardId.Linkuriboh && defender.IsFacedown()) return false;
if (attacker.Id == CardId.SandaionTheTimelord && !attacker.IsDisabled())
if (attacker.IsCode(CardId.Linkuriboh) && defender.IsFacedown()) return false;
if (attacker.IsCode(CardId.SandaionTheTimelord) && !attacker.IsDisabled())
{
attacker.RealPower = 9999;
return true;
}
if(attacker.Id==CardId.MichionTimelord && !attacker.IsDisabled())
if(attacker.IsCode(CardId.MichionTimelord) && !attacker.IsDisabled())
{
attacker.RealPower = 9999;
return true;
......@@ -771,49 +771,49 @@ namespace WindBot.Game.AI.Decks
IList<ClientCard> check = Bot.GetSpells();
foreach (ClientCard card1 in check)
{
if (card1.Id == CardId.AccuulatedFortune)
if (card1.IsCode(CardId.AccuulatedFortune))
HasAccuulatedFortune++;
}
foreach (ClientCard card1 in check)
{
if (card1.Id == CardId.SecretBlast)
if (card1.IsCode(CardId.SecretBlast))
blast_count++;
}
foreach (ClientCard card1 in check)
{
if (card1.Id == CardId.SectetBarrel)
if (card1.IsCode(CardId.SectetBarrel))
barrel_count++;
}
foreach (ClientCard card1 in check)
{
if (card1.Id == CardId.JustDesserts)
if (card1.IsCode(CardId.JustDesserts))
just_count++;
}
foreach (ClientCard card1 in check)
{
if (card1.Id == CardId.ChainStrike)
if (card1.IsCode(CardId.ChainStrike))
strike_count++;
}
foreach (ClientCard card1 in Bot.GetSpells())
{
if (card1.Id == CardId.RecklessGreed)
if (card1.IsCode(CardId.RecklessGreed))
greed_count++;
}
foreach (ClientCard card1 in check)
{
if (card1.Id == CardId.Waboku)
if (card1.IsCode(CardId.Waboku))
Waboku_count++;
}
foreach (ClientCard card1 in check)
{
if (card1.Id == CardId.ThreateningRoar)
if (card1.IsCode(CardId.ThreateningRoar))
Roar_count++;
}
......
......@@ -169,7 +169,7 @@ namespace WindBot.Game.AI.Decks
int BotZone = 0;
for (int i = 0; i <= 6; i++)
{
if (Enemy.MonsterZone[i] != null && Enemy.MonsterZone[i].Id == CardId.MekkKnightMorningStar)
if (Enemy.MonsterZone[i] != null && Enemy.MonsterZone[i].IsCode(CardId.MekkKnightMorningStar))
{
MekkKnightZone = i;
break;
......@@ -242,7 +242,7 @@ namespace WindBot.Game.AI.Decks
ApprenticeLllusionMagician_count = 0;
foreach (ClientCard count in Bot.GetMonsters())
{
if (count.Id == CardId.ApprenticeLllusionMagician && count.IsFaceup())
if (count.IsCode(CardId.ApprenticeLllusionMagician) && count.IsFaceup())
ApprenticeLllusionMagician_count++;
}
foreach (ClientCard dangerous in Enemy.GetMonsters())
......@@ -352,7 +352,7 @@ namespace WindBot.Game.AI.Decks
int ghost_count = 0;
foreach (ClientCard check in Enemy.Graveyard)
{
if (check.Id == CardId.Ghost)
if (check.IsCode(CardId.Ghost))
ghost_count++;
}
if (ghost_count != ghost_done)
......@@ -385,7 +385,7 @@ namespace WindBot.Game.AI.Decks
Bot.HasInMonstersZone(CardId.WindwitchSnowBell))
{
//AI.SelectPlace(Zones.z5, Zones.ExtraMonsterZones);
AI.SelectCard(new[] { CardId.WindwitchIceBell, CardId.WindwitchGlassBell });
AI.SelectCard(CardId.WindwitchIceBell, CardId.WindwitchGlassBell);
AI.SelectPosition(CardPosition.FaceUpAttack);
return true;
}
......@@ -502,7 +502,7 @@ namespace WindBot.Game.AI.Decks
private bool ChainEnemy()
{
if (AI.Utils.GetLastChainCard() != null &&
AI.Utils.GetLastChainCard().Id == CardId.UpstartGoblin)
AI.Utils.GetLastChainCard().IsCode(CardId.UpstartGoblin))
return false;
return Duel.LastChainPlayer == 1;
}
......@@ -577,7 +577,7 @@ namespace WindBot.Game.AI.Decks
{
foreach (ClientCard c in Bot.GetMonsters())
{
if (c.Id != CardId.WindwitchSnowBell && c.Level == 1 && c.Id != CardId.LinkSpider && c.Id != CardId.Linkuriboh)
if (!c.IsCode(CardId.WindwitchSnowBell) && c.Level == 1 && !c.IsCode(CardId.LinkSpider) && !c.IsCode(CardId.Linkuriboh))
{
AI.SelectCard(c);
return true;
......@@ -589,7 +589,7 @@ namespace WindBot.Game.AI.Decks
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;
if (Bot.HasInMonstersZone(CardId.WindwitchSnowBell)) return false;
return true;
}
......@@ -636,7 +636,7 @@ namespace WindBot.Game.AI.Decks
IList<ClientCard> magician = new List<ClientCard>();
foreach (ClientCard check in grave)
{
if (check.Id == CardId.DarkMagician)
if (check.IsCode(CardId.DarkMagician))
{
magician.Add(check);
}
......@@ -653,7 +653,7 @@ namespace WindBot.Game.AI.Decks
foreach (ClientCard target in Duel.ChainTargets)
{
if ((target.Id == CardId.DarkMagician || target.Id == CardId.DarkMagicianTheDragonKnight)
if ((target.IsCode(CardId.DarkMagician, CardId.DarkMagicianTheDragonKnight))
&& Card.IsFacedown())
{
AI.SelectYesNo(false);
......@@ -793,7 +793,7 @@ namespace WindBot.Game.AI.Decks
bool soul_faceup = false;
foreach (ClientCard check in Bot.GetSpells())
{
if (check.Id == CardId.EternalSoul && check.IsFaceup())
if (check.IsCode(CardId.EternalSoul) && check.IsFaceup())
{
soul_faceup = true;
}
......@@ -810,15 +810,9 @@ namespace WindBot.Game.AI.Decks
AI.SelectCard(CardId.DarkMagician);
ClientCard check = AI.Utils.GetOneEnemyBetterThanValue(2500, true);
if (check != null)
AI.SelectNextCard(new[] {
CardId.ApprenticeLllusionMagician,
CardId.DarkMagician,
CardId.MagicianOfLllusion});
AI.SelectNextCard(CardId.ApprenticeLllusionMagician, CardId.DarkMagician, CardId.MagicianOfLllusion);
else
AI.SelectNextCard(new[] {
CardId.ApprenticeLllusionMagician,
CardId.DarkMagician,
CardId.MagicianOfLllusion});
AI.SelectNextCard(CardId.ApprenticeLllusionMagician, CardId.DarkMagician, CardId.MagicianOfLllusion);
magician_sp = true;
return UniqueFaceupSpell();
}
......@@ -828,15 +822,9 @@ namespace WindBot.Game.AI.Decks
AI.SelectCard(CardId.DarkMagician);
ClientCard check = AI.Utils.GetOneEnemyBetterThanValue(2500, true);
if (check != null)
AI.SelectNextCard(new[] {
CardId.ApprenticeLllusionMagician,
CardId.DarkMagician,
CardId.MagicianOfLllusion});
AI.SelectNextCard(CardId.ApprenticeLllusionMagician, CardId.DarkMagician, CardId.MagicianOfLllusion);
else
AI.SelectNextCard(new[] {
CardId.ApprenticeLllusionMagician,
CardId.DarkMagician,
CardId.MagicianOfLllusion});
AI.SelectNextCard(CardId.ApprenticeLllusionMagician, CardId.DarkMagician, CardId.MagicianOfLllusion);
magician_sp = true;
return true;
}
......@@ -846,15 +834,9 @@ namespace WindBot.Game.AI.Decks
AI.SelectCard(CardId.DarkMagician);
ClientCard check = AI.Utils.GetOneEnemyBetterThanValue(2500, true);
if (check != null)
AI.SelectNextCard(new[] {
CardId.ApprenticeLllusionMagician,
CardId.DarkMagician,
CardId.MagicianOfLllusion});
AI.SelectNextCard(CardId.ApprenticeLllusionMagician, CardId.DarkMagician, CardId.MagicianOfLllusion);
else
AI.SelectNextCard(new[] {
CardId.ApprenticeLllusionMagician,
CardId.DarkMagician,
CardId.MagicianOfLllusion});
AI.SelectNextCard(CardId.ApprenticeLllusionMagician, CardId.DarkMagician, CardId.MagicianOfLllusion);
magician_sp = true;
return UniqueFaceupSpell();
}
......@@ -866,15 +848,9 @@ namespace WindBot.Game.AI.Decks
AI.SelectCard(CardId.DarkMagician);
ClientCard check = AI.Utils.GetOneEnemyBetterThanValue(2500, true);
if (check != null)
AI.SelectNextCard(new[] {
CardId.ApprenticeLllusionMagician,
CardId.DarkMagician,
CardId.MagicianOfLllusion});
AI.SelectNextCard(CardId.ApprenticeLllusionMagician, CardId.DarkMagician, CardId.MagicianOfLllusion);
else
AI.SelectNextCard(new[] {
CardId.ApprenticeLllusionMagician,
CardId.DarkMagician,
CardId.MagicianOfLllusion});
AI.SelectNextCard(CardId.ApprenticeLllusionMagician, CardId.DarkMagician, CardId.MagicianOfLllusion);
magician_sp = true;
return UniqueFaceupSpell();
}
......@@ -886,15 +862,9 @@ namespace WindBot.Game.AI.Decks
AI.SelectCard(CardId.DarkMagician);
ClientCard check = AI.Utils.GetOneEnemyBetterThanValue(2500, true);
if (check != null)
AI.SelectNextCard(new[] {
CardId.ApprenticeLllusionMagician,
CardId.DarkMagician,
CardId.MagicianOfLllusion});
AI.SelectNextCard(CardId.ApprenticeLllusionMagician, CardId.DarkMagician, CardId.MagicianOfLllusion);
else
AI.SelectNextCard(new[] {
CardId.ApprenticeLllusionMagician,
CardId.DarkMagician,
CardId.MagicianOfLllusion});
AI.SelectNextCard(CardId.ApprenticeLllusionMagician, CardId.DarkMagician, CardId.MagicianOfLllusion);
magician_sp = true;
return UniqueFaceupSpell();
}
......@@ -940,7 +910,7 @@ namespace WindBot.Game.AI.Decks
//AI.SelectPlace(Zones.z2, 2);
foreach (ClientCard m in Bot.GetSpells())
{
if (m.Id == CardId.EternalSoul && m.IsFaceup())
if (m.IsCode(CardId.EternalSoul) && m.IsFaceup())
soul_exist = true;
}
if (!soul_used && soul_exist)
......@@ -948,7 +918,7 @@ namespace WindBot.Game.AI.Decks
if (Bot.HasInMonstersZone(CardId.MagiciansRod))
{
AI.SelectCard(CardId.MagiciansRod);
AI.SelectNextCard(new[] { CardId.DarkMagician, CardId.DarkMagician });
AI.SelectNextCard(CardId.DarkMagician, CardId.DarkMagician);
return true;
}
}
......@@ -957,15 +927,15 @@ namespace WindBot.Game.AI.Decks
int ghost_count = 0;
foreach (ClientCard check in Enemy.Graveyard)
{
if (check.Id == CardId.Ghost)
if (check.IsCode(CardId.Ghost))
ghost_count++;
}
if (ghost_count != ghost_done)
{
if (Duel.CurrentChain.Count >= 2 && AI.Utils.GetLastChainCard().Id == 0)
if (Duel.CurrentChain.Count >= 2 && AI.Utils.GetLastChainCard().IsCode(0))
{
AI.SelectCard(CardId.MagiciansRod);
AI.SelectNextCard(new[] { CardId.DarkMagician, CardId.DarkMagician });
AI.SelectNextCard(CardId.DarkMagician, CardId.DarkMagician);
return true;
}
}
......@@ -981,50 +951,50 @@ namespace WindBot.Game.AI.Decks
}
}
if (count == 0) return false;
if ((target.Id == CardId.WindwitchGlassBell || target.Id == CardId.WindwitchIceBell) &&
if ((target.IsCode(CardId.WindwitchGlassBell, CardId.WindwitchIceBell)) &&
Bot.HasInMonstersZone(CardId.WindwitchIceBell) &&
Bot.HasInMonstersZone(CardId.WindwitchGlassBell))
return false;
AI.SelectCard(target);
AI.SelectNextCard(new[] { CardId.DarkMagician, CardId.DarkMagician });
AI.SelectNextCard(CardId.DarkMagician, CardId.DarkMagician);
return true;
}
if (Bot.HasInMonstersZone(CardId.MagiciansRod) || Bot.HasInMonstersZone(CardId.SpellbookMagicianOfProphecy))
{
AI.SelectCard(new[] { CardId.MagiciansRod, CardId.SpellbookMagicianOfProphecy });
AI.SelectNextCard(new[] { CardId.DarkMagician, CardId.DarkMagician });
AI.SelectCard(CardId.MagiciansRod, CardId.SpellbookMagicianOfProphecy);
AI.SelectNextCard(CardId.DarkMagician, CardId.DarkMagician);
return true;
}
if (Duel.Player == 1 && Bot.HasInMonstersZone(CardId.WindwitchGlassBell))
{
AI.SelectCard(CardId.WindwitchGlassBell);
AI.SelectNextCard(new[] { CardId.DarkMagician, CardId.DarkMagician });
AI.SelectNextCard(CardId.DarkMagician, CardId.DarkMagician);
return true;
}
if (Duel.Player == 1 && Bot.HasInMonstersZone(CardId.WindwitchIceBell))
{
AI.SelectCard(CardId.WindwitchIceBell);
AI.SelectNextCard(new[] { CardId.DarkMagician, CardId.DarkMagician });
AI.SelectNextCard(CardId.DarkMagician, CardId.DarkMagician);
return true;
}
if (Duel.Player == 1 && Bot.HasInMonstersZone(CardId.WindwitchSnowBell))
{
AI.SelectCard(CardId.WindwitchSnowBell);
AI.SelectNextCard(new[] { CardId.DarkMagician, CardId.DarkMagician });
AI.SelectNextCard(CardId.DarkMagician, CardId.DarkMagician);
return true;
}
if (Duel.Player == 1 && Bot.HasInMonstersZone(CardId.SpellbookMagicianOfProphecy))
{
AI.SelectCard(CardId.SpellbookMagicianOfProphecy);
AI.SelectNextCard(new[] { CardId.DarkMagician, CardId.DarkMagician });
AI.SelectNextCard(CardId.DarkMagician, CardId.DarkMagician);
return true;
}
if (Duel.Player == 1 && Bot.HasInMonstersZone(CardId.ApprenticeLllusionMagician) &&
(Bot.HasInSpellZone(CardId.EternalSoul) || Bot.HasInSpellZone(CardId.MagicianNavigation)))
{
AI.SelectCard(CardId.ApprenticeLllusionMagician);
AI.SelectNextCard(new[] { CardId.DarkMagician, CardId.DarkMagician });
AI.SelectNextCard(CardId.DarkMagician, CardId.DarkMagician);
return true;
}
......@@ -1033,8 +1003,8 @@ namespace WindBot.Game.AI.Decks
(Bot.HasInMonstersZone(CardId.DarkMagician) || Bot.HasInMonstersZone(CardId.ApprenticeLllusionMagician)) &&
Duel.Player == 1 && !Bot.HasInHand(CardId.DarkMagician))
{
AI.SelectCard(new[] { CardId.DarkMagician, CardId.ApprenticeLllusionMagician });
AI.SelectNextCard(new[] { CardId.DarkMagician, CardId.DarkMagician });
AI.SelectCard(CardId.DarkMagician, CardId.ApprenticeLllusionMagician);
AI.SelectNextCard(CardId.DarkMagician, CardId.DarkMagician);
return true;
}
return false;
......@@ -1045,7 +1015,7 @@ namespace WindBot.Game.AI.Decks
if (Secret_used)
AI.SelectCard(CardId.SpellbookOfKnowledge);
else
AI.SelectCard(new[] { CardId.SpellbookOfSecrets, CardId.SpellbookOfKnowledge });
AI.SelectCard(CardId.SpellbookOfSecrets, CardId.SpellbookOfKnowledge);
return true;
}
......@@ -1077,7 +1047,7 @@ namespace WindBot.Game.AI.Decks
int count = 0;
foreach (ClientCard check in Bot.GetMonsters())
{
if (check.Id != CardId.CrystalWingSynchroDragon)
if (!check.IsCode(CardId.CrystalWingSynchroDragon))
count++;
}
Logger.DebugWriteLine("%%%%%%%%%%%%%%%%SpellCaster= " + count);
......@@ -1090,12 +1060,7 @@ namespace WindBot.Game.AI.Decks
Bot.HasInMonstersZone(CardId.WindwitchGlassBell) ||
Bot.HasInMonstersZone(CardId.WindwitchIceBell))
{
AI.SelectCard(new[]
{
CardId.SpellbookMagicianOfProphecy,
CardId.MagiciansRod,
CardId.WindwitchGlassBell,
});
AI.SelectCard(CardId.SpellbookMagicianOfProphecy, CardId.MagiciansRod, CardId.WindwitchGlassBell);
return true;
}
if (Bot.HasInMonstersZone(CardId.ApprenticeLllusionMagician) && Bot.GetSpellCount() < 2 && Duel.Phase == DuelPhase.Main2)
......@@ -1118,7 +1083,7 @@ namespace WindBot.Game.AI.Decks
int count = 0;
foreach (ClientCard check in Bot.GetMonsters())
{
if (check.Id != CardId.CrystalWingSynchroDragon)
if (!check.IsCode(CardId.CrystalWingSynchroDragon))
count++;
}
Logger.DebugWriteLine("%%%%%%%%%%%%%%%%SpellCaster= " + count);
......@@ -1132,13 +1097,12 @@ namespace WindBot.Game.AI.Decks
Bot.HasInMonstersZone(CardId.WindwitchGlassBell) ||
Bot.HasInMonstersZone(CardId.WindwitchIceBell))
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.SpellbookMagicianOfProphecy,
CardId.MagiciansRod,
CardId.WindwitchGlassBell,
CardId.WindwitchIceBell,
});
CardId.WindwitchIceBell
);
return UniqueFaceupSpell();
}
......@@ -1196,11 +1160,7 @@ namespace WindBot.Game.AI.Decks
Bot.HasInHand(CardId.DarkMagicAttack)))
{
AI.SelectPosition(CardPosition.FaceUpAttack);
AI.SelectCard(new[]
{
CardId.SpellbookOfSecrets,
CardId.DarkMagicAttack,
});
AI.SelectCard(CardId.SpellbookOfSecrets, CardId.DarkMagicAttack);
return true;
}
if (Bot.HasInMonstersZone(CardId.ApprenticeLllusionMagician))
......@@ -1208,7 +1168,7 @@ namespace WindBot.Game.AI.Decks
int count = 0;
foreach (ClientCard check in Bot.Hand)
{
if (check.Id == CardId.WonderWand)
if (check.IsCode(CardId.WonderWand))
count++;
}
if (count >= 2)
......@@ -1223,14 +1183,7 @@ namespace WindBot.Game.AI.Decks
Bot.GetMonsterCount()==0)
{
AI.SelectPosition(CardPosition.FaceUpAttack);
AI.SelectCard(new[]
{
CardId.MagicianOfLllusion,
CardId.ApprenticeLllusionMagician,
CardId.TheEyeOfTimaeus,
CardId.DarkMagicInheritance,
CardId.WonderWand,
});
AI.SelectCard(CardId.MagicianOfLllusion, CardId.ApprenticeLllusionMagician, CardId.TheEyeOfTimaeus, CardId.DarkMagicInheritance, CardId.WonderWand);
return true;
}
if (!Bot.HasInHandOrInMonstersZoneOrInGraveyard(CardId.DarkMagician))
......@@ -1241,7 +1194,7 @@ namespace WindBot.Game.AI.Decks
int Navigation_count = 0;
foreach (ClientCard Navigation in Bot.Hand)
{
if (Navigation.Id == CardId.MagicianNavigation)
if (Navigation.IsCode(CardId.MagicianNavigation))
Navigation_count++;
}
if (Navigation_count >= 2)
......@@ -1249,14 +1202,7 @@ namespace WindBot.Game.AI.Decks
AI.SelectCard(CardId.MagicianNavigation);
return true;
}
AI.SelectCard(new[]
{
CardId.MagicianOfLllusion,
CardId.ApprenticeLllusionMagician,
CardId.TheEyeOfTimaeus,
CardId.DarkMagicInheritance,
CardId.WonderWand,
});
AI.SelectCard(CardId.MagicianOfLllusion, CardId.ApprenticeLllusionMagician, CardId.TheEyeOfTimaeus, CardId.DarkMagicInheritance, CardId.WonderWand);
return true;
}
return false;
......@@ -1296,7 +1242,7 @@ namespace WindBot.Game.AI.Decks
if (Secret_used)
AI.SelectCard(CardId.SpellbookOfKnowledge);
else
AI.SelectCard(new[] { CardId.SpellbookOfSecrets, CardId.SpellbookOfKnowledge });
AI.SelectCard(CardId.SpellbookOfSecrets, CardId.SpellbookOfKnowledge);
return true;
}
return false;
......@@ -1371,35 +1317,18 @@ namespace WindBot.Game.AI.Decks
{
if (Bot.HasInGraveyard(CardId.MagicianNavigation))
{
AI.SelectNextCard(new[] {
CardId.EternalSoul,
CardId.MagicianNavigation,
CardId.DarkMagicalCircle});
AI.SelectNextCard(CardId.EternalSoul, CardId.MagicianNavigation, CardId.DarkMagicalCircle);
}
else
AI.SelectNextCard(new[] {
CardId.EternalSoul,
CardId.MagicianNavigation,
CardId.DarkMagicalCircle});
AI.SelectNextCard(CardId.EternalSoul, CardId.MagicianNavigation, CardId.DarkMagicalCircle);
return true;
}
if (Bot.HasInGraveyard(CardId.MagicianNavigation))
{
AI.SelectNextCard(new[]
{
CardId.EternalSoul,
CardId.DarkMagicalCircle,
CardId.MagicianNavigation,
});
AI.SelectNextCard(CardId.EternalSoul, CardId.DarkMagicalCircle, CardId.MagicianNavigation);
}
else
AI.SelectNextCard(new[]
{
CardId.MagicianNavigation,
CardId.DarkMagicalCircle,
CardId.EternalSoul,
});
AI.SelectNextCard(CardId.MagicianNavigation, CardId.DarkMagicalCircle, CardId.EternalSoul);
return true;
}
return false;
......@@ -1483,11 +1412,7 @@ namespace WindBot.Game.AI.Decks
AI.SelectCard(CardId.EternalSoul);
return true;
}
AI.SelectCard(new[] {
CardId.LllusionMagic,
CardId.EternalSoul,
CardId.DarkMagicalCircle,
CardId.MagicianNavigation});
AI.SelectCard(CardId.LllusionMagic, CardId.EternalSoul, CardId.DarkMagicalCircle, CardId.MagicianNavigation);
return true;
}
else
......@@ -1523,16 +1448,7 @@ namespace WindBot.Game.AI.Decks
Bot.GetMonsterCount() > 1) return false;
if ((Bot.LifePoints - Enemy_atk <= 1000) &&
Bot.GetMonsterCount() == 1) return false;
AI.SelectCard(new[]
{
CardId.VentriloauistsClaraAndLucika,
CardId.SpellbookMagicianOfProphecy,
CardId.WindwitchGlassBell,
CardId.WindwitchIceBell,
CardId.MagiciansRod,
CardId.DarkMagician,
CardId.MagicianOfLllusion
});
AI.SelectCard(CardId.VentriloauistsClaraAndLucika, CardId.SpellbookMagicianOfProphecy, CardId.WindwitchGlassBell, CardId.WindwitchIceBell, CardId.MagiciansRod, CardId.DarkMagician, CardId.MagicianOfLllusion);
return true;
}
}
......@@ -1619,12 +1535,12 @@ namespace WindBot.Game.AI.Decks
int rod_count = 0;
foreach (ClientCard rod in Bot.GetMonsters())
{
if (rod.Id == CardId.MagiciansRod)
if (rod.IsCode(CardId.MagiciansRod))
rod_count++;
}
if (rod_count >= 2)
{
AI.SelectCard(new[] { CardId.MagiciansRod, CardId.MagiciansRod });
AI.SelectCard(CardId.MagiciansRod, CardId.MagiciansRod);
return true;
}
if (Bot.HasInMonstersZone(CardId.DarkMagician) &&
......@@ -1633,9 +1549,9 @@ namespace WindBot.Game.AI.Decks
&& Duel.Phase == DuelPhase.Main2)
{
if (rod_count >= 2)
AI.SelectCard(new[] { CardId.MagiciansRod, CardId.MagiciansRod });
AI.SelectCard(CardId.MagiciansRod, CardId.MagiciansRod);
else
AI.SelectCard(new[] { CardId.MagiciansRod, CardId.DarkMagician });
AI.SelectCard(CardId.MagiciansRod, CardId.DarkMagician);
return true;
}
if (Bot.HasInMonstersZone(CardId.MagiciansRod) &&
......@@ -1644,9 +1560,9 @@ namespace WindBot.Game.AI.Decks
&& Duel.Phase == DuelPhase.Main2)
{
if (rod_count >= 2)
AI.SelectCard(new[] { CardId.MagiciansRod, CardId.MagiciansRod });
AI.SelectCard(CardId.MagiciansRod, CardId.MagiciansRod);
else
AI.SelectCard(new[] { CardId.MagiciansRod, CardId.DarkMagician });
AI.SelectCard(CardId.MagiciansRod, CardId.DarkMagician);
return true;
}
return false;
......@@ -1654,7 +1570,7 @@ namespace WindBot.Game.AI.Decks
private bool ApprenticeWitchlingeff()
{
AI.SelectCard(new[] { CardId.MagiciansRod, CardId.DarkMagician, CardId.ApprenticeLllusionMagician });
AI.SelectCard(CardId.MagiciansRod, CardId.DarkMagician, CardId.ApprenticeLllusionMagician);
return true;
}
public override bool OnSelectHand()
......@@ -1716,7 +1632,7 @@ namespace WindBot.Game.AI.Decks
int maxxc_count = 0;
foreach (ClientCard check in Enemy.Graveyard)
{
if (check.Id == CardId.MaxxC)
if (check.IsCode(CardId.MaxxC))
maxxc_count++;
}
if (maxxc_count != maxxc_done)
......@@ -1727,7 +1643,7 @@ namespace WindBot.Game.AI.Decks
int lockbird_count = 0;
foreach (ClientCard check in Enemy.Graveyard)
{
if (check.Id == CardId.LockBird)
if (check.IsCode(CardId.LockBird))
lockbird_count++;
}
if (lockbird_count != lockbird_done)
......@@ -1738,7 +1654,7 @@ namespace WindBot.Game.AI.Decks
int ghost_count = 0;
foreach (ClientCard check in Enemy.Graveyard)
{
if (check.Id == CardId.Ghost)
if (check.IsCode(CardId.Ghost))
ghost_count++;
}
if (ghost_count != ghost_done)
......@@ -1766,21 +1682,21 @@ namespace WindBot.Game.AI.Decks
int count = 0;
foreach (ClientCard check in Enemy.Graveyard)
{
if (check.Id == CardId.MaxxC)
if (check.IsCode(CardId.MaxxC))
count++;
}
maxxc_done = count;
count = 0;
foreach (ClientCard check in Enemy.Graveyard)
{
if (check.Id == CardId.LockBird)
if (check.IsCode(CardId.LockBird))
count++;
}
lockbird_done = count;
count = 0;
foreach (ClientCard check in Enemy.Graveyard)
{
if (check.Id == CardId.Ghost)
if (check.IsCode(CardId.Ghost))
count++;
}
ghost_done = count;
......@@ -1800,7 +1716,7 @@ namespace WindBot.Game.AI.Decks
{
if (Bot.MonsterZone[a] != null && Enemy.MonsterZone[b] != null &&
SameMonsterColumn(a, b) &&
Bot.MonsterZone[a].Id == attacker.Id && Enemy.MonsterZone[b].Id == defender.Id)
Bot.MonsterZone[a].IsCode(attacker.Id) && Enemy.MonsterZone[b].IsCode(defender.Id))
{
attackerzone = a;
defenderzone = b;
......@@ -1820,27 +1736,23 @@ namespace WindBot.Game.AI.Decks
if (Duel.Player == 0 && Bot.GetMonsterCount() >= 2 && plan_C)
{
Logger.DebugWriteLine("*********dangerous********************* ");
if (attacker.Id == CardId.OddEyesAbsoluteDragon || attacker.Id == CardId.OddEyesWingDragon)
if (attacker.IsCode(CardId.OddEyesAbsoluteDragon, CardId.OddEyesWingDragon))
attacker.RealPower = 9999;
}
if ((attacker.Id == CardId.DarkMagician ||
attacker.Id == CardId.MagiciansRod ||
attacker.Id == CardId.BigEye ||
attacker.Id == CardId.ApprenticeWitchling) &&
if ((attacker.IsCode(CardId.DarkMagician, CardId.MagiciansRod, CardId.BigEye, CardId.ApprenticeWitchling)) &&
Bot.HasInHandOrHasInMonstersZone(CardId.ApprenticeLllusionMagician))
{
attacker.RealPower += 2000;
}
if (attacker.Id == CardId.ApprenticeLllusionMagician && ApprenticeLllusionMagician_count >= 2)
if (attacker.IsCode(CardId.ApprenticeLllusionMagician) && ApprenticeLllusionMagician_count >= 2)
{
attacker.RealPower += 2000;
}
if ((attacker.Id == CardId.DarkMagician || attacker.Id == CardId.DarkMagicianTheDragonKnight)
&& Bot.HasInSpellZone(CardId.EternalSoul))
if (attacker.IsCode(CardId.DarkMagician, CardId.DarkMagicianTheDragonKnight) && Bot.HasInSpellZone(CardId.EternalSoul))
{
return true;
}
if (attacker.Id == CardId.CrystalWingSynchroDragon)
if (attacker.IsCode(CardId.CrystalWingSynchroDragon))
{
if (defender.Level >= 5)
attacker.RealPower = 9999;
......@@ -1853,10 +1765,9 @@ namespace WindBot.Game.AI.Decks
big_attack_used = true;
return true;
}
if (attacker.Id == CardId.ApprenticeLllusionMagician)
if (attacker.IsCode(CardId.ApprenticeLllusionMagician))
Logger.DebugWriteLine("@@@@@@@@@@@@@@@@@@@ApprenticeLllusionMagician= " + attacker.RealPower);
if (Bot.HasInSpellZone(CardId.EternalSoul) &&
(attacker.Id == CardId.DarkMagician || attacker.Id == CardId.DarkMagicianTheDragonKnight || attacker.Id == CardId.MagicianOfLllusion))
if (Bot.HasInSpellZone(CardId.EternalSoul) && attacker.IsCode(CardId.DarkMagician, CardId.DarkMagicianTheDragonKnight, CardId.MagicianOfLllusion))
return true;
return base.OnPreBattleBetween(attacker, defender);
}
......@@ -1872,7 +1783,7 @@ namespace WindBot.Game.AI.Decks
{
if (Enemy.MonsterZone[b] != null &&
SameMonsterColumn(attackerzone, b) &&
Bot.MonsterZone[attackerzone].Id == attacker.Id && Enemy.MonsterZone[b].Id == defender.Id)
Bot.MonsterZone[attackerzone].IsCode(attacker.Id) && Enemy.MonsterZone[b].IsCode(defender.Id))
{
defenderzone = b;
}
......@@ -1907,7 +1818,7 @@ namespace WindBot.Game.AI.Decks
{
if (Bot.MonsterZone[a] != null && Enemy.MonsterZone[b]!=null &&
SameMonsterColumn(a,b) &&
Bot.MonsterZone[a].Id==attacker.Id && Enemy.MonsterZone[b].Id == defender.Id)
Bot.MonsterZone[a].IsCode(attacker.Id) && Enemy.MonsterZone[b].IsCode(defender.Id))
{
attackerzone = a;
defenderzone = b;
......
......@@ -136,7 +136,7 @@ namespace WindBot.Game.AI.Decks
int count = 0;
foreach (ClientCard card in Bot.Hand)
{
if (card.Id == CardId.DragunityDux)
if (card.IsCode(CardId.DragunityDux))
++count;
}
if (count >= 2)
......@@ -164,7 +164,7 @@ namespace WindBot.Game.AI.Decks
/*bool hasRealMonster = false;
foreach (ClientCard card in Bot.GetMonsters())
{
if (card.Id != CardId.AssaultBeast)
if (!card.IsCode(CardId.AssaultBeast))
{
hasRealMonster = true;
break;
......@@ -184,13 +184,13 @@ namespace WindBot.Game.AI.Decks
int remaining = 3;
foreach (ClientCard card in Bot.Hand)
if (card.Id == needId)
if (card.IsCode(needId))
remaining--;
foreach (ClientCard card in Bot.Graveyard)
if (card.Id == needId)
if (card.IsCode(needId))
remaining--;
foreach (ClientCard card in Bot.Banished)
if (card.Id == needId)
if (card.IsCode(needId))
remaining--;
if (remaining <= 0)
return false;
......@@ -243,12 +243,11 @@ namespace WindBot.Game.AI.Decks
private bool FoolishBurial()
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.DragunityPhalanx,
CardId.AssaultBeast,
CardId.StardustDragonAssaultMode
});
);
return true;
}
......@@ -262,8 +261,7 @@ namespace WindBot.Game.AI.Decks
ClientCard card = cards[i];
if (card.Attack < 2000)
break;
if (card.Id == (int) CardId.StardustDragonAssaultMode ||
card.Id == (int) CardId.FiveHeadedDragon)
if (card.IsCode(CardId.StardustDragonAssaultMode, CardId.FiveHeadedDragon))
continue;
if (card.IsMonster())
{
......@@ -298,7 +296,7 @@ namespace WindBot.Game.AI.Decks
int phalanxCount = 0;
foreach (ClientCard card in Bot.Graveyard)
{
if (card.Id == (int) CardId.DragunityPhalanx)
if (card.IsCode(CardId.DragunityPhalanx))
{
phalanxCount++;
break;
......@@ -315,7 +313,7 @@ namespace WindBot.Game.AI.Decks
{
foreach (ClientCard card in Bot.Graveyard)
{
if (card.Id == (int) CardId.DragunityPhalanx)
if (card.IsCode(CardId.DragunityPhalanx))
{
phalanxCount--;
tributes.Add(card);
......@@ -382,9 +380,7 @@ namespace WindBot.Game.AI.Decks
if (destroyCard == null)
return false;
if (tributeId != -1)
AI.SelectCard(tributeId);
AI.SelectNextCard(destroyCard);
return true;
......@@ -464,7 +460,7 @@ namespace WindBot.Game.AI.Decks
List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters)
{
if (monster.Id == CardId.StardustDragon && monster.Attacked)
if (monster.IsCode(CardId.StardustDragon) && monster.Attacked)
{
AI.SelectCard(monster);
return true;
......
......@@ -147,7 +147,7 @@ namespace WindBot.Game.AI.Decks
if (AI.Utils.IsOneEnemyBetterThanValue(atk, true))
return false;
if (Card.Id == CardId.SwapFrog)
if (Card.IsCode(CardId.SwapFrog))
m_swapFrogSummoned = Duel.Turn;
return true;
}
......@@ -200,7 +200,7 @@ namespace WindBot.Game.AI.Decks
List<ClientCard> spells = Bot.GetSpells();
foreach (ClientCard spell in spells)
{
if (spell.Id == CardId.GravityBind && !spell.IsFacedown())
if (spell.IsCode(CardId.GravityBind) && !spell.IsFacedown())
return false;
}
return true;
......@@ -208,9 +208,9 @@ namespace WindBot.Game.AI.Decks
private bool FrogMonsterRepos()
{
if (Card.Id == CardId.Unifrog)
if (Card.IsCode(CardId.Unifrog))
return Card.IsDefense();
if (Card.Id == CardId.DewdarkOfTheIceBarrier)
if (Card.IsCode(CardId.DewdarkOfTheIceBarrier))
return Card.IsDefense();
bool enemyBetter = AI.Utils.IsOneEnemyBetterThanValue(Card.Attack + (Card.IsFacedown() ? GetSpellBonus() : 0), true);
......@@ -222,10 +222,10 @@ namespace WindBot.Game.AI.Decks
if (Card.IsDefense() && !enemyBetter)
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;
if (Card.Id == CardId.FlipFlopFrog && Card.IsFacedown() && result)
if (Card.IsCode(CardId.FlipFlopFrog) && Card.IsFacedown() && result)
m_flipFlopFrogSummoned = Duel.Turn;
return result;
......@@ -242,7 +242,7 @@ namespace WindBot.Game.AI.Decks
{
foreach (ClientCard card in Bot.GetSpells())
{
if (card.Id == CardId.Solidarity)
if (card.IsCode(CardId.Solidarity))
atk += 800;
}
}
......
using YGOSharp.OCGWrapper.Enums;
using System.Collections.Generic;
using WindBot;
using WindBot.Game;
using WindBot.Game.AI;
namespace WindBot.Game.AI.Decks
{
[Deck("GrenMajuThunderBoarder", "AI_GrenMajuThunderBoarder", "Normal")]
public class GrenMajuThunderBoarderExecutor : DefaultExecutor
{
public class CardId
{
public const int InspectBoarder = 15397015;
public const int ThunderKingRaiOh = 71564252;
public const int AshBlossomAndJoyousSpring =14558127;
public const int GhostReaperAndWinterCherries = 62015408;
public const int GrenMajuDaEizo = 36584821;
public const int MaxxC = 23434538;
public const int EaterOfMillions = 63845230;
public const int HarpieFeatherDuster = 18144506;
public const int PotOfDesires = 35261759;
public const int CardOfDemise = 59750328;
public const int UpstartGoblin = 70368879;
public const int PotOfDuality = 98645731;
public const int Scapegoat = 73915051;
public const int MoonMirrorShield = 19508728;
public const int InfiniteImpermanence = 10045474;
public const int WakingTheDragon = 10813327;
public const int EvenlyMatched = 15693423;
public const int HeavyStormDuster = 23924608;
public const int DrowningMirrorForce = 47475363;
public const int MacroCosmos = 30241314;
public const int AntiSpellFragrance = 58921041;
public const int ImperialOrder = 61740673;
public const int PhatomKnightsSword = 61936647;
public const int UnendingNightmare= 69452756;
public const int SolemnWarning = 84749824;
public const int SolemStrike= 40605147;
public const int SolemnJudgment = 41420027;
public const int DarkBribe = 77538567;
public const int RaidraptorUltimateFalcon = 86221741;
public const int BorreloadDragon = 31833038;
public const int BirrelswordDragon = 85289965;
public const int FirewallDragon = 5043010;
public const int NingirsuTheWorldChaliceWarrior = 30194529;
public const int TopologicTrisbaena = 72529749;
public const int KnightmareUnicorn = 38342335;
public const int KnightmarePhoenix = 2857636;
public const int HeavymetalfoesElectrumite= 24094258;
public const int KnightmareCerberus = 75452921;
public const int CrystronNeedlefiber = 50588353;
public const int MissusRadiant= 3987233;
public const int BrandishMaidenKagari= 63288573;
public const int LinkSpider = 98978921;
public const int Linkuriboh = 41999284;
public const int KnightmareGryphon = 65330383;
}
public GrenMajuThunderBoarderExecutor(GameAI ai, Duel duel)
: base(ai, duel)
{
AddExecutor(ExecutorType.GoToBattlePhase, GoToBattlePhase);
AddExecutor(ExecutorType.Activate, CardId.EvenlyMatched, EvenlyMatchedeff);
//Sticker
AddExecutor(ExecutorType.Activate, CardId.MacroCosmos, MacroCosmoseff);
AddExecutor(ExecutorType.Activate, CardId.AntiSpellFragrance, AntiSpellFragranceeff);
//counter
AddExecutor(ExecutorType.Activate, CardId.AshBlossomAndJoyousSpring, DefaultAshBlossomAndJoyousSpring);
AddExecutor(ExecutorType.Activate, CardId.MaxxC, DefaultMaxxC);
AddExecutor(ExecutorType.Activate, CardId.InfiniteImpermanence, DefaultInfiniteImpermanence);
AddExecutor(ExecutorType.Activate, CardId.SolemnWarning, DefaultSolemnWarning);
AddExecutor(ExecutorType.Activate, CardId.SolemStrike, DefaultSolemnStrike);
AddExecutor(ExecutorType.Activate, CardId.ImperialOrder, ImperialOrderfirst);
AddExecutor(ExecutorType.Activate, CardId.HeavyStormDuster, HeavyStormDustereff);
AddExecutor(ExecutorType.Activate, CardId.UnendingNightmare, UnendingNightmareeff);
AddExecutor(ExecutorType.Activate, CardId.DarkBribe, DarkBribeeff);
AddExecutor(ExecutorType.Activate, CardId.ImperialOrder, ImperialOrdereff);
AddExecutor(ExecutorType.Activate, CardId.ThunderKingRaiOh, ThunderKingRaiOheff);
AddExecutor(ExecutorType.Activate, CardId.SolemnJudgment, DefaultSolemnJudgment);
AddExecutor(ExecutorType.Activate, CardId.DrowningMirrorForce, DrowningMirrorForceeff);
//first do
AddExecutor(ExecutorType.Activate, CardId.UpstartGoblin, UpstartGoblineff);
AddExecutor(ExecutorType.Activate, CardId.HarpieFeatherDuster, DefaultHarpiesFeatherDusterFirst);
AddExecutor(ExecutorType.Activate, CardId.PotOfDuality, PotOfDualityeff);
AddExecutor(ExecutorType.Activate, CardId.PotOfDesires, PotOfDesireseff);
AddExecutor(ExecutorType.Activate, CardId.CardOfDemise, CardOfDemiseeff);
//sp
AddExecutor(ExecutorType.SpSummon, CardId.MissusRadiant, MissusRadiantsp);
AddExecutor(ExecutorType.Activate, CardId.MissusRadiant, MissusRadianteff);
AddExecutor(ExecutorType.Activate, CardId.Linkuriboh, Linkuriboheff);
AddExecutor(ExecutorType.SpSummon, CardId.Linkuriboh, Linkuribohsp);
AddExecutor(ExecutorType.SpSummon, CardId.LinkSpider);
AddExecutor(ExecutorType.SpSummon, CardId.BorreloadDragon, BorreloadDragonsp);
AddExecutor(ExecutorType.Activate, CardId.BorreloadDragon, BorreloadDragoneff);
AddExecutor(ExecutorType.Activate, CardId.EaterOfMillions, EaterOfMillionseff);
AddExecutor(ExecutorType.Activate, CardId.WakingTheDragon, WakingTheDragoneff);
// normal summon
AddExecutor(ExecutorType.Summon, CardId.InspectBoarder, InspectBoardersummon);
AddExecutor(ExecutorType.Summon, CardId.GrenMajuDaEizo, GrenMajuDaEizosummon);
AddExecutor(ExecutorType.Summon, CardId.ThunderKingRaiOh, ThunderKingRaiOhsummon);
AddExecutor(ExecutorType.SpSummon, CardId.BorreloadDragon, BorreloadDragonspsecond);
AddExecutor(ExecutorType.SpSummon, CardId.EaterOfMillions, EaterOfMillionssp);
//spell
AddExecutor(ExecutorType.Activate, CardId.MoonMirrorShield, MoonMirrorShieldeff);
AddExecutor(ExecutorType.Activate, CardId.Scapegoat, DefaultScapegoat);
AddExecutor(ExecutorType.Activate, CardId.PhatomKnightsSword, PhatomKnightsSwordeff);
AddExecutor(ExecutorType.Repos, MonsterRepos);
//set
AddExecutor(ExecutorType.SpellSet, SpellSet);
}
bool CardOfDemiseeff_used = false;
bool eater_eff = false;
public override void OnNewTurn()
{
eater_eff = false;
CardOfDemiseeff_used = false;
}
public override void OnNewPhase()
{
foreach (ClientCard check in Bot.GetMonsters())
{
if (check.HasType(CardType.Fusion) || check.HasType(CardType.Xyz) ||
check.HasType(CardType.Synchro) || check.HasType(CardType.Link) ||
check.HasType(CardType.Ritual))
{
eater_eff = true;
break;
}
}
foreach (ClientCard check in Enemy.GetMonsters())
{
if (check.HasType(CardType.Fusion) || check.HasType(CardType.Xyz) ||
check.HasType(CardType.Synchro) || check.HasType(CardType.Link) ||
check.HasType(CardType.Ritual))
{
eater_eff = true;
break;
}
}
base.OnNewPhase();
}
private bool GoToBattlePhase()
{
return Bot.HasInHand(CardId.EvenlyMatched) && Duel.Turn >= 2 && Enemy.GetFieldCount() >= 2 && Bot.GetFieldCount() == 0;
}
private bool MacroCosmoseff()
{
return (Duel.LastChainPlayer == 1 || Duel.LastSummonPlayer == 1 || Duel.Player == 0) && UniqueFaceupSpell();
}
private bool AntiSpellFragranceeff()
{
int spell_count = 0;
foreach(ClientCard check in Bot.Hand)
{
if (check.HasType(CardType.Spell))
spell_count++;
}
if (spell_count >= 2) return false;
return Duel.Player == 1 && UniqueFaceupSpell();
}
private bool EvenlyMatchedeff()
{
return Enemy.GetFieldCount()-Bot.GetFieldCount() > 1;
}
private bool HeavyStormDustereff()
{
IList<ClientCard> targets = new List<ClientCard>();
foreach (ClientCard check in Enemy.GetSpells())
{
if (check.HasType(CardType.Continuous) || check.HasType(CardType.Field))
targets.Add(check);
}
if (AI.Utils.GetPZone(1, 0) != null && AI.Utils.GetPZone(1, 0).Type == 16777218)
{
targets.Add(AI.Utils.GetPZone(1, 0));
}
if (AI.Utils.GetPZone(1, 1) != null && AI.Utils.GetPZone(1, 1).Type == 16777218)
{
targets.Add(AI.Utils.GetPZone(1, 1));
}
foreach (ClientCard check in Enemy.GetSpells())
{
if (!check.HasType(CardType.Continuous) && !check.HasType(CardType.Field))
targets.Add(check);
}
if(DefaultOnBecomeTarget())
{
AI.SelectCard(targets);
return true;
}
int count = 0;
foreach(ClientCard check in Enemy.GetSpells())
{
if (check.Type == 16777218)
count++;
}
if(AI.Utils.GetLastChainCard()!=null &&
(AI.Utils.GetLastChainCard().HasType(CardType.Continuous)||
AI.Utils.GetLastChainCard().HasType(CardType.Field) || count==2) &&
Duel.LastChainPlayer==1)
{
AI.SelectCard(targets);
return true;
}
return false;
}
private bool UnendingNightmareeff()
{
ClientCard card = null;
foreach(ClientCard check in Enemy.GetSpells())
{
if (check.HasType(CardType.Continuous) || check.HasType(CardType.Field))
card = check;
break;
}
int count = 0;
foreach (ClientCard check in Enemy.GetSpells())
{
if (check.Type == 16777218)
count++;
}
if(count==2)
{
if (AI.Utils.GetPZone(1, 1) != null && AI.Utils.GetPZone(1, 1).Type == 16777218)
{
card=AI.Utils.GetPZone(1, 1);
}
}
if (card!=null && Bot.LifePoints>1000)
{
AI.SelectCard(card);
return true;
}
return false;
}
private bool DarkBribeeff()
{
if (AI.Utils.GetLastChainCard()!=null && AI.Utils.GetLastChainCard().IsCode(CardId.UpstartGoblin))
return false;
return true;
}
private bool ImperialOrderfirst()
{
if (AI.Utils.GetLastChainCard() != null && AI.Utils.GetLastChainCard().IsCode(CardId.UpstartGoblin))
return false;
return DefaultOnBecomeTarget() && AI.Utils.GetLastChainCard().HasType(CardType.Spell);
}
private bool ImperialOrdereff()
{
if (AI.Utils.GetLastChainCard() != null && AI.Utils.GetLastChainCard().IsCode(CardId.UpstartGoblin))
return false;
if (Duel.LastChainPlayer == 1)
{
foreach(ClientCard check in Enemy.GetSpells())
{
if (AI.Utils.GetLastChainCard() == check)
return true;
}
}
return false;
}
private bool DrowningMirrorForceeff()
{
if(Enemy.GetMonsterCount() ==1)
{
if(Enemy.BattlingMonster.Attack-Bot.LifePoints>=1000)
return DefaultUniqueTrap();
}
if (AI.Utils.GetTotalAttackingMonsterAttack(1) >= Bot.LifePoints)
return DefaultUniqueTrap();
if (Enemy.GetMonsterCount() >= 2)
return DefaultUniqueTrap();
return false;
}
private bool UpstartGoblineff()
{
return !DefaultSpellWillBeNegated();
}
private bool PotOfDualityeff()
{
if (DefaultSpellWillBeNegated())
return false;
int count = 0;
if (Bot.GetMonsterCount() > 0)
count = 1;
foreach(ClientCard card in Bot.Hand)
{
if (card.HasType(CardType.Monster))
count++;
}
if(AI.Utils.GetBestEnemyMonster()!=null && AI.Utils.GetBestEnemyMonster().Attack>=1900)
AI.SelectCard(
CardId.EaterOfMillions,
CardId.PotOfDesires,
CardId.GrenMajuDaEizo,
CardId.InspectBoarder,
CardId.ThunderKingRaiOh,
CardId.Scapegoat,
CardId.SolemnJudgment,
CardId.SolemnWarning,
CardId.SolemStrike,
CardId.InfiniteImpermanence
);
if (count == 0)
AI.SelectCard(
CardId.PotOfDesires,
CardId.InspectBoarder,
CardId.ThunderKingRaiOh,
CardId.EaterOfMillions,
CardId.GrenMajuDaEizo,
CardId.Scapegoat
);
else
{
AI.SelectCard(
CardId.PotOfDesires,
CardId.CardOfDemise,
CardId.SolemnJudgment,
CardId.SolemnWarning,
CardId.SolemStrike,
CardId.InfiniteImpermanence,
CardId.Scapegoat
);
}
return true;
}
private bool PotOfDesireseff()
{
if (CardOfDemiseeff_used) return false;
return Bot.Deck.Count > 14 && !DefaultSpellWillBeNegated();
}
private bool CardOfDemiseeff()
{
if (Bot.Hand.Count == 1 && Bot.GetSpellCountWithoutField() <= 3 && !DefaultSpellWillBeNegated())
{
CardOfDemiseeff_used = true;
return true;
}
return false;
}
private bool MoonMirrorShieldeff()
{
if(Card.Location==CardLocation.Hand)
{
if (Bot.GetMonsterCount() == 0) return false;
return !DefaultSpellWillBeNegated();
}
if(Card.Location==CardLocation.Grave)
{
return true;
}
return false;
}
private bool PhatomKnightsSwordeff()
{
if (Card.IsFaceup())
return true;
if(Duel.Phase==DuelPhase.BattleStart && Bot.BattlingMonster!=null && Enemy.BattlingMonster!=null)
{
if (Bot.BattlingMonster.Attack + 800 >= Enemy.BattlingMonster.GetDefensePower())
{
AI.SelectCard(Bot.BattlingMonster);
return DefaultUniqueTrap();
}
}
return false;
}
private bool InspectBoardersummon()
{
if (Bot.MonsterZone[0] == null)
AI.SelectPlace(Zones.z0);
else
AI.SelectPlace(Zones.z4);
return true;
}
private bool GrenMajuDaEizosummon()
{
if (Duel.Turn == 1) return false;
if (Bot.MonsterZone[0] == null)
AI.SelectPlace(Zones.z0);
else
AI.SelectPlace(Zones.z4);
return Bot.Banished.Count >= 6;
}
private bool ThunderKingRaiOhsummon()
{
if (Bot.MonsterZone[0] == null)
AI.SelectPlace(Zones.z0);
else
AI.SelectPlace(Zones.z4);
return true;
}
private bool ThunderKingRaiOheff()
{
if(Duel.SummoningCards.Count > 0)
{
foreach(ClientCard m in Duel.SummoningCards)
{
if (m.Attack >= 1900)
return true;
}
}
return false;
}
private bool BorreloadDragonsp()
{
if (!Bot.HasInMonstersZone(CardId.MissusRadiant)) return false;
IList<ClientCard> material_list = new List<ClientCard>();
foreach (ClientCard monster in Bot.GetMonsters())
{
if (monster.IsCode(CardId.MissusRadiant, CardId.LinkSpider, CardId.Linkuriboh))
material_list.Add(monster);
if (material_list.Count == 3) break;
}
if(material_list.Count>=3)
{
AI.SelectMaterials(material_list);
return true;
}
return false;
}
private bool BorreloadDragonspsecond()
{
if (!Bot.HasInMonstersZone(CardId.MissusRadiant)) return false;
IList<ClientCard> material_list = new List<ClientCard>();
foreach (ClientCard monster in Bot.GetMonsters())
{
if (monster.IsCode(CardId.MissusRadiant, CardId.LinkSpider, CardId.Linkuriboh))
material_list.Add(monster);
if (material_list.Count == 3) break;
}
if (material_list.Count >= 3)
{
AI.SelectMaterials(material_list);
return true;
}
return false;
}
public bool BorreloadDragoneff()
{
if (ActivateDescription == -1 && (Duel.Phase==DuelPhase.BattleStart||Duel.Phase==DuelPhase.End))
{
ClientCard enemy_monster = Enemy.BattlingMonster;
if (enemy_monster != null && enemy_monster.HasPosition(CardPosition.Attack))
{
return (Card.Attack - enemy_monster.Attack < Enemy.LifePoints);
}
return true;
};
ClientCard BestEnemy = AI.Utils.GetBestEnemyMonster(true);
ClientCard WorstBot = Bot.GetMonsters().GetLowestAttackMonster();
if (BestEnemy == null || BestEnemy.HasPosition(CardPosition.FaceDown)) return false;
if (WorstBot == null || WorstBot.HasPosition(CardPosition.FaceDown)) return false;
if (BestEnemy.Attack >= WorstBot.RealPower)
{
AI.SelectCard(BestEnemy);
return true;
}
return false;
}
private bool EaterOfMillionssp()
{
if (Bot.MonsterZone[0] == null)
AI.SelectPlace(Zones.z0);
else
AI.SelectPlace(Zones.z4);
if (Enemy.HasInMonstersZone(CardId.KnightmareGryphon, true)) return false;
if (Bot.HasInMonstersZone(CardId.InspectBoarder) && !eater_eff) return false;
if (AI.Utils.GetProblematicEnemyMonster() == null && Bot.ExtraDeck.Count < 5) return false;
if (Bot.GetMonstersInMainZone().Count >= 5) return false;
if (AI.Utils.IsTurn1OrMain2()) return false;
AI.SelectPosition(CardPosition.FaceUpAttack);
IList<ClientCard> targets = new List<ClientCard>();
foreach (ClientCard e_c in Bot.ExtraDeck)
{
targets.Add(e_c);
if (targets.Count >= 5)
{
AI.SelectCard(targets);
/*AI.SelectCard(new[] {
CardId.BingirsuTheWorldChaliceWarrior,
CardId.TopologicTrisbaena,
CardId.KnightmareCerberus,
CardId.KnightmarePhoenix,
CardId.KnightmareUnicorn,
CardId.BrandishMaidenKagari,
CardId.HeavymetalfoesElectrumite,
CardId.CrystronNeedlefiber,
CardId.FirewallDragon,
CardId.BirrelswordDragon,
CardId.RaidraptorUltimateFalcon,
});*/
AI.SelectPlace(Zones.z4 | Zones.z0);
return true;
}
}
Logger.DebugWriteLine("*** Eater use up the extra deck.");
foreach (ClientCard s_c in Bot.GetSpells())
{
targets.Add(s_c);
if (targets.Count >= 5)
{
AI.SelectCard(targets);
return true;
}
}
return false;
}
private bool EaterOfMillionseff()
{
if (Enemy.BattlingMonster.HasPosition(CardPosition.Attack) && (Bot.BattlingMonster.Attack - Enemy.BattlingMonster.GetDefensePower() >= Enemy.LifePoints)) return false;
return true;
}
private bool WakingTheDragoneff()
{
AI.SelectCard(new[] { CardId.RaidraptorUltimateFalcon });
return true;
}
private bool MissusRadiantsp()
{
IList<ClientCard> material_list = new List<ClientCard>();
foreach (ClientCard monster in Bot.GetMonsters())
{
if (monster.HasAttribute(CardAttribute.Earth) && monster.Level==1 && !monster.IsCode(CardId.EaterOfMillions))
material_list.Add(monster);
if (material_list.Count == 2) break;
}
if (material_list.Count < 2) return false;
if (Bot.HasInMonstersZone(CardId.MissusRadiant)) return false;
AI.SelectMaterials(material_list);
if (Bot.MonsterZone[0] == null && Bot.MonsterZone[2] == null && Bot.MonsterZone[5] == null)
AI.SelectPlace(Zones.z5);
else
AI.SelectPlace(Zones.z6);
return true;
}
private bool MissusRadianteff()
{
AI.SelectCard(CardId.MaxxC, CardId.MissusRadiant);
return true;
}
private bool Linkuribohsp()
{
foreach (ClientCard c in Bot.GetMonsters())
{
if (!c.IsCode(CardId.EaterOfMillions, CardId.Linkuriboh) && c.Level==1)
{
AI.SelectMaterials(c);
return true;
}
}
return false;
}
private bool Linkuriboheff()
{
if (Duel.LastChainPlayer == 0 && AI.Utils.GetLastChainCard().IsCode(CardId.Linkuriboh)) return false;
return true;
}
private bool MonsterRepos()
{
if (Card.IsCode(CardId.EaterOfMillions) && Card.IsAttack()) return false;
return DefaultMonsterRepos();
}
private bool SpellSet()
{
int count = 0;
foreach(ClientCard check in Bot.Hand)
{
if (check.IsCode(CardId.CardOfDemise))
count++;
}
if (count == 2 && Bot.Hand.Count == 2 && Bot.GetSpellCountWithoutField() <= 2)
return true;
if (Card.IsCode(CardId.MacroCosmos) && Bot.HasInSpellZone(CardId.MacroCosmos)) return false;
if (Card.IsCode(CardId.AntiSpellFragrance) && Bot.HasInSpellZone(CardId.AntiSpellFragrance)) return false;
if (CardOfDemiseeff_used)return true;
if (Card.IsCode(CardId.EvenlyMatched) && (Enemy.GetFieldCount() - Bot.GetFieldCount()) < 0) return false;
if (Card.IsCode(CardId.AntiSpellFragrance) && Bot.HasInSpellZone(CardId.AntiSpellFragrance)) return false;
if (Card.IsCode(CardId.MacroCosmos) && Bot.HasInSpellZone(CardId.MacroCosmos)) return false;
if (Duel.Turn > 1 && Duel.Phase == DuelPhase.Main1 && Bot.HasAttackingMonster())
return false;
if (Card.IsCode(CardId.InfiniteImpermanence))
return Bot.GetFieldCount() > 0 && Bot.GetSpellCountWithoutField() < 4;
if (Card.IsCode(CardId.Scapegoat))
return true;
if (Card.HasType(CardType.Trap))
return Bot.GetSpellCountWithoutField() < 4;
if(Bot.HasInSpellZone(CardId.AntiSpellFragrance,true))
{
if (Card.IsCode(CardId.UpstartGoblin, CardId.PotOfDesires, CardId.PotOfDuality)) return true;
if (Card.IsCode(CardId.CardOfDemise) && Bot.HasInSpellZone(CardId.CardOfDemise)) return false;
if (Card.HasType(CardType.Spell))
return Bot.GetSpellCountWithoutField() < 4;
}
return false;
}
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
{
if (attacker.IsCode(_CardId.EaterOfMillions) && (Bot.HasInMonstersZone(CardId.InspectBoarder) && eater_eff) && !attacker.IsDisabled())
{
attacker.RealPower = 9999;
return true;
}
if (attacker.IsCode(_CardId.EaterOfMillions) && !Bot.HasInMonstersZone(CardId.InspectBoarder) && !attacker.IsDisabled())
{
attacker.RealPower = 9999;
return true;
}
return base.OnPreBattleBetween(attacker, defender);
}
public override ClientCard OnSelectAttacker(IList<ClientCard> attackers, IList<ClientCard> defenders)
{
for (int i = 0; i < attackers.Count; ++i)
{
ClientCard attacker = attackers[i];
if (attacker.IsCode(CardId.BirrelswordDragon, CardId.EaterOfMillions)) return attacker;
}
return null;
}
public override bool OnSelectHand()
{
return true;
}
}
}
\ No newline at end of file
......@@ -79,7 +79,7 @@ namespace WindBot.Game.AI.Decks
return false;
int remaining = 2;
foreach (ClientCard card in Bot.Banished)
if (card.Id == CardId.WhiteNightDragon)
if (card.IsCode(CardId.WhiteNightDragon))
remaining--;
if (remaining > 0)
{
......@@ -154,7 +154,7 @@ namespace WindBot.Game.AI.Decks
// We should summon Horus the Black Flame Dragon LV6 if he can lvlup.
if (Enemy.GetMonsterCount() != 0 && !AI.Utils.IsAllEnemyBetterThanValue(2300 - 1, false))
foreach (ClientCard card in Main.SummonableCards)
if (card.Id == 11224103)
if (card.IsCode(11224103))
return false;
return DefaultTributeSummon();
......@@ -197,7 +197,7 @@ namespace WindBot.Game.AI.Decks
ClientCard monster = cards[i];
if (monster.Attack < 2300)
return false;
if (monster.Race == (int)CardRace.Dragon && monster.Id != CardId.HorusTheBlackFlameDragonLv8)
if (monster.Race == (int)CardRace.Dragon && !monster.IsCode(CardId.HorusTheBlackFlameDragonLv8))
{
summonCard = monster;
break;
......
......@@ -91,6 +91,7 @@ namespace WindBot.Game.AI.Decks
public override void OnNewTurn()
{
ClownUsed = false;
base.OnNewTurn();
}
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
......@@ -109,13 +110,13 @@ namespace WindBot.Game.AI.Decks
IList<ClientCard> result = new List<ClientCard>();
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);
if (result.Count >= max)
break;
}
AI.Utils.CheckSelectCount(result, cards, min, max);
return result;
return AI.Utils.CheckSelectCount(result, cards, min, max);
}
private bool ReinforcementOfTheArmyEffect()
......@@ -138,26 +139,24 @@ namespace WindBot.Game.AI.Decks
if (!Bot.HasInHand(CardId.Lumina))
AI.SelectCard(CardId.Lumina);
else
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.Raiden,
CardId.Lumina,
CardId.Minerva,
CardId.Lyla
});
);
return true;
}
private bool SolarRechargeEffect()
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.Wulf,
CardId.Felis,
CardId.Minerva,
CardId.Lyla,
CardId.Raiden
});
);
return true;
}
......@@ -173,14 +172,13 @@ namespace WindBot.Game.AI.Decks
private bool GoblindberghEffect()
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.Felis,
CardId.Wulf,
CardId.Raiden,
CardId.PerformageTrickClown,
CardId.ThousandBlades
});
);
return true;
}
......@@ -196,17 +194,14 @@ namespace WindBot.Game.AI.Decks
}
else
{
AI.SelectCard(new[] {
AI.SelectCard(
CardId.Wulf,
CardId.Felis,
CardId.Minerva,
CardId.ThousandBlades
});
);
}
AI.SelectNextCard(new[] {
CardId.Raiden,
CardId.Felis
});
AI.SelectNextCard(CardId.Raiden, CardId.Felis);
return true;
}
......
......@@ -390,7 +390,7 @@ namespace WindBot.Game.AI.Decks
Pillused = true;
foreach (ClientCard card in Bot.GetMonsters())
{
if (card.Id == CardId.UltimateConductorTytanno && card.IsFaceup())
if (card.IsCode(CardId.UltimateConductorTytanno) && card.IsFaceup())
return false;
}
Ultimate_ss++;
......@@ -410,12 +410,12 @@ namespace WindBot.Game.AI.Decks
private bool MonsterRepos()
{
if (Card.Id == CardId.UltimateConductorTytanno && Card.IsFacedown()) return true;
if (Card.Id == CardId.ElShaddollConstruct && Card.IsFacedown()) return true;
if (Card.Id == CardId.ElShaddollConstruct && Card.IsAttack()) return false;
if (Card.Id == CardId.GlowUpBulb && Card.IsDefense()) return false;
if (Card.Id == 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.UltimateConductorTytanno) && Card.IsFacedown()) return true;
if (Card.IsCode(CardId.ElShaddollConstruct) && Card.IsFacedown()) return true;
if (Card.IsCode(CardId.ElShaddollConstruct) && Card.IsAttack()) return false;
if (Card.IsCode(CardId.GlowUpBulb) && Card.IsDefense()) return false;
if (Card.IsCode(CardId.ShaddollDragon) && Card.IsFacedown() && Enemy.GetMonsterCount() >= 0) return true;
if (Card.IsCode(CardId.ShaddollSquamata) && Card.IsFacedown() && Enemy.GetMonsterCount() >= 0) return true;
return base.DefaultMonsterRepos();
}
......@@ -430,7 +430,7 @@ namespace WindBot.Game.AI.Decks
{
foreach (ClientCard card in Bot.GetMonsters())
{
if (card.Id == CardId.UltimateConductorTytanno && card.IsFaceup())
if (card.IsCode(CardId.UltimateConductorTytanno) && card.IsFaceup())
return false;
}
if (Pillused == true) return false;
......@@ -446,27 +446,11 @@ namespace WindBot.Game.AI.Decks
};
if (Bot.HasInGraveyard(targets))
{
AI.SelectCard(new[] {
CardId.GiantRex,
CardId.DogorantheMadFlameKaiju,
CardId.OvertexCoatls,
CardId.GamecieltheSeaTurtleKaiju,
CardId.RadiantheMultidimensionalKaiju,
CardId.SouleatingOviraptor,
CardId.UltimateConductorTytanno,
});
AI.SelectCard(CardId.GiantRex, CardId.DogorantheMadFlameKaiju, CardId.OvertexCoatls, CardId.GamecieltheSeaTurtleKaiju, CardId.RadiantheMultidimensionalKaiju, CardId.SouleatingOviraptor, CardId.UltimateConductorTytanno);
}
else
{
AI.SelectCard(new[] {
CardId.GiantRex,
CardId.DogorantheMadFlameKaiju,
CardId.GamecieltheSeaTurtleKaiju,
CardId.RadiantheMultidimensionalKaiju,
CardId.OvertexCoatls,
CardId.SouleatingOviraptor,
CardId.UltimateConductorTytanno,
});
AI.SelectCard(CardId.GiantRex, CardId.DogorantheMadFlameKaiju, CardId.GamecieltheSeaTurtleKaiju, CardId.RadiantheMultidimensionalKaiju, CardId.OvertexCoatls, CardId.SouleatingOviraptor, CardId.UltimateConductorTytanno);
}
IList<int> targets2 = new[] {
CardId.GiantRex,
......@@ -479,42 +463,10 @@ namespace WindBot.Game.AI.Decks
};
if (Bot.HasInGraveyard(targets))
{
AI.SelectNextCard(new[] {
CardId.ShaddollBeast,
CardId.ShaddollDragon,
CardId.KeeperOfDragonicMagic,
CardId.ShaddollSquamata,
CardId.SouleatingOviraptor,
CardId.Raiden,
CardId.Lumina,
CardId.ShaddollHedgehog,
CardId.AshBlossom,
CardId.GhostOgre,
CardId.ShaddollFalco,
CardId.MaxxC,
CardId.PlaguespreaderZombie,
CardId.GlowUpBulb,
CardId.FairyTailSnow,
});
AI.SelectNextCard(CardId.ShaddollBeast, CardId.ShaddollDragon, CardId.KeeperOfDragonicMagic, CardId.ShaddollSquamata, CardId.SouleatingOviraptor, CardId.Raiden, CardId.Lumina, CardId.ShaddollHedgehog, CardId.AshBlossom, CardId.GhostOgre, CardId.ShaddollFalco, CardId.MaxxC, CardId.PlaguespreaderZombie, CardId.GlowUpBulb, CardId.FairyTailSnow);
}
else
AI.SelectNextCard(new[] {
CardId.ShaddollBeast,
CardId.ShaddollDragon,
CardId.KeeperOfDragonicMagic,
CardId.ShaddollSquamata,
CardId.SouleatingOviraptor,
CardId.Raiden,
CardId.Lumina,
CardId.ShaddollHedgehog,
CardId.AshBlossom,
CardId.GhostOgre,
CardId.ShaddollFalco,
CardId.MaxxC,
CardId.PlaguespreaderZombie,
CardId.GlowUpBulb,
CardId.FairyTailSnow,
});
AI.SelectNextCard(CardId.ShaddollBeast, CardId.ShaddollDragon, CardId.KeeperOfDragonicMagic, CardId.ShaddollSquamata, CardId.SouleatingOviraptor, CardId.Raiden, CardId.Lumina, CardId.ShaddollHedgehog, CardId.AshBlossom, CardId.GhostOgre, CardId.ShaddollFalco, CardId.MaxxC, CardId.PlaguespreaderZombie, CardId.GlowUpBulb, CardId.FairyTailSnow);
AI.SelectThirdCard(new[] {
CardId.UltimateConductorTytanno,
......@@ -552,7 +504,7 @@ namespace WindBot.Game.AI.Decks
IList<ClientCard> all = new List<ClientCard>();
foreach (ClientCard check in grave)
{
if (check.Id == CardId.GiantRex)
if (check.IsCode(CardId.GiantRex))
{
all.Add(check);
}
......@@ -745,23 +697,20 @@ namespace WindBot.Game.AI.Decks
if (deck_check)
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.ElShaddollConstruct,
CardId.ElShaddollShekhinaga,
CardId.ElShaddollGrysra,
CardId.ElShaddollWinda
});
AI.SelectNextCard(new[]
{
);
AI.SelectNextCard(
CardId.ShaddollSquamata,
CardId.ShaddollBeast,
CardId.ShaddollHedgehog,
CardId.ShaddollDragon,
CardId.ShaddollFalco,
CardId.FairyTailSnow,
});
CardId.FairyTailSnow
);
AI.SelectPosition(CardPosition.FaceUpAttack);
return true;
}
......@@ -841,14 +790,12 @@ namespace WindBot.Game.AI.Decks
{
if (DefaultBreakthroughSkill())
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.ShaddollBeast,
CardId.ShaddollSquamata,
CardId.ShaddollHedgehog,
CardId.ShaddollDragon,
CardId.ShaddollFalco,
}
CardId.ShaddollFalco
);
}
else
......@@ -925,14 +872,12 @@ namespace WindBot.Game.AI.Decks
return true;
else
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.ElShaddollConstruct,
CardId.ElShaddollShekhinaga,
CardId.ElShaddollGrysra,
CardId.ElShaddollWinda,
CardId.ShaddollSquamata,
}
CardId.ShaddollSquamata
);
}
......@@ -947,25 +892,28 @@ namespace WindBot.Game.AI.Decks
{
if (AI.Utils.ChainContainsCard(CardId.ElShaddollConstruct))
{
AI.SelectNextCard(new[]{
AI.SelectNextCard(
CardId.ShaddollFalco,
CardId.ShaddollSquamata,
CardId.ShaddollDragon,
});
CardId.ShaddollDragon
);
}
else
{
AI.SelectCard(new[]{
AI.SelectCard(
CardId.ShaddollSquamata,
CardId.ShaddollDragon,
});
CardId.ShaddollDragon
);
}
}
else
{
AI.SelectCard(new[] { CardId.ShaddollFusion, CardId.SinisterShadowGames });
AI.SelectCard(
CardId.ShaddollFusion,
CardId.SinisterShadowGames
);
}
return true;
}
......@@ -1018,11 +966,7 @@ namespace WindBot.Game.AI.Decks
}
else
{
AI.SelectCard(new[]
{
CardId.ShaddollSquamata,
CardId.FairyTailSnow,
});
AI.SelectCard(CardId.ShaddollSquamata, CardId.FairyTailSnow);
}
return true;
}
......@@ -1030,8 +974,8 @@ namespace WindBot.Game.AI.Decks
public bool Hand_act_eff()
{
//if (Card.Id == 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.Urara) && Bot.HasInHand(CardId.LockBird) && Bot.HasInSpellZone(CardId.Re)) return false;
if (Card.IsCode(CardId.GhostOgre) && Card.Location == CardLocation.Hand && Bot.HasInMonstersZone(CardId.GhostOgre)) return false;
return (Duel.LastChainPlayer == 1);
}
//other extra
......@@ -1098,6 +1042,7 @@ namespace WindBot.Game.AI.Decks
if (targets.Count == 0)
return false;
AI.SelectCard(0);
AI.SelectNextCard(targets);
return true;
}
......@@ -1127,14 +1072,8 @@ namespace WindBot.Game.AI.Decks
};
int count=0;
foreach (ClientCard monster in Bot.GetMonsters())
if (monster.Id == CardId.GlowUpBulb ||
monster.Id == CardId.FairyTailSnow ||
monster.Id == CardId.KeeperOfDragonicMagic ||
monster.Id == CardId.SouleatingOviraptor||
monster.Id == CardId.GiantRex||
monster.Id == CardId.Lumina||
monster.Id == CardId.Raiden
)
if (monster.IsCode(CardId.GlowUpBulb, CardId.FairyTailSnow, CardId.KeeperOfDragonicMagic,
CardId.SouleatingOviraptor, CardId.GiantRex, CardId.Lumina, CardId.Raiden))
count++;
if (!Bot.HasInMonstersZone(CardId.GlowUpBulb) || count<2)
return false;
......@@ -1149,7 +1088,7 @@ namespace WindBot.Game.AI.Decks
bool DarkHole = false;
foreach (ClientCard card in Enemy.GetSpells())
{
if (card.Id == 53129443 && card.IsFaceup())
if (card.IsCode(53129443) && card.IsFaceup())
{
DarkHole = true;
}
......@@ -1158,7 +1097,12 @@ namespace WindBot.Game.AI.Decks
{
CrystronNeedlefibereff_used = true;
AI.SelectCard(new[] { CardId.GhostOgre, CardId.GlowUpBulb, CardId.PlaguespreaderZombie, CardId.ShaddollFalco });
AI.SelectCard(
CardId.GhostOgre,
CardId.GlowUpBulb,
CardId.PlaguespreaderZombie,
CardId.ShaddollFalco
);
return true;
}
......@@ -1221,12 +1165,12 @@ namespace WindBot.Game.AI.Decks
{
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);
return true;
}
if (hand.Id == CardId.Urara || hand.Id == CardId.Ghost)
if (hand.IsCode(CardId.Urara, CardId.Ghost))
{
if (Tuner_ss())
{
......@@ -1260,7 +1204,7 @@ namespace WindBot.Game.AI.Decks
private bool RedWyverneff()
{
IList<ClientCard> check = Enemy.MonsterZone;
IList<ClientCard> check = Enemy.GetMonsters();
ClientCard best = null;
foreach (ClientCard monster in check)
{
......@@ -1303,9 +1247,9 @@ namespace WindBot.Game.AI.Decks
{
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;
if (attacker.Id == CardId.UltimateConductorTytanno && !attacker.IsDisabled() && defender.IsDefense())
if (attacker.IsCode(CardId.UltimateConductorTytanno) && !attacker.IsDisabled() && defender.IsDefense())
attacker.RealPower = 9999;
}
return base.OnPreBattleBetween(attacker, defender);
......
......@@ -106,9 +106,9 @@ namespace WindBot.Game.AI.Decks
if (!Bot.HasInHand(NekrozRituelCard) || Bot.HasInHand(CardId.Shurit) || !Bot.HasInHand(NekrozSpellCard))
return true;
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;
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 false;
}
......@@ -271,9 +271,9 @@ namespace WindBot.Game.AI.Decks
List<int> NekrozCard = new List<int>();
try
{
foreach (ClientCard Card in Bot.Hand)
if (Card != null && NekrozRituelCard.Contains((int)Card.Id))
NekrozCard.Add(Card.Id);
foreach (ClientCard card in Bot.Hand)
if (card != null && card.IsCode(NekrozRituelCard))
NekrozCard.Add(card.Id);
foreach (int Id in NekrozCard)
{
......
using YGOSharp.OCGWrapper.Enums;
using System.Collections.Generic;
using WindBot;
using WindBot.Game;
using WindBot.Game.AI;
namespace WindBot.Game.AI.Decks
{
[Deck("Phantasm", "AI_Phantasm", "Normal")]
public class PhantasmExecutor : DefaultExecutor
{
public class CardId
{
public const int MegalosmasherX = 81823360;
public const int AshBlossom = 14558127;
public const int EaterOfMillions = 63845230;
public const int HarpieFeatherDuster = 18144506;
public const int PotOfDesires = 35261759;
public const int FossilDig = 47325505;
public const int CardOfDemise = 59750328;
public const int Terraforming = 73628505;
public const int PotOfDuality = 98645731;
public const int Scapegoat = 73915051;
public const int PacifisThePhantasmCity = 2819435;
public const int InfiniteImpermanence = 10045474;
public const int PhantasmSprialBattle = 34302287;
public const int DrowningMirrorForce = 47475363;
public const int StarlightRoad = 58120309;
public const int PhantasmSpiralPower = 61397885;
public const int Metaverse = 89208725;
public const int SeaStealthAttack = 19089195;
public const int GozenMatch = 53334471;
public const int SkillDrain = 82732705;
public const int TheHugeRevolutionIsOver = 99188141;
public const int StardustDragon = 44508094;
public const int TopologicBomberDragon = 5821478;
public const int BorreloadDragon = 31833038;
public const int BorrelswordDragon = 85289965;
public const int KnightmareGryphon = 65330383;
public const int TopologicTrisbaena = 72529749;
public const int SummonSorceress = 61665245;
public const int KnightmareUnicorn = 38342335;
public const int KnightmarePhoenix = 2857636;
public const int KnightmareCerberus = 75452921;
public const int CrystronNeedlefiber = 50588353;
public const int MissusRadiant = 3987233;
public const int LinkSpider = 98978921;
public const int Linkuriboh = 41999284;
public const int ElShaddollWinda = 94977269;
public const int BrandishSkillJammingWave = 25955749;
public const int BrandishSkillAfterburner = 99550630;
public const int EternalSoul = 48680970;
public const int SuperboltThunderDragon = 15291624;
}
public PhantasmExecutor(GameAI ai, Duel duel)
: base(ai, duel)
{
//counter
AddExecutor(ExecutorType.GoToBattlePhase, GoToBattlePhase);
AddExecutor(ExecutorType.Activate, CardId.StarlightRoad, PreventFeatherDustereff);
AddExecutor(ExecutorType.Activate, CardId.TheHugeRevolutionIsOver, PreventFeatherDustereff);
AddExecutor(ExecutorType.Activate, _CardId.GhostBelle, DefaultGhostBelleAndHauntedMansion);
AddExecutor(ExecutorType.Activate, _CardId.CalledByTheGrave, DefaultCalledByTheGrave);
AddExecutor(ExecutorType.Activate, _CardId.EffectVeiler, DefaultEffectVeiler);
AddExecutor(ExecutorType.Activate, _CardId.InfiniteImpermanence, DefaultInfiniteImpermanence);
AddExecutor(ExecutorType.Activate, _CardId.AshBlossom, DefaultAshBlossomAndJoyousSpring);
AddExecutor(ExecutorType.Activate, _CardId.GhostOgreAndSnowRabbit, DefaultGhostOgreAndSnowRabbit);
//trap activate
AddExecutor(ExecutorType.Activate, CardId.SeaStealthAttack, SeaStealthAttackeff);
AddExecutor(ExecutorType.Activate, CardId.PhantasmSprialBattle, PhantasmSprialBattleeff);
AddExecutor(ExecutorType.Activate, CardId.PhantasmSpiralPower, PhantasmSpiralPowereff);
AddExecutor(ExecutorType.Activate, CardId.DrowningMirrorForce, DrowningMirrorForceeff);
AddExecutor(ExecutorType.Activate, CardId.GozenMatch, GozenMatcheff);
AddExecutor(ExecutorType.Activate, CardId.SkillDrain, SkillDraineff);
AddExecutor(ExecutorType.Activate, CardId.Metaverse, Metaverseeff);
//sp
AddExecutor(ExecutorType.SpSummon, CardId.BorrelswordDragon, BorrelswordDragonsp);
AddExecutor(ExecutorType.Activate, CardId.BorrelswordDragon, BorrelswordDragoneff);
AddExecutor(ExecutorType.SpSummon, CardId.MissusRadiant, MissusRadiantsp);
AddExecutor(ExecutorType.Activate, CardId.MissusRadiant, MissusRadianteff);
AddExecutor(ExecutorType.Activate, CardId.Linkuriboh, Linkuriboheff);
AddExecutor(ExecutorType.SpSummon, CardId.Linkuriboh, Linkuribohsp);
//first
AddExecutor(ExecutorType.Activate, CardId.HarpieFeatherDuster, DefaultHarpiesFeatherDusterFirst);
AddExecutor(ExecutorType.Activate, CardId.FossilDig, FossilDigeff);
AddExecutor(ExecutorType.Activate, CardId.Terraforming, Terraformingeff);
AddExecutor(ExecutorType.Activate, CardId.PotOfDuality, PotOfDualityeff);
AddExecutor(ExecutorType.Activate, CardId.PotOfDesires, PotOfDesireseff);
AddExecutor(ExecutorType.Activate, CardId.PacifisThePhantasmCity, PacifisThePhantasmCityeff);
//summon
AddExecutor(ExecutorType.Summon, CardId.MegalosmasherX, MegalosmasherXsummon);
//sp
AddExecutor(ExecutorType.SpSummon, CardId.EaterOfMillions, EaterOfMillionssp);
AddExecutor(ExecutorType.Activate, CardId.EaterOfMillions, EaterOfMillionseff);
//other
AddExecutor(ExecutorType.Activate, CardId.Scapegoat, DefaultScapegoat);
AddExecutor(ExecutorType.SpellSet, CardId.SeaStealthAttack, NoSetAlreadyDone);
AddExecutor(ExecutorType.SpellSet, CardId.StarlightRoad, StarlightRoadset);
AddExecutor(ExecutorType.SpellSet, CardId.TheHugeRevolutionIsOver, TheHugeRevolutionIsOverset);
AddExecutor(ExecutorType.SpellSet, CardId.DrowningMirrorForce);
AddExecutor(ExecutorType.SpellSet, CardId.InfiniteImpermanence, InfiniteImpermanenceset);
AddExecutor(ExecutorType.SpellSet, CardId.Scapegoat, NoSetAlreadyDone);
AddExecutor(ExecutorType.SpellSet, CardId.GozenMatch, NoSetAlreadyDone);
AddExecutor(ExecutorType.SpellSet, CardId.SkillDrain, NoSetAlreadyDone);
AddExecutor(ExecutorType.SpellSet, CardId.Metaverse);
AddExecutor(ExecutorType.SpellSet, SpellSeteff);
AddExecutor(ExecutorType.Activate, CardId.CardOfDemise, CardOfDemiseeff);
AddExecutor(ExecutorType.Repos, MonsterRepos);
}
bool summon_used = false;
bool CardOfDemiseeff_used = false;
bool SeaStealthAttackeff_used = false;
public override void OnNewTurn()
{
summon_used = false;
CardOfDemiseeff_used = false;
SeaStealthAttackeff_used = false;
base.OnNewTurn();
}
private bool PreventFeatherDustereff()
{
return Duel.LastChainPlayer == 1;
}
private bool GoToBattlePhase()
{
if (Enemy.GetMonsterCount() == 0)
{
if (AI.Utils.GetTotalAttackingMonsterAttack(0) >= Enemy.LifePoints)
{
return true;
}
}
return false;
}
private bool PhantasmSprialBattleeff()
{
if (DefaultOnBecomeTarget() && Card.Location==CardLocation.SpellZone)
{
AI.SelectCard(AI.Utils.GetBestEnemyCard(false,true));
return true;
}
if(Enemy.HasInSpellZone(CardId.EternalSoul))
{
AI.SelectCard(CardId.EternalSoul);
return UniqueFaceupSpell();
}
if(Bot.UnderAttack && Bot.BattlingMonster != null && Bot.BattlingMonster.IsCode(CardId.MegalosmasherX))
{
AI.SelectCard(Enemy.BattlingMonster);
return UniqueFaceupSpell();
}
if (Bot.GetMonsterCount() > 0 && !Bot.HasInSpellZone(CardId.SeaStealthAttack) &&
AI.Utils.IsOneEnemyBetterThanValue(2000, false) && Duel.Phase==DuelPhase.BattleStart)
{
AI.SelectCard(AI.Utils.GetBestEnemyMonster(true,true));
return UniqueFaceupSpell();
}
if (AI.Utils.GetProblematicEnemyCard(9999,true)!=null)
{
if (AI.Utils.GetProblematicEnemyCard(9999, true).IsCode(CardId.ElShaddollWinda) &&
!AI.Utils.GetProblematicEnemyCard(9999, true).IsDisabled())
return false;
AI.SelectCard(AI.Utils.GetProblematicEnemyCard(9999, true));
return UniqueFaceupSpell();
}
return false;
}
private bool PhantasmSpiralPowereff()
{
if (DefaultOnBecomeTarget() && Card.Location == CardLocation.SpellZone) return true;
if(Duel.Player == 0 || (Duel.Player==1 && Bot.BattlingMonster!=null))
{
if(Enemy.HasInMonstersZone(CardId.ElShaddollWinda))
{
AI.SelectCard(CardId.ElShaddollWinda);
return UniqueFaceupSpell();
}
if(Enemy.HasInMonstersZone(CardId.SuperboltThunderDragon))
{
AI.SelectCard(CardId.SuperboltThunderDragon);
return UniqueFaceupSpell();
}
}
return DefaultInfiniteImpermanence() && UniqueFaceupSpell();
}
private bool DrowningMirrorForceeff()
{
int count = 0;
foreach(ClientCard m in Enemy.GetMonsters())
{
if (m.IsAttack()) count++;
}
if (AI.Utils.GetTotalAttackingMonsterAttack(1) >= Bot.LifePoints)
return true;
return count >= 2;
}
private bool GozenMatcheff()
{
if (Bot.GetMonsterCount() >= 4 || Bot.HasInSpellZone(CardId.Scapegoat)) return false;
if (DefaultOnBecomeTarget()) return true;
int dark_count = 0;
int Divine_count = 0;
int Earth_count = 0;
int Fire_count = 0;
int Light_count = 0;
int Water_count = 0;
int Wind_count = 0;
foreach (ClientCard m in Enemy.GetMonsters())
{
if (m.HasAttribute(CardAttribute.Dark)) dark_count++;
if (m.HasAttribute(CardAttribute.Divine)) Divine_count++;
if (m.HasAttribute(CardAttribute.Earth)) Earth_count++;
if (m.HasAttribute(CardAttribute.Fire)) Fire_count++;
if (m.HasAttribute(CardAttribute.Light)) Light_count++;
if (m.HasAttribute(CardAttribute.Water)) Water_count++;
if (m.HasAttribute(CardAttribute.Wind)) Wind_count++;
}
if (dark_count > 1) dark_count = 1;
if (Divine_count > 1) Divine_count = 1;
if (Earth_count > 1) Earth_count = 1;
if (Fire_count > 1) Fire_count = 1;
if (Light_count > 1) Light_count = 1;
if (Water_count > 1) Water_count = 1;
if (Wind_count > 1) Wind_count = 1;
return ((dark_count + Divine_count + Earth_count + Fire_count + Light_count + Water_count + Wind_count) >= 2 && UniqueFaceupSpell());
}
private bool SkillDraineff()
{
if (Duel.LastChainPlayer == 1 && AI.Utils.GetLastChainCard().Location == CardLocation.MonsterZone)
return UniqueFaceupSpell();
return false;
}
private bool Metaverseeff()
{
if (Duel.LastChainPlayer == 0) return false;
if (!Bot.HasInSpellZone(CardId.PacifisThePhantasmCity))
{
AI.SelectOption(1);
return UniqueFaceupSpell();
}
else
{
AI.SelectOption(0);
return UniqueFaceupSpell();
}
}
private bool CardOfDemiseeff()
{
if (DefaultSpellWillBeNegated()) return false;
AI.SelectPlace(Zones.z2);
if(Card.Location==CardLocation.Hand)
{
if (Bot.Hand.Count <= 1 && Bot.GetSpellCountWithoutField() <= 3)
{
CardOfDemiseeff_used = true;
return true;
}
}
else
{
if (Bot.Hand.Count <= 1 && Bot.GetSpellCountWithoutField() <= 4)
{
CardOfDemiseeff_used = true;
return true;
}
}
return false;
}
private bool FossilDigeff()
{
if (DefaultSpellWillBeNegated()) return false;
if (CardOfDemiseeff_used && summon_used) return false;
return true;
}
private bool PotOfDualityeff()
{
if(!Bot.HasInHandOrInSpellZone(CardId.PacifisThePhantasmCity) &&
!Bot.HasInHandOrInSpellZone(CardId.Metaverse))
{
if(Bot.HasInGraveyard(CardId.PacifisThePhantasmCity) && !Bot.HasInHandOrInSpellZone(CardId.SeaStealthAttack))
{
AI.SelectCard(
CardId.SeaStealthAttack,
CardId.PacifisThePhantasmCity,
CardId.Terraforming,
CardId.Metaverse,
CardId.CardOfDemise,
CardId.Scapegoat
);
}
else
{
AI.SelectCard(
CardId.PacifisThePhantasmCity,
CardId.Terraforming,
CardId.Metaverse,
CardId.CardOfDemise,
CardId.Scapegoat
);
}
}
else if(!Bot.HasInHandOrInSpellZone(CardId.SeaStealthAttack))
{
AI.SelectCard(
CardId.SeaStealthAttack,
CardId.CardOfDemise,
CardId.PotOfDesires,
CardId.Scapegoat
);
}
else
{
AI.SelectCard(
CardId.CardOfDemise,
CardId.PotOfDesires,
CardId.Scapegoat
);
}
return true;
}
private bool Terraformingeff()
{
if (DefaultSpellWillBeNegated()) return false;
if (CardOfDemiseeff_used && Bot.HasInSpellZone(CardId.PacifisThePhantasmCity)) return false;
return true;
}
private bool PacifisThePhantasmCityeff()
{
if (DefaultSpellWillBeNegated()) return false;
if(Card.Location==CardLocation.Hand)
{
if (Bot.HasInSpellZone(CardId.PacifisThePhantasmCity))
return false;
return true;
}
else
{
ClientCard target = null;
foreach(ClientCard s in Bot.GetSpells())
{
if(s.IsCode(CardId.SeaStealthAttack) && Card.IsFaceup())
{
target = s;
break;
}
}
foreach(ClientCard m in Bot.GetMonsters())
{
if(m.HasAttribute(CardAttribute.Water))
{
if (target != null && !SeaStealthAttackeff_used)
{
if (AI.Utils.IsChainTarget(Card) || AI.Utils.IsChainTarget(target))
return false;
}
break;
}
}
AI.SelectPlace(Zones.z1 | Zones.z3);
AI.SelectCard(CardId.PhantasmSprialBattle);
return true;
}
}
private bool MegalosmasherXsummon()
{
AI.SelectPlace(Zones.z1 | Zones.z3);
summon_used = true;
return true;
}
private bool BorrelswordDragonsp()
{
if (!Bot.HasInMonstersZone(CardId.MissusRadiant))
return false;
IList<ClientCard> material_list = new List<ClientCard>();
foreach (ClientCard m in Bot.GetMonsters())
{
if (m.IsCode(CardId.MissusRadiant))
{
material_list.Add(m);
break;
}
}
foreach (ClientCard m in Bot.GetMonsters())
{
if (m.IsCode(CardId.Linkuriboh, CardId.LinkSpider))
{
material_list.Add(m);
if (material_list.Count == 3)
break;
}
}
if (material_list.Count == 3)
{
AI.SelectMaterials(material_list);
return true;
}
return false;
}
private bool BorrelswordDragoneff()
{
if (ActivateDescription == AI.Utils.GetStringId(CardId.BorrelswordDragon, 0))
{
if (AI.Utils.IsChainTarget(Card) && AI.Utils.GetBestEnemyMonster(true, true) != null)
{
AI.SelectCard(AI.Utils.GetBestEnemyMonster(true, true));
return true;
}
if (Duel.Player == 1 && Bot.BattlingMonster == Card)
{
AI.SelectCard(Enemy.BattlingMonster);
return true;
}
if (Duel.Player == 1 && Bot.BattlingMonster != null &&
(Enemy.BattlingMonster.Attack - Bot.BattlingMonster.Attack) >= Bot.LifePoints)
{
AI.SelectCard(Enemy.BattlingMonster);
return true;
}
if (Duel.Player == 0 && Duel.Phase == DuelPhase.BattleStart)
{
foreach (ClientCard check in Enemy.GetMonsters())
{
if (check.IsAttack() && !check.HasType(CardType.Link))
{
AI.SelectCard(check);
return true;
}
}
}
return false;
}
return true;
}
private bool EaterOfMillionssp()
{
if (Bot.MonsterZone[1] == null)
AI.SelectPlace(Zones.z1);
else
AI.SelectPlace(Zones.z3);
if (Enemy.HasInMonstersZone(CardId.KnightmareGryphon, true)) return false;
if (AI.Utils.GetProblematicEnemyMonster() == null && Bot.ExtraDeck.Count < 5) return false;
if (Bot.GetMonstersInMainZone().Count >= 5) return false;
if (AI.Utils.IsTurn1OrMain2()) return false;
AI.SelectPosition(CardPosition.FaceUpAttack);
IList<ClientCard> material_list = new List<ClientCard>();
if(Bot.HasInExtra(CardId.BorreloadDragon))
{
AI.SelectCard(
CardId.TopologicBomberDragon,
CardId.TopologicTrisbaena,
CardId.KnightmareGryphon,
CardId.SummonSorceress,
CardId.BorreloadDragon
);
}
else
{
foreach(ClientCard m in Bot.ExtraDeck)
{
if (material_list.Count == 5) break;
material_list.Add(m);
}
}
return true;
}
private bool EaterOfMillionseff()
{
if (Enemy.BattlingMonster.HasPosition(CardPosition.Attack) && (Bot.BattlingMonster.Attack - Enemy.BattlingMonster.GetDefensePower() >= Enemy.LifePoints)) return false;
return true;
}
private bool MissusRadiantsp()
{
IList<ClientCard> material_list = new List<ClientCard>();
foreach (ClientCard monster in Bot.GetMonsters())
{
if (monster.HasAttribute(CardAttribute.Earth) && monster.Level == 1 && !monster.IsCode(CardId.EaterOfMillions))
material_list.Add(monster);
if (material_list.Count == 2) break;
}
if (material_list.Count < 2) return false;
if (Bot.HasInMonstersZone(CardId.MissusRadiant)) return false;
AI.SelectMaterials(material_list);
if ((Bot.MonsterZone[0] == null || Bot.MonsterZone[0].Level==1) &&
(Bot.MonsterZone[2] == null || Bot.MonsterZone[2].Level == 1)&&
Bot.MonsterZone[5] == null)
AI.SelectPlace(Zones.z5);
else
AI.SelectPlace(Zones.z6);
return true;
}
private bool MissusRadianteff()
{
AI.SelectCard(new[]
{
CardId.MissusRadiant,
});
return true;
}
private bool Linkuribohsp()
{
foreach (ClientCard c in Bot.GetMonsters())
{
if (!c.IsCode(CardId.EaterOfMillions, CardId.Linkuriboh) && c.Level == 1)
{
AI.SelectMaterials(c);
return true;
}
}
return false;
}
private bool Linkuriboheff()
{
if (Duel.LastChainPlayer == 0 && AI.Utils.GetLastChainCard().IsCode(CardId.Linkuriboh)) return false;
return true;
}
private bool SeaStealthAttackeff()
{
if (DefaultOnBecomeTarget())
{
AI.SelectCard(CardId.MegalosmasherX);
SeaStealthAttackeff_used = true;
return true;
}
if ((Card.IsFacedown() && Bot.HasInHandOrInSpellZoneOrInGraveyard(CardId.PacifisThePhantasmCity)))
{
if (!Bot.HasInSpellZone(CardId.PacifisThePhantasmCity))
{
if(Bot.HasInGraveyard(CardId.PacifisThePhantasmCity))
{
foreach (ClientCard s in Bot.GetGraveyardSpells())
{
if (s.IsCode(CardId.PacifisThePhantasmCity))
{
AI.SelectYesNo(true);
AI.SelectCard(s);
break;
}
}
}
else
{
foreach (ClientCard s in Bot.Hand)
{
if (s.IsCode(CardId.PacifisThePhantasmCity))
{
AI.SelectYesNo(true);
AI.SelectCard(s);
break;
}
}
}
}
else
AI.SelectYesNo(false);
return UniqueFaceupSpell();
}
else if(Card.IsFaceup())
{
ClientCard target = null;
foreach(ClientCard s in Bot.GetSpells())
{
if (s.IsCode(CardId.PacifisThePhantasmCity))
target = s;
}
if (target != null && AI.Utils.IsChainTarget(target))
{
SeaStealthAttackeff_used = true;
return true;
}
target = AI.Utils.GetLastChainCard();
if(target!=null)
{
if(target.IsCode(CardId.BrandishSkillAfterburner))
{
AI.SelectCard(CardId.MegalosmasherX);
SeaStealthAttackeff_used = true;
return true;
}
if(Enemy.GetGraveyardSpells().Count>=3 && target.IsCode(CardId.BrandishSkillJammingWave))
{
AI.SelectCard(CardId.MegalosmasherX);
SeaStealthAttackeff_used = true;
return true;
}
}
}
return false;
}
private bool PotOfDesireseff()
{
return Bot.Deck.Count >= 18;
}
private bool StarlightRoadset()
{
if (Duel.Turn > 1 && Duel.Phase == DuelPhase.Main1 && Bot.HasAttackingMonster())
return false;
if (Bot.HasInSpellZone(CardId.TheHugeRevolutionIsOver)) return false;
return true;
}
private bool TheHugeRevolutionIsOverset()
{
if (Duel.Turn > 1 && Duel.Phase == DuelPhase.Main1 && Bot.HasAttackingMonster())
return false;
if (Bot.HasInSpellZone(CardId.StarlightRoad)) return false;
return true;
}
private bool InfiniteImpermanenceset()
{
return !Bot.IsFieldEmpty();
}
private bool NoSetAlreadyDone()
{
if (Duel.Turn > 1 && Duel.Phase == DuelPhase.Main1 && Bot.HasAttackingMonster())
return false;
if (Bot.HasInSpellZone(Card.Id)) return false;
return true;
}
private bool SpellSeteff()
{
if (Card.HasType(CardType.Field)) return false;
if (CardOfDemiseeff_used) return true;
if(Bot.HasInHandOrInSpellZone(CardId.CardOfDemise) && !CardOfDemiseeff_used)
{
int hand_spell_count = 0;
foreach(ClientCard s in Bot.Hand)
{
if (s.HasType(CardType.Trap) || s.HasType(CardType.Spell) && !s.HasType(CardType.Field))
hand_spell_count++;
}
int zone_count = 5 - Bot.GetSpellCountWithoutField();
return zone_count- hand_spell_count >= 1;
}
if(Card.IsCode(CardId.PhantasmSprialBattle, CardId.PhantasmSpiralPower))
{
if (Bot.HasInMonstersZone(CardId.MegalosmasherX) &&
!Bot.HasInHandOrInSpellZone(CardId.PacifisThePhantasmCity) &&
!Bot.HasInHandOrInSpellZone(CardId.Metaverse))
return true;
}
return false;
}
private bool MonsterRepos()
{
if (Card.Level >= 5)
{
foreach (ClientCard s in Bot.GetSpells())
{
if (s.IsFaceup() && s.IsCode(CardId.SeaStealthAttack) &&
Bot.HasInSpellZone(CardId.PacifisThePhantasmCity) &&
Card.IsAttack())
return false;
}
}
if (Card.IsCode(CardId.EaterOfMillions) && !Card.IsDisabled() && Card.IsAttack())
return false;
return DefaultMonsterRepos();
}
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
{
if(attacker.IsCode(CardId.PacifisThePhantasmCity+1) && defender.IsCode(CardId.EaterOfMillions))
{
if (attacker.RealPower >= defender.RealPower) return true;
}
if(attacker.Level>=5)
{
foreach(ClientCard s in Bot.GetSpells())
{
if (s.IsFaceup() && s.IsCode(CardId.SeaStealthAttack) && Bot.HasInSpellZone(CardId.PacifisThePhantasmCity))
{
attacker.RealPower = 9999;
if (defender.IsCode(CardId.EaterOfMillions)) return true;
}
}
}
return base.OnPreBattleBetween(attacker, defender);
}
public override ClientCard OnSelectAttacker(IList<ClientCard> attackers, IList<ClientCard> defenders)
{
for (int i = 0; i < attackers.Count; ++i)
{
ClientCard attacker = attackers[i];
if (attacker.IsCode(CardId.EaterOfMillions)) return attacker;
}
return null;
}
public override bool OnSelectHand()
{
return true;
}
}
}
......@@ -141,7 +141,7 @@ namespace WindBot.Game.AI.Decks
for (int i = 1; i <= max; ++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);
}
if (selected.Count == 0)
......@@ -152,7 +152,7 @@ namespace WindBot.Game.AI.Decks
private bool NormalSummon()
{
if (Card.Id == CardId.Scout)
if (Card.IsCode(CardId.Scout))
return false;
if (Card.Level < 8)
AI.SelectOption(1);
......@@ -166,8 +166,7 @@ namespace WindBot.Game.AI.Decks
private bool PotOfDualityEffect()
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.Scout,
CardId.SkillDrain,
CardId.VanitysEmptiness,
......@@ -178,7 +177,7 @@ namespace WindBot.Game.AI.Decks
CardId.Carrier,
CardId.SolemnStrike,
CardId.CardOfDemise
});
);
return !ShouldPendulum();
}
......@@ -196,7 +195,7 @@ namespace WindBot.Game.AI.Decks
{
foreach (ClientCard card in Bot.GetSpells())
{
if (card.Id == Card.Id)
if (card.IsCode(Card.Id))
return false;
}
return TrapSetWhenZoneFree();
......@@ -304,12 +303,7 @@ namespace WindBot.Game.AI.Decks
}
else if (handcount>0 || fieldcount>0)
{
AI.SelectCard(new[]
{
CardId.Saqlifice,
CardId.Shell,
CardId.Helix
});
AI.SelectCard(CardId.Saqlifice, CardId.Shell, CardId.Helix);
}
else
{
......
......@@ -162,7 +162,7 @@ namespace WindBot.Game.AI.Decks
{
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(card2);
......@@ -172,19 +172,18 @@ namespace WindBot.Game.AI.Decks
if (result.Count > 0)
break;
}
AI.Utils.CheckSelectCount(result, cards, min, max);
return result;
return AI.Utils.CheckSelectCount(result, cards, min, max);
}
private bool UnexpectedDaiEffect()
{
if (Bot.HasInHand(CardId.RescueRabbit) || NormalSummoned)
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.MysteryShellDragon,
CardId.PhantomGryphon,
CardId.MegalosmasherX
});
);
else if (AI.Utils.IsTurn1OrMain2())
{
if (Bot.HasInHand(CardId.MysteryShellDragon))
......@@ -203,11 +202,7 @@ namespace WindBot.Game.AI.Decks
else if (Bot.HasInHand(CardId.PhantomGryphon))
AI.SelectCard(CardId.PhantomGryphon);
else if (Bot.HasInHand(CardId.AngelTrumpeter))
AI.SelectCard(new[]
{
CardId.MetalfoesGoldriver,
CardId.MasterPendulumTheDracoslayer
});
AI.SelectCard(CardId.MetalfoesGoldriver, CardId.MasterPendulumTheDracoslayer);
}
return true;
}
......@@ -216,22 +211,20 @@ namespace WindBot.Game.AI.Decks
{
if (AI.Utils.IsTurn1OrMain2())
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.MegalosmasherX,
CardId.MysteryShellDragon
});
);
}
else
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.MasterPendulumTheDracoslayer,
CardId.PhantomGryphon,
CardId.MegalosmasherX,
CardId.MetalfoesGoldriver,
CardId.AngelTrumpeter
});
);
}
return true;
}
......@@ -358,6 +351,7 @@ namespace WindBot.Game.AI.Decks
private bool LightningChidoriEffect()
{
ClientCard problematicCard = AI.Utils.GetProblematicEnemyCard();
AI.SelectCard(0);
AI.SelectNextCard(problematicCard);
return true;
}
......@@ -423,6 +417,7 @@ namespace WindBot.Game.AI.Decks
ClientCard result = AI.Utils.GetOneEnemyBetterThanValue(2000, true);
if (result != null)
{
AI.SelectCard(0);
AI.SelectNextCard(result);
return true;
}
......
......@@ -120,15 +120,13 @@ namespace WindBot.Game.AI.Decks
public override IList<ClientCard> OnSelectXyzMaterial(IList<ClientCard> cards, int min, int max)
{
IList<ClientCard> result = new List<ClientCard>();
AI.Utils.SelectPreferredCards(result, new[] {
IList<ClientCard> result = AI.Utils.SelectPreferredCards(new[] {
CardId.MistArchfiend,
CardId.PanzerDragon,
CardId.SolarWindJammer,
CardId.StarDrawing
}, cards, min, max);
AI.Utils.CheckSelectCount(result, cards, min, max);
return result;
return AI.Utils.CheckSelectCount(result, cards, min, max);
}
private bool NormalSummon()
......@@ -149,8 +147,7 @@ namespace WindBot.Game.AI.Decks
{
if (!NeedLV5())
return false;
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.QuickdrawSynchron,
CardId.ZWEagleClaw,
CardId.SolarWindJammer,
......@@ -159,7 +156,7 @@ namespace WindBot.Game.AI.Decks
CardId.WindUpSoldier,
CardId.StarDrawing,
CardId.ChronomalyGoldenJet
});
);
return true;
}
......@@ -187,15 +184,15 @@ namespace WindBot.Game.AI.Decks
int lv5Count = 0;
foreach (ClientCard card in Bot.Hand)
{
if (card.Id == CardId.SolarWindJammer && Bot.GetMonsterCount() == 0)
if (card.IsCode(CardId.SolarWindJammer) && Bot.GetMonsterCount() == 0)
++lv5Count;
if (card.Id == CardId.InstantFusion && !InstantFusionUsed)
if (card.IsCode(CardId.InstantFusion) && !InstantFusionUsed)
++lv5Count;
if (card.Id == CardId.QuickdrawSynchron && Bot.Hand.ContainsMonsterWithLevel(4))
if (card.IsCode(CardId.QuickdrawSynchron) && Bot.Hand.ContainsMonsterWithLevel(4))
++lv5Count;
if (card.Id == CardId.MistArchfiend && !NormalSummoned)
if (card.IsCode(CardId.MistArchfiend) && !NormalSummoned)
++lv5Count;
if (card.Id == CardId.DoubleSummon && DoubleSummonEffect())
if (card.IsCode(CardId.DoubleSummon) && DoubleSummonEffect())
++lv5Count;
}
if (lv5Count >= 2)
......@@ -335,14 +332,13 @@ namespace WindBot.Game.AI.Decks
{
if (!UniqueFaceupSpell())
return false;
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.CyberDragonInfinity,
CardId.CyberDragonNova,
CardId.TirasKeeperOfGenesis,
CardId.SharkFortress,
CardId.Number61Volcasaurus
});
);
return true;
}
......@@ -389,8 +385,8 @@ namespace WindBot.Game.AI.Decks
if (monster.HasType(CardType.Monster) &&
!monster.HasType(CardType.Xyz) &&
(monster.Level == 5
|| monster.Id == CardId.StarDrawing
|| (monster.Id == CardId.WindUpSoldier) && !monster.Equals(Card)))
|| monster.IsCode(CardId.StarDrawing)
|| (monster.IsCode(CardId.WindUpSoldier)) && !monster.Equals(Card)))
return true;
}
return false;
......
......@@ -175,12 +175,12 @@ namespace WindBot.Game.AI.Decks
IList<ClientCard> targets = Enemy.GetSpells();
if (targets.Count > 0)
{
AI.SelectCard(new[]{
AI.SelectCard(
CardId.DualAssembloom,
CardId.Bitron,
CardId.Digitron,
CardId.RecodedAlive
});
);
AI.SelectNextCard(targets);
return true;
}
......@@ -284,7 +284,7 @@ namespace WindBot.Game.AI.Decks
List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters)
{
if (monster.Id == CardId.BalancerLord)
if (monster.IsCode(CardId.BalancerLord))
{
AI.SelectCard(monster);
selected = true;
......@@ -306,14 +306,13 @@ namespace WindBot.Game.AI.Decks
}
if (selected)
{
AI.SelectNextCard(new[]
{
AI.SelectNextCard(
CardId.ROMCloudia,
CardId.BalancerLord,
CardId.Kleinant,
CardId.Draconnet,
CardId.Backlinker
});
);
return true;
}
return false;
......@@ -360,24 +359,24 @@ namespace WindBot.Game.AI.Decks
{
if (Card.Location == CardLocation.MonsterZone)
{
AI.SelectCard(new[]{
AI.SelectCard(
CardId.BootStagguard,
CardId.BalancerLord,
CardId.Kleinant,
CardId.Linkslayer,
CardId.Draconnet,
CardId.RAMClouder
});
);
return true;
}
else
{
AI.SelectCard(new[]{
AI.SelectCard(
CardId.BalancerLord,
CardId.Kleinant,
CardId.RAMClouder,
CardId.DotScaper
});
);
return true;
}
}
......@@ -404,7 +403,7 @@ namespace WindBot.Game.AI.Decks
};
foreach (ClientCard monster in Bot.Hand)
{
if (targets.Contains(monster.Id))
if (monster.IsCode(targets))
{
AI.SelectCard(targets);
return true;
......@@ -418,7 +417,7 @@ namespace WindBot.Game.AI.Decks
};
foreach (ClientCard monster in Bot.GetMonsters())
{
if (targets2.Contains(monster.Id))
if (monster.IsCode(targets2))
{
AI.SelectCard(targets2);
return true;
......@@ -429,7 +428,7 @@ namespace WindBot.Game.AI.Decks
private bool RAMClouderEffect()
{
AI.SelectCard(new[]{
AI.SelectCard(
CardId.StagToken,
CardId.Bitron,
CardId.Digitron,
......@@ -437,8 +436,8 @@ namespace WindBot.Game.AI.Decks
CardId.Draconnet,
CardId.Backlinker,
CardId.RAMClouder
});
AI.SelectNextCard(new[]{
);
AI.SelectNextCard(
CardId.DecodeTalker,
CardId.EncodeTalker,
CardId.TriGateWizard,
......@@ -450,7 +449,7 @@ namespace WindBot.Game.AI.Decks
CardId.ROMCloudia,
CardId.Linkslayer,
CardId.RAMClouder
});
);
return true;
}
......
......@@ -152,7 +152,7 @@ namespace WindBot.Game.AI.Decks
{
if (!defender.IsMonsterHasPreventActivationEffectInBattle())
{
if (attacker.Id == CardId.HiSpeedroidChanbara && !attacker.IsDisabled())
if (attacker.IsCode(CardId.HiSpeedroidChanbara) && !attacker.IsDisabled())
attacker.RealPower = attacker.RealPower + 200;
}
return base.OnPreBattleBetween(attacker, defender);
......@@ -229,12 +229,12 @@ namespace WindBot.Game.AI.Decks
private bool FoolishBurialGoodsEffect()
{
AI.SelectCard(new[]{
AI.SelectCard(
CardId.MetalfoesFusion,
CardId.WidowAnchor,
CardId.Engage,
CardId.HornetDrones
});
);
return true;
}
......@@ -312,13 +312,13 @@ namespace WindBot.Game.AI.Decks
if (target > 0)
AI.SelectCard(target);
else
AI.SelectCard(new[] {
AI.SelectCard(
CardId.Multirole,
CardId.AreaZero,
CardId.Afterburners,
CardId.JammingWave,
CardId.Raye
});
);
return true;
}
......@@ -330,13 +330,13 @@ namespace WindBot.Game.AI.Decks
if (target > 0)
AI.SelectCard(target);
else
AI.SelectCard(new[] {
AI.SelectCard(
CardId.Multirole,
CardId.AreaZero,
CardId.Afterburners,
CardId.JammingWave,
CardId.Raye
});
);
return true;
}
......@@ -399,7 +399,7 @@ namespace WindBot.Game.AI.Decks
IList<ClientCard> targets = new List<ClientCard>();
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);
}
if (targets.Count > 0)
......@@ -451,7 +451,7 @@ namespace WindBot.Game.AI.Decks
}
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);
return true;
......@@ -459,7 +459,7 @@ namespace WindBot.Game.AI.Decks
}
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);
return true;
......@@ -482,7 +482,7 @@ namespace WindBot.Game.AI.Decks
}
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);
return true;
......@@ -490,7 +490,7 @@ namespace WindBot.Game.AI.Decks
}
foreach (ClientCard target in Bot.GetSpells())
{
if (target.Id == CardId.AreaZero)
if (target.IsCode(CardId.AreaZero))
{
AI.SelectCard(target);
return true;
......@@ -498,7 +498,7 @@ namespace WindBot.Game.AI.Decks
}
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);
return true;
......@@ -562,11 +562,7 @@ namespace WindBot.Game.AI.Decks
}
else
{
AI.SelectCard(new[] {
CardId.Shizuku,
CardId.Kagari,
CardId.Hayate
});
AI.SelectCard(CardId.Shizuku, CardId.Kagari, CardId.Hayate);
}
}
......@@ -595,11 +591,7 @@ namespace WindBot.Game.AI.Decks
AI.SelectCard(CardId.JammingWave);
}
else
AI.SelectCard(new[] {
CardId.Engage,
CardId.HornetDrones,
CardId.WidowAnchor
});
AI.SelectCard(CardId.Engage, CardId.HornetDrones, CardId.WidowAnchor);
return true;
}
......@@ -619,11 +611,7 @@ namespace WindBot.Game.AI.Decks
if (target != 0)
AI.SelectCard(target);
else
AI.SelectCard(new[] {
CardId.Engage,
CardId.HornetDrones,
CardId.WidowAnchor
});
AI.SelectCard(CardId.Engage, CardId.HornetDrones, CardId.WidowAnchor);
return true;
}
......
......@@ -116,7 +116,7 @@ namespace WindBot.Game.AI.Decks
{
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;
}
return base.OnPreBattleBetween(attacker, defender);
......@@ -138,19 +138,17 @@ namespace WindBot.Game.AI.Decks
}
else
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.CryomancerOfTheIceBarrier,
CardId.DewdarkOfTheIceBarrier
});
);
}
return true;
}
private bool SurfaceEffect()
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.ToadallyAwesome,
CardId.HeraldOfTheArcLight,
CardId.SwapFrog,
......@@ -159,7 +157,7 @@ namespace WindBot.Game.AI.Decks
CardId.DupeFrog,
CardId.Ronintoadin,
CardId.GraydleSlimeJr
});
);
return true;
}
......@@ -182,8 +180,7 @@ namespace WindBot.Game.AI.Decks
else if (Bot.HasInGraveyard(CardId.DupeFrog) && !Bot.HasInGraveyard(CardId.Ronintoadin))
AI.SelectCard(CardId.Ronintoadin);
else
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.GraydleSlimeJr,
CardId.Ronintoadin,
CardId.DupeFrog,
......@@ -191,18 +188,17 @@ namespace WindBot.Game.AI.Decks
CardId.DewdarkOfTheIceBarrier,
CardId.PriorOfTheIceBarrier,
CardId.SwapFrog
});
);
return true;
}
private bool SalvageEffect()
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.SwapFrog,
CardId.PriorOfTheIceBarrier,
CardId.GraydleSlimeJr
});
);
return true;
}
......@@ -215,8 +211,7 @@ namespace WindBot.Game.AI.Decks
else if (Bot.HasInGraveyard(CardId.DupeFrog) && !Bot.HasInGraveyard(CardId.Ronintoadin))
AI.SelectCard(CardId.Ronintoadin);
else
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.Ronintoadin,
CardId.DupeFrog,
CardId.CryomancerOfTheIceBarrier,
......@@ -224,7 +219,7 @@ namespace WindBot.Game.AI.Decks
CardId.PriorOfTheIceBarrier,
CardId.GraydleSlimeJr,
CardId.SwapFrog
});
);
return true;
}
......@@ -238,12 +233,11 @@ namespace WindBot.Game.AI.Decks
{
if (Bot.HasInHand(CardId.DupeFrog))
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.PriorOfTheIceBarrier,
CardId.GraydleSlimeJr,
CardId.SwapFrog
});
);
return true;
}
}
......@@ -259,8 +253,7 @@ namespace WindBot.Game.AI.Decks
{
AI.SelectCard(CardId.GraydleSlimeJr);
AI.SelectPosition(CardPosition.FaceUpDefence);
AI.SelectNextCard(new[]
{
AI.SelectNextCard(
CardId.SwapFrog,
CardId.CryomancerOfTheIceBarrier,
CardId.DewdarkOfTheIceBarrier,
......@@ -268,7 +261,7 @@ namespace WindBot.Game.AI.Decks
CardId.DupeFrog,
CardId.PriorOfTheIceBarrier,
CardId.GraydleSlimeJr
});
);
return true;
}
......@@ -315,7 +308,7 @@ namespace WindBot.Game.AI.Decks
};
foreach (ClientCard monster in monsters)
{
if (suitableCost.Contains(monster.Id))
if (monster.IsCode(suitableCost))
{
AI.SelectCard(monster);
return true;
......@@ -325,7 +318,7 @@ namespace WindBot.Game.AI.Decks
{
foreach (ClientCard monster in monsters)
{
if (monster.Id == CardId.DupeFrog)
if (monster.IsCode(CardId.DupeFrog))
{
AI.SelectCard(monster);
return true;
......@@ -337,7 +330,7 @@ namespace WindBot.Game.AI.Decks
{
foreach (ClientCard monster in hands)
{
if (monster.Id == CardId.GraydleSlimeJr)
if (monster.IsCode(CardId.GraydleSlimeJr))
{
AI.SelectCard(monster);
return true;
......@@ -348,7 +341,7 @@ namespace WindBot.Game.AI.Decks
{
foreach (ClientCard monster in hands)
{
if (monster.Id == CardId.DupeFrog)
if (monster.IsCode(CardId.DupeFrog))
{
AI.SelectCard(monster);
return true;
......@@ -357,7 +350,7 @@ namespace WindBot.Game.AI.Decks
}
foreach (ClientCard monster in hands)
{
if (monster.Id == CardId.Ronintoadin || monster.Id == CardId.DupeFrog)
if (monster.IsCode(CardId.Ronintoadin, CardId.DupeFrog))
{
AI.SelectCard(monster);
return true;
......@@ -378,12 +371,11 @@ namespace WindBot.Game.AI.Decks
}
else
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.SwapFrog,
CardId.PriorOfTheIceBarrier,
CardId.GraydleSlimeJr
});
);
}
return true;
}
......@@ -392,27 +384,25 @@ namespace WindBot.Game.AI.Decks
SelectXYZDetach(Card.Overlays);
if (Duel.Player == 0)
{
AI.SelectNextCard(new[]
{
AI.SelectNextCard(
CardId.SwapFrog,
CardId.CryomancerOfTheIceBarrier,
CardId.DewdarkOfTheIceBarrier,
CardId.Ronintoadin,
CardId.DupeFrog,
CardId.GraydleSlimeJr
});
);
}
else
{
AI.SelectNextCard(new[]
{
AI.SelectNextCard(
CardId.DupeFrog,
CardId.SwapFrog,
CardId.Ronintoadin,
CardId.GraydleSlimeJr,
CardId.CryomancerOfTheIceBarrier,
CardId.DewdarkOfTheIceBarrier
});
);
AI.SelectPosition(CardPosition.FaceUpDefence);
}
return true;
......@@ -442,7 +432,7 @@ namespace WindBot.Game.AI.Decks
List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters)
{
if (monster.Id == CardId.ToadallyAwesome && monster.Attack <= 2200)
if (monster.IsCode(CardId.ToadallyAwesome) && monster.Attack <= 2200)
{
SelectXYZDetach(Card.Overlays);
AI.SelectNextCard(monster);
......@@ -451,7 +441,7 @@ namespace WindBot.Game.AI.Decks
}
foreach (ClientCard monster in monsters)
{
if (monster.Id == CardId.SkyCavalryCentaurea && monster.Attack <= 2000)
if (monster.IsCode(CardId.SkyCavalryCentaurea) && monster.Attack <= 2000)
{
SelectXYZDetach(Card.Overlays);
AI.SelectNextCard(monster);
......@@ -460,7 +450,7 @@ namespace WindBot.Game.AI.Decks
}
foreach (ClientCard monster in monsters)
{
if (monster.Id == CardId.DaigustoPhoenix && monster.Attack <= 1500)
if (monster.IsCode(CardId.DaigustoPhoenix) && monster.Attack <= 1500)
{
SelectXYZDetach(Card.Overlays);
AI.SelectNextCard(monster);
......@@ -566,8 +556,7 @@ namespace WindBot.Game.AI.Decks
else if (Overlays.Contains(CardId.Ronintoadin) && Bot.HasInGraveyard(CardId.DupeFrog) && !Bot.HasInGraveyard(CardId.Ronintoadin))
AI.SelectCard(CardId.Ronintoadin);
else
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.GraydleSlimeJr,
CardId.Ronintoadin,
CardId.DupeFrog,
......@@ -575,7 +564,7 @@ namespace WindBot.Game.AI.Decks
CardId.DewdarkOfTheIceBarrier,
CardId.PriorOfTheIceBarrier,
CardId.SwapFrog
});
);
}
}
}
......@@ -37,7 +37,7 @@ namespace WindBot.Game.AI.Decks
public const int Ring = 83555666;
public const int Strike = 40605147;
public const int Warn = 84749824;
public const int Grass = 10813327;
public const int Awaken = 10813327;
public const int Linkuri = 41999284;
public const int Linkspi = 98978921;
......@@ -80,6 +80,13 @@ namespace WindBot.Game.AI.Decks
int GraveCall_id = 0;
int GraveCall_count = 0;
List<int> SkyStrike_list = new List<int> {
26077387, 8491308, 63288573, 90673288,
21623008, 25955749, 63166095, 99550630,
25733157, 51227866, 52340444,98338152,
24010609, 97616504, 50005218
};
public TrickstarExecutor(GameAI ai, Duel duel)
: base(ai, duel)
{
......@@ -87,7 +94,7 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.Activate, CardId.MG, G_act);
AddExecutor(ExecutorType.Activate, CardId.Strike, DefaultSolemnStrike);
AddExecutor(ExecutorType.Activate, CardId.Warn, DefaultSolemnWarning);
AddExecutor(ExecutorType.Activate, CardId.Grass, Grass_ss);
AddExecutor(ExecutorType.Activate, CardId.Awaken, Awaken_ss);
AddExecutor(ExecutorType.Activate, CardId.Urara, Hand_act_eff);
AddExecutor(ExecutorType.Activate, CardId.Ghost, Hand_act_eff);
AddExecutor(ExecutorType.Activate, CardId.Ring, Ring_act);
......@@ -99,6 +106,7 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.Activate, CardId.DarkHole, DarkHole_eff);
// spell clean
AddExecutor(ExecutorType.Activate, field_activate);
AddExecutor(ExecutorType.Activate, CardId.Stage, Stage_Lock);
AddExecutor(ExecutorType.Activate, CardId.Feather, Feather_Act);
AddExecutor(ExecutorType.Activate, CardId.Stage, Stage_act);
......@@ -106,6 +114,7 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.Activate, CardId.TG, TG_eff);
AddExecutor(ExecutorType.Activate, CardId.Tuner,Tuner_eff);
AddExecutor(ExecutorType.SpellSet, Five_Rainbow);
// ex ss
AddExecutor(ExecutorType.SpSummon, CardId.Borrel, Borrel_ss);
......@@ -160,15 +169,69 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.SpellSet, SpellSet);
}
public bool SpellSet()
public bool Five_Rainbow()
{
if (Enemy.HasInSpellZone(19619755,true) || Bot.HasInSpellZone(19619755, true))
{
if (Card.HasType(CardType.Field)) return false;
bool has_setcard = false;
for (int i = 0; i < 5; ++i)
{
if (Card.Id == CardId.Sheep && Bot.HasInSpellZone(CardId.Sheep)) return false;
return DefaultSpellSet();
ClientCard sp = Bot.SpellZone[i];
if (sp != null && sp.HasPosition(CardPosition.FaceDown))
{
has_setcard = true;
break;
}
}
if (has_setcard) return false;
AI.SelectPlace(SelectSTPlace());
return true;
}
return false;
}
public bool Has_down_arrow(int id)
public int SelectSTPlace()
{
List<int> list = new List<int>();
list.Add(0);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(4);
int n = list.Count;
while (n-- > 1)
{
return (id == CardId.Linkuri || id == CardId.Linkspi || id == CardId.Unicorn);
int index = Program.Rand.Next(n + 1);
int temp = list[index];
list[index] = list[n];
list[n] = temp;
}
foreach(int seq in list)
{
int zone = (int)System.Math.Pow(2, seq);
if (Bot.SpellZone[seq] == null) return zone;
}
return 0;
}
public bool SpellSet()
{
if (Card.IsCode(CardId.Sheep) && Bot.HasInSpellZone(CardId.Sheep)) return false;
if (DefaultSpellSet())
{
AI.SelectPlace(SelectSTPlace());
return true;
} else if (Enemy.HasInSpellZone(58921041,true) || Bot.HasInSpellZone(58921041, true))
{
if (Card.IsCode(CardId.Stage)) return !Bot.HasInSpellZone(CardId.Stage);
if (Card.IsSpell())
{
AI.SelectPlace(SelectSTPlace());
return true;
}
}
return false;
}
public bool IsTrickstar(int id)
......@@ -176,12 +239,43 @@ namespace WindBot.Game.AI.Decks
return (id == CardId.Yellow || id == CardId.Red || id == CardId.Pink || id == CardId.White || id == CardId.Stage || id == CardId.Re || id == CardId.Crown);
}
public bool field_activate()
{
if (Card.HasPosition(CardPosition.FaceDown) && Card.HasType(CardType.Field) && Card.Location == CardLocation.SpellZone)
{
// field spells that forbid other fields' activate
return !Card.IsCode(71650854, 78082039);
}
return false;
}
public bool spell_trap_activate()
{
if (Card.Location != CardLocation.SpellZone && Card.Location != CardLocation.Hand) return true;
if (Enemy.HasInMonstersZone(CardId.Exterio,true) && !Bot.HasInHandOrHasInMonstersZone(CardId.Ghost)) return false;
if (Card.IsSpell())
{
if (Enemy.HasInMonstersZone(33198837, true) && !Bot.HasInHandOrHasInMonstersZone(CardId.Ghost)) return false;
if (Enemy.HasInSpellZone(61740673, true) || Bot.HasInSpellZone(61740673,true)) return false;
if (Enemy.HasInMonstersZone(37267041, true) || Bot.HasInMonstersZone(37267041, true)) return false;
return true;
}
if (Card.IsTrap())
{
if (Enemy.HasInSpellZone(51452091, true) || Bot.HasInSpellZone(51452091, true)) return false;
if (Enemy.HasInSpellZone(51452091, true) || Bot.HasInSpellZone(51452091, true)) return false;
return true;
}
// how to get here?
return false;
}
public int[] Useless_List()
{
return new[]
{
CardId.Tuner,
CardId.Grass,
CardId.Awaken,
CardId.Crown,
CardId.Pink,
CardId.Pot,
......@@ -216,7 +310,7 @@ namespace WindBot.Game.AI.Decks
return atk;
}
public bool Grass_ss()
public bool Awaken_ss()
{
// judge whether can ss from exdeck
bool judge = (Bot.ExtraDeck.Count > 0);
......@@ -231,15 +325,60 @@ namespace WindBot.Game.AI.Decks
// can ss from exdeck
if (judge)
{
bool fornextss = AI.Utils.ChainContainsCard(CardId.Grass);
bool fornextss = AI.Utils.ChainContainsCard(CardId.Awaken);
IList<ClientCard> ex = Bot.ExtraDeck;
ClientCard ex_best = null;
foreach (ClientCard ex_card in ex)
{
if (!fornextss)
{
if (Bot.HasInExtra(CardId.Exterio))
{
bool has_skystriker = false;
foreach (ClientCard card in Enemy.Graveyard)
{
if (card != null && card.IsCode(SkyStrike_list))
{
has_skystriker = true;
break;
}
}
if (!has_skystriker)
{
foreach (ClientCard card in Enemy.GetSpells())
{
if (card != null && card.IsCode(SkyStrike_list))
{
has_skystriker = true;
break;
}
}
}
if (!has_skystriker)
{
foreach (ClientCard card in Enemy.GetSpells())
{
if (card != null && card.IsCode(SkyStrike_list))
{
has_skystriker = true;
break;
}
}
}
if (has_skystriker)
{
AI.SelectCard(CardId.Exterio);
return true;
} else
{
if (ex_best == null || ex_card.Attack > ex_best.Attack) ex_best = ex_card;
}
}
else
{
if (ex_best == null || ex_card.Attack > ex_best.Attack) ex_best = ex_card;
}
}
else
{
if (getLinkMarker(ex_card.Id) != 5 && (ex_best == null || ex_card.Attack > ex_best.Attack)) ex_best = ex_card;
......@@ -250,7 +389,7 @@ namespace WindBot.Game.AI.Decks
AI.SelectCard(ex_best);
}
}
if (!judge || AI.Utils.ChainContainsCard(CardId.Grass))
if (!judge || AI.Utils.ChainContainsCard(CardId.Awaken))
{
// cannot ss from exdeck or have more than 1 grass in chain
int[] secondselect = new[]
......@@ -266,7 +405,7 @@ namespace WindBot.Game.AI.Decks
CardId.Yellow,
CardId.Pink
};
if (!AI.Utils.ChainContainsCard(CardId.Grass))
if (!AI.Utils.ChainContainsCard(CardId.Awaken))
{
if (!judge && Bot.GetRemainingCount(CardId.Ghost, 2) > 0)
{
......@@ -292,14 +431,7 @@ namespace WindBot.Game.AI.Decks
// tuner ss
if (ActivateDescription == -1)
{
AI.SelectCard(new[]
{
CardId.Ghost,
CardId.TG,
CardId.Tuner,
CardId.Urara,
CardId.BF
});
AI.SelectCard(CardId.Ghost, CardId.TG, CardId.Tuner, CardId.Urara, CardId.BF);
return true;
};
// counter
......@@ -366,6 +498,7 @@ namespace WindBot.Game.AI.Decks
}
else
{
if (!spell_trap_activate()) return false;
foreach (ClientCard card in spells)
{
if (card.IsFacedown() && card != stage_locked)
......@@ -378,6 +511,7 @@ namespace WindBot.Game.AI.Decks
if (selected == null)
return false;
AI.SelectCard(selected);
AI.SelectPlace(SelectSTPlace());
return true;
}
......@@ -389,27 +523,31 @@ namespace WindBot.Game.AI.Decks
public bool Feather_Act()
{
if (!spell_trap_activate()) return false;
if (AI.Utils.GetProblematicEnemySpell() != null)
{
List<ClientCard> grave = Bot.GetGraveyardSpells();
foreach (ClientCard self_card in grave)
{
if (self_card.Id == CardId.Galaxy)
if (self_card.IsCode(CardId.Galaxy))
return false;
}
AI.SelectPlace(SelectSTPlace());
return true;
}
// activate when more than 2 cards
if (Enemy.GetSpellCount() <= 1)
return false;
AI.SelectPlace(SelectSTPlace());
return true;
}
public bool Sheep_Act()
{
if (!spell_trap_activate()) return false;
if (Duel.Player == 0) return false;
if (Duel.Phase == DuelPhase.End) return true;
if (Duel.LastChainPlayer == 1 && (AI.Utils.IsChainTarget(Card) || (AI.Utils.GetLastChainCard().Id == CardId.Feather && !Bot.HasInSpellZone(CardId.Grass)))) return true;
if (Duel.LastChainPlayer == 1 && (AI.Utils.IsChainTarget(Card) || (AI.Utils.GetLastChainCard().IsCode(CardId.Feather) && !Bot.HasInSpellZone(CardId.Awaken)))) return true;
if (Duel.Phase > DuelPhase.Main1 && Duel.Phase < DuelPhase.Main2)
{
int total_atk = 0;
......@@ -425,68 +563,37 @@ namespace WindBot.Game.AI.Decks
public bool Stage_act()
{
if (Card.Location != CardLocation.Hand) return false;
if (Card.Location == CardLocation.SpellZone && Card.HasPosition(CardPosition.FaceUp)) return false;
if (!spell_trap_activate()) return false;
if (!NormalSummoned)
{
if (!Bot.HasInHand(CardId.Yellow))
{
AI.SelectCard(new[]
{
CardId.Yellow,
CardId.Pink,
CardId.Red,
CardId.White
});
AI.SelectCard(CardId.Yellow, CardId.Pink, CardId.Red, CardId.White);
stage_locked = null;
return true;
}
else if (Enemy.LifePoints <= 1000 && Bot.GetRemainingCount(CardId.Pink,1) > 0)
{
AI.SelectCard(new[]
{
CardId.Pink,
CardId.Yellow,
CardId.Red,
CardId.White
});
AI.SelectCard(CardId.Pink, CardId.Yellow, CardId.Red, CardId.White);
stage_locked = null;
return true;
}
else if (Bot.HasInHand(CardId.Yellow) && ! Bot.HasInHand(CardId.Red))
{
AI.SelectCard(new[]
{
CardId.Red,
CardId.Pink,
CardId.Yellow,
CardId.White
});
AI.SelectCard(CardId.Red, CardId.Pink, CardId.Yellow, CardId.White);
stage_locked = null;
return true;
}
else if (Enemy.GetMonsterCount() > 0 && AI.Utils.GetBestEnemyMonster().Attack >= AI.Utils.GetBestAttack(Bot))
{
AI.SelectCard(new[]
{
CardId.White,
CardId.Yellow,
CardId.Pink,
CardId.Red
});
AI.SelectCard(CardId.White, CardId.Yellow, CardId.Pink, CardId.Red);
stage_locked = null;
return true;
}
else if (!Bot.HasInSpellZone(CardId.Stage))
{
AI.SelectCard(new[]
{
CardId.Yellow,
CardId.Pink,
CardId.Red,
CardId.White
});
AI.SelectCard(CardId.Yellow, CardId.Pink, CardId.Red, CardId.White);
stage_locked = null;
return true;
}
......@@ -497,47 +604,23 @@ namespace WindBot.Game.AI.Decks
{
if (Enemy.LifePoints <= 1000 && !pink_ss && Bot.GetRemainingCount(CardId.Pink,1) > 0)
{
AI.SelectCard(new[]
{
CardId.Pink,
CardId.Yellow,
CardId.Red,
CardId.White
});
AI.SelectCard(CardId.Pink, CardId.Yellow, CardId.Red, CardId.White);
stage_locked = null;
return true;
}
if (Enemy.GetMonsterCount() > 0 && AI.Utils.GetBestEnemyMonster().Attack >= AI.Utils.GetBestAttack(Bot) && !Bot.HasInHand(CardId.White))
{
AI.SelectCard(new[]
{
CardId.White,
CardId.Yellow,
CardId.Pink,
CardId.Red
});
AI.SelectCard(CardId.White, CardId.Yellow, CardId.Pink, CardId.Red);
stage_locked = null;
return true;
}
if (Bot.HasInMonstersZone(CardId.Yellow) && !Bot.HasInHand(CardId.Red))
{
AI.SelectCard(new[]
{
CardId.Red,
CardId.Pink,
CardId.Yellow,
CardId.White
});
AI.SelectCard(CardId.Red, CardId.Pink, CardId.Yellow, CardId.White);
stage_locked = null;
return true;
}
AI.SelectCard(new[]
{
CardId.Yellow,
CardId.Pink,
CardId.Red,
CardId.White
});
AI.SelectCard(CardId.Yellow, CardId.Pink, CardId.Red, CardId.White);
stage_locked = null;
return true;
}
......@@ -547,14 +630,20 @@ namespace WindBot.Game.AI.Decks
public bool Pot_Act()
{
return Bot.Deck.Count > 15;
if (!spell_trap_activate()) return false;
if (Bot.Deck.Count > 15)
{
AI.SelectPlace(SelectSTPlace());
return true;
}
return false;
}
public bool Hand_act_eff()
{
if (GraveCall_count > 0 && GraveCall_id == Card.Id) return false;
if (Card.Id == CardId.Urara && Bot.HasInHand(CardId.LockBird) && Bot.HasInSpellZone(CardId.Re)) return false;
if (Card.Id == CardId.Ghost && Card.Location == CardLocation.Hand && Bot.HasInMonstersZone(CardId.Ghost)) return false;
if (Card.IsCode(CardId.Urara) && Bot.HasInHand(CardId.LockBird) && Bot.HasInSpellZone(CardId.Re)) return false;
if (Card.IsCode(CardId.Ghost) && Card.Location == CardLocation.Hand && Bot.HasInMonstersZone(CardId.Ghost)) return false;
return (Duel.LastChainPlayer == 1);
}
......@@ -593,21 +682,11 @@ namespace WindBot.Game.AI.Decks
{
if (!NormalSummoned && Bot.HasInGraveyard(CardId.Yellow))
{
AI.SelectCard(new[]
{
CardId.Yellow,
CardId.Red,
CardId.White
});
AI.SelectCard(CardId.Yellow, CardId.Red, CardId.White);
return true;
} else
{
AI.SelectCard(new[]
{
CardId.Red,
CardId.Yellow,
CardId.White
});
AI.SelectCard(CardId.Red, CardId.Yellow, CardId.White);
return true;
}
}
......@@ -621,11 +700,11 @@ namespace WindBot.Game.AI.Decks
if (AI.Utils.IsTurn1OrMain2()) return false;
AI.SelectPosition(CardPosition.FaceUpAttack);
IList<ClientCard> targets = new List<ClientCard>();
if (Bot.SpellZone[5] != null && Bot.SpellZone[5].IsFacedown())
if (Bot.SpellZone[5] != null && !Bot.SpellZone[5].IsCode(CardId.Stage))
{
targets.Add(Bot.SpellZone[5]);
}
if (Bot.SpellZone[5] != null && Bot.SpellZone[5].Id == CardId.Stage && Bot.HasInHand(CardId.Stage))
if (Bot.SpellZone[5] != null && Bot.SpellZone[5].IsCode(CardId.Stage) && Bot.HasInHand(CardId.Stage))
{
targets.Add(Bot.SpellZone[5]);
}
......@@ -684,7 +763,7 @@ namespace WindBot.Game.AI.Decks
{
if (red_ss_count >= 6) return false;
if ((AI.Utils.ChainContainsCard(CardId.DarkHole) || AI.Utils.ChainContainsCard(99330325) || AI.Utils.ChainContainsCard(53582587)) && AI.Utils.ChainContainsCard(CardId.Red)) return false;
if (Duel.LastChainPlayer == 0 && AI.Utils.GetLastChainCard().Id == CardId.Red)
if (Duel.LastChainPlayer == 0 && AI.Utils.GetLastChainCard().IsCode(CardId.Red))
{
foreach (ClientCard m in Bot.GetMonsters())
{
......@@ -707,7 +786,7 @@ namespace WindBot.Game.AI.Decks
ClientCard tosolve_enemy = AI.Utils.GetOneEnemyBetterThanMyBest();
foreach (ClientCard c in self_m)
{
if (IsTrickstar(c.Id) && c.Id != CardId.Red)
if (IsTrickstar(c.Id) && !c.IsCode(CardId.Red))
{
if (c.Attacked)
{
......@@ -716,7 +795,7 @@ namespace WindBot.Game.AI.Decks
red_ss_count += 1;
return true;
}
if (c.Id == CardId.Pink) return false;
if (c.IsCode(CardId.Pink)) return false;
if (tosolve_enemy != null)
{
if (Bot.HasInHand(CardId.White) && c.Attack + c.BaseAttack < tosolve_enemy.Attack)
......@@ -727,7 +806,7 @@ namespace WindBot.Game.AI.Decks
red_ss_count += 1;
return true;
}
if (!Bot.HasInHand(CardId.White) && tosolve_enemy.Attack <= 3200 && c.Id == CardId.White)
if (!Bot.HasInHand(CardId.White) && tosolve_enemy.Attack <= 3200 && c.IsCode(CardId.White))
{
AI.SelectCard(c);
Red_SelectPos(c);
......@@ -765,7 +844,7 @@ namespace WindBot.Game.AI.Decks
self_monster.Sort(AIFunctions.CompareDefensePower);
foreach(ClientCard card in self_monster)
{
if (IsTrickstar(card.Id) && card.Id != CardId.Red)
if (IsTrickstar(card.Id) && !card.IsCode(CardId.Red))
{
AI.SelectCard(card);
Red_SelectPos(card);
......@@ -783,46 +862,19 @@ namespace WindBot.Game.AI.Decks
{
if (!Bot.HasInHand(CardId.Stage) && !Bot.HasInSpellZone(CardId.Stage) && Bot.GetRemainingCount(CardId.Stage, 3) > 0)
{
AI.SelectCard(new[]
{
CardId.Stage,
CardId.Red,
CardId.White,
CardId.Pink,
CardId.Re,
CardId.Crown,
CardId.Yellow
});
AI.SelectCard(CardId.Stage, CardId.Red, CardId.White, CardId.Pink, CardId.Re, CardId.Crown, CardId.Yellow);
return true;
}
if (Enemy.LifePoints <= 1000)
{
if (Bot.GetRemainingCount(CardId.Pink, 1) > 0 && !pink_ss)
{
AI.SelectCard(new[]
{
CardId.Pink,
CardId.Stage,
CardId.Red,
CardId.White,
CardId.Re,
CardId.Crown,
CardId.Yellow
});
AI.SelectCard(CardId.Pink, CardId.Stage, CardId.Red, CardId.White, CardId.Re, CardId.Crown, CardId.Yellow);
return true;
}
else if (Bot.HasInGraveyard(CardId.Pink) && Bot.GetRemainingCount(CardId.Crown, 1) > 0)
{
AI.SelectCard(new[]
{
CardId.Crown,
CardId.Pink,
CardId.Re,
CardId.Stage,
CardId.Red,
CardId.White,
CardId.Yellow
});
AI.SelectCard(CardId.Crown, CardId.Pink, CardId.Re, CardId.Stage, CardId.Red, CardId.White, CardId.Yellow);
return true;
}
}
......@@ -830,68 +882,23 @@ namespace WindBot.Game.AI.Decks
{
if (Bot.HasInGraveyard(CardId.Red) && Bot.GetRemainingCount(CardId.Pink, 1) > 0 && !pink_ss)
{
AI.SelectCard(new[]
{
CardId.Pink,
CardId.Red,
CardId.White,
CardId.Re,
CardId.Stage,
CardId.Crown,
CardId.Yellow
});
AI.SelectCard(CardId.Pink, CardId.Red, CardId.White, CardId.Re, CardId.Stage, CardId.Crown, CardId.Yellow);
}
else if (Bot.HasInGraveyard(CardId.Pink) && Bot.HasInGraveyard(CardId.Red) && Bot.GetRemainingCount(CardId.Ring, 1) > 0)
{
AI.SelectCard(new[]
{
CardId.Crown,
CardId.Red,
CardId.White,
CardId.Re,
CardId.Stage,
CardId.Pink,
CardId.Yellow
});
AI.SelectCard(CardId.Crown, CardId.Red, CardId.White, CardId.Re, CardId.Stage, CardId.Pink, CardId.Yellow);
}
else if (Bot.GetRemainingCount(CardId.White, 2) > 0 && Enemy.LifePoints <= 4000)
{
AI.SelectCard(new[]
{
CardId.White,
CardId.Red,
CardId.Pink,
CardId.Re,
CardId.Stage,
CardId.Crown,
CardId.Yellow
});
AI.SelectCard(CardId.White, CardId.Red, CardId.Pink, CardId.Re, CardId.Stage, CardId.Crown, CardId.Yellow);
}
else if (Bot.HasInGraveyard(CardId.White) && Bot.GetRemainingCount(CardId.Crown, 1) > 0)
{
AI.SelectCard(new[]
{
CardId.Crown,
CardId.Red,
CardId.Pink,
CardId.Re,
CardId.Stage,
CardId.White,
CardId.Yellow
});
AI.SelectCard(CardId.Crown, CardId.Red, CardId.Pink, CardId.Re, CardId.Stage, CardId.White, CardId.Yellow);
}
else
{
AI.SelectCard(new[]
{
CardId.Red,
CardId.Pink,
CardId.Re,
CardId.Crown,
CardId.Stage,
CardId.White,
CardId.Yellow
});
AI.SelectCard(CardId.Red, CardId.Pink, CardId.Re, CardId.Crown, CardId.Stage, CardId.White, CardId.Yellow);
}
return true;
}
......@@ -900,55 +907,19 @@ namespace WindBot.Game.AI.Decks
int power = AI.Utils.GetProblematicEnemyMonster().GetDefensePower();
if (power >= 1800 && power <= 3600 && Bot.GetRemainingCount(CardId.White, 2) > 0 && !Bot.HasInHand(CardId.White))
{
AI.SelectCard(new[]
{
CardId.White,
CardId.Red,
CardId.Pink,
CardId.Re,
CardId.Stage,
CardId.Crown,
CardId.Yellow
});
AI.SelectCard(CardId.White, CardId.Red, CardId.Pink, CardId.Re, CardId.Stage, CardId.Crown, CardId.Yellow);
}
else
{
AI.SelectCard(new[]
{
CardId.Red,
CardId.Pink,
CardId.Re,
CardId.Crown,
CardId.Stage,
CardId.White,
CardId.Yellow
});
AI.SelectCard(CardId.Red, CardId.Pink, CardId.Re, CardId.Crown, CardId.Stage, CardId.White, CardId.Yellow);
}
return true;
}
if ((Bot.HasInHand(CardId.Red) || Bot.HasInHand(CardId.Stage) || Bot.HasInHand(CardId.Yellow)) && Bot.GetRemainingCount(CardId.Re,1) > 0) {
AI.SelectCard(new[]
{
CardId.Re,
CardId.Red,
CardId.White,
CardId.Crown,
CardId.Pink,
CardId.Stage,
CardId.Yellow
});
AI.SelectCard(CardId.Re, CardId.Red, CardId.White, CardId.Crown, CardId.Pink, CardId.Stage, CardId.Yellow);
return true;
}
AI.SelectCard(new[]
{
CardId.Red,
CardId.Pink,
CardId.Re,
CardId.Crown,
CardId.Stage,
CardId.White,
CardId.Yellow
});
AI.SelectCard(CardId.Red, CardId.Pink, CardId.Re, CardId.Crown, CardId.Stage, CardId.White, CardId.Yellow);
return true;
}
......@@ -1024,6 +995,7 @@ namespace WindBot.Game.AI.Decks
public bool Reincarnation()
{
if (Card.Location == CardLocation.Grave) return Ts_reborn();
if (!spell_trap_activate()) return false;
if (Bot.HasInHand(CardId.LockBird))
{
if (lockbird_useful || AI.Utils.IsChainTarget(Card) || (Duel.Player == 1 && AI.Utils.ChainContainsCard(CardId.Feather))) {
......@@ -1037,9 +1009,14 @@ namespace WindBot.Game.AI.Decks
public bool Crown_eff()
{
if (Card.Location == CardLocation.Hand)
if (Card.Location == CardLocation.Hand || (Card.Location == CardLocation.SpellZone && Card.HasPosition(CardPosition.FaceDown)))
{
if (!spell_trap_activate()) return false;
if (Duel.Phase <= DuelPhase.Main1 && Ts_reborn())
{
if (Duel.Phase <= DuelPhase.Main1) return Ts_reborn();
AI.SelectPlace(SelectSTPlace());
return true;
}
return false;
}
if (Bot.HasInHand(CardId.Pink) && GraveCall_id != CardId.Pink)
......@@ -1054,7 +1031,7 @@ namespace WindBot.Game.AI.Decks
if (hand.IsMonster() && IsTrickstar(hand.Id))
{
if (hand.Attack >= Enemy.LifePoints) return true;
if (hand.Id != CardId.Yellow)
if (!hand.IsCode(CardId.Yellow))
{
if (AI.Utils.GetOneEnemyBetterThanValue(hand.Attack, false) == null) return true;
}
......@@ -1082,26 +1059,14 @@ namespace WindBot.Game.AI.Decks
}
else
{
AI.SelectCard(new[]
{
CardId.Red,
CardId.White,
CardId.Yellow,
CardId.Pink
});
AI.SelectCard(CardId.Red, CardId.White, CardId.Yellow, CardId.Pink);
return true;
}
}
else
{
AI.SelectCard(new[]
{
CardId.Red,
CardId.White,
CardId.Yellow,
CardId.Pink
});
AI.SelectCard(CardId.Red, CardId.White, CardId.Yellow, CardId.Pink);
return true;
}
}
......@@ -1139,7 +1104,7 @@ namespace WindBot.Game.AI.Decks
public bool Tuner_ns()
{
if ((Card.Id == CardId.Tuner && Bot.HasInExtra(CardId.Crystal) && !tuner_eff_used) || Tuner_ss())
if ((Card.IsCode(CardId.Tuner) && Bot.HasInExtra(CardId.Crystal) && !tuner_eff_used) || Tuner_ss())
{
NormalSummoned = true;
return true;
......@@ -1151,17 +1116,17 @@ namespace WindBot.Game.AI.Decks
{
if (crystal_eff_used || Bot.HasInMonstersZone(CardId.Crystal)) return false;
if (Bot.GetMonsterCount() == 0 || !Bot.HasInExtra(CardId.Crystal)) return false;
if (Card.Id == CardId.Ghost && Bot.GetRemainingCount(CardId.Ghost, 2) <= 0) return false;
if (Card.IsCode(CardId.Ghost) && Bot.GetRemainingCount(CardId.Ghost, 2) <= 0) return false;
int count = 0;
if (Card.Id != CardId.Urara) count += 1;
if (!Card.IsCode(CardId.Urara)) count += 1;
foreach(ClientCard hand in Bot.Hand)
{
if (hand.Id == Card.Id) count += 1;
if (hand.IsCode(Card.Id)) count += 1;
}
if (count < 2) return false;
foreach(ClientCard m in Bot.GetMonsters())
{
if (m.Id != CardId.Eater && getLinkMarker(m.Id) <= 2) return true;
if (!m.IsCode(CardId.Eater) && getLinkMarker(m.Id) <= 2) return true;
}
return false;
}
......@@ -1175,7 +1140,8 @@ namespace WindBot.Game.AI.Decks
public bool Ring_act()
{
if (Duel.LastChainPlayer == 0 && AI.Utils.GetLastChainCard() != null && AI.Utils.GetLastChainCard().Id == CardId.Ghost) return false;
if (Duel.LastChainPlayer == 0 && AI.Utils.GetLastChainCard() != null && AI.Utils.GetLastChainCard().IsCode(CardId.Ghost)) return false;
if (!spell_trap_activate()) return false;
ClientCard target = AI.Utils.GetProblematicEnemyMonster();
if (target == null && AI.Utils.IsChainTarget(Card))
{
......@@ -1194,7 +1160,7 @@ namespace WindBot.Game.AI.Decks
{
foreach(ClientCard c in Bot.GetMonsters())
{
if (c.Id != CardId.Eater && c.Level == 1 && c.Id != CardId.Linkuri && c.Id != CardId.Linkspi)
if (!c.IsCode(CardId.Eater, CardId.Linkuri, CardId.Linkspi) && c.Level == 1)
{
AI.SelectCard(c);
return true;
......@@ -1205,8 +1171,8 @@ namespace WindBot.Game.AI.Decks
public bool Linkuri_eff()
{
if (Duel.LastChainPlayer == 0 && AI.Utils.GetLastChainCard().Id == CardId.Linkuri) return false;
AI.SelectCard(new[] { CardId.Tuner, CardId.BF + 1 });
if (Duel.LastChainPlayer == 0 && AI.Utils.GetLastChainCard().IsCode(CardId.Linkuri)) return false;
AI.SelectCard(CardId.Tuner, CardId.BF + 1);
return true;
}
......@@ -1215,10 +1181,7 @@ namespace WindBot.Game.AI.Decks
if (crystal_eff_used) return false;
if (Bot.HasInMonstersZone(CardId.BF) && Bot.HasInMonstersZone(CardId.BF + 1))
{
AI.SelectCard(new[]
{CardId.BF,
CardId.BF + 1
});
AI.SelectCard(CardId.BF, CardId.BF + 1);
return true;
}
foreach(ClientCard extra_card in Bot.GetMonstersInExtraZone())
......@@ -1229,7 +1192,7 @@ namespace WindBot.Game.AI.Decks
foreach(ClientCard t_check in Bot.GetMonsters())
{
if (t_check.IsFacedown()) continue;
if (t_check.Id == CardId.BF || t_check.Id == CardId.Tuner || t_check.Id == CardId.Urara || t_check.Id == CardId.Ghost)
if (t_check.IsCode(CardId.BF, CardId.Tuner, CardId.Urara, CardId.Ghost))
{
targets.Add(t_check);
break;
......@@ -1241,7 +1204,7 @@ namespace WindBot.Game.AI.Decks
foreach (ClientCard e_check in m_list)
{
if (e_check.IsFacedown()) continue;
if (targets[0] != e_check && getLinkMarker(e_check.Id) <= 2 && e_check.Id != CardId.Eater && e_check.Id != CardId.Crystal)
if (targets[0] != e_check && getLinkMarker(e_check.Id) <= 2 && !e_check.IsCode(CardId.Eater, CardId.Crystal))
{
targets.Add(e_check);
break;
......@@ -1257,7 +1220,7 @@ namespace WindBot.Game.AI.Decks
if (Duel.Player == 0)
{
crystal_eff_used = true;
AI.SelectCard(new[] { CardId.Tuner, CardId.Ghost , CardId.Urara});
AI.SelectCard(CardId.Tuner, CardId.Ghost, CardId.Urara);
return true;
}
else if (AI.Utils.IsChainTarget(Card) || AI.Utils.GetProblematicEnemySpell() != null) return true;
......@@ -1321,11 +1284,11 @@ namespace WindBot.Game.AI.Decks
if (ex_1 != null && ex_1.Controller == 0) ex = ex_1;
if (ex_2 != null && ex_2.Controller == 0) ex = ex_2;
if (ex == null) return false;
if (!Has_down_arrow(ex.Id)) return false;
if (!ex.HasLinkMarker(2)) return false;
IList<ClientCard> targets = new List<ClientCard>();
foreach (ClientCard s_m in Bot.GetMonsters())
{
if (s_m.Id == CardId.Eater) continue;
if (s_m.IsCode(CardId.Eater)) continue;
if (s_m != Bot.MonsterZone[5] && s_m != Bot.MonsterZone[6]) targets.Add(s_m);
if (targets.Count == 2) break;
}
......@@ -1367,7 +1330,7 @@ namespace WindBot.Game.AI.Decks
foreach (ClientCard s_m in main_list)
{
if (s_m.IsFacedown()) continue;
if ((s_m.Id != CardId.Eater || (s_m.Id == CardId.Eater && s_m.IsDisabled())) && !targets.ContainsCardWithId(s_m.Id))
if ((!s_m.IsCode(CardId.Eater) || (s_m.IsCode(CardId.Eater) && s_m.IsDisabled())) && !targets.ContainsCardWithId(s_m.Id))
{
targets.Add(s_m);
};
......@@ -1378,7 +1341,7 @@ namespace WindBot.Game.AI.Decks
foreach (ClientCard s_m in Bot.GetMonstersInExtraZone())
{
if (s_m.IsFacedown()) continue;
if (s_m.Id != CardId.Eater && !targets.ContainsCardWithId(s_m.Id))
if (!s_m.IsCode(CardId.Eater) && !targets.ContainsCardWithId(s_m.Id))
{
targets.Add(s_m);
};
......@@ -1393,6 +1356,19 @@ namespace WindBot.Game.AI.Decks
public bool Phoneix_eff()
{
AI.SelectCard(Useless_List());
ClientCard target = AI.Utils.GetProblematicEnemySpell();
if (target != null)
{
AI.SelectNextCard(target);
} else
{
List<ClientCard> spells = Enemy.GetSpells();
RandomSort(spells);
foreach (ClientCard card in spells)
{
if ((card != stage_locked || card.HasPosition(CardPosition.FaceUp)) && !(card.IsShouldNotBeTarget() || card.IsShouldNotBeMonsterTarget())) AI.SelectNextCard(card);
}
}
return true;
}
......@@ -1433,7 +1409,7 @@ namespace WindBot.Game.AI.Decks
sort_list.Sort(AIFunctions.CompareCardAttack);
foreach (ClientCard s_m in sort_list)
{
if ((s_m.Id != CardId.Eater || (s_m.Id == CardId.Eater && m.IsMonsterHasPreventActivationEffectInBattle())) && getLinkMarker(s_m.Id) <= 2 && s_m.IsFaceup())
if ((!s_m.IsCode(CardId.Eater) || (s_m.IsCode(CardId.Eater) && m.IsMonsterHasPreventActivationEffectInBattle())) && getLinkMarker(s_m.Id) <= 2 && s_m.IsFaceup())
{
if (!targets.ContainsCardWithId(s_m.Id))
{
......@@ -1455,21 +1431,27 @@ namespace WindBot.Game.AI.Decks
// avoid cards that cannot target.
AI.SelectCard(Useless_List());
IList<ClientCard> enemy_list = new List<ClientCard>();
enemy_list.Add(m);
if (!m.IsShouldNotBeMonsterTarget() && !m.IsShouldNotBeTarget()) enemy_list.Add(m);
foreach(ClientCard enemy in Enemy.GetMonstersInExtraZone())
{
if (enemy != null && !enemy_list.Contains(enemy)) enemy_list.Add(enemy);
if (enemy != null && !enemy_list.Contains(enemy) && !enemy.IsShouldNotBeMonsterTarget() && !enemy.IsShouldNotBeTarget()) enemy_list.Add(enemy);
}
foreach (ClientCard enemy in Enemy.GetMonstersInMainZone())
{
if (enemy != null && !enemy_list.Contains(enemy)) enemy_list.Add(enemy);
if (enemy != null && !enemy_list.Contains(enemy) && !enemy.IsShouldNotBeMonsterTarget() && !enemy.IsShouldNotBeTarget()) enemy_list.Add(enemy);
}
foreach (ClientCard enemy in Enemy.GetSpells())
{
if (enemy != null && !enemy_list.Contains(enemy)) enemy_list.Add(enemy);
if (enemy != null && !enemy_list.Contains(enemy) && !enemy.IsShouldNotBeMonsterTarget() && !enemy.IsShouldNotBeTarget()) enemy_list.Add(enemy);
}
if (enemy_list.Count > 0)
{
AI.SelectNextCard(enemy_list);
return true;
} else
{
return false;
}
}
public bool Snake_ss()
......@@ -1516,12 +1498,12 @@ namespace WindBot.Game.AI.Decks
{
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);
return true;
}
if (hand.Id == CardId.Urara || hand.Id == CardId.Ghost)
if (hand.IsCode(CardId.Urara, CardId.Ghost))
{
if (Tuner_ss())
{
......@@ -1557,12 +1539,7 @@ namespace WindBot.Game.AI.Decks
public bool Missus_eff()
{
AI.SelectCard(new[]
{
CardId.MG,
CardId.Missus,
CardId.Snake
});
AI.SelectCard(CardId.MG, CardId.Missus, CardId.Snake);
return true;
}
......@@ -1593,7 +1570,7 @@ namespace WindBot.Game.AI.Decks
{
already_link2 = true;
material_list.Add(m);
} else if (m.Id != CardId.Sheep + 1 && (m.Id != CardId.Eater))
} else if (!m.IsCode(CardId.Sheep + 1, CardId.Eater))
{
material_list.Add(m);
}
......@@ -1635,8 +1612,10 @@ namespace WindBot.Game.AI.Decks
return false;
}
// unfinished.
public bool GraveCall_eff()
{
if (!spell_trap_activate()) return false;
if (Duel.LastChainPlayer == 1)
{
if (AI.Utils.GetLastChainCard().IsMonster() && Enemy.HasInGraveyard(AI.Utils.GetLastChainCard().Id))
......@@ -1652,6 +1631,7 @@ namespace WindBot.Game.AI.Decks
public bool DarkHole_eff()
{
if (!spell_trap_activate()) return false;
if (Bot.GetMonsterCount() == 0)
{
......@@ -1663,10 +1643,18 @@ namespace WindBot.Game.AI.Decks
int bestenemy = -1;
foreach (ClientCard enemy in Enemy.GetMonsters())
{
if (enemy.IsMonsterDangerous()) return true;
if (enemy.IsMonsterDangerous())
{
AI.SelectPlace(SelectSTPlace());
return true;
}
if (enemy.IsFaceup() && (enemy.GetDefensePower() > bestenemy)) bestenemy = enemy.GetDefensePower();
}
return (bestPower <= bestenemy);
if (bestPower <= bestenemy)
{
AI.SelectPlace(SelectSTPlace());
return true;
}
}
return false;
}
......@@ -1688,12 +1676,21 @@ namespace WindBot.Game.AI.Decks
public bool MonsterRepos()
{
if (Card.Id == CardId.Eater) return (!Card.HasPosition(CardPosition.Attack));
if (Card.IsCode(CardId.Eater)) return (!Card.HasPosition(CardPosition.Attack));
if (IsTrickstar(Card.Id) && !white_eff_used && Bot.HasInHand(CardId.White) && Card.IsAttack() && Duel.Phase == DuelPhase.Main1) return false;
if (Card.IsFaceup() && Card.IsDefense() && Card.Attack == 0)
return false;
if (Card.IsCode(CardId.Pink))
{
if ((Bot.HasInSpellZone(CardId.Stage, true) && Enemy.LifePoints <= 1000) || (!Bot.HasInSpellZone(CardId.Stage, true) && Enemy.LifePoints <= 800))
{
return !Card.HasPosition(CardPosition.Attack);
}
}
bool enemyBetter = IsAllEnemyBetter();
if (Card.IsAttack() && enemyBetter)
......@@ -1747,8 +1744,8 @@ namespace WindBot.Game.AI.Decks
if (!defender.IsMonsterHasPreventActivationEffectInBattle() && !attacker.IsDisabled())
{
if ((attacker.Id == CardId.Eater && !defender.HasType(CardType.Token)) || attacker.Id == CardId.Borrel) return AI.Attack(attacker, defender);
if ((attacker.Id == CardId.Ultimate || attacker.Id == CardId.Cardian) && attacker.RealPower > defender.RealPower) return AI.Attack(attacker, defender);
if ((attacker.IsCode(CardId.Eater) && !defender.HasType(CardType.Token)) || attacker.IsCode(CardId.Borrel)) return AI.Attack(attacker, defender);
if ((attacker.IsCode(CardId.Ultimate, CardId.Cardian)) && attacker.RealPower > defender.RealPower) return AI.Attack(attacker, defender);
}
if (!OnPreBattleBetween(attacker, defender))
......@@ -1769,7 +1766,7 @@ namespace WindBot.Game.AI.Decks
for (int i = 0; i < attackers.Count; ++i)
{
ClientCard attacker = attackers[i];
if (attacker.Id == CardId.Borrel || attacker.Id == CardId.Eater) return attacker;
if (attacker.IsCode(CardId.Borrel, CardId.Eater)) return attacker;
}
return null;
}
......
......@@ -163,7 +163,7 @@ namespace WindBot.Game.AI.Decks
if (Card == null)
return true;
// Logger.DebugWriteLine(Card.Name);
if (Card.Id == CardId.YosenjuKama2)
if (Card.IsCode(CardId.YosenjuKama2))
return Card.ShouldDirectAttack;
else
return true;
......@@ -181,18 +181,15 @@ namespace WindBot.Game.AI.Decks
public override IList<ClientCard> OnSelectXyzMaterial(IList<ClientCard> cards, int min, int max)
{
IList<ClientCard> result = new List<ClientCard>();
AI.Utils.SelectPreferredCards(result, CardId.YosenjuTsujik, cards, min, max);
AI.Utils.CheckSelectCount(result, cards, min, max);
return result;
IList<ClientCard> result = AI.Utils.SelectPreferredCards(CardId.YosenjuTsujik, cards, min, max);
return AI.Utils.CheckSelectCount(result, cards, min, max);
}
private bool PotOfDualityEffect()
{
if (CardOfDemiseUsed)
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.StarlightRoad,
CardId.MagicDrain,
CardId.SolemnJudgment,
......@@ -204,12 +201,11 @@ namespace WindBot.Game.AI.Decks
CardId.SolemnWarning,
CardId.MacroCosmos,
CardId.CardOfDemise
});
);
}
else
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.YosenjuKama3,
CardId.YosenjuKama1,
CardId.YosenjuKama2,
......@@ -223,8 +219,8 @@ namespace WindBot.Game.AI.Decks
CardId.SolemnJudgment,
CardId.SolemnWarning,
CardId.MacroCosmos,
CardId.CardOfDemise,
});
CardId.CardOfDemise
);
}
return true;
}
......@@ -243,7 +239,7 @@ namespace WindBot.Game.AI.Decks
{
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 false;
......@@ -253,7 +249,7 @@ namespace WindBot.Game.AI.Decks
{
foreach (ClientCard card in Bot.GetSpells())
{
if (card.Id == Card.Id)
if (card.IsCode(Card.Id))
return false;
}
return TrapSetWhenZoneFree();
......@@ -274,12 +270,7 @@ namespace WindBot.Game.AI.Decks
// Don't activate the return to hand effect first
if (Duel.Phase == DuelPhase.End)
return false;
AI.SelectCard(new[]
{
CardId.YosenjuKama1,
CardId.YosenjuKama2,
CardId.YosenjuKama3
});
AI.SelectCard(CardId.YosenjuKama1, CardId.YosenjuKama2, CardId.YosenjuKama3);
return true;
}
......@@ -312,6 +303,7 @@ namespace WindBot.Game.AI.Decks
ClientCard target = AI.Utils.GetOneEnemyBetterThanValue(oppoBestAttack, true);
if (target != null)
{
AI.SelectCard(0);
AI.SelectNextCard(target);
}
return true;
......
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using WindBot;
using WindBot.Game;
using WindBot.Game.AI;
......@@ -103,7 +104,7 @@ namespace WindBot.Game.AI.Decks
// Summons: Effects
AddExecutor(ExecutorType.Activate, CardId.Goblindbergh, 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.Honest, DefaultHonestEffect);
......@@ -138,14 +139,12 @@ namespace WindBot.Game.AI.Decks
public override IList<ClientCard> OnSelectXyzMaterial(IList<ClientCard> cards, int min, int max)
{
IList<ClientCard> result = new List<ClientCard>();
AI.Utils.SelectPreferredCards(result, new[] {
IList<ClientCard> result = AI.Utils.SelectPreferredCards(new[] {
CardId.StarDrawing,
CardId.SolarWindJammer,
CardId.Goblindbergh
}, cards, min, max);
AI.Utils.CheckSelectCount(result, cards, min, max);
return result;
return AI.Utils.CheckSelectCount(result, cards, min, max);
}
private bool Number39Utopia()
......@@ -171,14 +170,13 @@ namespace WindBot.Game.AI.Decks
private bool ReinforcementOfTheArmy()
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.Goblindbergh,
CardId.TinGoldfish,
CardId.StarDrawing,
CardId.Kagetokage,
CardId.SacredCrane
});
);
return true;
}
......@@ -225,16 +223,22 @@ namespace WindBot.Game.AI.Decks
private bool GoblindberghEffect()
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.SacredCrane,
CardId.HeroicChallengerExtraSword,
CardId.StarDrawing,
CardId.SummonerMonk
});
);
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()
{
IList<int> costs = new[]
......@@ -247,13 +251,12 @@ namespace WindBot.Game.AI.Decks
if (Bot.HasInHand(costs))
{
AI.SelectCard(costs);
AI.SelectNextCard(new[]
{
AI.SelectNextCard(
CardId.SacredCrane,
CardId.StarDrawing,
CardId.Goblindbergh,
CardId.TinGoldfish
});
);
AI.SelectPosition(CardPosition.FaceUpDefence);
return true;
}
......@@ -273,7 +276,7 @@ namespace WindBot.Game.AI.Decks
private bool MonsterRepos()
{
if (Card.Id == CardId.NumberS39UtopiatheLightning && Card.IsAttack())
if (Card.IsCode(CardId.NumberS39UtopiatheLightning) && Card.IsAttack())
return false;
return base.DefaultMonsterRepos();
}
......
......@@ -230,14 +230,14 @@ namespace WindBot.Game.AI.Decks
{
foreach (ClientCard card in Enemy.Graveyard)
{
if (card.Id == CardId.AleisterTheInvoker)
if (card.IsCode(CardId.AleisterTheInvoker))
{
return card;
}
}
foreach (ClientCard card in Bot.Graveyard)
{
if (card.Id == CardId.AleisterTheInvoker)
if (card.IsCode(CardId.AleisterTheInvoker))
{
return card;
}
......@@ -270,20 +270,18 @@ namespace WindBot.Game.AI.Decks
{
if (Bot.HasInGraveyard(CardId.Whiptail) || Bot.HasInGraveyard(CardId.Thoroughblade))
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.Broadbull,
CardId.Tigermortar,
CardId.Chakanine,
CardId.Thoroughblade,
CardId.Ratpier,
CardId.Whiptail
});
AI.SelectNextCard(new[]
{
);
AI.SelectNextCard(
CardId.Whiptail,
CardId.Thoroughblade
});
);
return true;
}
return false;
......@@ -336,12 +334,7 @@ namespace WindBot.Game.AI.Decks
// return false;
AI.SelectCard(CardId.Chakanine);
AI.SelectNextCard(CardId.Tigermortar);
AI.SelectThirdCard(new[]
{
CardId.Ratpier,
CardId.Whiptail,
CardId.Thoroughblade
});
AI.SelectThirdCard(CardId.Ratpier, CardId.Whiptail, CardId.Thoroughblade);
return true;
}
......@@ -384,14 +377,13 @@ namespace WindBot.Game.AI.Decks
private bool BroadbullEffect()
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.Tigermortar,
CardId.Chakanine,
CardId.Drident,
CardId.AleisterTheInvoker,
CardId.PhotonThrasher
});
);
if (Bot.HasInHand(CardId.Whiptail) && !Bot.HasInHand(CardId.Ratpier))
AI.SelectNextCard(CardId.Ratpier);
else
......@@ -445,7 +437,7 @@ namespace WindBot.Game.AI.Decks
List<ClientCard> monsters = Bot.GetMonsters();
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;
break;
......@@ -455,7 +447,7 @@ namespace WindBot.Game.AI.Decks
{
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;
break;
......@@ -475,12 +467,11 @@ namespace WindBot.Game.AI.Decks
private bool RatpierEffect()
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.ZoodiacCombo,
CardId.Thoroughblade,
CardId.ZoodiacBarrage
});
);
return true;
}
......@@ -491,15 +482,14 @@ namespace WindBot.Game.AI.Decks
ClientCard target = AI.Utils.GetBestEnemyCard(true);
if (target == null)
return false;
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.Broadbull,
CardId.Tigermortar,
CardId.Chakanine,
CardId.Thoroughblade,
CardId.Ratpier,
CardId.Whiptail
});
);
AI.SelectNextCard(target);
return true;
}
......@@ -516,17 +506,15 @@ namespace WindBot.Game.AI.Decks
private bool DaigustoEmeralEffect()
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.Ratpier,
CardId.AleisterTheInvoker,
CardId.Whiptail
});
AI.SelectNextCard(new[]
{
);
AI.SelectNextCard(
CardId.Ratpier,
CardId.DaigustoEmeral
});
);
return true;
}
......@@ -550,21 +538,19 @@ namespace WindBot.Game.AI.Decks
{
foreach (ClientCard spell in Bot.GetSpells())
{
if (spell.Id == CardId.ZoodiacBarrage && !Card.Equals(spell))
if (spell.IsCode(CardId.ZoodiacBarrage) && !Card.Equals(spell))
return false;
}
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.FireFormationTenki,
CardId.MagicalMeltdown,
CardId.ZoodiacBarrage
});
AI.SelectNextCard(new[]
{
);
AI.SelectNextCard(
CardId.Ratpier,
CardId.Whiptail,
CardId.Thoroughblade
});
);
AI.SelectPosition(CardPosition.FaceUpDefence);
return true;
}
......@@ -576,20 +562,18 @@ namespace WindBot.Game.AI.Decks
if (Card.Location != CardLocation.Grave)
{
AI.SelectCard(CardId.Drident);
AI.SelectNextCard(new[]
{
AI.SelectNextCard(
CardId.Whiptail,
CardId.Ratpier,
CardId.Thoroughblade
});
);
}
return true;
}
private bool MonsterRebornEffect()
{
AI.SelectCard(new[]
{
AI.SelectCard(
CardId.Ratpier,
CardId.Whiptail,
CardId.InvokedMechaba,
......@@ -598,13 +582,13 @@ namespace WindBot.Game.AI.Decks
CardId.Tigermortar,
CardId.Chakanine,
CardId.Broadbull
});
);
return true;
}
private bool MonsterRepos()
{
if (Card.Id == CardId.NumberS39UtopiatheLightning && Card.IsAttack())
if (Card.IsCode(CardId.NumberS39UtopiatheLightning) && Card.IsAttack())
return false;
return base.DefaultMonsterRepos();
}
......
using System;
using System.Collections.Generic;
using System.Linq;
using YGOSharp.OCGWrapper.Enums;
using WindBot;
using WindBot.Game;
......@@ -21,10 +22,15 @@ namespace WindBot.Game.AI
public const int SuperAntiKaijuWarMachineMechaDogoran = 84769941;
public const int UltimateConductorTytanno = 18940556;
public const int ElShaddollConstruct = 20366274;
public const int AllyOfJusticeCatastor = 26593852;
public const int DupeFrog = 46239604;
public const int MaraudingCaptain = 2460565;
public const int BlackRoseDragon = 73580471;
public const int JudgmentDragon = 57774843;
public const int TopologicTrisbaena = 72529749;
public const int EvilswarmExcitonKnight = 46772449;
public const int HarpiesFeatherDuster = 18144506;
public const int DarkMagicAttack = 2314238;
......@@ -38,12 +44,42 @@ namespace WindBot.Game.AI
public const int Number39Utopia = 84013237;
public const int UltimayaTzolkin = 1686814;
public const int VampireFräulein = 6039967;
public const int MoonMirrorShield = 19508728;
public const int PhantomKnightsFogBlade = 25542642;
public const int VampireFraeulein = 6039967;
public const int InjectionFairyLily = 79575620;
public const int BlueEyesChaosMAXDragon = 55410871;
public const int AshBlossom = 14558127;
public const int MaxxC = 23434538;
public const int LockBird = 94145021;
public const int GhostOgreAndSnowRabbit = 59438930;
public const int GhostBelle = 73642296;
public const int EffectVeiler = 63845230;
public const int CalledByTheGrave = 24224830;
public const int InfiniteImpermanence = 10045474;
public const int GalaxySoldier = 46659709;
public const int MacroCosmos = 30241314;
public const int UpstartGoblin = 70368879;
public const int CyberEmergency = 60600126;
public const int EaterOfMillions = 63845230;
public const int InvokedPurgatrio = 12307878;
public const int ChaosAncientGearGiant = 51788412;
public const int UltimateAncientGearGolem = 12652643;
public const int RedDragonArchfiend = 70902743;
public const int ImperialOrder = 61740673;
public const int NaturiaBeast = 33198837;
public const int AntiSpellFragrance = 58921041;
}
int HonestEffectCount = 0;
protected DefaultExecutor(GameAI ai, Duel duel)
: base(ai, duel)
{
......@@ -58,10 +94,8 @@ namespace WindBot.Game.AI
/// <returns>BattlePhaseAction including the target, or null (in this situation, GameAI will check the next attacker)</returns>
public override BattlePhaseAction OnSelectAttackTarget(ClientCard attacker, IList<ClientCard> defenders)
{
for (int i = 0; i < defenders.Count; ++i)
foreach (ClientCard defender in defenders)
{
ClientCard defender = defenders[i];
attacker.RealPower = attacker.Attack;
defender.RealPower = defender.GetDefensePower();
if (!OnPreBattleBetween(attacker, defender))
......@@ -96,47 +130,66 @@ namespace WindBot.Game.AI
if (defender.IsMonsterDangerous())
{
bool canignoreit = false;
if (attacker.Id == _CardId.UltimateConductorTytanno && !attacker.IsDisabled() && defender.IsDefense())
canignoreit = true;
if (!canignoreit)
bool canIgnoreIt = !attacker.IsDisabled() && (
attacker.IsCode(_CardId.UltimateConductorTytanno) && defender.IsDefense() ||
attacker.IsCode(_CardId.ElShaddollConstruct) && defender.IsSpecialSummoned ||
attacker.IsCode(_CardId.AllyOfJusticeCatastor) && !defender.HasAttribute(CardAttribute.Dark));
if (!canIgnoreIt)
return false;
}
if (defender.Id == _CardId.CrystalWingSynchroDragon && defender.IsAttack() && !defender.IsDisabled() && attacker.Level >= 5)
foreach (ClientCard equip in defender.EquipCards)
{
if (equip.IsCode(_CardId.MoonMirrorShield) && !equip.IsDisabled())
{
return false;
}
}
if (defender.Id == _CardId.NumberS39UtopiaTheLightning && defender.IsAttack() && !defender.IsDisabled() && defender.HasXyzMaterial(2, _CardId.Number39Utopia))
if (!defender.IsDisabled())
{
if (defender.IsCode(_CardId.CrystalWingSynchroDragon) && defender.IsAttack() && attacker.Level >= 5)
return false;
if (defender.IsCode(_CardId.AllyOfJusticeCatastor) && !attacker.HasAttribute(CardAttribute.Dark))
return false;
if (defender.IsCode(_CardId.NumberS39UtopiaTheLightning) && defender.IsAttack() && defender.HasXyzMaterial(2, _CardId.Number39Utopia))
defender.RealPower = 5000;
if (defender.Id == _CardId.VampireFräulein && !defender.IsDisabled())
if (defender.IsCode(_CardId.VampireFraeulein))
defender.RealPower += (Enemy.LifePoints > 3000) ? 3000 : (Enemy.LifePoints - 100);
if (defender.Id == _CardId.InjectionFairyLily && !defender.IsDisabled() && Enemy.LifePoints > 2000)
if (defender.IsCode(_CardId.InjectionFairyLily) && Enemy.LifePoints > 2000)
defender.RealPower += 3000;
}
}
if (!defender.IsMonsterHasPreventActivationEffectInBattle())
{
if (attacker.Id == _CardId.NumberS39UtopiaTheLightning && !attacker.IsDisabled() && attacker.HasXyzMaterial(2, _CardId.Number39Utopia))
if (attacker.IsCode(_CardId.NumberS39UtopiaTheLightning) && !attacker.IsDisabled() && attacker.HasXyzMaterial(2, _CardId.Number39Utopia))
attacker.RealPower = 5000;
foreach (ClientCard equip in attacker.EquipCards)
{
if (equip.IsCode(_CardId.MoonMirrorShield) && !equip.IsDisabled())
{
attacker.RealPower = defender.RealPower + 100;
}
}
}
if (Enemy.HasInMonstersZone(_CardId.DupeFrog, true) && defender.Id != _CardId.DupeFrog)
if (Enemy.HasInMonstersZone(_CardId.DupeFrog, true) && !(defender).IsCode(_CardId.DupeFrog))
return false;
if (Enemy.HasInMonstersZone(_CardId.MaraudingCaptain, true) && defender.Id != _CardId.MaraudingCaptain && defender.Race == (int)CardRace.Warrior)
if (Enemy.HasInMonstersZone(_CardId.MaraudingCaptain, true) && !defender.IsCode(_CardId.MaraudingCaptain) && defender.Race == (int)CardRace.Warrior)
return false;
if (defender.Id == _CardId.UltimayaTzolkin && !defender.IsDisabled())
{
List<ClientCard> monsters = Enemy.GetMonsters();
foreach (ClientCard monster in monsters)
{
if (monster.HasType(CardType.Synchro))
if (defender.IsCode(_CardId.UltimayaTzolkin) && !defender.IsDisabled() && Enemy.GetMonsters().Any(monster => !monster.Equals(defender) && monster.HasType(CardType.Synchro)))
return false;
if (defender.OwnTargets.Any(card => card.IsCode(_CardId.PhantomKnightsFogBlade) && !card.IsDisabled()))
return false;
}
}
return true;
}
......@@ -173,14 +226,20 @@ namespace WindBot.Game.AI
return false;
}
public override void OnNewTurn()
{
HonestEffectCount = 0;
}
/// <summary>
/// Destroy face-down cards first, in our turn.
/// </summary>
protected bool DefaultMysticalSpaceTyphoon()
{
foreach (ClientCard card in Duel.CurrentChain)
if (card.Id == _CardId.MysticalSpaceTyphoon)
if (Duel.CurrentChain.Any(card => card.IsCode(_CardId.MysticalSpaceTyphoon)))
{
return false;
}
List<ClientCard> spells = Enemy.GetSpells();
if (spells.Count == 0)
......@@ -190,14 +249,10 @@ namespace WindBot.Game.AI
if (selected == null)
{
foreach (ClientCard card in spells)
{
if (Duel.Player == 1 && !card.HasType(CardType.Continuous))
continue;
selected = card;
if (Duel.Player == 0 && card.IsFacedown())
break;
}
if (Duel.Player == 0)
selected = spells.FirstOrDefault(card => card.IsFacedown());
if (Duel.Player == 1)
selected = spells.FirstOrDefault(card => card.HasType(CardType.Continuous) || card.HasType(CardType.Equip));
}
if (selected == null)
......@@ -212,7 +267,7 @@ namespace WindBot.Game.AI
protected bool DefaultCosmicCyclone()
{
foreach (ClientCard card in Duel.CurrentChain)
if (card.Id == _CardId.CosmicCyclone)
if (card.IsCode(_CardId.CosmicCyclone))
return false;
return (Bot.LifePoints > 1000) && DefaultMysticalSpaceTyphoon();
}
......@@ -234,14 +289,7 @@ namespace WindBot.Game.AI
}
else
{
foreach (ClientCard card in spells)
{
if (card.IsFacedown())
{
selected = card;
break;
}
}
selected = spells.FirstOrDefault(card => card.IsFacedown());
}
if (selected == null)
......@@ -258,7 +306,7 @@ namespace WindBot.Game.AI
{
if (AI.Utils.IsAllEnemyBetter(true))
{
ClientCard monster = Enemy.GetMonsters().GetHighestAttackMonster();
ClientCard monster = Enemy.GetMonsters().GetHighestAttackMonster(true);
if (monster != null && monster.HasType(CardType.Effect) && !monster.HasType(CardType.Link) && (monster.HasType(CardType.Xyz) || monster.Level > 4))
{
AI.SelectCard(monster);
......@@ -273,7 +321,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultCompulsoryEvacuationDevice()
{
ClientCard target = AI.Utils.GetProblematicEnemyMonster();
ClientCard target = AI.Utils.GetProblematicEnemyMonster(0, true);
if (target != null)
{
AI.SelectCard(target);
......@@ -281,7 +329,7 @@ namespace WindBot.Game.AI
}
if (AI.Utils.IsChainTarget(Card))
{
ClientCard monster = AI.Utils.GetBestEnemyMonster();
ClientCard monster = AI.Utils.GetBestEnemyMonster(false, true);
if (monster != null)
{
AI.SelectCard(monster);
......@@ -298,20 +346,115 @@ namespace WindBot.Game.AI
{
if (!AI.Utils.IsAllEnemyBetter(true))
return false;
ClientCard selected = null;
int BestAtk = 0;
foreach (ClientCard card in Bot.Graveyard)
ClientCard selected = Bot.Graveyard.OrderByDescending(card => card.Attack).FirstOrDefault();
AI.SelectCard(selected);
return true;
}
/// <summary>
/// Default Scapegoat effect
/// </summary>
protected bool DefaultScapegoat()
{
if (DefaultSpellWillBeNegated()) return false;
if (Duel.Player == 0) return false;
if (Duel.Phase == DuelPhase.End) return true;
if (DefaultOnBecomeTarget()) return true;
if (Duel.Phase > DuelPhase.Main1 && Duel.Phase < DuelPhase.Main2)
{
if (card.Attack > BestAtk)
if (Enemy.HasInMonstersZone(new[]
{
BestAtk = card.Attack;
selected = card;
_CardId.UltimateConductorTytanno,
_CardId.InvokedPurgatrio,
_CardId.ChaosAncientGearGiant,
_CardId.UltimateAncientGearGolem,
_CardId.RedDragonArchfiend
}, true)) return false;
if (AI.Utils.GetTotalAttackingMonsterAttack(1) >= Bot.LifePoints) return true;
}
return false;
}
AI.SelectCard(selected);
return true;
/// <summary>
/// Always active in opponent's turn.
/// </summary>
protected bool DefaultMaxxC()
{
return Duel.Player == 1;
}
/// <summary>
/// Always disable opponent's effect except some cards like UpstartGoblin
/// </summary>
protected bool DefaultAshBlossomAndJoyousSpring()
{
int[] ignoreList = {
_CardId.MacroCosmos,
_CardId.UpstartGoblin,
_CardId.CyberEmergency
};
if (AI.Utils.GetLastChainCard().IsCode(ignoreList))
return false;
return Duel.LastChainPlayer == 1;
}
/// <summary>
/// Always activate unless the activating card is disabled
/// </summary>
protected bool DefaultGhostOgreAndSnowRabbit()
{
if (AI.Utils.GetLastChainCard() != null && AI.Utils.GetLastChainCard().IsDisabled())
return false;
return DefaultTrap();
}
/// <summary>
/// Always disable opponent's effect
/// </summary>
protected bool DefaultGhostBelleAndHauntedMansion()
{
return DefaultTrap();
}
/// <summary>
/// Same as DefaultBreakthroughSkill
/// </summary>
protected bool DefaultEffectVeiler()
{
if (AI.Utils.GetLastChainCard() != null && AI.Utils.GetLastChainCard().IsCode(_CardId.GalaxySoldier) && Enemy.Hand.Count >= 3) return false;
if (AI.Utils.ChainContainsCard(_CardId.EffectVeiler))
return false;
return DefaultBreakthroughSkill();
}
/// <summary>
/// Chain common hand traps
/// </summary>
protected bool DefaultCalledByTheGrave()
{
int[] targetList =
{
_CardId.MaxxC,
_CardId.LockBird,
_CardId.GhostOgreAndSnowRabbit,
_CardId.AshBlossom,
_CardId.GhostBelle
};
if (Duel.LastChainPlayer == 1)
{
foreach (int id in targetList)
{
if (AI.Utils.GetLastChainCard().IsCode(id))
{
AI.SelectCard(id);
return UniqueFaceupSpell();
}
}
}
return false;
}
/// <summary>
/// Default InfiniteImpermanence effect
/// </summary>
protected bool DefaultInfiniteImpermanence()
{
// TODO: disable s & t
return DefaultBreakthroughSkill();
}
/// <summary>
/// Chain the enemy monster, or disable monster like Rescue Rabbit.
/// </summary>
......@@ -322,27 +465,42 @@ namespace WindBot.Game.AI
if (Duel.Player == 1)
{
foreach (ClientCard target in Enemy.GetMonsters())
{
if (target.IsMonsterShouldBeDisabledBeforeItUseEffect())
ClientCard target = Enemy.MonsterZone.GetShouldBeDisabledBeforeItUseEffectMonster();
if (target != null)
{
AI.SelectCard(target);
return true;
}
}
}
ClientCard LastChainCard = AI.Utils.GetLastChainCard();
if (LastChainCard == null)
return false;
if (LastChainCard.Controller != 1 || LastChainCard.Location != CardLocation.MonsterZone
|| LastChainCard.IsDisabled() || LastChainCard.IsShouldNotBeTarget() || LastChainCard.IsShouldNotBeSpellTrapTarget())
return false;
if (LastChainCard != null && LastChainCard.Controller == 1 && LastChainCard.Location == CardLocation.MonsterZone &&
!LastChainCard.IsDisabled() && !LastChainCard.IsShouldNotBeTarget() && !LastChainCard.IsShouldNotBeSpellTrapTarget())
{
AI.SelectCard(LastChainCard);
return true;
}
if (Bot.BattlingMonster != null && Enemy.BattlingMonster != null)
{
if (!Enemy.BattlingMonster.IsDisabled() && Enemy.BattlingMonster.IsCode(_CardId.EaterOfMillions))
{
AI.SelectCard(Enemy.BattlingMonster);
return true;
}
}
if (Duel.Phase == DuelPhase.BattleStart && Duel.Player == 1 &&
Enemy.HasInMonstersZone(_CardId.NumberS39UtopiaTheLightning, true))
{
AI.SelectCard(_CardId.NumberS39UtopiaTheLightning);
return true;
}
return false;
}
/// <summary>
/// Activate only except this card is the target or we summon monsters.
/// </summary>
......@@ -472,31 +630,70 @@ namespace WindBot.Game.AI
{
if (Card.IsFaceup() && Card.IsDefense() && Card.Attack == 0)
return false;
if (Enemy.HasInMonstersZone(_CardId.BlueEyesChaosMAXDragon) &&
Card.IsAttack() && (4000-Card.Defense)*2>(4000 - Card.Attack))
if (Enemy.HasInMonstersZone(_CardId.BlueEyesChaosMAXDragon, true) &&
Card.IsAttack() && (4000 - Card.Defense) * 2 > (4000 - Card.Attack))
return false;
if (Enemy.HasInMonstersZone(_CardId.BlueEyesChaosMAXDragon) &&
if (Enemy.HasInMonstersZone(_CardId.BlueEyesChaosMAXDragon, true) &&
Card.IsDefense() && Card.IsFaceup() &&
(4000 - Card.Defense) * 2 > (4000 - Card.Attack))
return true;
bool enemyBetter = AI.Utils.IsAllEnemyBetter(true);
bool enemyBetter = AI.Utils.IsAllEnemyBetter(true);
if (Card.IsAttack() && enemyBetter)
return true;
if (Card.IsDefense() && !enemyBetter && Card.Attack >= Card.Defense)
return true;
return false;
}
/// <summary>
/// If spell will be negated
/// </summary>
protected bool DefaultSpellWillBeNegated()
{
return Bot.HasInSpellZone(_CardId.ImperialOrder, true, true) || Enemy.HasInSpellZone(_CardId.ImperialOrder, true) || Enemy.HasInMonstersZone(_CardId.NaturiaBeast, true);
}
/// <summary>
/// If spell must set first to activate
/// </summary>
protected bool DefaultSpellMustSetFirst()
{
ClientCard card = null;
foreach (ClientCard check in Bot.GetSpells())
{
if (check.IsCode(_CardId.AntiSpellFragrance) && !check.IsDisabled())
card = check;
}
if (card != null && card.IsFaceup())
return true;
return Bot.HasInSpellZone(_CardId.AntiSpellFragrance, true, true) || Enemy.HasInSpellZone(_CardId.AntiSpellFragrance, true);
}
/// <summary>
/// if spell/trap is the target or enermy activate HarpiesFeatherDuster
/// </summary>
protected bool DefaultOnBecomeTarget()
{
if (AI.Utils.IsChainTarget(Card)) return true;
if (AI.Utils.ChainContainsCard(_CardId.EvilswarmExcitonKnight)) return true;
if (Enemy.HasInSpellZone(_CardId.HarpiesFeatherDuster, true)) return true;
if (Enemy.HasInSpellZone(_CardId.DarkMagicAttack, true)) return true;
int[] destroyAllList =
{
_CardId.EvilswarmExcitonKnight,
_CardId.BlackRoseDragon,
_CardId.JudgmentDragon,
_CardId.TopologicTrisbaena
};
int[] destroyAllOpponentList =
{
_CardId.HarpiesFeatherDuster,
_CardId.DarkMagicAttack
};
if (AI.Utils.ChainContainsCard(destroyAllList)) return true;
if (Enemy.HasInSpellZone(destroyAllOpponentList, true)) return true;
// TODO: ChainContainsCard(id, player)
return false;
}
/// <summary>
......@@ -523,12 +720,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool UniqueFaceupSpell()
{
foreach (ClientCard card in Bot.GetSpells())
{
if (card.Id == Card.Id && card.IsFaceup())
return false;
}
return true;
return !Bot.GetSpells().Any(card => card.IsCode(Card.Id) && card.IsFaceup());
}
/// <summary>
......@@ -536,12 +728,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool UniqueFaceupMonster()
{
foreach (ClientCard card in Bot.GetMonsters())
{
if (card.Id == Card.Id && card.IsFaceup())
return false;
}
return true;
return !Bot.GetMonsters().Any(card => card.IsCode(Card.Id) && card.IsFaceup());
}
/// <summary>
......@@ -549,11 +736,8 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultDontChainMyself()
{
foreach (CardExecutor exec in Executors)
{
if (exec.Type == Type && exec.CardId == Card.Id)
if (Executors.Any(exec => exec.Type == Type && exec.CardId == Card.Id))
return false;
}
return Duel.LastChainPlayer != 0;
}
......@@ -562,13 +746,9 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultChickenGame()
{
int count = 0;
foreach (CardExecutor exec in Executors)
{
if (exec.Type == Type && exec.CardId == Card.Id)
count++;
}
if (count > 1 || Bot.LifePoints <= 1000)
if (Executors.Count(exec => exec.Type == Type && exec.CardId == Card.Id) > 1)
return false;
if (Bot.LifePoints <= 1000)
return false;
if (Bot.LifePoints <= Enemy.LifePoints && ActivateDescription == AI.Utils.GetStringId(_CardId.ChickenGame, 0))
return true;
......@@ -582,22 +762,8 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultAllureofDarkness()
{
IList<ClientCard> condition = Bot.Hand;
IList<ClientCard> check = new List<ClientCard>();
ClientCard con = null;
foreach (ClientCard card in condition)
{
if (card.HasAttribute(CardAttribute.Dark))
{
con = card;
break;
}
}
if (con != null)
{
return true;
}
return false;
ClientCard target = Bot.Hand.FirstOrDefault(card => card.HasAttribute(CardAttribute.Dark));
return target != null;
}
/// <summary>
......@@ -620,14 +786,17 @@ namespace WindBot.Game.AI
{
if (monster.HasType(CardType.Tuner))
tuner = true;
else if (!monster.HasType(CardType.Xyz))
else if (!monster.HasType(CardType.Xyz) && !monster.HasType(CardType.Link))
{
nontuner = true;
levels[monster.Level] = levels[monster.Level] + 1;
}
if (monster.IsOneForXyz())
{
AI.SelectOption(XYZ);
return true;
}
levels[monster.Level] = levels[monster.Level] + 1;
}
if (tuner && nontuner)
{
......@@ -694,40 +863,42 @@ namespace WindBot.Game.AI
{
if (Card.Location == CardLocation.Grave)
{
AI.SelectCard(new[]
{
AI.SelectCard(
_CardId.GamecieltheSeaTurtleKaiju,
_CardId.KumongoustheStickyStringKaiju,
_CardId.GadarlatheMysteryDustKaiju,
_CardId.RadiantheMultidimensionalKaiju,
_CardId.DogorantheMadFlameKaiju,
_CardId.ThunderKingtheLightningstrikeKaiju,
_CardId.JizukirutheStarDestroyingKaiju,
});
_CardId.JizukirutheStarDestroyingKaiju
);
return true;
}
AI.SelectCard(new[]
if (DefaultDarkHole())
{
AI.SelectCard(
_CardId.JizukirutheStarDestroyingKaiju,
_CardId.ThunderKingtheLightningstrikeKaiju,
_CardId.DogorantheMadFlameKaiju,
_CardId.RadiantheMultidimensionalKaiju,
_CardId.GadarlatheMysteryDustKaiju,
_CardId.KumongoustheStickyStringKaiju,
_CardId.GamecieltheSeaTurtleKaiju,
});
AI.SelectNextCard(new[]
{
_CardId.GamecieltheSeaTurtleKaiju
);
AI.SelectNextCard(
_CardId.SuperAntiKaijuWarMachineMechaDogoran,
_CardId.GamecieltheSeaTurtleKaiju,
_CardId.KumongoustheStickyStringKaiju,
_CardId.GadarlatheMysteryDustKaiju,
_CardId.RadiantheMultidimensionalKaiju,
_CardId.DogorantheMadFlameKaiju,
_CardId.ThunderKingtheLightningstrikeKaiju,
_CardId.ThunderKingtheLightningstrikeKaiju
);
return true;
}
});
return DefaultDarkHole();
return false;
}
/// <summary>
......@@ -747,7 +918,7 @@ namespace WindBot.Game.AI
};
foreach (ClientCard monster in Enemy.GetMonsters())
{
if (kaijus.Contains(monster.Id))
if (monster.IsCode(kaijus))
return Card.GetDefensePower() > monster.GetDefensePower();
}
ClientCard card = Enemy.MonsterZone.GetFloodgate();
......@@ -809,19 +980,8 @@ namespace WindBot.Game.AI
if (selfCount < oppoCount)
return true;
int selfAttack = 0;
List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters)
{
selfAttack += monster.GetDefensePower();
}
int oppoAttack = 0;
monsters = Enemy.GetMonsters();
foreach (ClientCard monster in monsters)
{
oppoAttack += monster.GetDefensePower();
}
int selfAttack = Bot.GetMonsters().Sum(monster => (int?)monster.GetDefensePower()) ?? 0;
int oppoAttack = Enemy.GetMonsters().Sum(monster => (int?)monster.GetDefensePower()) ?? 0;
return selfAttack < oppoAttack;
}
......@@ -862,6 +1022,7 @@ namespace WindBot.Game.AI
ClientCard target = AI.Utils.GetProblematicEnemyCard();
if (target != null)
{
AI.SelectCard(0);
AI.SelectNextCard(target);
return true;
}
......@@ -883,24 +1044,9 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultScarlightRedDragonArchfiendEffect()
{
int selfCount = 0;
List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters)
{
// The bot don't know if the card is special summoned, so let we assume all monsters are special summoned
if (!monster.Equals(Card) && monster.HasType(CardType.Effect) && monster.Attack <= Card.Attack)
selfCount++;
}
int oppoCount = 0;
monsters = Enemy.GetMonsters();
foreach (ClientCard monster in monsters)
{
if (monster.HasType(CardType.Effect) && monster.Attack <= Card.Attack)
oppoCount++;
}
return (oppoCount > 0 && selfCount <= oppoCount) || oppoCount >= 3;
int selfCount = Bot.GetMonsters().Count(monster => !monster.Equals(Card) && monster.IsSpecialSummoned && monster.HasType(CardType.Effect) && monster.Attack <= Card.Attack);
int oppoCount = Enemy.GetMonsters().Count(monster => monster.IsSpecialSummoned && monster.HasType(CardType.Effect) && monster.Attack <= Card.Attack);
return selfCount <= oppoCount || oppoCount >= 3;
}
/// <summary>
......@@ -914,9 +1060,14 @@ namespace WindBot.Game.AI
(((Bot.BattlingMonster.Attack < Enemy.BattlingMonster.Attack) || Bot.BattlingMonster.Attack >= Enemy.LifePoints)
|| ((Bot.BattlingMonster.Attack < Enemy.BattlingMonster.Defense) && (Bot.BattlingMonster.Attack + Enemy.BattlingMonster.Attack > Enemy.BattlingMonster.Defense)));
}
else return AI.Utils.IsTurn1OrMain2();
}
if (AI.Utils.IsTurn1OrMain2() && HonestEffectCount <= 5)
{
HonestEffectCount++;
return true;
}
return false;
}
}
}
......@@ -127,7 +127,7 @@ namespace WindBot.Game.AI
public void SendOnDirectAttack(string attacker)
{
if (attacker == "" || attacker == null)
if (string.IsNullOrEmpty(attacker))
{
attacker = _facedownmonstername;
}
......
......@@ -74,6 +74,12 @@
UltimateConductorTytanno = 18940556,
OvertexCoatls = 41782653,
FirePrison = 269510,
LairOfDarkness = 59160188
LairOfDarkness = 59160188,
SuperboltThunderDragon = 15291624,
ThunderDragonLord = 41685633,
CyberDragonInfinity = 10443957,
ImperialCustom = 9995766,
InspectorBoarder = 15397015
}
}
......@@ -6,14 +6,64 @@
public enum InvincibleMonster
{
SpiritReaper = 23205979,
Marshmallon = 31305911,
LionHeart = 54366836,
Yubel = 78371393,
YubelIncarnate = 4779091,
YubelNightmare = 31764700,
MaskedHeroDivineWind = 22093873,
YubelTheUltimateNightmare = 31764700,
YubelTerrorIncarnate = 4779091,
SandaionTheTimelord = 33015627,
DarknessNeosphere = 60417395,
GabrionTheTimelord = 6616912,
MichionTheTimelord = 7733560,
ZaphionTheTimelord = 28929131,
HailonTheTimelord = 34137269,
RaphionTheTimelord = 60222213,
SadionTheTimelord = 65314286,
MetaionTheTimelord = 74530899,
CastleGate = 36931229
Yubel = 78371393,
KamionTheTimelord = 91712985,
LazionTheTimelord = 92435533,
CloudianEyeofTheTyphoon = 57610714,
GimmickPuppetShadowFeeler = 34620088,
TheLegendaryFishermanIII = 44968687,
CastleGate = 36931229,
CloudianNimbusman = 20003527,
ExodiaNecross = 12600382,
Gellenduo = 11662742,
CloudianAltus = 79703905,
CloudianStormDragon = 13474291,
CloudianCirrostratus = 43318266,
CloudianTurbulence = 16197610,
CloudianAcidCloud = 17810268,
SuperheavySamuraiBlueBrawler = 41628550,
DinoSewing = 27143874,
Marshmallon = 31305911,
ShibaWarriorTaro = 27416701,
XSaberPashuul = 23093604,
SuperheavySamuraiBlowtorch = 7864030,
VijamTheCubicSeed = 15610297,
ArcanaForce0TheFool = 62892347,
ReptilianneNaga = 79491903,
AbyssStungray = 97232518,
ArmityleTheChaosPhantom = 43378048,
BlueEyesTwinBurstDragon = 2129638,
GladiatorBeastNerokius = 29357956,
MaskedHERODivineWind = 22093873,
ElementalHEROShiningPhoenixEnforcer = 88820235,
LunalightCatDancer = 51777272,
ElementalHEROPhoenixEnforcer = 41436536,
BloomDivaTheMelodiousChoir = 84988419,
ReaperonTheNightmare = 85684223,
BeelzeusofTheDiabolicDragons = 8763963,
DragocytosCorruptedNethersoulDragon = 21435914,
BeelzeofTheDiabolicDragons = 34408491,
BlackwingArmorMaster = 69031175,
DaigustoSphreeze = 29552709,
DarkDiviner = 31919988,
NumberC92HearteartHChaosDragon = 47017574,
Number92HearteartHDragon = 97403510,
Number51FinisherTheStrongArm = 56292140,
NumberC96DarkStorm = 77205367,
NumberF0UtopicFutureFutureSlash = 43490025,
NumberF0UtopicFuture = 65305468,
GoukiTheGiantOgre = 47946130,
BorrelswordDragon = 85289965
}
}
......@@ -32,6 +32,7 @@
HazyFlamePeryton = 37803172,
HazyFlameGriffin = 74010769,
BlueEyesChaosMAXDragon = 55410871,
BlueEyesChaosDragon = 20654247,
SupremeKingZARC = 13331639,
CrimsonNovaTrinitytheDarkCubicLord = 72664875,
LunalightLeoDancer = 24550676,
......
using System;
using System.Collections.Generic;
using System.Linq;
using YGOSharp.OCGWrapper.Enums;
using WindBot;
using WindBot.Game;
......@@ -82,12 +83,12 @@ namespace WindBot.Game.AI
public virtual void OnChaining(int player, ClientCard card)
{
// For overriding
}
public virtual void OnChainEnd()
{
// For overriding
}
public virtual void OnNewPhase()
{
......@@ -239,12 +240,7 @@ namespace WindBot.Game.AI
private bool DefaultNoExecutor()
{
foreach (CardExecutor exec in Executors)
{
if (exec.Type == Type && exec.CardId == Card.Id)
return false;
}
return true;
return Executors.All(exec => exec.Type != Type || exec.CardId != Card.Id);
}
}
}
\ No newline at end of file
......@@ -8,6 +8,9 @@
MonsterSet,
SpellSet,
Activate,
SummonOrSet
SummonOrSet,
GoToBattlePhase,
GoToMainPhase2,
GoToEndPhase
}
}
\ No newline at end of file
using System.Collections.Generic;
using System.IO;
using System.Linq;
using YGOSharp.OCGWrapper;
using YGOSharp.OCGWrapper.Enums;
......@@ -12,6 +13,7 @@ namespace WindBot.Game
public string Name { get; private set; }
public int Position { get; set; }
public int Sequence { get; set; }
public CardLocation Location { get; set; }
public int Alias { get; private set; }
public int Level { get; private set; }
......@@ -35,24 +37,35 @@ namespace WindBot.Game
public int SelectSeq { get; set; }
public int OpParam1 { get; set; }
public int OpParam2 { get; set; }
public List<ClientCard> EquipCards { get; set; }
public ClientCard EquipTarget;
public List<ClientCard> OwnTargets { get; set; }
public List<ClientCard> TargetCards { get; set; }
public bool CanDirectAttack { get; set; }
public bool ShouldDirectAttack { get; set; }
public bool Attacked { get; set; }
public bool IsLastAttacker { get; set; }
public bool IsSpecialSummoned { get; set; }
public int[] ActionIndex { get; set; }
public IDictionary<int, int> ActionActivateIndex { get; private set; }
public ClientCard(int id, CardLocation loc)
: this(id, loc, 0)
public ClientCard(int id, CardLocation loc, int sequence)
: this(id, loc, -1 , 0)
{
}
public ClientCard(int id, CardLocation loc, int position)
public ClientCard(int id, CardLocation loc, int sequence, int position)
{
SetId(id);
Sequence = sequence;
Position = position;
Overlays = new List<int>();
EquipCards = new List<ClientCard>();
OwnTargets = new List<ClientCard>();
TargetCards = new List<ClientCard>();
ActionIndex = new int[16];
ActionActivateIndex = new Dictionary<int, int>();
Location = loc;
......@@ -64,7 +77,11 @@ namespace WindBot.Game
Id = id;
Data = NamedCard.Get(Id);
if (Data != null)
{
Name = Data.Name;
if (Data.Alias != 0)
Alias = Data.Alias;
}
}
public void Update(BinaryReader packet, Duel duel)
......@@ -75,8 +92,8 @@ namespace WindBot.Game
if ((flag & (int)Query.Position) != 0)
{
Controller = duel.GetLocalPlayer(packet.ReadByte());
packet.ReadByte();
packet.ReadByte();
Location = (CardLocation)packet.ReadByte();
Sequence = packet.ReadByte();
Position = packet.ReadByte();
}
if ((flag & (int)Query.Alias) != 0)
......@@ -126,10 +143,10 @@ namespace WindBot.Game
}
if ((flag & (int)Query.Owner) != 0)
Owner = duel.GetLocalPlayer(packet.ReadInt32());
if ((flag & (int)Query.IsDisabled) != 0)
Disabled = packet.ReadInt32();
if ((flag & (int)Query.IsPublic) != 0)
packet.ReadInt32();
if ((flag & (int)Query.Status) != 0) {
int status = packet.ReadInt32();
Disabled = status & 0x0001;
}
if ((flag & (int)Query.LScale) != 0)
LScale = packet.ReadInt32();
if ((flag & (int)Query.RScale) != 0)
......@@ -141,29 +158,108 @@ 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)
{
return ((LinkMarker & dir) != 0);
return (LinkMarker & dir) != 0;
}
public bool HasLinkMarker(LinkMarker dir)
public bool HasLinkMarker(CardLinkMarker dir)
{
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)
{
return ((LinkMarker & (int)dir) != 0);
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)
{
return ((Type & (int)type) != 0);
return (Type & (int)type) != 0;
}
public bool HasPosition(CardPosition position)
{
return ((Position & (int)position) != 0);
return (Position & (int)position) != 0;
}
public bool HasAttribute(CardAttribute attribute)
{
return ((Attribute & (int)attribute) != 0);
return (Attribute & (int)attribute) != 0;
}
public bool HasSetcode(int setcode)
{
if (Data == null) return false;
long setcodes = Data.Setcode;
int settype = setcode & 0xfff;
int setsubtype = setcode & 0xf000;
while (setcodes > 0)
{
long check_setcode = setcodes & 0xffff;
setcodes >>= 16;
if ((check_setcode & 0xfff) == settype && (check_setcode & 0xf000 & setsubtype) == setsubtype) return true;
}
return false;
}
public bool IsMonster()
......@@ -188,7 +284,7 @@ namespace WindBot.Game
public bool IsExtraCard()
{
return (HasType(CardType.Fusion) || HasType(CardType.Synchro) || HasType(CardType.Xyz));
return HasType(CardType.Fusion) || HasType(CardType.Synchro) || HasType(CardType.Xyz) || HasType(CardType.Link);
}
public bool IsFaceup()
......@@ -213,7 +309,22 @@ namespace WindBot.Game
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()
......
using System.Collections.Generic;
using System.Linq;
using WindBot.Game.AI;
using YGOSharp.OCGWrapper.Enums;
namespace WindBot.Game
......@@ -15,6 +17,7 @@ namespace WindBot.Game
public int LifePoints;
public ClientCard BattlingMonster;
public bool UnderAttack;
public ClientField()
{
......@@ -31,9 +34,9 @@ namespace WindBot.Game
ExtraDeck = new List<ClientCard>();
for (int i = 0; i < deck; ++i)
Deck.Add(new ClientCard(0, CardLocation.Deck));
Deck.Add(new ClientCard(0, CardLocation.Deck, -1));
for (int i = 0; i < extra; ++i)
ExtraDeck.Add(new ClientCard(0, CardLocation.Extra));
ExtraDeck.Add(new ClientCard(0, CardLocation.Extra, -1));
}
public int GetMonstersExtraZoneCount()
......@@ -95,30 +98,36 @@ namespace WindBot.Game
return count;
}
public int GetFieldCount()
{
return GetSpellCount() + GetMonsterCount();
}
public int GetFieldHandCount()
{
return GetSpellCount() + GetMonsterCount() + GetHandCount();
}
public bool IsFieldEmpty()
{
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()
{
return GetCards(MonsterZone);
}
public List<ClientCard> GetGraveyardMonsters()
{
return GetCards(Graveyard, CardType.Monster);
......@@ -141,23 +150,12 @@ namespace WindBot.Game
public List<ClientCard> GetMonstersInExtraZone()
{
List<ClientCard> cards = new List<ClientCard>();
if (MonsterZone[5] != null)
cards.Add(MonsterZone[5]);
if (MonsterZone[6] != null)
cards.Add(MonsterZone[6]);
return cards;
return GetMonsters().Where((card, i) => i >= 5).ToList();
}
public List<ClientCard> GetMonstersInMainZone()
{
List<ClientCard> cards = new List<ClientCard>();
for (int i = 0; i < 5; i++)
{
if (MonsterZone[i] != null)
cards.Add(MonsterZone[i]);
}
return cards;
return GetMonsters().Where((card, i) => i < 5).ToList();
}
public bool HasInHand(int cardId)
......@@ -202,44 +200,32 @@ namespace WindBot.Game
public bool HasAttackingMonster()
{
IList<ClientCard> monsters = GetMonsters();
foreach (ClientCard card in monsters)
{
if (card.IsAttack())
return true;
}
return false;
return GetMonsters().Any(card => card.IsAttack());
}
public bool HasDefendingMonster()
{
IList<ClientCard> monsters = GetMonsters();
foreach (ClientCard card in monsters)
{
if (card.IsDefense())
return true;
}
return false;
return GetMonsters().Any(card => card.IsDefense());
}
public bool HasInMonstersZone(int cardId, bool notDisabled = false, bool hasXyzMaterial = false)
public bool HasInMonstersZone(int cardId, bool notDisabled = false, bool hasXyzMaterial = false, bool faceUp = false)
{
return HasInCards(MonsterZone, cardId, notDisabled, hasXyzMaterial);
return HasInCards(MonsterZone, cardId, notDisabled, hasXyzMaterial, faceUp);
}
public bool HasInMonstersZone(IList<int> cardId, bool notDisabled = false, bool hasXyzMaterial = false)
public bool HasInMonstersZone(IList<int> cardId, bool notDisabled = false, bool hasXyzMaterial = false, bool faceUp = false)
{
return HasInCards(MonsterZone, cardId, notDisabled, hasXyzMaterial);
return HasInCards(MonsterZone, cardId, notDisabled, hasXyzMaterial, faceUp);
}
public bool HasInSpellZone(int cardId, bool notDisabled = false)
public bool HasInSpellZone(int cardId, bool notDisabled = false, bool faceUp = false)
{
return HasInCards(SpellZone, cardId, notDisabled);
return HasInCards(SpellZone, cardId, notDisabled, false, faceUp);
}
public bool HasInSpellZone(IList<int> cardId, bool notDisabled = false)
public bool HasInSpellZone(IList<int> cardId, bool notDisabled = false, bool faceUp = false)
{
return HasInCards(SpellZone, cardId, notDisabled);
return HasInCards(SpellZone, cardId, notDisabled, false, faceUp);
}
public bool HasInHandOrInSpellZone(int cardId)
......@@ -315,94 +301,46 @@ namespace WindBot.Game
public int GetRemainingCount(int cardId, int initialCount)
{
int remaining = initialCount;
foreach (ClientCard card in Hand)
if (card != null && card.Id == cardId)
remaining--;
foreach (ClientCard card in SpellZone)
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--;
remaining = remaining - Hand.Count(card => card != null && card.IsCode(cardId));
remaining = remaining - SpellZone.Count(card => card != null && card.IsCode(cardId));
remaining = remaining - Graveyard.Count(card => card != null && card.IsCode(cardId));
remaining = remaining - Banished.Count(card => card != null && card.IsCode(cardId));
return (remaining < 0) ? 0 : remaining;
}
private static int GetCount(IEnumerable<ClientCard> cards)
{
int count = 0;
foreach (ClientCard card in cards)
{
if (card != null)
count++;
}
return count;
return cards.Count(card => card != null);
}
public int GetCountCardInZone(IEnumerable<ClientCard> cards, int cardId)
{
int count = 0;
foreach (ClientCard card in cards)
{
if (card != null && card.Id == cardId)
count++;
}
return count;
return cards.Count(card => card != null && card.IsCode(cardId));
}
public int GetCountCardInZone(IEnumerable<ClientCard> cards, List<int> cardId)
{
int count = 0;
foreach (ClientCard card in cards)
{
if (card != null && cardId.Contains(card.Id))
count++;
}
return count;
return cards.Count(card => card != null && card.IsCode(cardId));
}
private static List<ClientCard> GetCards(IEnumerable<ClientCard> cards, CardType type)
{
List<ClientCard> nCards = new List<ClientCard>();
foreach (ClientCard card in cards)
{
if (card != null && card.HasType(type))
nCards.Add(card);
}
return nCards;
return cards.Where(card => card != null && card.HasType(type)).ToList();
}
private static List<ClientCard> GetCards(IEnumerable<ClientCard> cards)
{
List<ClientCard> nCards = new List<ClientCard>();
foreach (ClientCard card in cards)
{
if (card != null)
nCards.Add(card);
}
return nCards;
return cards.Where(card => card != null).ToList();
}
private static bool HasInCards(IEnumerable<ClientCard> cards, int cardId, bool notDisabled = false, bool hasXyzMaterial = false)
{
foreach (ClientCard card in cards)
private static bool HasInCards(IEnumerable<ClientCard> cards, int cardId, bool notDisabled = false, bool hasXyzMaterial = false, bool faceUp = false)
{
if (card != null && card.Id == cardId && !(notDisabled && card.IsDisabled()) && !(hasXyzMaterial && !card.HasXyzMaterial()))
return true;
}
return false;
return cards.Any(card => card != null && card.IsCode(cardId) && !(notDisabled && card.IsDisabled()) && !(hasXyzMaterial && !card.HasXyzMaterial()) && !(faceUp && card.IsFacedown()));
}
private static bool HasInCards(IEnumerable<ClientCard> cards, IList<int> cardId, bool notDisabled = false, bool hasXyzMaterial = false)
private static bool HasInCards(IEnumerable<ClientCard> cards, IList<int> cardId, bool notDisabled = false, bool hasXyzMaterial = false, bool faceUp = false)
{
foreach (ClientCard card in cards)
{
if (card != null && cardId.Contains(card.Id) && !(notDisabled && card.IsDisabled()) && !(hasXyzMaterial && !card.HasXyzMaterial()))
return true;
}
return false;
return cards.Any(card => card != null && card.IsCode(cardId) && !(notDisabled && card.IsDisabled()) && !(hasXyzMaterial && !card.HasXyzMaterial()) && !(faceUp && card.IsFacedown()));
}
}
}
\ No newline at end of file
......@@ -83,8 +83,7 @@ namespace WindBot.Game
}
catch (Exception)
{
if (reader != null)
reader.Close();
reader?.Close();
return null;
}
}
......
......@@ -19,7 +19,10 @@ namespace WindBot.Game
public int LastChainPlayer { get; set; }
public IList<ClientCard> CurrentChain { get; set; }
public IList<ClientCard> ChainTargets { get; set; }
public IList<ClientCard> ChainTargetOnly { get; set; }
public int LastSummonPlayer { get; set; }
public IList<ClientCard> SummoningCards { get; set; }
public IList<ClientCard> LastSummonedCards { get; set; }
public Duel()
{
......@@ -29,15 +32,18 @@ namespace WindBot.Game
LastChainPlayer = -1;
CurrentChain = new List<ClientCard>();
ChainTargets = new List<ClientCard>();
ChainTargetOnly = new List<ClientCard>();
LastSummonPlayer = -1;
SummoningCards = new List<ClientCard>();
LastSummonedCards = new List<ClientCard>();
}
public ClientCard GetCard(int player, CardLocation loc, int index)
public ClientCard GetCard(int player, CardLocation loc, int seq)
{
return GetCard(player, (int)loc, index, 0);
return GetCard(player, (int)loc, seq, 0);
}
public ClientCard GetCard(int player, int loc, int index, int subindex)
public ClientCard GetCard(int player, int loc, int seq, int subSeq)
{
if (player < 0 || player > 1)
return null;
......@@ -73,51 +79,52 @@ namespace WindBot.Game
if (cards == null)
return null;
if (index >= cards.Count)
if (seq >= cards.Count)
return null;
if (isXyz)
{
ClientCard card = cards[index];
if (card == null || subindex >= card.Overlays.Count)
ClientCard card = cards[seq];
if (card == null || subSeq >= card.Overlays.Count)
return null;
return null; // TODO card.Overlays[subindex]
return null; // TODO card.Overlays[subSeq]
}
return cards[index];
return cards[seq];
}
public void AddCard(CardLocation loc, int cardId, int player, int zone, int pos)
public void AddCard(CardLocation loc, int cardId, int player, int seq, int pos)
{
switch (loc)
{
case CardLocation.Hand:
Fields[player].Hand.Add(new ClientCard(cardId, loc, pos));
Fields[player].Hand.Add(new ClientCard(cardId, loc, -1, pos));
break;
case CardLocation.Grave:
Fields[player].Graveyard.Add(new ClientCard(cardId, loc, pos));
Fields[player].Graveyard.Add(new ClientCard(cardId, loc,-1, pos));
break;
case CardLocation.Removed:
Fields[player].Banished.Add(new ClientCard(cardId, loc, pos));
Fields[player].Banished.Add(new ClientCard(cardId, loc, -1, pos));
break;
case CardLocation.MonsterZone:
Fields[player].MonsterZone[zone] = new ClientCard(cardId, loc, pos);
Fields[player].MonsterZone[seq] = new ClientCard(cardId, loc, seq, pos);
break;
case CardLocation.SpellZone:
Fields[player].SpellZone[zone] = new ClientCard(cardId, loc, pos);
Fields[player].SpellZone[seq] = new ClientCard(cardId, loc, seq, pos);
break;
case CardLocation.Deck:
Fields[player].Deck.Add(new ClientCard(cardId, loc, pos));
Fields[player].Deck.Add(new ClientCard(cardId, loc, -1, pos));
break;
case CardLocation.Extra:
Fields[player].ExtraDeck.Add(new ClientCard(cardId, loc, pos));
Fields[player].ExtraDeck.Add(new ClientCard(cardId, loc, -1, pos));
break;
}
}
public void AddCard(CardLocation loc, ClientCard card, int player, int zone, int pos, int id)
public void AddCard(CardLocation loc, ClientCard card, int player, int seq, int pos, int id)
{
card.Location = loc;
card.Sequence = seq;
card.Position = pos;
card.SetId(id);
switch (loc)
......@@ -132,10 +139,10 @@ namespace WindBot.Game
Fields[player].Banished.Add(card);
break;
case CardLocation.MonsterZone:
Fields[player].MonsterZone[zone] = card;
Fields[player].MonsterZone[seq] = card;
break;
case CardLocation.SpellZone:
Fields[player].SpellZone[zone] = card;
Fields[player].SpellZone[seq] = card;
break;
case CardLocation.Deck:
Fields[player].Deck.Add(card);
......@@ -146,7 +153,7 @@ namespace WindBot.Game
}
}
public void RemoveCard(CardLocation loc, ClientCard card, int player, int zone)
public void RemoveCard(CardLocation loc, ClientCard card, int player, int seq)
{
switch (loc)
{
......@@ -160,10 +167,10 @@ namespace WindBot.Game
Fields[player].Banished.Remove(card);
break;
case CardLocation.MonsterZone:
Fields[player].MonsterZone[zone] = null;
Fields[player].MonsterZone[seq] = null;
break;
case CardLocation.SpellZone:
Fields[player].SpellZone[zone] = null;
Fields[player].SpellZone[seq] = null;
break;
case CardLocation.Deck:
Fields[player].Deck.Remove(card);
......
......@@ -91,13 +91,13 @@ namespace WindBot.Game
/// </summary>
public void OnNewPhase()
{
m_selector = null;
m_nextSelector = null;
m_thirdSelector = null;
m_selector.Clear();
m_position.Clear();
m_selector_pointer = -1;
m_materialSelector = null;
m_option = -1;
m_yesno = -1;
m_position = CardPosition.FaceUpAttack;
m_place = 0;
if (Duel.Player == 0 && Duel.Phase == DuelPhase.Draw)
{
......@@ -129,6 +129,8 @@ namespace WindBot.Game
/// </summary>
public void OnChainEnd()
{
m_selector.Clear();
m_selector_pointer = -1;
Executor.OnChainEnd();
}
......@@ -142,6 +144,14 @@ namespace WindBot.Game
Executor.SetBattle(battle);
foreach (CardExecutor exec in Executor.Executors)
{
if (exec.Type == ExecutorType.GoToMainPhase2 && battle.CanMainPhaseTwo && exec.Func()) // check if should enter main phase 2 directly
{
return ToMainPhase2();
}
if (exec.Type == ExecutorType.GoToEndPhase && battle.CanEndPhase && exec.Func()) // check if should enter end phase directly
{
return ToEndPhase();
}
for (int i = 0; i < battle.ActivableCards.Count; ++i)
{
ClientCard card = battle.ActivableCards[i];
......@@ -350,10 +360,7 @@ namespace WindBot.Game
return result;
result = new List<ClientCard>();
// TODO: use selector
for (int i = 0; i < cards.Count; i++)
{
result.Add(cards[i]);
}
result = cards.ToList();
return result;
}
......@@ -382,6 +389,18 @@ namespace WindBot.Game
Executor.SetMain(main);
foreach (CardExecutor exec in Executor.Executors)
{
if (exec.Type == ExecutorType.GoToEndPhase && main.CanEndPhase && exec.Func()) // check if should enter end phase directly
{
_dialogs.SendEndTurn();
return new MainPhaseAction(MainPhaseAction.MainAction.ToEndPhase);
}
if (exec.Type==ExecutorType.GoToBattlePhase && main.CanBattlePhase && exec.Func()) // check if should enter battle phase directly
{
return new MainPhaseAction(MainPhaseAction.MainAction.ToBattlePhase);
}
// NOTICE: GoToBattlePhase and GoToEndPhase has no "card" can be accessed to ShouldExecute(), so instead use exec.Func() to check ...
// enter end phase and enter battle pahse is in higher priority.
for (int i = 0; i < main.ActivableCards.Count; ++i)
{
ClientCard card = main.ActivableCards[i];
......@@ -409,7 +428,6 @@ namespace WindBot.Game
if (ShouldExecute(exec, card, ExecutorType.SpSummon))
{
_dialogs.SendSummon(card.Name);
Duel.LastSummonPlayer = 0;
return new MainPhaseAction(MainPhaseAction.MainAction.SpSummon, card.ActionIndex);
}
}
......@@ -418,7 +436,6 @@ namespace WindBot.Game
if (ShouldExecute(exec, card, ExecutorType.Summon))
{
_dialogs.SendSummon(card.Name);
Duel.LastSummonPlayer = 0;
return new MainPhaseAction(MainPhaseAction.MainAction.Summon, card.ActionIndex);
}
if (ShouldExecute(exec, card, ExecutorType.SummonOrSet))
......@@ -430,7 +447,6 @@ namespace WindBot.Game
return new MainPhaseAction(MainPhaseAction.MainAction.SetMonster, card.ActionIndex);
}
_dialogs.SendSummon(card.Name);
Duel.LastSummonPlayer = 0;
return new MainPhaseAction(MainPhaseAction.MainAction.Summon, card.ActionIndex);
}
}
......@@ -490,8 +506,7 @@ namespace WindBot.Game
/// <returns>Selected position.</returns>
public CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions)
{
CardPosition selector_selected = m_position;
m_position = CardPosition.FaceUpAttack;
CardPosition selector_selected = GetSelectedPosition();
CardPosition executor_selected = Executor.OnSelectPosition(cardId, positions);
......@@ -532,10 +547,15 @@ namespace WindBot.Game
}
else
{
if (hint == HINTMSG_SMATERIAL)
switch (hint)
{
case HINTMSG_SMATERIAL:
selected = Executor.OnSelectSynchroMaterial(cards, sum, min, max);
if (hint == HINTMSG_RELEASE)
break;
case HINTMSG_RELEASE:
selected = Executor.OnSelectRitualTribute(cards, sum, min, max);
break;
}
}
if (selected != null)
{
......@@ -555,6 +575,12 @@ namespace WindBot.Game
if (mode)
{
// equal
if (sum == 0 && min == 0)
{
return new List<ClientCard>();
}
if (min <= 1)
{
// try special level first
......@@ -721,92 +747,173 @@ namespace WindBot.Game
// _ Others functions _
// Those functions are used by the AI behavior.
private CardSelector m_selector;
private CardSelector m_nextSelector;
private CardSelector m_thirdSelector;
private CardSelector m_materialSelector;
private CardPosition m_position = CardPosition.FaceUpAttack;
private int m_place;
private int m_option;
private int m_number;
private int m_announce;
private int m_yesno;
private IList<CardAttribute> m_attributes = new List<CardAttribute>();
private IList<CardSelector> m_selector = new List<CardSelector>();
private IList<CardPosition> m_position = new List<CardPosition>();
private int m_selector_pointer = -1;
private IList<CardRace> m_races = new List<CardRace>();
public void SelectCard(ClientCard card)
{
m_selector = new CardSelector(card);
m_selector_pointer = m_selector.Count();
m_selector.Add(new CardSelector(card));
}
public void SelectCard(IList<ClientCard> cards)
{
m_selector = new CardSelector(cards);
m_selector_pointer = m_selector.Count();
m_selector.Add(new CardSelector(cards));
}
public void SelectCard(int cardId)
{
m_selector = new CardSelector(cardId);
m_selector_pointer = m_selector.Count();
m_selector.Add(new CardSelector(cardId));
}
public void SelectCard(IList<int> ids)
{
m_selector = new CardSelector(ids);
m_selector_pointer = m_selector.Count();
m_selector.Add(new CardSelector(ids));
}
public void SelectCard(params int[] ids)
{
m_selector_pointer = m_selector.Count();
m_selector.Add(new CardSelector(ids));
}
public void SelectCard(CardLocation loc)
{
m_selector = new CardSelector(loc);
m_selector_pointer = m_selector.Count();
m_selector.Add(new CardSelector(loc));
}
public void SelectNextCard(ClientCard card)
{
m_nextSelector = new CardSelector(card);
if (m_selector_pointer == -1)
{
Logger.WriteErrorLine("Error: Call SelectNextCard() before SelectCard()");
m_selector_pointer = 0;
}
m_selector.Insert(m_selector_pointer, new CardSelector(card));
}
public void SelectNextCard(IList<ClientCard> cards)
{
m_nextSelector = new CardSelector(cards);
if (m_selector_pointer == -1)
{
Logger.WriteErrorLine("Error: Call SelectNextCard() before SelectCard()");
m_selector_pointer = 0;
}
m_selector.Insert(m_selector_pointer, new CardSelector(cards));
}
public void SelectNextCard(int cardId)
{
m_nextSelector = new CardSelector(cardId);
if (m_selector_pointer == -1)
{
Logger.WriteErrorLine("Error: Call SelectNextCard() before SelectCard()");
m_selector_pointer = 0;
}
m_selector.Insert(m_selector_pointer, new CardSelector(cardId));
}
public void SelectNextCard(IList<int> ids)
{
m_nextSelector = new CardSelector(ids);
if (m_selector_pointer == -1)
{
Logger.WriteErrorLine("Error: Call SelectNextCard() before SelectCard()");
m_selector_pointer = 0;
}
m_selector.Insert(m_selector_pointer, new CardSelector(ids));
}
public void SelectNextCard(params int[] ids)
{
if (m_selector_pointer == -1)
{
Logger.WriteErrorLine("Error: Call SelectNextCard() before SelectCard()");
m_selector_pointer = 0;
}
m_selector.Insert(m_selector_pointer, new CardSelector(ids));
}
public void SelectNextCard(CardLocation loc)
{
m_nextSelector = new CardSelector(loc);
if (m_selector_pointer == -1)
{
Logger.WriteErrorLine("Error: Call SelectNextCard() before SelectCard()");
m_selector_pointer = 0;
}
m_selector.Insert(m_selector_pointer, new CardSelector(loc));
}
public void SelectThirdCard(ClientCard card)
{
m_thirdSelector = new CardSelector(card);
if (m_selector_pointer == -1)
{
Logger.WriteErrorLine("Error: Call SelectThirdCard() before SelectCard()");
m_selector_pointer = 0;
}
m_selector.Insert(m_selector_pointer, new CardSelector(card));
}
public void SelectThirdCard(IList<ClientCard> cards)
{
m_thirdSelector = new CardSelector(cards);
if (m_selector_pointer == -1)
{
Logger.WriteErrorLine("Error: Call SelectThirdCard() before SelectCard()");
m_selector_pointer = 0;
}
m_selector.Insert(m_selector_pointer, new CardSelector(cards));
}
public void SelectThirdCard(int cardId)
{
m_thirdSelector = new CardSelector(cardId);
if (m_selector_pointer == -1)
{
Logger.WriteErrorLine("Error: Call SelectThirdCard() before SelectCard()");
m_selector_pointer = 0;
}
m_selector.Insert(m_selector_pointer, new CardSelector(cardId));
}
public void SelectThirdCard(IList<int> ids)
{
m_thirdSelector = new CardSelector(ids);
if (m_selector_pointer == -1)
{
Logger.WriteErrorLine("Error: Call SelectThirdCard() before SelectCard()");
m_selector_pointer = 0;
}
m_selector.Insert(m_selector_pointer, new CardSelector(ids));
}
public void SelectThirdCard(params int[] ids)
{
if (m_selector_pointer == -1)
{
Logger.WriteErrorLine("Error: Call SelectThirdCard() before SelectCard()");
m_selector_pointer = 0;
}
m_selector.Insert(m_selector_pointer, new CardSelector(ids));
}
public void SelectThirdCard(CardLocation loc)
{
m_thirdSelector = new CardSelector(loc);
if (m_selector_pointer == -1)
{
Logger.WriteErrorLine("Error: Call SelectThirdCard() before SelectCard()");
m_selector_pointer = 0;
}
m_selector.Insert(m_selector_pointer, new CardSelector(loc));
}
public void SelectMaterials(ClientCard card)
......@@ -841,24 +948,29 @@ namespace WindBot.Game
public CardSelector GetSelectedCards()
{
CardSelector selected = m_selector;
m_selector = null;
if (m_nextSelector != null)
CardSelector selected = null;
if (m_selector.Count > 0)
{
m_selector = m_nextSelector;
m_nextSelector = null;
if (m_thirdSelector != null)
{
m_nextSelector = m_thirdSelector;
m_thirdSelector = null;
selected = m_selector[m_selector.Count - 1];
m_selector.RemoveAt(m_selector.Count - 1);
}
return selected;
}
public CardPosition GetSelectedPosition()
{
CardPosition selected = CardPosition.FaceUpAttack;
if (m_position.Count > 0)
{
selected = m_position[0];
m_position.RemoveAt(0);
}
return selected;
}
public void SelectPosition(CardPosition pos)
{
m_position = pos;
m_position.Add(pos);
}
public void SelectPlace(int zones)
......@@ -933,12 +1045,7 @@ namespace WindBot.Game
/// <returns>A list of the selected attributes.</returns>
public virtual IList<CardAttribute> OnAnnounceAttrib(int count, IList<CardAttribute> attributes)
{
IList<CardAttribute> foundAttributes = new List<CardAttribute>();
foreach (CardAttribute attribute in m_attributes)
{
if(attributes.Contains(attribute))
foundAttributes.Add(attribute);
}
IList<CardAttribute> foundAttributes = m_attributes.Where(attributes.Contains).ToList();
if (foundAttributes.Count > 0)
return foundAttributes;
......@@ -953,12 +1060,7 @@ namespace WindBot.Game
/// <returns>A list of the selected races.</returns>
public virtual IList<CardRace> OnAnnounceRace(int count, IList<CardRace> races)
{
IList<CardRace> foundRaces = new List<CardRace>();
foreach (CardRace race in m_races)
{
if (races.Contains(race))
foundRaces.Add(race);
}
IList<CardRace> foundRaces = m_races.Where(races.Contains).ToList();
if (foundRaces.Count > 0)
return foundRaces;
......@@ -996,12 +1098,10 @@ namespace WindBot.Game
private bool ShouldExecute(CardExecutor exec, ClientCard card, ExecutorType type, int desc = -1)
{
Executor.SetCard(type, card, desc);
if (card != null &&
return card != null &&
exec.Type == type &&
(exec.CardId == -1 || exec.CardId == card.Id) &&
(exec.Func == null || exec.Func()))
return true;
return false;
(exec.Func == null || exec.Func());
}
}
}
......@@ -27,6 +27,7 @@ namespace WindBot.Game
private int _hand;
private bool _debug;
private int _select_hint;
private GameMessage _lastMessage;
public GameBehavior(GameClient game)
{
......@@ -61,6 +62,7 @@ namespace WindBot.Game
GameMessage msg = (GameMessage)packet.ReadByte();
if (_messages.ContainsKey(msg))
_messages[msg](packet);
_lastMessage = msg;
return;
}
if (_packets.ContainsKey(id))
......@@ -99,7 +101,10 @@ namespace WindBot.Game
_messages.Add(GameMessage.Recover, OnRecover);
_messages.Add(GameMessage.LpUpdate, OnLpUpdate);
_messages.Add(GameMessage.Move, OnMove);
_messages.Add(GameMessage.Swap, OnSwap);
_messages.Add(GameMessage.Attack, OnAttack);
_messages.Add(GameMessage.Battle, OnBattle);
_messages.Add(GameMessage.AttackDisabled, OnAttackDisabled);
_messages.Add(GameMessage.PosChange, OnPosChange);
_messages.Add(GameMessage.Chaining, OnChaining);
_messages.Add(GameMessage.ChainEnd, OnChainEnd);
......@@ -128,9 +133,16 @@ namespace WindBot.Game
_messages.Add(GameMessage.AnnounceRace, OnAnnounceRace);
_messages.Add(GameMessage.AnnounceCardFilter, OnAnnounceCard);
_messages.Add(GameMessage.RockPaperScissors, OnRockPaperScissors);
_messages.Add(GameMessage.SpSummoning, OnSpSummon);
_messages.Add(GameMessage.SpSummoned, OnSpSummon);
_messages.Add(GameMessage.Equip, OnEquip);
_messages.Add(GameMessage.Unequip, OnUnEquip);
_messages.Add(GameMessage.CardTarget, OnCardTarget);
_messages.Add(GameMessage.CancelTarget, OnCancelTarget);
_messages.Add(GameMessage.Summoning, OnSummoning);
_messages.Add(GameMessage.Summoned, OnSummoned);
_messages.Add(GameMessage.SpSummoning, OnSpSummoning);
_messages.Add(GameMessage.SpSummoned, OnSpSummoned);
_messages.Add(GameMessage.FlipSummoning, OnSummoning);
_messages.Add(GameMessage.FlipSummoned, OnSummoned);
}
private void OnJoinGame(BinaryReader packet)
......@@ -308,7 +320,7 @@ namespace WindBot.Game
{
_ai.OnRetry();
Connection.Close();
throw new Exception("Got MSG_RETRY.");
throw new Exception("Got MSG_RETRY. Last message is " + _lastMessage);
}
private void OnHint(BinaryReader packet)
......@@ -316,6 +328,14 @@ namespace WindBot.Game
int type = packet.ReadByte();
int player = packet.ReadByte();
int data = packet.ReadInt32();
if (type == 1) // HINT_EVENT
{
if (data == 24) // battling
{
_duel.Fields[0].UnderAttack = false;
_duel.Fields[1].UnderAttack = false;
}
}
if (type == 3) // HINT_SELECTMSG
{
_select_hint = data;
......@@ -359,7 +379,7 @@ namespace WindBot.Game
for (int i = 0; i < count; ++i)
{
_duel.Fields[player].Deck.RemoveAt(_duel.Fields[player].Deck.Count - 1);
_duel.Fields[player].Hand.Add(new ClientCard(0, CardLocation.Hand));
_duel.Fields[player].Hand.Add(new ClientCard(0, CardLocation.Hand, -1));
}
_ai.OnDraw(player);
}
......@@ -430,19 +450,19 @@ namespace WindBot.Game
_duel.Fields[player].Deck.Clear();
for (int i = 0; i < mcount; ++i)
{
_duel.Fields[player].Deck.Add(new ClientCard(0, CardLocation.Deck));
_duel.Fields[player].Deck.Add(new ClientCard(0, CardLocation.Deck, -1));
}
_duel.Fields[player].ExtraDeck.Clear();
for (int i = 0; i < ecount; ++i)
{
int code = packet.ReadInt32() & 0x7fffffff;
_duel.Fields[player].ExtraDeck.Add(new ClientCard(code, CardLocation.Extra));
_duel.Fields[player].ExtraDeck.Add(new ClientCard(code, CardLocation.Extra, -1));
}
_duel.Fields[player].Hand.Clear();
for (int i = 0; i < hcount; ++i)
{
int code = packet.ReadInt32();
_duel.Fields[player].Hand.Add(new ClientCard(code, CardLocation.Hand));
_duel.Fields[player].Hand.Add(new ClientCard(code, CardLocation.Hand,-1));
}
}
......@@ -478,8 +498,12 @@ namespace WindBot.Game
if (_debug)
Logger.WriteLine("(Go to " + (_duel.Phase.ToString()) + ")");
_duel.LastSummonPlayer = -1;
_duel.SummoningCards.Clear();
_duel.LastSummonedCards.Clear();
_duel.Fields[0].BattlingMonster = null;
_duel.Fields[1].BattlingMonster = null;
_duel.Fields[0].UnderAttack = false;
_duel.Fields[1].UnderAttack = false;
_ai.OnNewPhase();
}
......@@ -507,6 +531,7 @@ namespace WindBot.Game
private void OnMove(BinaryReader packet)
{
// TODO: update equip cards and target cards
int cardId = packet.ReadInt32();
int previousControler = GetLocalPlayer(packet.ReadByte());
int previousLocation = packet.ReadByte();
......@@ -557,6 +582,8 @@ namespace WindBot.Game
else
{
_duel.AddCard((CardLocation)currentLocation, card, currentControler, currentSequence, currentPosition, cardId);
if (card != null && previousLocation != currentLocation)
card.IsSpecialSummoned = false;
if (_debug && card != null)
Logger.WriteLine("(" + previousControler.ToString() + " 's " + (card.Name ?? "UnKnowCard")
+ " from " +
......@@ -565,6 +592,27 @@ namespace WindBot.Game
}
}
private void OnSwap(BinaryReader packet)
{
int cardId1 = packet.ReadInt32();
int controler1 = GetLocalPlayer(packet.ReadByte());
int location1 = packet.ReadByte();
int sequence1 = packet.ReadByte();
packet.ReadByte();
int cardId2 = packet.ReadInt32();
int controler2 = GetLocalPlayer(packet.ReadByte());
int location2 = packet.ReadByte();
int sequence2 = packet.ReadByte();
packet.ReadByte();
ClientCard card1 = _duel.GetCard(controler1, (CardLocation)location1, sequence1);
ClientCard card2 = _duel.GetCard(controler2, (CardLocation)location2, sequence2);
if (card1 == null || card2 == null) return;
_duel.RemoveCard((CardLocation)location1, card1, controler1, sequence1);
_duel.RemoveCard((CardLocation)location2, card2, controler2, sequence2);
_duel.AddCard((CardLocation)location2, card1, controler2, sequence2, card1.Position, cardId1);
_duel.AddCard((CardLocation)location1, card2, controler1, sequence1, card2.Position, cardId2);
}
private void OnAttack(BinaryReader packet)
{
int ca = GetLocalPlayer(packet.ReadByte());
......@@ -585,25 +633,40 @@ namespace WindBot.Game
}
_duel.Fields[attackcard.Controller].BattlingMonster = attackcard;
_duel.Fields[1 - attackcard.Controller].BattlingMonster = defendcard;
_duel.Fields[1 - attackcard.Controller].UnderAttack = true;
if (ld == 0 && (attackcard != null) && (ca != 0))
if (ld == 0 && ca != 0)
{
_ai.OnDirectAttack(attackcard);
}
}
private void OnBattle(BinaryReader packet)
{
_duel.Fields[0].UnderAttack = false;
_duel.Fields[1].UnderAttack = false;
}
private void OnAttackDisabled(BinaryReader packet)
{
_duel.Fields[0].UnderAttack = false;
_duel.Fields[1].UnderAttack = false;
}
private void OnPosChange(BinaryReader packet)
{
packet.ReadInt32(); // card id
int pc = GetLocalPlayer(packet.ReadByte());
int pl = packet.ReadByte();
int ps = packet.ReadSByte();
packet.ReadSByte(); // pp
int pp = packet.ReadSByte();
int cp = packet.ReadSByte();
ClientCard card = _duel.GetCard(pc, (CardLocation)pl, ps);
if (card != null)
{
card.Position = cp;
if ((pp & (int) CardPosition.FaceUp) > 0 && (cp & (int) CardPosition.FaceDown) > 0)
card.ClearCardTargets();
if (_debug)
Logger.WriteLine("(" + (card.Name ?? "UnKnowCard") + " change position to " + (CardPosition)cp + ")");
}
......@@ -621,7 +684,8 @@ namespace WindBot.Game
if (_debug)
if (card != null) Logger.WriteLine("(" + cc.ToString() + " 's " + (card.Name ?? "UnKnowCard") + " activate effect)");
_ai.OnChaining(card, cc);
_duel.ChainTargets.Clear();
//_duel.ChainTargets.Clear();
_duel.ChainTargetOnly.Clear();
_duel.LastSummonPlayer = -1;
_duel.CurrentChain.Add(card);
_duel.LastChainPlayer = cc;
......@@ -633,7 +697,8 @@ namespace WindBot.Game
_ai.OnChainEnd();
_duel.LastChainPlayer = -1;
_duel.CurrentChain.Clear();
//_duel.ChainTargets.Clear();
_duel.ChainTargets.Clear();
_duel.ChainTargetOnly.Clear();
}
private void OnCardSorting(BinaryReader packet)
......@@ -650,7 +715,7 @@ namespace WindBot.Game
int seq = packet.ReadByte();
ClientCard card;
if (((int)loc & (int)CardLocation.Overlay) != 0)
card = new ClientCard(id, CardLocation.Overlay);
card = new ClientCard(id, CardLocation.Overlay, -1);
else
card = _duel.GetCard(controler, loc, seq);
if (card == null) continue;
......@@ -697,9 +762,8 @@ namespace WindBot.Game
packet.ReadInt32(); // ???
ClientCard card = _duel.GetCard(player, (CardLocation)loc, seq);
if (card == null) return;
card.Update(packet, _duel);
card?.Update(packet, _duel);
}
private void OnUpdateData(BinaryReader packet)
......@@ -758,6 +822,7 @@ namespace WindBot.Game
if (_debug)
Logger.WriteLine("(" + (CardLocation)loc + " 's " + (card.Name ?? "UnKnowCard") + " become target)");
_duel.ChainTargets.Add(card);
_duel.ChainTargetOnly.Add(card);
}
}
......@@ -837,7 +902,7 @@ namespace WindBot.Game
packet.ReadByte(); // pos
ClientCard card;
if (((int)loc & (int)CardLocation.Overlay) != 0)
card = new ClientCard(id, CardLocation.Overlay);
card = new ClientCard(id, CardLocation.Overlay, -1);
else
card = _duel.GetCard(player, loc, seq);
if (card == null) continue;
......@@ -896,7 +961,7 @@ namespace WindBot.Game
packet.ReadByte(); // pos
ClientCard card;
if (((int)loc & (int)CardLocation.Overlay) != 0)
card = new ClientCard(id, CardLocation.Overlay);
card = new ClientCard(id, CardLocation.Overlay, -1);
else
card = _duel.GetCard(player, loc, seq);
if (card == null) continue;
......@@ -977,6 +1042,10 @@ namespace WindBot.Game
int sseq = packet.ReadByte();
int desc = packet.ReadInt32();
if (desc == 221) // trigger effect
{
desc = 0;
}
cards.Add(_duel.GetCard(con, loc, seq, sseq));
descs.Add(desc);
}
......@@ -1051,7 +1120,8 @@ namespace WindBot.Game
return;
}
if (card.Id == 0) card.SetId(cardId);
if (card.Id == 0)
card.SetId(cardId);
int reply = _ai.OnSelectEffectYn(card, desc) ? (1) : (0);
Connection.Send(CtosMessage.Response, reply);
......@@ -1303,9 +1373,11 @@ namespace WindBot.Game
{
result[index++] = 0;
}
for (int i = 0; i < selected.Count; ++i)
int l = 0;
while (l < selected.Count)
{
result[index++] = (byte)selected[i].SelectSeq;
result[index++] = (byte)selected[l].SelectSeq;
++l;
}
BinaryWriter reply = GamePacketFactory.Create(CtosMessage.Response);
......@@ -1397,9 +1469,117 @@ namespace WindBot.Game
Connection.Send(CtosMessage.Response, result);
}
private void OnSpSummon(BinaryReader packet)
private void OnEquip(BinaryReader packet)
{
int equipCardControler = GetLocalPlayer(packet.ReadByte());
int equipCardLocation = packet.ReadByte();
int equipCardSequence = packet.ReadSByte();
packet.ReadByte();
int targetCardControler = GetLocalPlayer(packet.ReadByte());
int targetCardLocation = packet.ReadByte();
int targetCardSequence = packet.ReadSByte();
packet.ReadByte();
ClientCard equipCard = _duel.GetCard(equipCardControler, (CardLocation)equipCardLocation, equipCardSequence);
ClientCard targetCard = _duel.GetCard(targetCardControler, (CardLocation)targetCardLocation, targetCardSequence);
if (equipCard == null || targetCard == null) return;
equipCard.EquipTarget?.EquipCards.Remove(equipCard);
equipCard.EquipTarget = targetCard;
targetCard.EquipCards.Add(equipCard);
}
private void OnUnEquip(BinaryReader packet)
{
int equipCardControler = GetLocalPlayer(packet.ReadByte());
int equipCardLocation = packet.ReadByte();
int equipCardSequence = packet.ReadSByte();
packet.ReadByte();
ClientCard equipCard = _duel.GetCard(equipCardControler, (CardLocation)equipCardLocation, equipCardSequence);
if (equipCard == null) return;
if (equipCard.EquipTarget != null)
{
equipCard.EquipTarget.EquipCards.Remove(equipCard);
equipCard.EquipTarget = null;
}
}
private void OnCardTarget(BinaryReader packet)
{
int ownerCardControler = GetLocalPlayer(packet.ReadByte());
int ownerCardLocation = packet.ReadByte();
int ownerCardSequence = packet.ReadSByte();
packet.ReadByte();
int targetCardControler = GetLocalPlayer(packet.ReadByte());
int targetCardLocation = packet.ReadByte();
int targetCardSequence = packet.ReadSByte();
packet.ReadByte();
ClientCard ownerCard = _duel.GetCard(ownerCardControler, (CardLocation)ownerCardLocation, ownerCardSequence);
ClientCard targetCard = _duel.GetCard(targetCardControler, (CardLocation)targetCardLocation, targetCardSequence);
if (ownerCard == null || targetCard == null) return;
ownerCard.TargetCards.Add(targetCard);
targetCard.OwnTargets.Add(ownerCard);
}
private void OnCancelTarget(BinaryReader packet)
{
int ownerCardControler = GetLocalPlayer(packet.ReadByte());
int ownerCardLocation = packet.ReadByte();
int ownerCardSequence = packet.ReadSByte();
packet.ReadByte();
int targetCardControler = GetLocalPlayer(packet.ReadByte());
int targetCardLocation = packet.ReadByte();
int targetCardSequence = packet.ReadSByte();
packet.ReadByte();
ClientCard ownerCard = _duel.GetCard(ownerCardControler, (CardLocation)ownerCardLocation, ownerCardSequence);
ClientCard targetCard = _duel.GetCard(targetCardControler, (CardLocation)targetCardLocation, targetCardSequence);
if (ownerCard == null || targetCard == null) return;
ownerCard.TargetCards.Remove(targetCard);
targetCard.OwnTargets.Remove(ownerCard);
}
private void OnSummoning(BinaryReader packet)
{
_duel.LastSummonedCards.Clear();
int code = packet.ReadInt32();
int currentControler = GetLocalPlayer(packet.ReadByte());
int currentLocation = packet.ReadByte();
int currentSequence = packet.ReadSByte();
int currentPosition = packet.ReadSByte();
ClientCard card = _duel.GetCard(currentControler, (CardLocation)currentLocation, currentSequence);
_duel.SummoningCards.Add(card);
_duel.LastSummonPlayer = currentControler;
}
private void OnSummoned(BinaryReader packet)
{
foreach (ClientCard card in _duel.SummoningCards)
{
_duel.LastSummonedCards.Add(card);
}
_duel.SummoningCards.Clear();
}
private void OnSpSummoning(BinaryReader packet)
{
_duel.LastSummonedCards.Clear();
_ai.CleanSelectMaterials();
int code = packet.ReadInt32();
int currentControler = GetLocalPlayer(packet.ReadByte());
int currentLocation = packet.ReadByte();
int currentSequence = packet.ReadSByte();
int currentPosition = packet.ReadSByte();
ClientCard card = _duel.GetCard(currentControler, (CardLocation)currentLocation, currentSequence);
_duel.SummoningCards.Add(card);
_duel.LastSummonPlayer = currentControler;
}
private void OnSpSummoned(BinaryReader packet)
{
foreach (ClientCard card in _duel.SummoningCards)
{
card.IsSpecialSummoned = true;
_duel.LastSummonedCards.Add(card);
}
_duel.SummoningCards.Clear();
}
}
}
......@@ -66,6 +66,7 @@
<Compile Include="Game\AI\CardSelector.cs" />
<Compile Include="Game\AI\DeckAttribute.cs" />
<Compile Include="Game\AI\DecksManager.cs" />
<Compile Include="Game\AI\Decks\AltergeistExecutor.cs" />
<Compile Include="Game\AI\Decks\BlackwingExecutor.cs" />
<Compile Include="Game\AI\Decks\CyberDragonExecutor.cs" />
<Compile Include="Game\AI\Decks\DarkMagicianExecutor.cs" />
......@@ -78,12 +79,15 @@
<Compile Include="Game\AI\Decks\GravekeeperExecutor.cs" />
<Compile Include="Game\AI\Decks\RainbowExecutor.cs" />
<Compile Include="Game\AI\Decks\BlueEyesExecutor.cs" />
<Compile Include="Game\AI\Decks\BlueEyesMaxDragonExecutor.cs" />
<Compile Include="Game\AI\Decks\BurnExecutor.cs" />
<Compile Include="Game\AI\Decks\ChainBurnExecutor.cs" />
<Compile Include="Game\AI\Decks\EvilswarmExecutor.cs" />
<Compile Include="Game\AI\Decks\GraydleExecutor.cs" />
<Compile Include="Game\AI\Decks\GrenMajuThunderBoarderExecutor.cs" />
<Compile Include="Game\AI\Decks\LightswornExecutor.cs" />
<Compile Include="Game\AI\Decks\LightswornShaddoldinosourExecutor.cs" />
<Compile Include="Game\AI\Decks\PhantasmExecutor.cs" />
<Compile Include="Game\AI\Decks\QliphortExecutor.cs" />
<Compile Include="Game\AI\Decks\ST1732Executor.cs" />
<Compile Include="Game\AI\Decks\TrickstarExecutor.cs" />
......
......@@ -22,7 +22,7 @@ namespace WindBot
Host = "127.0.0.1";
Port = 7911;
HostInfo = "";
Version = 0x1345;
Version = 0x1347;
Hand = 0;
Debug = false;
Chat = true;
......
No preview for this file type
No preview for this file type
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