Commit 91b1f962 authored by wind2009's avatar wind2009 Committed by mercury233

Trickstar deck update (#68)

parent d6afaed2
......@@ -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 (Card.Id == CardId.Sheep && Bot.HasInSpellZone(CardId.Sheep)) return false;
return DefaultSpellSet();
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)
{
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.Id == 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.Id == 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.Id != 71650854 && Card.Id != 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 && SkyStrike_list.Contains(card.Id))
{
has_skystriker = true;
break;
}
}
if (!has_skystriker)
{
foreach (ClientCard card in Enemy.GetSpells())
{
if (card != null && SkyStrike_list.Contains(card.Id))
{
has_skystriker = true;
break;
}
}
}
if (!has_skystriker)
{
foreach (ClientCard card in Enemy.GetSpells())
{
if (card != null && SkyStrike_list.Contains(card.Id))
{
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)
{
......@@ -366,6 +505,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 +518,7 @@ namespace WindBot.Game.AI.Decks
if (selected == null)
return false;
AI.SelectCard(selected);
AI.SelectPlace(SelectSTPlace());
return true;
}
......@@ -389,6 +530,7 @@ 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();
......@@ -397,19 +539,22 @@ namespace WindBot.Game.AI.Decks
if (self_card.Id == 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().Id == CardId.Feather && !Bot.HasInSpellZone(CardId.Awaken)))) return true;
if (Duel.Phase > DuelPhase.Main1 && Duel.Phase < DuelPhase.Main2)
{
int total_atk = 0;
......@@ -425,8 +570,8 @@ 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))
......@@ -547,7 +692,13 @@ 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()
......@@ -621,7 +772,7 @@ 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].Id != CardId.Stage)
{
targets.Add(Bot.SpellZone[5]);
}
......@@ -1024,6 +1175,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 +1189,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)
......@@ -1176,6 +1333,7 @@ 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 (!spell_trap_activate()) return false;
ClientCard target = AI.Utils.GetProblematicEnemyMonster();
if (target == null && AI.Utils.IsChainTarget(Card))
{
......@@ -1321,7 +1479,7 @@ 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())
{
......@@ -1393,6 +1551,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;
}
......@@ -1455,21 +1626,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()
......@@ -1635,8 +1812,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 +1831,7 @@ namespace WindBot.Game.AI.Decks
public bool DarkHole_eff()
{
if (!spell_trap_activate()) return false;
if (Bot.GetMonsterCount() == 0)
{
......@@ -1663,10 +1843,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;
}
......@@ -1694,6 +1882,15 @@ namespace WindBot.Game.AI.Decks
if (Card.IsFaceup() && Card.IsDefense() && Card.Attack == 0)
return false;
if (Card.Id == 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)
......
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