Commit 023c747a authored by wind2009's avatar wind2009

Merge branch 'master' into fapaiji

parents c6aad034 94cd3eb0
Pipeline #25505 passed with stage
in 25 seconds
#created by ...
#main
81497285
81497285
2347656
41165831
73602965
73602965
75730490
1225009
1225009
1225009
37629703
37629703
37629703
14558127
14558127
14558127
23434538
23434538
23434538
74018812
74018812
74018812
2511
2511
2511
49238328
49238328
5380979
5380979
6351147
6351147
10045474
10045474
10045474
30748475
53417695
83326048
92714517
92714517
92714517
#extra
22850702
22850702
93039339
93039339
29479265
93084621
93084621
24269961
24269961
24269961
67680512
67680512
29301450
71607202
94259633
!side
#created by ...
#main
83334932
83334932
83334932
82112494
82112494
82112494
19510093
19510093
34496660
34496660
34496660
90361010
90361010
90361010
78391364
78391364
56727340
56727340
14624296
95500396
10604644
23434538
23434538
23434538
14558127
14558127
14558127
49036338
38814750
38814750
97268402
97268402
73642296
73642296
59438930
59438930
59438930
94145021
94145021
94145021
#extra
64193046
84815190
30983281
44508094
27548199
76471944
74586817
28912357
38342335
27381364
22423493
65741786
33918636
33918636
33918636
!side
{
"welcome": [
"是宵夜哒哟!",
"什么灵摆卡组都会玩的哟!",
"什么?你说超重不是灵摆卡组?"
],
"deckerror": [
"{0}的数量不对!快去改成无禁限模式!。"
],
"duelstart": [
"给你展现一下超重的魅力!"
],
"newturn": [
"抽卡!弁庆你别上手救我了!",
"抽卡!P身子你别上手救我了!"
],
"endturn": [
"哼哼,到你的回合了!",
"喜不喜欢我的展开呢?"
],
"directattack": [
"我用{0}直接攻击!"
],
"attack": [
"我用{0}攻击{1}!"
],
"ondirectattack": [
"不许打!不许打呀!",
"呜哇!要被打倒惹~"
],
"facedownmonstername": "怪兽",
"activate": [
"呼呼呼,{0}的效果太厉害了!",
"呼呼呼,我使用{0}的效果。"
],
"summon": [
"呼呼呼,我召唤{0}!"
],
"setmonster": [
"呼呼呼,我盖放了一只怪兽。"
],
"chaining": [
"此刻!{0}的效果发动!"
]
}
......@@ -434,6 +434,15 @@ namespace WindBot.Game.AI
if (selected.Count >= max)
break;
}
if (selected.Count < min)
{
#if DEBUG
throw new Exception("Not enough cards to CheckSelectCount");
#else
Logger.WriteErrorLine("Not enough cards to CheckSelectCount, using default");
return null;
#endif
}
}
while (selected.Count > max)
{
......
......@@ -21,7 +21,8 @@ namespace WindBot.Game.AI
/// </summary>
public static bool IsMonsterDangerous(this ClientCard card)
{
return !card.IsDisabled() && Enum.IsDefined(typeof(DangerousMonster), card.Id);
return !card.IsDisabled() &&
(Enum.IsDefined(typeof(DangerousMonster), card.Id) || (card.HasSetcode(0x18d) && (card.HasType(CardType.Ritual) || card.EquipCards.Count > 0)));
}
/// <summary>
......
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using WindBot;
using WindBot.Game;
using WindBot.Game.AI;
using System.Linq;
namespace WindBot.Game.AI.Decks
{
......@@ -324,23 +325,37 @@ namespace WindBot.Game.AI.Decks
public int SelectSTPlace(ClientCard card=null, bool avoid_Impermanence = false)
{
List<int> list = new List<int> { 0, 1, 2, 3, 4 };
if (card == null) card = Card;
List<int> list = new List<int>();
for (int seq = 0; seq < 5; ++seq)
{
if (Bot.SpellZone[seq] == null)
{
if (card != null && card.Location == CardLocation.Hand && avoid_Impermanence && Impermanence_list.Contains(seq)) continue;
list.Add(seq);
}
}
int n = list.Count;
while (n-- > 1)
{
int index = Program.Rand.Next(n + 1);
int temp = list[index];
list[index] = list[n];
list[n] = temp;
int index = Program.Rand.Next(list.Count);
int nextIndex = (index + Program.Rand.Next(list.Count - 1)) % list.Count;
int tempInt = list[index];
list[index] = list[nextIndex];
list[nextIndex] = tempInt;
}
foreach (int seq in list)
if (avoid_Impermanence && Bot.GetMonsters().Any(c => c.IsFaceup() && !c.IsDisabled()))
{
int zone = (int)System.Math.Pow(2, seq);
if (Bot.SpellZone[seq] == null)
foreach (int seq in list)
{
if (card != null && card.Location == CardLocation.Hand && avoid_Impermanence && Impermanence_list.Contains(seq)) continue;
return zone;
};
ClientCard enemySpell = Enemy.SpellZone[4 - seq];
if (enemySpell != null && enemySpell.IsFacedown()) continue;
return (int)System.Math.Pow(2, seq);
}
}
foreach (int seq in list)
{
return (int)System.Math.Pow(2, seq);
}
return 0;
}
......@@ -2656,6 +2671,27 @@ namespace WindBot.Game.AI.Decks
attacked_Meluseek.Clear();
}
public override void OnChaining(int player, ClientCard card)
{
if (card == null) return;
if (player == 1)
{
if (card.IsCode(_CardId.InfiniteImpermanence))
{
for (int i = 0; i < 5; ++i)
{
if (Enemy.SpellZone[i] == card)
{
Impermanence_list.Add(4-i);
break;
}
}
}
}
base.OnChaining(player, card);
}
public bool MonsterRepos()
{
if (Card.Attack == 0) return (Card.IsAttack());
......@@ -2797,7 +2833,8 @@ namespace WindBot.Game.AI.Decks
// throw all??
return null;
}
return null;
return base.OnSelectCard(cards, min, max, hint, cancelable);
}
public override CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions)
......
......@@ -146,7 +146,8 @@ namespace WindBot.Game.AI.Decks
return Util.CheckSelectCount(result, cards, min, max);
}
Logger.DebugWriteLine("Use default.");
return null;
return base.OnSelectCard(cards, min, max, hint, cancelable);
}
public override IList<ClientCard> OnSelectXyzMaterial(IList<ClientCard> cards, int min, int max)
......
......@@ -2,8 +2,6 @@ using YGOSharp.OCGWrapper.Enums;
using System.Collections.Generic;
using System.Linq;
using System;
using System.CodeDom;
using System.Security.AccessControl;
namespace WindBot.Game.AI.Decks
{
......@@ -62,6 +60,7 @@ namespace WindBot.Game.AI.Decks
public const int DimensionalFissure = 81674782;
public const int BanisheroftheRadiance = 94853057;
public const int BanisheroftheLight = 61528025;
public const int GhostMournerMoonlitChill = 52038441;
}
public DogmatikaExecutor(GameAI ai, Duel duel)
......@@ -133,6 +132,7 @@ namespace WindBot.Game.AI.Decks
const int SetcodeOrcust = 0x11b;
const int SetcodeDogmatika = 0x145;
const int hintTimingMainEnd = 0x4;
const int hintDamageStep = 0x2000;
Dictionary<int, List<int>> DeckCountTable = new Dictionary<int, List<int>>{
{3, new List<int> { CardId.DogmatikaEcclesia, _CardId.AshBlossom, _CardId.MaxxC, CardId.KnightmareCorruptorIblee, CardId.NadirServant,
......@@ -1081,7 +1081,7 @@ namespace WindBot.Game.AI.Decks
}
}
public override void OnMove(int cardId, int previousControler, int previousLocation, int currentControler, int currentLocation)
public override void OnMove(ClientCard card, int previousControler, int previousLocation, int currentControler, int currentLocation)
{
if (previousControler == 1 && currentLocation == (int)CardLocation.MonsterZone)
{
......@@ -1093,13 +1093,29 @@ namespace WindBot.Game.AI.Decks
}
}
base.OnMove(cardId, previousControler, previousLocation, currentControler, currentLocation);
base.OnMove(card, previousControler, previousLocation, currentControler, currentLocation);
}
public override ClientCard OnSelectAttacker(IList<ClientCard> attackers, IList<ClientCard> defenders)
public override BattlePhaseAction OnBattle(IList<ClientCard> attackers, IList<ClientCard> defenders)
{
if (attackers.Count() > 0) return attackers[attackers.Count() - 1];
return null;
if (attackers.Count() == 1 && defenders.Count() == 1)
{
if (defenders[0].IsCode(CardId.KnightmareCorruptorIblee) && !confirmLink2) return new BattlePhaseAction(BattlePhaseAction.BattleAction.ToMainPhaseTwo);
}
if (attackers.Count() > 0 && defenders.Count() > 0)
{
List<ClientCard> sortedAttacker = attackers.OrderBy(card => card.Attack).ToList();
for (int k = 0; k < sortedAttacker.Count; ++k)
{
ClientCard attacker = sortedAttacker[k];
attacker.IsLastAttacker = k == sortedAttacker.Count - 1;
BattlePhaseAction result = OnSelectAttackTarget(attacker, defenders);
if (result != null)
return result;
}
}
return base.OnBattle(attackers, defenders);
}
public override BattlePhaseAction OnSelectAttackTarget(ClientCard attacker, IList<ClientCard> defenders)
......@@ -1113,6 +1129,9 @@ namespace WindBot.Game.AI.Decks
if (attacker.RealPower > defender.RealPower)
return AI.Attack(attacker, defender);
if (attacker.RealPower == defender.RealPower && defender.IsAttack() && Bot.GetMonsterCount() >= Enemy.GetMonsterCount())
return AI.Attack(attacker, defender);
}
if (attacker.CanDirectAttack)
......@@ -1989,13 +2008,17 @@ namespace WindBot.Game.AI.Decks
ClientCard lastChainCard = Util.GetLastChainCard();
if (lastChainCard != null && lastChainCard.Controller == 1 && lastChainCard.IsMonster())
{
foreach (ClientCard chainTarget in Duel.LastChainTargets)
bool negateFlag = lastChainCard.IsCode(_CardId.EffectVeiler, CardId.GhostMournerMoonlitChill);
if (Duel.Turn > 1 || !negateFlag)
{
if (selfCasterList.Contains(chainTarget))
foreach (ClientCard chainTarget in Duel.LastChainTargets)
{
selfTarget = chainTarget;
activateFlag = true;
break;
if (selfCasterList.Contains(chainTarget) && (!negateFlag || !chainTarget.IsCode(CardId.DiabellstarTheBlackWitch)))
{
selfTarget = chainTarget;
activateFlag = true;
break;
}
}
}
}
......@@ -2022,7 +2045,8 @@ namespace WindBot.Game.AI.Decks
if (!onlyAlbaZoa)
{
List<ClientCard> toDestroyMonsterList = Enemy.GetMonsters().Where(card => card.IsFaceup()
&& card.Attack > 0 && card.Attack <= targetAttack && !currentDestroyCardList.Contains(card)).ToList();
&& card.Attack > 0 && card.Attack <= targetAttack && !currentDestroyCardList.Contains(card)
&& (Duel.Player == 1 || card != Enemy.BattlingMonster)).ToList();
if (toDestroyMonsterList.Count() > 1)
{
activateFlag = true;
......@@ -2031,7 +2055,13 @@ namespace WindBot.Game.AI.Decks
}
// decrease attack
if (Bot.UnderAttack && !onlyAlbaZoa && (Bot.BattlingMonster?.GetDefensePower() ?? 0) <= (Enemy.BattlingMonster?.GetDefensePower() ?? 0))
int botWorstPower = Util.GetWorstBotMonster()?.GetDefensePower() ?? 0;
bool decreaseFlag = Duel.Player == 1 && Enemy.GetMonsters().Any(card => card.Attack >= botWorstPower
&& card.IsMonsterHasPreventActivationEffectInBattle()) && Duel.Phase > DuelPhase.Main1 && Duel.Phase < DuelPhase.Main2;
decreaseFlag |= (!onlyAlbaZoa || (Bot.BattlingMonster?.IsCode(CardId.DogmatikaAlbaZoa) ?? false))
&& (Bot.BattlingMonster?.GetDefensePower() ?? 0) <= (Enemy.BattlingMonster?.GetDefensePower() ?? 0)
&& Duel.LastChainPlayer != 0 && (CurrentTiming & hintDamageStep) != 0 && CurrentTiming > 0;
if (decreaseFlag)
{
activateFlag = true;
}
......@@ -2425,7 +2455,7 @@ namespace WindBot.Game.AI.Decks
if (targetCard == null || extraToDiscard == null)
{
bool check1 = DefaultOnBecomeTarget();
bool check2 = Bot.UnderAttack && (Bot.BattlingMonster?.GetDefensePower() ?? 0) <= (Enemy.BattlingMonster?.GetDefensePower() ?? 0);
bool check2 = Bot.UnderAttack && (Bot.BattlingMonster?.GetDefensePower() ?? 0) <= (Enemy.BattlingMonster?.GetDefensePower() ?? 0) && Duel.LastChainPlayer != 0;;
bool check3 = Duel.Player == 1 && Duel.Phase == DuelPhase.End && Duel.LastChainPlayer != 0;
bool check4 = Duel.Player == 1 && avoid2Monster && Enemy.GetMonsterCount() >= 2 && Duel.LastChainPlayer != 0;
Logger.DebugWriteLine("===punishment check flag: " + check1 + " " + check2 + " " + check3 + " " + check4);
......@@ -2820,7 +2850,7 @@ namespace WindBot.Game.AI.Decks
if (Card.IsAttack() && enemyBetter)
return true;
if (Card.IsDefense() && !enemyBetter && selfAttack >= Card.Defense)
if (Card.IsDefense() && !enemyBetter)
return true;
return false;
}
......
......@@ -629,25 +629,42 @@ namespace WindBot.Game.AI.Decks
/// <param name="avoidList">Whether need to avoid set in this place</param>
public void SelectSTPlace(ClientCard card = null, bool avoidImpermanence = false, List<int> avoidList = null)
{
List<int> list = new List<int> { 0, 1, 2, 3, 4 };
if (card == null) card = Card;
List<int> list = new List<int>();
for (int seq = 0; seq < 5; ++seq)
{
if (Bot.SpellZone[seq] == null)
{
if (card != null && card.Location == CardLocation.Hand && avoidImpermanence && infiniteImpermanenceList.Contains(seq)) continue;
if (avoidList != null && avoidList.Contains(seq)) continue;
list.Add(seq);
}
}
int n = list.Count;
while (n-- > 1)
{
int index = Program.Rand.Next(n + 1);
int temp = list[index];
list[index] = list[n];
list[n] = temp;
int index = Program.Rand.Next(list.Count);
int nextIndex = (index + Program.Rand.Next(list.Count - 1)) % list.Count;
int tempInt = list[index];
list[index] = list[nextIndex];
list[nextIndex] = tempInt;
}
foreach (int seq in list)
if (avoidImpermanence && Bot.GetMonsters().Any(c => c.IsFaceup() && !c.IsDisabled()))
{
int zone = (int)System.Math.Pow(2, seq);
if (Bot.SpellZone[seq] == null)
foreach (int seq in list)
{
if (card != null && card.Location == CardLocation.Hand && avoidImpermanence && infiniteImpermanenceList.Contains(seq)) continue;
if (avoidList != null && avoidList.Contains(seq)) continue;
ClientCard enemySpell = Enemy.SpellZone[4 - seq];
if (enemySpell != null && enemySpell.IsFacedown()) continue;
int zone = (int)System.Math.Pow(2, seq);
AI.SelectPlace(zone);
return;
};
}
}
foreach (int seq in list)
{
int zone = (int)System.Math.Pow(2, seq);
AI.SelectPlace(zone);
return;
}
AI.SelectPlace(0);
}
......@@ -816,6 +833,7 @@ namespace WindBot.Game.AI.Decks
public override void OnNewTurn()
{
if (Duel.Turn <= 1) calledbytheGraveCount.Clear();
enemyActivateMaxxC = false;
enemyActivateLockBird = false;
infiniteImpermanenceList.Clear();
......
This source diff could not be displayed because it is too large. You can view the blob instead.
using YGOSharp.OCGWrapper;
using YGOSharp.OCGWrapper.Enums;
using System.Collections.Generic;
using System.Linq;
using System;
using WindBot;
using WindBot.Game;
using WindBot.Game.AI;
namespace WindBot.Game.AI.Decks
{
[Deck("SuperheavySamurai", "AI_SuperheavySamurai")]
public class SuperheavySamuraiExecutor : DefaultExecutor
{
public class CardId
{
public const int Benkei = 19510093;//弁庆
public const int Wagon = 34496660;//大八
public const int Soulpiercer = 90361010;//岩融
public const int Wakaushi = 82112494;//牛若
public const int Scales = 78391364;//天秤
public const int Booster = 56727340;//地铠
public const int Motorbike = 83334932;//摩托
public const int Soulhorns = 14624296;//双角
public const int Soulpeacemaker = 95500396;//仲裁
public const int Regulus = 10604644;//轩辕十四
public const int MaxxG = 23434538;//增殖的G
public const int JoyousSpring = 14558127;//灰流丽
public const int PsyFrameDriver = 49036338;//PSY骨架驱动者
public const int PsyFramegearGamma = 38814750;//PSY骨架装备·γ
public const int EffectVeiler = 97268402;//效果遮蒙者
public const int HauntedMansion = 73642296;//屋敷童
public const int SnowRabbit = 59438930;//幽鬼兔
public const int LockBird = 94145021;//小丑与锁鸟
//extra
public const int Masurawo = 64193046;//益荒男
public const int Fleur = 84815190;//鲜花女男爵
public const int ASStardustDragon = 30983281;//加速同调星尘龙
public const int StardustDragon = 30983281;//星尘龙
public const int SavageDragon = 27548199;//狞猛龙
public const int Sarutobi = 76471944;//猿飞
public const int PSYFramelordOmega = 74586817;//PSY骨架王·Ω
public const int GearGigant = 28912357;//齿轮齿巨人
public const int Unicorn = 38342335;//独角兽
public const int Elf = 27381364;//卫星闪灵·淘气精灵
public const int Genius = 22423493;//路径灵
public const int IP = 65741786;//I:P伪装舞会莱娜
public const int Scarecrow = 33918636;//案山子
}
private bool normal_summon = false;
private bool p_summoned = false;
private bool p_summoning = false;
private bool activate_Motorbike = false;//摩托
private bool activate_Wakaushi = false;//神童
private bool activate_Scales = false;//天秤
private bool activate_Wagon = false;//大巴
private bool activate_Booster = false;//地铠
private bool activate_Soulpeacemaker = false;//仲裁
private bool activate_Benkei = false;//弁庆
private bool need_Gear = false;//齿轮齿巨人
//案山子
private bool activate_Scarecrow=false;
private bool summon_Scarecrow=false;
private bool activate_Sarutobi = false;//猿飞
private bool activate_Genius = false;//路径灵
//淘气精灵
private bool activate_Elf = false;
private bool summon_Elf = false;
//手坑
private bool activate_MaxxG = false;//增殖的G
private bool activate_PSY = false;//PSY
private bool activate_LockBird = false;//小丑与锁鸟
private bool to_deck = false;
public SuperheavySamuraiExecutor(GameAI ai, Duel duel)
: base(ai, duel)
{
AddExecutor(ExecutorType.Activate, CardId.PSYFramelordOmega);
AddExecutor(ExecutorType.Activate, CardId.IP,IPFunction);
AddExecutor(ExecutorType.Activate, CardId.Sarutobi,SarutobiFunction);
AddExecutor(ExecutorType.Activate, CardId.Unicorn,UnicornFunction);
AddExecutor(ExecutorType.Activate, CardId.MaxxG,MaxxCFunction);
AddExecutor(ExecutorType.Activate, CardId.JoyousSpring,DefaultAshBlossomAndJoyousSpring);
AddExecutor(ExecutorType.Activate, CardId.SnowRabbit,DefaultGhostOgreAndSnowRabbit);
AddExecutor(ExecutorType.Activate, CardId.EffectVeiler,DefaultBreakthroughSkill);
AddExecutor(ExecutorType.Activate, CardId.LockBird,LockBirdFunction);
AddExecutor(ExecutorType.Activate, CardId.PsyFramegearGamma,FunctionInHand);
AddExecutor(ExecutorType.Activate, CardId.HauntedMansion,FunctionInHand);
AddExecutor(ExecutorType.Activate, CardId.Masurawo,MasurawoFunction);
AddExecutor(ExecutorType.Activate, CardId.Genius,GeniusFunction);
//Motorbike's Effect
AddExecutor(ExecutorType.Activate, CardId.Motorbike,MotorbikeFunction);
//Scales's Effect
AddExecutor(ExecutorType.SpSummon, CardId.Scales);
AddExecutor(ExecutorType.Activate, CardId.Scales,ScalesFunction);
//Synchron
AddExecutor(ExecutorType.SpSummon, CardId.ASStardustDragon,ASStardustDragonSynchronFunction2);
AddExecutor(ExecutorType.SpSummon, CardId.Fleur,FleurSynchronFunction2);
AddExecutor(ExecutorType.Activate, CardId.Wakaushi,WakaushiFunction);
AddExecutor(ExecutorType.Activate, CardId.Wakaushi,WakaushiEffectFunction);
AddExecutor(ExecutorType.Activate, CardId.Benkei,BenkeiEffectFunction);
//Normal Summon & Effect
AddExecutor(ExecutorType.Summon, CardId.Soulpiercer,NormalSummonFunction);
AddExecutor(ExecutorType.Activate, CardId.Soulpiercer,SoulpiercerFunction);
AddExecutor(ExecutorType.Summon, CardId.Wagon,NormalSummonFunction);
AddExecutor(ExecutorType.Activate, CardId.Wagon,WagonFunction);
AddExecutor(ExecutorType.Activate, CardId.Wagon,WagonFunction);
AddExecutor(ExecutorType.Summon, CardId.Booster,BoosterNormalSummonFunction);
AddExecutor(ExecutorType.Summon, CardId.Scales,ScalesNormalSummonFunction);
//boost & Gear
AddExecutor(ExecutorType.Activate, CardId.Booster,BoosterEquipFunction);
AddExecutor(ExecutorType.Activate, CardId.Booster,BoosterFunction);
AddExecutor(ExecutorType.SpSummon, CardId.GearGigant,GearGigantXyzFunction);
AddExecutor(ExecutorType.Activate, CardId.GearGigant,GearGigantFunction);
//equip Soulpiercer
AddExecutor(ExecutorType.Activate, CardId.Soulpiercer,SoulpiercerEquipFunction);
//Link Scarecrow
AddExecutor(ExecutorType.SpSummon, CardId.Scarecrow,ScarecrowLinkFunction);
AddExecutor(ExecutorType.Activate, CardId.Scarecrow,ScarecrowFunction);
//Synchron
AddExecutor(ExecutorType.SpSummon, CardId.ASStardustDragon,ASStardustDragonSynchronFunction);
//Effect After Synchron
AddExecutor(ExecutorType.Activate, CardId.SavageDragon,SavageDragonFunction);
AddExecutor(ExecutorType.Activate, CardId.ASStardustDragon,ASStardustDragonFunction);
//Wakaushi's Effect After Synchron
AddExecutor(ExecutorType.Activate, CardId.Wakaushi,WakaushiReturnPFunction);
//Synchron
AddExecutor(ExecutorType.SpSummon, CardId.Fleur,FleurSynchronFunction);
AddExecutor(ExecutorType.Activate, CardId.Fleur,FleurFunction);
//equip Soulpeacemaker
AddExecutor(ExecutorType.Activate, CardId.Soulpeacemaker,SoulpeacemakerEquipFunction);
AddExecutor(ExecutorType.Activate, CardId.Soulpeacemaker,SoulpeacemakerFunction);
//Link
AddExecutor(ExecutorType.SpSummon, CardId.Genius,GeniusLinkFunction);
AddExecutor(ExecutorType.SpSummon, Psummon);
//Link
AddExecutor(ExecutorType.SpSummon, CardId.Elf,ElfLinkFunction);
AddExecutor(ExecutorType.Activate, CardId.Elf,ElfFunction);
AddExecutor(ExecutorType.Activate, CardId.Motorbike,MotorbikeFunction);
//Regulus's Effect
AddExecutor(ExecutorType.Activate, CardId.Regulus,RegulusFunction);
//Synchron
AddExecutor(ExecutorType.SpSummon, CardId.SavageDragon,SavageDragonSynchronFunction);
//Link
AddExecutor(ExecutorType.SpSummon, CardId.IP,IPLinkFunction);
//Synchron
AddExecutor(ExecutorType.SpSummon, CardId.Masurawo,MasurawoSynchronFunction);
AddExecutor(ExecutorType.SpSummon, CardId.Sarutobi,DeSynchronFunction);
AddExecutor(ExecutorType.SpSummon, CardId.PSYFramelordOmega);
//equip Soulhorns
AddExecutor(ExecutorType.Activate, CardId.Soulhorns,SoulhornsEquipFunction);
//booster
AddExecutor(ExecutorType.Activate, CardId.Booster,BoosterEquipFunction2);
AddExecutor(ExecutorType.Activate, CardId.Booster,BoosterFunction);
}
public override void OnNewTurn()
{
normal_summon = false;
p_summoned = false;
p_summoning = false;
activate_Motorbike = false;
activate_Wakaushi = false;
activate_Scales = false;
activate_Wagon = false;
activate_Booster = false;
activate_Soulpeacemaker = false;
activate_Benkei = false;
need_Gear = false;
activate_Scarecrow=false;
summon_Scarecrow=false;
activate_Elf = false;
summon_Elf = false;
activate_MaxxG = false;
activate_PSY = false;
activate_LockBird = false;
activate_Genius = false;
activate_Sarutobi = false;
to_deck = false;
}
public override bool OnSelectHand()
{
return true;
}
public override int OnSelectPlace(int cardId, int player, CardLocation location, int available)
{
if (player == 0 && location == CardLocation.MonsterZone)
{
if (cardId == CardId.Scarecrow)
{
int a=(Zones.z6 & available);
int b=(Zones.z5 & available);
if (Bot.MonsterZone[2] != null && Bot.MonsterZone[2].Controller == 0 && !FinalCards(Bot.MonsterZone[2].Id))
a = 0;
else if (Bot.MonsterZone[0] != null && Bot.MonsterZone[0].Controller == 0 && !FinalCards(Bot.MonsterZone[0].Id))
b = 0;
if (b > 0) return Zones.z5;
if (a > 0) return Zones.z6;
}
else if (cardId == CardId.Unicorn || cardId == CardId.Elf || cardId == CardId.IP)
{
if ((Zones.z6 & available) > 0) return Zones.z6;
if ((Zones.z5 & available) > 0) return Zones.z5;
}
else if (cardId == CardId.Genius)
{
int a=(Zones.z6 & available);
int b=(Zones.z5 & available);
if (Bot.MonsterZone[4] != null && Bot.MonsterZone[4].Controller == 0 && !FinalCards(Bot.MonsterZone[4].Id))
a = 0;
else if (Bot.MonsterZone[0] != null && Bot.MonsterZone[0].Controller == 0 && !FinalCards(Bot.MonsterZone[0].Id))
b = 0;
if (a > 0) return Zones.z6;
if (b > 0) return Zones.z5;
}
else if (cardId == CardId.Regulus || cardId == CardId.GearGigant)
{
if ((Zones.z3 & available) > 0) return Zones.z3;
}
else
{
if ((Zones.z1 & available) > 0) return Zones.z1;
if ((Zones.z4 & available) > 0) return Zones.z4;
if ((Zones.z2 & available) > 0) return Zones.z2;
if ((Zones.z3 & available) > 0) return Zones.z3;
if ((Zones.z0 & available) > 0) return Zones.z0;
}
}
return base.OnSelectPlace(cardId, player, location, available);
}
public override IList<ClientCard> OnSelectCard(IList<ClientCard> cards, int min, int max, int hint, bool cancelable)
{
if (AI.HaveSelectedCards()) return null;
if (p_summoning || ((Card == Bot.SpellZone[0] || Card == Bot.SpellZone[4]) && hint == HintMsg.SpSummon &&
Card.HasType(CardType.Pendulum)))
{
List<ClientCard> result = new List<ClientCard>();
List<ClientCard> scards = cards.Where(card => card != null && card.HasSetcode(0x9a) && card.Level == 4).ToList();
if (scards.Count <2) scards = cards.Where(card => card != null && card.HasSetcode(0x9a)).ToList();
p_summoning = false;
if (scards.Count > 0) return Util.CheckSelectCount(result, scards, 1, 1);
else if (min == 0) return result; // empty
}
return base.OnSelectCard(cards, min, max, hint, cancelable);
}
private List<ClientCard> GetZoneCards(CardLocation loc, ClientField player)
{
List<ClientCard> res = new List<ClientCard>();
List<ClientCard> temp = new List<ClientCard>();
if ((loc & CardLocation.Hand) > 0) { temp = player.Hand.Where(card => card != null).ToList(); if (temp.Count() > 0) res.AddRange(temp); }
if ((loc & CardLocation.MonsterZone) > 0) { temp = player.GetMonsters(); if (temp.Count() > 0) res.AddRange(temp); }
if ((loc & CardLocation.SpellZone) > 0) { temp = player.GetSpells(); if (temp.Count() > 0) res.AddRange(temp); }
if ((loc & CardLocation.Grave) > 0) { temp = player.Graveyard.Where(card => card != null).ToList(); if (temp.Count() > 0) res.AddRange(temp); }
if ((loc & CardLocation.Removed) > 0) { temp = player.Banished.Where(card => card != null).ToList(); if (temp.Count() > 0) res.AddRange(temp); }
if ((loc & CardLocation.Extra) > 0) { temp = player.ExtraDeck.Where(card => card != null).ToList(); if (temp.Count() > 0) res.AddRange(temp); }
return res;
}
private bool FinalCards(int cname)
{
int[] cardsname = new[] {CardId.Masurawo,CardId.Fleur,CardId.SavageDragon,CardId.Sarutobi,CardId.Regulus,CardId.IP};
foreach(var cardname in cardsname)
{
if (cname == cardname) return true;
}
return false;
}
private bool TurnerCards(int cname)
{
int[] cardsname =new[] {CardId.PsyFramegearGamma,CardId.Wakaushi,CardId.Motorbike};
foreach(var cardname in cardsname)
{
if (cname == cardname) return true;
}
return false;
}
private bool Psummon()
{
List<ClientCard> cards = GetZoneCards(CardLocation.Hand, Bot).Where(card => card != null && card.HasSetcode(0x9a) && card.Level > 1 && card.Level < 8).ToList();
if (cards.Count > 0 && Card.Location == CardLocation.SpellZone)
{
p_summoning = true;
p_summoned = true;
return true;
}
return false;
}
private bool MaxxCFunction()
{
activate_MaxxG = true;
return DefaultMaxxC() && !activate_LockBird;
}
private bool FunctionInHand()
{
return Duel.LastChainPlayer == 1;
}
private bool LockBirdFunction()
{
if (Duel.Player == 0)
{
return false;
}
activate_LockBird = true;
return !activate_MaxxG;
}
private bool MotorbikeFunction()
{
if (Card.Location == CardLocation.Hand)
{
int targetid = -1;
if (!(Bot.HasInHand(CardId.Wakaushi)||Bot.HasInMonstersZone(CardId.Wakaushi)||Bot.HasInSpellZone(CardId.Wakaushi))&&!activate_Wakaushi)
{
targetid = CardId.Wakaushi;
}
else if (!Bot.HasInHand(CardId.Soulpeacemaker) && !activate_Soulpeacemaker && !normal_summon)
{
targetid = CardId.Soulpeacemaker;
}
else
{
targetid = CardId.Soulpiercer;
}
if (targetid > 0) AI.SelectCard(targetid);
activate_Motorbike = true;
return true;
}
else if (Card.Location == CardLocation.MonsterZone && activate_Elf)
{
AI.SelectCard(Card);
activate_Elf = false;
return true;
}
return false;
}
private bool BoosterNormalSummonFunction()
{
List<ClientCard> cards = Bot.Hand.GetMonsters().Where(card => card != null && card.Id == CardId.Booster).ToList();
return (NormalSummonFunction() && !activate_Booster && cards.Count >= 2);
}
private bool ScalesNormalSummonFunction()
{
return (NormalSummonFunction() && (Bot.HasInGraveyard(new[] {
CardId.Soulpiercer,
CardId.Motorbike,
CardId.Wakaushi,
CardId.Wagon,
CardId.Booster,
}) || (Bot.HasInHand(CardId.Booster) && !activate_Booster)));
}
private bool NormalSummonFunction()
{
normal_summon = true;
return DefaultMonsterSummon();
}
private bool ScalesFunction()
{
AI.SelectCard(new[] {
CardId.Soulpiercer,
CardId.Motorbike,
CardId.Wakaushi,
CardId.Wagon,
CardId.Booster,
});
activate_Scales = true;
return true;
}
private bool WagonFunction()
{
if (ActivateDescription == Util.GetStringId(CardId.Wagon, 0))
return Card.IsAttack();
if (ActivateDescription == Util.GetStringId(CardId.Wagon, 1))
{
int targetid = -1;
if (!(Bot.HasInHand(CardId.Soulpiercer)||Bot.HasInMonstersZone(CardId.Soulpiercer)))
{
targetid = CardId.Soulpiercer;
}
else if (!Bot.HasInHand(CardId.Soulpeacemaker) && !activate_Soulpeacemaker)
{
targetid = CardId.Soulpeacemaker;
}
else if (!Bot.HasInHand(CardId.Booster) && !activate_Booster)
{
targetid = CardId.Booster;
}
if (targetid > 0) AI.SelectCard(targetid);
activate_Wagon = true;
return true;
}
else
{
return true;
}
}
private bool SoulpiercerFunction()
{
if (Card.Location == CardLocation.Grave)
{
int CardCount = GetZoneCards(CardLocation.Hand, Bot).Count(card => card != null && card.HasSetcode(0x9a) && card.Level >= 2 && card.Level <= 7);
int targetid = -1;
if (!Bot.HasInHand(CardId.Motorbike) && !activate_Motorbike)
{
targetid = CardId.Motorbike;
}
else if (!(Bot.HasInHand(CardId.Wakaushi) || Bot.HasInMonstersZone(CardId.Wakaushi) || Bot.HasInSpellZone(CardId.Wakaushi)) && !activate_Wakaushi)
{
targetid = CardId.Wakaushi;
}
else if (!Bot.HasInHand(CardId.Soulpeacemaker) && !activate_Soulpeacemaker)
{
targetid = CardId.Soulpeacemaker;
}
else if (!Bot.HasInHand(CardId.Scales) && !activate_Scales && (!normal_summon || !p_summoned) && (activate_Soulpeacemaker || (!Bot.HasInHand(CardId.Soulpeacemaker) && !Bot.HasInSpellZone(CardId.Soulpeacemaker))))
{
targetid = CardId.Scales;
}
else if (!Bot.HasInHand(CardId.Wagon) && !activate_Wagon)
{
targetid = CardId.Wagon;
}
else if (CardCount < 2 && !p_summoned)
{
targetid = CardId.Wakaushi;
}
else if (!Bot.HasInHand(CardId.Booster) && !activate_Booster)
{
targetid = CardId.Booster;
}
else if (!Bot.HasInHand(CardId.Soulhorns) && !Bot.HasInSpellZone(CardId.Soulhorns) && (Bot.HasInMonstersZone(CardId.Sarutobi) || Bot.HasInMonstersZone(CardId.Masurawo)))
{
targetid = CardId.Soulhorns;
}
else {targetid = CardId.Wakaushi;}
if (targetid > 0) AI.SelectCard(targetid);
return true;
}
return false;
}
private bool WakaushiFunction()
{
if (Card.Location != CardLocation.Hand||Bot.HasInMonstersZone(CardId.Wakaushi))
return false;
ClientCard l = Util.GetPZone(0, 0);
ClientCard r = Util.GetPZone(0, 1);
if (l == null && r == null)
return true;
if (l == null && r.RScale != Card.LScale)
return true;
if (r == null && l.LScale != Card.RScale)
return true;
return false;
}
private bool WakaushiEffectFunction()
{
if (Card.Location == CardLocation.SpellZone)
{
AI.SelectCard(CardId.Benkei);
activate_Wakaushi = true;
return true;
}
return false;
}
private bool BenkeiEffectFunction()
{
if (Card.Location == CardLocation.SpellZone)
{
int targetid = -1;
if (!(Bot.HasInHand(CardId.Soulpiercer)||Bot.HasInMonstersZone(CardId.Soulpiercer)))
{
targetid = CardId.Soulpiercer;
}
else if (!Bot.HasInHand(CardId.Soulpeacemaker) && !activate_Soulpeacemaker)
{
targetid = CardId.Soulpeacemaker;
}
else if (!Bot.HasInHand(CardId.Booster) && !activate_Booster)
{
targetid = CardId.Booster;
}
if (targetid > 0) AI.SelectCard(targetid);
activate_Benkei = true;
return true;
}
return false;
}
private bool WakaushiReturnPFunction()
{
if (Card.Location == CardLocation.Extra||Card.Location == CardLocation.Removed)
{
ClientCard l = Util.GetPZone(0, 0);
ClientCard r = Util.GetPZone(0, 1);
if (l == null && r == null)
return true;
if (l == null && r.RScale != Card.LScale)
return true;
if (r == null && l.LScale != Card.RScale)
return true;
}
return false;
}
private bool MasurawoFunction()
{
if (ActivateDescription == 96)
{
List<ClientCard> cards = GetZoneCards(CardLocation.SpellZone, Bot).Where(card => card != null && card.HasSetcode(0x9a)).ToList();
if (cards.Count > 0)
{
AI.SelectCard(cards);
return true;
}
else
{
cards = GetZoneCards(CardLocation.MonsterZone, Bot).Where(card => card != null && card.HasSetcode(0x9a) && !FinalCards(card.Id)).ToList();
if (cards.Count > 0)
{
AI.SelectCard(cards);
return true;
}
}
}
return true;
}
private bool MasurawoSynchronFunction()
{
bool chk = true;
if (Bot.HasInMonstersZone(CardId.ASStardustDragon) || Bot.HasInMonstersZone(CardId.Benkei))
chk = false;
var materials_lists = Util.GetSynchroMaterials(Bot.MonsterZone,12,1,1,false,chk,null,
card => { return !FinalCards(card.Id); });
if (materials_lists.Count <= 0) return false;
AI.SelectMaterials(materials_lists[0]);
AI.SelectPosition(CardPosition.FaceUpDefence);
return true;
}
private bool FleurSynchronFunction()
{
bool chk = true;
if (Bot.HasInMonstersZone(CardId.Motorbike) && (Bot.HasInMonstersZone(CardId.ASStardustDragon) || Bot.HasInMonstersZone(CardId.Benkei)))
chk = false;
var materials_lists = Util.GetSynchroMaterials(Bot.MonsterZone,10,1,1,false,chk,null,
card => { return !FinalCards(card.Id); });
if (materials_lists.Count <= 0) return false;
AI.SelectMaterials(materials_lists[0]);
return true;
}
private bool FleurSynchronFunction2()
{
var materials_lists = Util.GetSynchroMaterials(Bot.MonsterZone,10,1,1,false,false,null,
card => { return !FinalCards(card.Id); });
if (materials_lists.Count <= 0) return false;
AI.SelectMaterials(materials_lists[0]);
return true;
}
private bool DeSynchronFunction()
{
AI.SelectPosition(CardPosition.FaceUpDefence);
return true;
}
private bool SavageDragonSynchronFunction()
{
if (Bot.HasInGraveyard(new[] {
CardId.Scarecrow,
CardId.IP,
CardId.Genius,
CardId.Unicorn,
CardId.Elf,
}))
{
return true;
}
return false;
}
private bool ASStardustDragonSynchronFunction()
{
if (Bot.HasInGraveyard(CardId.Motorbike) || Bot.HasInGraveyard(CardId.PsyFramegearGamma))
{
return (Bot.HasInExtra(CardId.Fleur) || Bot.HasInExtra(CardId.Masurawo));
}
return false;
}
private bool ASStardustDragonSynchronFunction2()
{
if (!activate_Scales || !activate_PSY) return false;
if (Bot.HasInGraveyard(CardId.Motorbike) || Bot.HasInGraveyard(CardId.PsyFramegearGamma))
{
return (Bot.HasInExtra(CardId.Fleur) || Bot.HasInExtra(CardId.Masurawo));
}
return false;
}
private bool SavageDragonFunction()
{
if (Duel.LastChainPlayer == 1)
return true;
AI.SelectCard(new[]
{
CardId.Unicorn,
CardId.Genius,
CardId.Elf,
CardId.IP,
CardId.Scarecrow
});
return true;
}
private bool ASStardustDragonFunction()
{
if (Duel.LastChainPlayer == 1 && ActivateDescription == Util.GetStringId(CardId.ASStardustDragon, 0))
{
return true;
}
else if (ActivateDescription == Util.GetStringId(CardId.ASStardustDragon, 0))
{
int targetid = -1;
if (Bot.HasInGraveyard(CardId.Motorbike))
{
targetid = CardId.Motorbike;
}
else if (Bot.HasInGraveyard(CardId.PsyFramegearGamma))
{
targetid = CardId.PsyFramegearGamma;
}
if (targetid > 0) AI.SelectCard(targetid);
if (targetid == CardId.Motorbike && !Bot.HasInExtra(CardId.Fleur) && Bot.HasInExtra(CardId.Masurawo))
activate_Elf = true;
return true;
}
return false;
}
private bool ScarecrowLinkFunction()
{
List<ClientCard> material = new List<ClientCard>();
List<ClientCard> cards = Bot.GetMonstersInExtraZone().Where(card => card != null && card.Id == CardId.Scarecrow).ToList();
if (cards.Count > 0 || summon_Scarecrow || activate_Scarecrow) return false;
int targetid = -1;
if (Bot.MonsterZone[0] != null && Bot.MonsterZone[2] != null) {
if (Bot.MonsterZone[0].Id == CardId.Soulpiercer) material.Add(Bot.MonsterZone[0]);
else if (Bot.MonsterZone[2].Id == CardId.Soulpiercer) material.Add(Bot.MonsterZone[2]);
else if (!FinalCards(Bot.MonsterZone[0].Id) && Bot.MonsterZone[0].HasSetcode(0x9a)) material.Add(Bot.MonsterZone[0]);
else if (!FinalCards(Bot.MonsterZone[2].Id) && Bot.MonsterZone[2].HasSetcode(0x9a)) material.Add(Bot.MonsterZone[2]);
}
else if (Bot.HasInMonstersZone(CardId.Soulpiercer))
{
targetid = CardId.Soulpiercer;
}
else if (Bot.HasInMonstersZone(CardId.Wagon))
{
targetid = CardId.Wagon;
}
if (material.Count > 0) AI.SelectMaterials(material);
else if (targetid > 0) AI.SelectMaterials(targetid);
summon_Scarecrow=true;
return (Bot.HasInGraveyard(new[] {
CardId.Soulpiercer,
CardId.Wakaushi,
CardId.Benkei,
CardId.Wagon,
})||Bot.HasInMonstersZone(new[] {
CardId.Soulpiercer,
CardId.Wagon,
CardId.Wakaushi,
}));
}
private bool DragonRavineField()
{
if (Card.Location == CardLocation.Hand)
return DefaultField();
return false;
}
private bool ScarecrowFunction()
{
int tributeId = -1;
if (Bot.HasInHand(CardId.PsyFrameDriver))
{tributeId = CardId.PsyFrameDriver;}
else if (Bot.HasInHand(CardId.PsyFramegearGamma))
{tributeId = CardId.PsyFramegearGamma;}
else if (Bot.HasInHand(CardId.Benkei))
{tributeId = CardId.Benkei;}
else if (Bot.HasInHand(CardId.HauntedMansion))
{tributeId = CardId.HauntedMansion;}
else if (Bot.HasInHand(CardId.EffectVeiler))
{tributeId = CardId.EffectVeiler;}
else if (Bot.HasInHand(CardId.SnowRabbit))
{tributeId = CardId.SnowRabbit;}
else if (Bot.HasInHand(CardId.JoyousSpring))
{tributeId = CardId.JoyousSpring;}
else if (Bot.HasInHand(CardId.Booster))
{tributeId = CardId.Booster;}
else if (Bot.HasInHand(CardId.Wagon))
{tributeId = CardId.Wagon;}
else if (Bot.HasInHand(CardId.Scales))
{tributeId = CardId.Scales;}
else if (Bot.HasInHand(CardId.LockBird))
{tributeId = CardId.LockBird;}
else if (Bot.HasInHand(CardId.MaxxG))
{tributeId = CardId.MaxxG;}
int needId = -1;
if (Bot.HasInGraveyard(CardId.Soulpiercer))
{
if (Bot.HasInGraveyard(CardId.Scales) && !activate_Scales)
{needId = CardId.Scales;}
else
{needId = CardId.Soulpiercer;}
}
else if (Bot.HasInGraveyard(CardId.Masurawo))
{needId = CardId.Masurawo;}
else if (Bot.HasInGraveyard(CardId.Sarutobi))
{needId = CardId.Sarutobi;}
else if (Bot.HasInMonstersZone(CardId.Soulpiercer))
{
if (Bot.HasInGraveyard(CardId.Wakaushi))
{needId = CardId.Wakaushi;}
if (Bot.HasInGraveyard(CardId.Motorbike))
{needId = CardId.Motorbike;}
}
if (GetZoneCards(CardLocation.Hand, Bot).Count(card => card != null && card.Id == CardId.Scales) + GetZoneCards(CardLocation.Grave, Bot).Count(card => card != null && card.Id == CardId.Scales) + GetZoneCards(CardLocation.Onfield, Bot).Count(card => card != null && card.Id == CardId.Scales) == 2 && GetZoneCards(CardLocation.Hand, Bot).Count(card => card != null && card.Id == CardId.Scales)>=1 && !activate_Scales)
{
tributeId = CardId.Scales;
needId = CardId.Scales;
}
AI.SelectCard(tributeId);
AI.SelectNextCard(needId);
activate_Scarecrow = true;
if (!summon_Scarecrow
&& ((Bot.HasInHand(CardId.Wakaushi) || Bot.HasInSpellZone(CardId.Wakaushi)) && !activate_Wakaushi)
&& (Bot.HasInHand(CardId.Motorbike) && !activate_Motorbike)
&& ((Bot.HasInHand(CardId.Soulpeacemaker) || Bot.HasInSpellZone(CardId.Soulpeacemaker)) && !activate_Soulpeacemaker)
&& (Bot.HasInSpellZone(CardId.Benkei) && !activate_Benkei)
&& (Bot.HasInHand(CardId.Soulpiercer) && !normal_summon)
&& ((Bot.HasInGraveyard(CardId.Scales) || Bot.HasInHand(CardId.Soulpiercer)) && !activate_Scales && !normal_summon)
)
{
activate_Scarecrow = false;
summon_Scarecrow = false;
}
else if (needId != CardId.Soulpiercer)
{
activate_Scarecrow = false;
summon_Scarecrow = false;
}
return true;
}
private bool UnicornFunction()
{
List<ClientCard> Enemycards = GetZoneCards(CardLocation.Onfield,Enemy);
if (Bot.Hand.Count == 0 || Enemycards.Count(card => card != null && !card.IsShouldNotBeTarget()) == 0)
{
if (to_deck) to_deck = false;
return false;
}
int tributeId = -1;
if (Bot.HasInHand(CardId.PsyFrameDriver))
{tributeId = CardId.PsyFrameDriver;}
else if (Bot.HasInHand(CardId.PsyFramegearGamma))
{tributeId = CardId.PsyFramegearGamma;}
else if (Bot.HasInHand(CardId.Benkei))
{tributeId = CardId.Benkei;}
else if (Bot.HasInHand(CardId.HauntedMansion))
{tributeId = CardId.HauntedMansion;}
else if (Bot.HasInHand(CardId.EffectVeiler))
{tributeId = CardId.EffectVeiler;}
else if (Bot.HasInHand(CardId.SnowRabbit))
{tributeId = CardId.SnowRabbit;}
else if (Bot.HasInHand(CardId.JoyousSpring))
{tributeId = CardId.JoyousSpring;}
else if (Bot.HasInHand(CardId.Booster))
{tributeId = CardId.Booster;}
else if (Bot.HasInHand(CardId.Wagon))
{tributeId = CardId.Wagon;}
else if (Bot.HasInHand(CardId.Scales))
{tributeId = CardId.Scales;}
else if (Bot.HasInHand(CardId.LockBird))
{tributeId = CardId.LockBird;}
else if (Bot.HasInHand(CardId.MaxxG))
{tributeId = CardId.MaxxG;}
if (to_deck) to_deck = false;
AI.SelectCard(tributeId);
return true;
}
private bool BoosterEquipFunction()
{
if (Card.Location != CardLocation.Hand || activate_Booster)
return false;
List<ClientCard> ChkCardsHand = Bot.Hand.GetMonsters().ToList();
foreach (var card in ChkCardsHand)
{
if (card.Id == CardId.Motorbike && !activate_Motorbike) return false;
else if (card.Id == CardId.Soulpiercer) return false;
else if (card.Id == CardId.Soulpeacemaker && !activate_Soulpeacemaker) return false;
else if (card.Id == CardId.Wakaushi && !activate_Wakaushi) return false;
else if (card.Id == CardId.Wagon && (!activate_Wagon || !normal_summon)) return false;
else if (card.Id == CardId.Benkei && !activate_Benkei) return false;
}
List<ClientCard> ChkCardsSpell = GetZoneCards(CardLocation.SpellZone,Bot).Where(card => card != null && card.IsFaceup()).ToList();
foreach (var card in ChkCardsSpell)
{
if (card.Id == CardId.Wakaushi && !activate_Wakaushi) return false;
else if (card.Id == CardId.Soulpiercer) return false;
else if (card.Id == CardId.Soulpeacemaker && !activate_Soulpeacemaker) return false;
else if (card.Id == CardId.Wakaushi && !activate_Wakaushi) return false;
else if (card.Id == CardId.Benkei && !activate_Benkei) return false;
}
List<ClientCard> ChkCardsMonster = GetZoneCards(CardLocation.MonsterZone,Bot).Where(card => card != null && card.IsFaceup() && card.Level == 4).ToList();
if (ChkCardsMonster.Count == 0) return false;
foreach (var card in ChkCardsMonster)
{
if (card.Id == CardId.Soulpiercer) return false;
}
List<ClientCard> ChkCardsGrave = GetZoneCards(CardLocation.Grave,Bot).ToList();
foreach (var card in ChkCardsGrave)
{
if (card.Id == CardId.Soulpiercer && (Bot.HasInMonstersZone(CardId.Scarecrow) || Bot.HasInExtra(CardId.Scarecrow))) return false;
else if (card.Level == 4 && card.HasRace(CardRace.Machine) && Bot.HasInHand(CardId.Scales) && !normal_summon) return false;
}
if (Bot.HasInExtra(CardId.IP) && p_summoned) return true;
need_Gear = true;
return true;
}
private bool BoosterEquipFunction2()
{
if (Bot.HasInExtra(CardId.IP) && p_summoned) return true;
return false;
}
private bool BoosterFunction()
{
if (Card.Location == CardLocation.SpellZone)
{
activate_Booster = true;
return true;
}
return false;
}
private bool GearGigantXyzFunction()
{
if (need_Gear)
{
need_Gear = false;
return true;
}
return false;
}
private bool GearGigantFunction()
{
if (Card.Location == CardLocation.MonsterZone)
{
List<ClientCard> ChkCards = GetZoneCards(CardLocation.MonsterZone,Bot).Where(card => card != null && card.IsFaceup() && card.HasSetcode(0x9a)).ToList();
int targetid = -1;
if (!Bot.HasInHand(CardId.Motorbike) && !activate_Motorbike)
{
targetid = CardId.Motorbike;
}
else if (!(Bot.HasInHand(CardId.Wakaushi) || Bot.HasInSpellZone(CardId.Wakaushi)) && !activate_Wakaushi)
{
targetid = CardId.Wakaushi;
}
else if (!Bot.HasInHand(CardId.Soulpiercer) && (!normal_summon || (ChkCards.Count >= 1)))
{
targetid = CardId.Soulpiercer;
}
if (targetid > 0) AI.SelectCard(targetid);
return true;
}
return false;
}
private bool SoulpiercerEquipFunction()
{
if (Card.Location != CardLocation.Hand)
return false;
int tributeId = -1;
if (Bot.HasInMonstersZone(CardId.Wagon))
{tributeId = CardId.Wagon;}
else if (Bot.HasInMonstersZone(CardId.Wakaushi))
{tributeId = CardId.Wakaushi;}
AI.SelectCard(tributeId);
return Bot.HasInMonstersZone(new[] {
CardId.Wakaushi,
CardId.Wagon,
});
}
private bool SoulpeacemakerEquipFunction()
{
if (Card.Location != CardLocation.Hand)
return false;
int tributeId = -1;
if (Bot.HasInMonstersZone(CardId.Scarecrow))
{tributeId = CardId.Scarecrow;}
else if (Bot.HasInMonstersZone(CardId.Soulpiercer))
{tributeId = CardId.Soulpiercer;}
AI.SelectCard(tributeId);
return Bot.HasInMonstersZone(new[] {
CardId.Scarecrow,
CardId.Soulpiercer,
});
}
private bool SoulhornsEquipFunction()
{
if (Card.Location != CardLocation.Hand)
return false;
int tributeId = -1;
if (Bot.HasInMonstersZone(CardId.Masurawo))
{tributeId = CardId.Masurawo;}
else if (Bot.HasInMonstersZone(CardId.Sarutobi))
{tributeId = CardId.Sarutobi;}
AI.SelectCard(tributeId);
return Bot.HasInMonstersZone(new[] {
CardId.Masurawo,
CardId.Sarutobi,
});
}
private bool SoulpeacemakerFunction()
{
if (Card.Location == CardLocation.SpellZone)
{
int tributeId = -1;
if (Bot.HasInMonstersZone(CardId.Soulpiercer))
{tributeId = CardId.Wakaushi;}
else if (Bot.HasInGraveyard(CardId.Soulpiercer)||!activate_Scales)
{tributeId = CardId.Scales;}
else if (!Bot.HasInGraveyard(CardId.Soulpiercer)||activate_Scales)
{tributeId = CardId.Soulpiercer;}
AI.SelectCard(tributeId);
activate_Soulpeacemaker = true;
return true;
}
return false;
}
private bool GeniusLinkFunction()
{
if ((Bot.MonsterZone[4] != null && Bot.MonsterZone[4].Controller == 0 && !FinalCards(Bot.MonsterZone[4].Id)) && (Bot.MonsterZone[0] != null && Bot.MonsterZone[0].Controller == 0 && !FinalCards(Bot.MonsterZone[0].Id)))
return false;
int CardCount = 0;
foreach (ClientCard card in Bot.Hand.GetMonsters())
{
if (card.HasRace(CardRace.Machine) && (card.Level >= 2 && card.Level <= 7))
{CardCount++;}
}
if (CardCount < 2 && !Bot.HasInMonstersZone(CardId.Soulpiercer)){return false;}
if (Bot.HasInHand(CardId.Regulus) || Bot.HasInGraveyard(CardId.Regulus) || Bot.HasInSpellZone(CardId.Regulus) || Bot.HasInMonstersZone(CardId.Regulus)) return false;
bool linkchk = false;
List<ClientCard> materials = new List<ClientCard>();
if (Bot.MonsterZone[6] != null && Bot.MonsterZone[6].Controller == 0 && Bot.MonsterZone[6].Id != CardId.Scarecrow && !FinalCards(Bot.MonsterZone[6].Id))
{
materials.Add(Bot.MonsterZone[6]);
linkchk = true;
}
else if (Bot.MonsterZone[5] != null && Bot.MonsterZone[5].Controller == 0 && Bot.MonsterZone[5].Id != CardId.Scarecrow && !FinalCards(Bot.MonsterZone[6].Id))
{
materials.Add(Bot.MonsterZone[5]);
linkchk = true;
}
List<ClientCard> cards = Bot.GetMonstersInMainZone().Where(card => card != null && card.IsFaceup() && card.HasRace(CardRace.Machine)).ToList();
foreach (var card in cards)
{
if (card == null || FinalCards(card.Id)) continue;
else materials.Add(card);
}
if (materials.Count <=1) return false;
AI.SelectMaterials(materials);
return ((Bot.GetMonstersInExtraZone().Count == 0 || linkchk) && !p_summoned && !activate_Genius);
}
private bool GeniusFunction()
{
if (ActivateDescription == Util.GetStringId(CardId.Genius,1))
{
AI.SelectCard(CardId.Regulus);
activate_Genius = true;
return true;
}
return false;
}
private bool ElfLinkFunction()
{
if (!Bot.HasInGraveyard(CardId.Motorbike)) return false;
List<ClientCard> materials = new List<ClientCard>();
if (Bot.MonsterZone[6] != null && Bot.MonsterZone[6].Controller == 0 && !FinalCards(Bot.MonsterZone[6].Id))
{
materials.Add(Bot.MonsterZone[6]);
}
else if (Bot.MonsterZone[5] != null && Bot.MonsterZone[5].Controller == 0 && !FinalCards(Bot.MonsterZone[5].Id))
{
materials.Add(Bot.MonsterZone[5]);
}
List<ClientCard> TunrerCards = Bot.GetMonstersInMainZone().Where(card => card != null && card.IsFaceup() && TurnerCards(card.Id) && !FinalCards(card.Id)).ToList();
List<ClientCard> UnTunrercards = Bot.GetMonstersInMainZone().Where(card => card != null && card.IsFaceup() && !TurnerCards(card.Id) && !FinalCards(card.Id)).ToList();
if (UnTunrercards.Count == 0) return false;
else if (TunrerCards.Count >= UnTunrercards.Count && UnTunrercards.Count > 0)
{
foreach (var card in TunrerCards)
{
if (card == null) continue;
else if (materials.Count(ccard =>ccard != null && ccard.Id == card.Id) <= 0) materials.Add(card);
}
}
else
{
foreach (var card in UnTunrercards)
{
if (card == null) continue;
else if (materials.Count(ccard =>ccard != null && ccard.Id == card.Id) <= 0) materials.Add(card);
}
}
if (materials.Count <=1) return false;
AI.SelectMaterials(materials);
summon_Elf = true;
return true;
}
private bool ElfFunction()
{
AI.SelectCard(CardId.Motorbike);
AI.SelectPosition(CardPosition.FaceUpDefence);
activate_Elf = true;
return Bot.HasInGraveyard(CardId.Motorbike);
}
private bool RegulusFunction()
{
if (Card.Location == CardLocation.Hand)
{
int tributeId = -1;
if (Bot.HasInGraveyard(CardId.Soulpiercer))
{tributeId = CardId.Soulpiercer;}
else if (Bot.HasInGraveyard(CardId.Motorbike))
{tributeId = CardId.Motorbike;}
AI.SelectCard(tributeId);
activate_Genius = true;
return true;
}
else if (Duel.LastChainPlayer == 1)
{
return true;
}
return false;
}
private bool FleurFunction()
{
if (ActivateDescription == Util.GetStringId(CardId.Fleur, 0))
{
ClientCard card = Util.GetProblematicEnemyMonster(0, true);
if (card != null)
{
AI.SelectCard(card);
return true;
}
card = Util.GetBestEnemySpell(true);
if (card != null)
{
AI.SelectCard(card);
return true;
}
List<ClientCard> cards = GetZoneCards(CardLocation.Onfield, Enemy);
cards = cards.Where(tcard => tcard != null && !tcard.IsShouldNotBeTarget()).ToList();
if (cards.Count <= 0) return false;
AI.SelectCard(cards);
return true;
}
else if (ActivateDescription == Util.GetStringId(CardId.Fleur, 1))
{
return Duel.LastChainPlayer == 1;
}
return false;
}
private bool IPLinkFunction()
{
List<ClientCard> cards = GetZoneCards(CardLocation.MonsterZone,Bot).Where(card => card != null && card.IsFaceup() && card.Id != CardId.Scarecrow && (card.Id != CardId.Elf || (card.Id == CardId.Elf && !summon_Elf)) && !FinalCards(card.Id)).ToList();
if (cards.Count <=1) return false;
AI.SelectMaterials(cards);
return true;
}
private bool IPFunction()
{
if (Duel.LastChainPlayer == 0) return false;
if (Bot.HasInExtra(CardId.Unicorn))
{
List<ClientCard> material = new List<ClientCard>();
List<ClientCard> cards = GetZoneCards(CardLocation.MonsterZone,Bot).Where(card => card != null && card != Card && card.IsFaceup() && !FinalCards(card.Id) && card.Id != CardId.IP && card.Id != CardId.Scarecrow).ToList();
List<ClientCard> Enemycards = GetZoneCards(CardLocation.MonsterZone,Enemy);
if (activate_Sarutobi) Enemycards = GetZoneCards(CardLocation.Onfield,Enemy);
if (Bot.Hand.Count == 0 || Enemycards.Count(card => card != null && !card.IsShouldNotBeTarget()) == 0 || cards.Count == 0) return false;
bool linkchk = false;
foreach (var card in cards)
{
if (card != null && (card.Id != CardId.Elf || (card.Id == CardId.Elf && !summon_Elf)))
{
material.Add(card);
linkchk = true;
break;
}
}
AI.SelectCard(CardId.Unicorn);
material.Insert(0,Card);
AI.SelectMaterials(material);
if (!to_deck) to_deck = true;
return linkchk;
}
return false;
}
private bool SarutobiFunction()
{
List<ClientCard> Enemycards = GetZoneCards(CardLocation.SpellZone,Enemy);
if (Enemycards.Count(card => card != null && !card.IsShouldNotBeTarget()) == 0 || to_deck) return false;
AI.SelectCard(Enemycards);
activate_Sarutobi = true;
return true;
}
}
}
......@@ -700,6 +700,7 @@ namespace WindBot.Game.AI.Decks
public override void OnNewTurn()
{
if (Duel.Turn <= 1) calledbytheGraveCount.Clear();
enemyActivateMaxxC = false;
enemyActivateLockBird = false;
......@@ -780,7 +781,17 @@ namespace WindBot.Game.AI.Decks
/// <param name="avoidList">Whether need to avoid set in this place</param>
public void SelectSTPlace(ClientCard card = null, bool avoidImpermanence = false, List<int> avoidList = null)
{
List<int> list = new List<int> { 0, 1, 2, 3, 4 };
if (card == null) card = Card;
List<int> list = new List<int>();
for (int seq = 0; seq < 5; ++seq)
{
if (Bot.SpellZone[seq] == null)
{
if (card != null && card.Location == CardLocation.Hand && avoidImpermanence && infiniteImpermanenceList.Contains(seq)) continue;
if (avoidList != null && avoidList.Contains(seq)) continue;
list.Add(seq);
}
}
int n = list.Count;
while (n-- > 1)
{
......@@ -790,16 +801,22 @@ namespace WindBot.Game.AI.Decks
list[index] = list[nextIndex];
list[nextIndex] = tempInt;
}
foreach (int seq in list)
if (avoidImpermanence && Bot.GetMonsters().Any(c => c.IsFaceup() && !c.IsDisabled()))
{
int zone = (int)System.Math.Pow(2, seq);
if (Bot.SpellZone[seq] == null)
foreach (int seq in list)
{
if (card != null && card.Location == CardLocation.Hand && avoidImpermanence && infiniteImpermanenceList.Contains(seq)) continue;
if (avoidList != null && avoidList.Contains(seq)) continue;
ClientCard enemySpell = Enemy.SpellZone[4 - seq];
if (enemySpell != null && enemySpell.IsFacedown()) continue;
int zone = (int)System.Math.Pow(2, seq);
AI.SelectPlace(zone);
return;
};
}
}
foreach (int seq in list)
{
int zone = (int)System.Math.Pow(2, seq);
AI.SelectPlace(zone);
return;
}
AI.SelectPlace(0);
}
......
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using WindBot;
using WindBot.Game;
using WindBot.Game.AI;
using System.Linq;
namespace WindBot.Game.AI.Decks
{
......@@ -67,6 +68,7 @@ namespace WindBot.Game.AI.Decks
return 1;
}
List<int> Impermanence_list = new List<int>();
bool NormalSummoned = false;
ClientCard stage_locked = null;
bool pink_ss = false;
......@@ -190,21 +192,39 @@ namespace WindBot.Game.AI.Decks
return false;
}
public int SelectSTPlace()
public int SelectSTPlace(ClientCard card = null, bool avoid_Impermanence = false)
{
List<int> list = new List<int> { 0, 1, 2, 3, 4 };
if (card == null) card = Card;
List<int> list = new List<int>();
for (int seq = 0; seq < 5; ++seq)
{
if (Bot.SpellZone[seq] == null)
{
if (card != null && card.Location == CardLocation.Hand && avoid_Impermanence && Impermanence_list.Contains(seq)) continue;
list.Add(seq);
}
}
int n = list.Count;
while (n-- > 1)
{
int index = Program.Rand.Next(n + 1);
int temp = list[index];
list[index] = list[n];
list[n] = temp;
int index = Program.Rand.Next(list.Count);
int nextIndex = (index + Program.Rand.Next(list.Count - 1)) % list.Count;
int tempInt = list[index];
list[index] = list[nextIndex];
list[nextIndex] = tempInt;
}
foreach(int seq in list)
if (avoid_Impermanence && Bot.GetMonsters().Any(c => c.IsFaceup() && !c.IsDisabled()))
{
int zone = (int)System.Math.Pow(2, seq);
if (Bot.SpellZone[seq] == null) return zone;
foreach (int seq in list)
{
ClientCard enemySpell = Enemy.SpellZone[4 - seq];
if (enemySpell != null && enemySpell.IsFacedown()) continue;
return (int)System.Math.Pow(2, seq);
}
}
foreach (int seq in list)
{
return (int)System.Math.Pow(2, seq);
}
return 0;
}
......@@ -505,7 +525,7 @@ namespace WindBot.Game.AI.Decks
if (selected == null)
return false;
AI.SelectCard(selected);
AI.SelectPlace(SelectSTPlace());
AI.SelectPlace(SelectSTPlace(Card, true));
return true;
}
......@@ -526,13 +546,13 @@ namespace WindBot.Game.AI.Decks
if (self_card.IsCode(CardId.Galaxy))
return false;
}
AI.SelectPlace(SelectSTPlace());
AI.SelectPlace(SelectSTPlace(Card, true));
return true;
}
// activate when more than 2 cards
if (Enemy.GetSpellCount() <= 1)
return false;
AI.SelectPlace(SelectSTPlace());
AI.SelectPlace(SelectSTPlace(Card, true));
return true;
}
......@@ -627,7 +647,7 @@ namespace WindBot.Game.AI.Decks
if (!spell_trap_activate()) return false;
if (Bot.Deck.Count > 15)
{
AI.SelectPlace(SelectSTPlace());
AI.SelectPlace(SelectSTPlace(Card, true));
return true;
}
return false;
......@@ -1003,7 +1023,7 @@ namespace WindBot.Game.AI.Decks
if (!spell_trap_activate()) return false;
if (Duel.Phase <= DuelPhase.Main1 && Ts_reborn())
{
AI.SelectPlace(SelectSTPlace());
AI.SelectPlace(SelectSTPlace(Card, true));
return true;
}
return false;
......@@ -1634,14 +1654,14 @@ namespace WindBot.Game.AI.Decks
{
if (enemy.IsMonsterDangerous())
{
AI.SelectPlace(SelectSTPlace());
AI.SelectPlace(SelectSTPlace(Card, true));
return true;
}
if (enemy.IsFaceup() && (enemy.GetDefensePower() > bestenemy)) bestenemy = enemy.GetDefensePower();
}
if (bestPower <= bestenemy)
{
AI.SelectPlace(SelectSTPlace());
AI.SelectPlace(SelectSTPlace(Card, true));
return true;
}
}
......@@ -1697,6 +1717,11 @@ namespace WindBot.Game.AI.Decks
public override void OnNewTurn()
{
if (Duel.Turn <= 1)
{
GraveCall_count = 0;
GraveCall_id = 0;
}
NormalSummoned = false;
stage_locked = null;
pink_ss = false;
......@@ -1705,6 +1730,7 @@ namespace WindBot.Game.AI.Decks
white_eff_used = false;
lockbird_useful = false;
lockbird_used = false;
Impermanence_list.Clear();
if (GraveCall_count > 0)
{
if (--GraveCall_count <= 0)
......@@ -1714,6 +1740,27 @@ namespace WindBot.Game.AI.Decks
}
}
public override void OnChaining(int player, ClientCard card)
{
if (card == null) return;
if (player == 1)
{
if (card.IsCode(_CardId.InfiniteImpermanence))
{
for (int i = 0; i < 5; ++i)
{
if (Enemy.SpellZone[i] == card)
{
Impermanence_list.Add(4-i);
break;
}
}
}
}
base.OnChaining(player, card);
}
public override BattlePhaseAction OnSelectAttackTarget(ClientCard attacker, IList<ClientCard> defenders)
{
ClientCard lowestattack = null;
......
......@@ -269,6 +269,7 @@ namespace WindBot.Game.AI.Decks
// new turn reset
public override void OnNewTurn()
{
if (Duel.Turn <= 1) CalledbytheGraveCount.Clear();
CrossoutDesignatorTarget = 0;
MadameVerreGainedATK = false;
summoned = false;
......@@ -858,27 +859,44 @@ namespace WindBot.Game.AI.Decks
/// <param name="card">Card to set(default current card)</param>
/// <param name="avoid_Impermanence">Whether need to avoid InfiniteImpermanence</param>
/// <param name="avoid_list">Whether need to avoid set in this place</param>
public void SelectSTPlace(ClientCard card = null, bool avoid_Impermanence = false, List<int> avoid_list=null)
public void SelectSTPlace(ClientCard card = null, bool avoid_Impermanence = false, List<int> avoid_list = null)
{
List<int> list = new List<int> { 0, 1, 2, 3, 4 };
if (card == null) card = Card;
List<int> list = new List<int>();
for (int seq = 0; seq < 5; ++seq)
{
if (Bot.SpellZone[seq] == null)
{
if (card != null && card.Location == CardLocation.Hand && avoid_Impermanence && Impermanence_list.Contains(seq)) continue;
if (avoid_list != null && avoid_list.Contains(seq)) continue;
list.Add(seq);
}
}
int n = list.Count;
while (n-- > 1)
{
int index = Program.Rand.Next(n + 1);
int temp = list[index];
list[index] = list[n];
list[n] = temp;
int index = Program.Rand.Next(list.Count);
int nextIndex = (index + Program.Rand.Next(list.Count - 1)) % list.Count;
int tempInt = list[index];
list[index] = list[nextIndex];
list[nextIndex] = tempInt;
}
foreach (int seq in list)
if (avoid_Impermanence && Bot.GetMonsters().Any(c => c.IsFaceup() && !c.IsDisabled()))
{
int zone = (int)System.Math.Pow(2, seq);
if (Bot.SpellZone[seq] == null)
foreach (int seq in list)
{
if (card != null && card.Location == CardLocation.Hand && avoid_Impermanence && Impermanence_list.Contains(seq)) continue;
if (avoid_list != null && avoid_list.Contains(seq)) continue;
ClientCard enemySpell = Enemy.SpellZone[4 - seq];
if (enemySpell != null && enemySpell.IsFacedown()) continue;
int zone = (int)System.Math.Pow(2, seq);
AI.SelectPlace(zone);
return;
};
}
}
foreach (int seq in list)
{
int zone = (int)System.Math.Pow(2, seq);
AI.SelectPlace(zone);
return;
}
AI.SelectPlace(0);
}
......
......@@ -2115,7 +2115,9 @@ namespace WindBot.Game.AI.Decks
result.AddRange(tRelease);
result.AddRange(nRelease);
}
return Func.CheckSelectCount(Util, result, cards, min, max);
IList<ClientCard> selectResult = Func.CheckSelectCount(Util, result, cards, min, max);
if (selectResult == null) return base.OnSelectCard(cards, min, max, hint, cancelable);
return selectResult;
}
private bool HasInDeck(int id)
{
......
......@@ -125,8 +125,72 @@ namespace WindBot.Game.AI
public const int VaylantzWorld_ShinraBansho = 49568943;
public const int VaylantzWorld_KonigWissen = 75952542;
public const int DivineArsenalAAZEUS_SkyThunder = 90448279;
public const int LightningStorm = 14532163;
public const int BelialMarquisOfDarkness = 33655493;
public const int ChirubiméPrincessOfAutumnLeaves = 87294988;
public const int PerformapalBarokuriboh = 19050066;
public const int LabrynthArchfiend = 48745395;
public const int HarpiesPetDragonFearsomeFireBlast = 4991081;
public const int DynaHeroFurHire = 25123713;
public const int Hieracosphinx = 82260502;
public const int SpeedroidPassinglider = 26420373;
public const int TyrOfTheNordicChampions = 2333365;
public const int ValkyrianKnight = 99348756;
public const int Victoria = 75162696;
public const int MadolcheChouxvalier = 75363626;
public const int LadyOfD = 67511500;
public const int MermailAbysslung = 95466842;
public const int HarpiesPetBabyDragon = 6924874;
public const int HandHoldingGenie = 94535485;
public const int GolemDragon = 9666558;
public const int TwilightRoseKnight = 2986553;
public const int PerformapalThunderhino = 70458081;
public const int MiracleFlipper = 131182;
public const int Decoyroid = 25034083;
public const int AltergeistFifinellag = 12977245;
public const int BatterymanD = 55401221;
public const int Watthopper = 61380658;
public const int EgyptianGodSlime = 42166000;
public const int DinowrestlerChimeraTWrextle = 22900219;
public const int DinowrestlerGigaSpinosavate = 58672736;
public const int ScarredWarrior = 45298492;
public const int SharkFortress = 50449881;
public const int HeroicChampionClaivesolish = 97453744;
public const int GhostrickAlucard = 75367227;
public const int DinowrestlerKingTWrextle = 77967790;
public const int PerformapalMissDirector = 92932860;
public const int AncientWarriorsMasterfulSunMou = 40140448;
public const int AncientWarriorsVirtuousLiuXuan = 40428851;
public const int CommandKnight = 10375182;
public const int HunterOwl = 51962254;
public const int RokketRecharger = 5969957;
public const int EmissaryOfTheOasis = 6103294;
public const int Zuttomozaurus = 24454387;
public const int Otoshidamashi = 14957440;
public const int NaturiaMosquito = 17285476;
public const int RescueACEHydrant = 37617348;
public const int MeizenTheBattleNinja = 11825276;
public const int VindikiteRGenex = 73483491;
public const int PrincessCologne = 75574498;
public const int Number48ShadowLich = 1426714;
public const int PhantomToken = 1426715;
public const int DuelLinkDragonTheDuelDragon = 60025883;
public const int DuelDragonToken = 60025884;
public const int SeleneQueenOfTheMasterMagicians = 45819647;
public const int TheWingedDragonofRaSphereMode = 10000080;
public const int RockOfTheVanquisher = 28168628;
public const int SpiralDischarge = 29477860;
public const int GaiaTheDragonChampion = 66889139;
public const int CrusadiaVanguard = 55312487;
public const int GladiatorBeastDomitianus = 33652635;
public const int PatricianOfDarkness = 19153634;
public const int DictatorOfD = 66961194;
public const int NovoxTheSilenforcerDisciple = 25801745;
public const int SilenforcingBarrier = 98477480;
public const int Hinotama = 46130346;
......@@ -135,7 +199,24 @@ namespace WindBot.Game.AI
protected class _Setcode
{
public const int Watt = 0xe;
public const int Speedroid = 0x2016;
public const int EarthboundImmortal = 0x1021;
public const int Naturia = 0x2a;
public const int Nordic = 0x42;
public const int Harpie = 0x64;
public const int Madolche = 0x71;
public const int Ghostrick = 0x8d;
public const int OddEyes = 0x99;
public const int Performapal = 0x9f;
public const int BlueEyes = 0xdd;
public const int FurHire = 0x114;
public const int Altergeist = 0x103;
public const int Crusadia = 0x116;
public const int Endymion = 0x12a;
public const int AncientWarriors = 0x137;
public const int RescueACE = 0x18b;
public const int VanquishSoul = 0x195;
}
protected DefaultExecutor(GameAI ai, Duel duel)
......@@ -151,6 +232,79 @@ namespace WindBot.Game.AI
AddExecutor(ExecutorType.Activate, _CardId.HarpiesFeatherDuster, DefaultHarpiesFeatherDusterFirst);
}
protected int lightningStormOption = -1;
/// <summary>
/// Defined:
/// if monster with code as KEY, other monsters with rules as VALUE won't be targeted for attack.
/// </summary>
protected Dictionary<int, Func<ClientCard, bool>> DefenderProtectRule = new Dictionary<int, Func<ClientCard, bool>> {
{_CardId.BelialMarquisOfDarkness, defender => defender.IsFaceup()},
{_CardId.ChirubiméPrincessOfAutumnLeaves, defender => defender.HasRace(CardRace.Plant)},
{_CardId.PerformapalBarokuriboh, defender => true},
{_CardId.LabrynthArchfiend, defender => defender.HasRace(CardRace.Fiend) && !defender.IsCode(_CardId.LabrynthArchfiend)},
{_CardId.HarpiesPetDragonFearsomeFireBlast, defender => defender.Level <= 6 && defender.HasSetcode(_Setcode.Harpie)},
{_CardId.DynaHeroFurHire, defender => defender.HasSetcode(_Setcode.FurHire)},
{_CardId.Hieracosphinx, defender => defender.IsFacedown()},
{_CardId.SpeedroidPassinglider, defender => defender.HasSetcode(_Setcode.Speedroid)},
{_CardId.TyrOfTheNordicChampions, defender => defender.HasSetcode(_Setcode.Nordic)},
{_CardId.ValkyrianKnight, defender => defender.HasRace(CardRace.Warrior) && !defender.IsCode(_CardId.ValkyrianKnight)},
{_CardId.Victoria, defender => defender.HasRace(CardRace.Fairy)},
{_CardId.MadolcheChouxvalier, defender => defender.HasSetcode(_Setcode.Madolche) && !defender.IsCode(_CardId.MadolcheChouxvalier)},
{_CardId.LadyOfD, defender => defender.HasRace(CardRace.Dragon)},
{_CardId.MermailAbysslung, defender => defender.HasAttribute(CardAttribute.Water)},
{_CardId.HarpiesPetBabyDragon, defender => defender.HasSetcode(_Setcode.Harpie) && !defender.IsCode(_CardId.HarpiesPetBabyDragon)},
{_CardId.HandHoldingGenie, defender => true},
{_CardId.GolemDragon, defender => defender.HasRace(CardRace.Dragon)},
{_CardId.MaraudingCaptain, defender => defender.HasRace(CardRace.Warrior)},
{_CardId.TwilightRoseKnight, defender => defender.HasRace(CardRace.Plant)},
{_CardId.PerformapalThunderhino, defender => defender.HasSetcode(_Setcode.Performapal)},
{_CardId.MiracleFlipper, defender => defender.IsFaceup()},
{_CardId.Decoyroid, defender => defender.IsFaceup()},
{_CardId.DupeFrog, defender => true},
{_CardId.AltergeistFifinellag, defender => defender.HasSetcode(_Setcode.Altergeist)},
{_CardId.BatterymanD, defender => defender.HasRace(CardRace.Thunder) && !defender.IsCode(_CardId.BatterymanD)},
{_CardId.Watthopper, defender => defender.HasSetcode(_Setcode.Watt) && defender.IsFaceup()},
{_CardId.EgyptianGodSlime, defender => true},
{_CardId.DinowrestlerChimeraTWrextle, defender => true},
{_CardId.DinowrestlerGigaSpinosavate, defender => true},
{_CardId.ScarredWarrior, defender => defender.HasRace(CardRace.Warrior) && defender.IsFaceup()},
{_CardId.SharkFortress, defender => true},
{_CardId.HeroicChampionClaivesolish, defender => true},
{_CardId.GhostrickAlucard, defender => defender.HasSetcode(_Setcode.Ghostrick) || defender.IsFacedown()},
{_CardId.MekkKnightCrusadiaAstram, defender => true},
{_CardId.DinowrestlerKingTWrextle, defender => true}
};
/// <summary>
/// Defined:
/// if monster with KEY on field, and meet VALUE(monster, all monster), it cannot be targeted for attack.
/// </summary>
protected Dictionary<int, Func<ClientCard, List<ClientCard>, bool>> DefenderInvisbleRule = new Dictionary<int, Func<ClientCard, List<ClientCard>, bool>> {
{_CardId.UltimayaTzolkin, (defender, list) => list.Any(monster => !monster.Equals(defender) && monster.HasType(CardType.Synchro))},
{_CardId.PerformapalMissDirector, (defender, list) => list.Any(monster => monster.HasSetcode(_Setcode.OddEyes))},
{_CardId.AncientWarriorsMasterfulSunMou, (defender, list) => list.Any(monster => !monster.Equals(defender) && monster.HasSetcode(_Setcode.AncientWarriors))},
{_CardId.AncientWarriorsVirtuousLiuXuan, (defender, list) => list.Any(monster => !monster.Equals(defender) && monster.HasSetcode(_Setcode.AncientWarriors))},
{_CardId.CommandKnight, (defender, list) => list.Any(monster => !monster.Equals(defender))},
{_CardId.HunterOwl, (defender, list) => list.Any(monster => !monster.Equals(defender) && monster.HasAttribute(CardAttribute.Wind))},
{_CardId.RokketRecharger, (defender, list) => list.Any(monster => monster.IsExtraCard() && monster.HasAttribute(CardAttribute.Dark))},
{_CardId.EmissaryOfTheOasis, (defender, list) => list.Any(monster => monster.HasType(CardType.Normal) && monster.Level <= 3)},
{_CardId.Zuttomozaurus, (defender, list) => list.Any(monster => !monster.Equals(defender) && monster.HasRace(CardRace.Dinosaur))},
{_CardId.Otoshidamashi, (defender, list) => list.Any(monster => !monster.HasType(CardType.Tuner))},
{_CardId.NaturiaMosquito, (defender, list) => list.Any(monster => !monster.Equals(defender) && monster.HasSetcode(_Setcode.Naturia))},
{_CardId.RescueACEHydrant, (defender, list) => list.Any(monster => !monster.IsCode(_CardId.RescueACEHydrant) && monster.HasSetcode(_Setcode.RescueACE))},
{_CardId.MeizenTheBattleNinja, (defender, list) => list.Any(monster => monster.IsFacedown())},
{_CardId.VindikiteRGenex, (defender, list) => true},
{_CardId.PrincessCologne, (defender, list) => list.Any(monster => !monster.Equals(defender))},
{_CardId.Number48ShadowLich, (defender, list) => list.Any(monster => monster.IsCode(_CardId.PhantomToken))},
{_CardId.DuelLinkDragonTheDuelDragon, (defender, list) => list.Any(monster => monster.IsCode(_CardId.DuelDragonToken))},
{_CardId.SeleneQueenOfTheMasterMagicians, (defender, list) => list.Any(monster => monster.HasSetcode(_Setcode.Endymion))},
{_CardId.TheWingedDragonofRaSphereMode, (defender, list) => true}
};
/// <summary>
/// Decide which card should the attacker attack.
/// </summary>
......@@ -200,21 +354,16 @@ namespace WindBot.Game.AI
return false;
}
foreach (ClientCard equip in defender.EquipCards)
{
if (equip.IsCode(_CardId.MoonMirrorShield) && !equip.IsDisabled())
{
return false;
}
}
if (defender.EquipCards.Any(equip => equip.IsCode(_CardId.MoonMirrorShield) && !equip.IsDisabled()))
return false;
if (!defender.IsDisabled())
{
if (defender.IsCode(_CardId.MekkKnightCrusadiaAstram) && defender.IsAttack() && attacker.IsSpecialSummoned)
return false;
defender.RealPower += attacker.Attack;
if (defender.IsCode(_CardId.CrystalWingSynchroDragon) && defender.IsAttack() && attacker.Level >= 5)
return false;
defender.RealPower += attacker.Attack;
if (defender.IsCode(_CardId.AllyOfJusticeCatastor) && !attacker.HasAttribute(CardAttribute.Dark))
return false;
......@@ -240,37 +389,68 @@ namespace WindBot.Game.AI
if (attacker.IsMonsterInvincible())
attacker.RealPower = 9999;
if (attacker.EquipCards.Any(equip => equip.IsCode(_CardId.MoonMirrorShield) && !equip.IsDisabled()))
attacker.RealPower = defender.RealPower + 100;
}
foreach (ClientCard equip in attacker.EquipCards)
foreach (ClientCard protecter in Enemy.GetMonsters())
{
if (!protecter.IsDisabled() && protecter != defender)
{
if (equip.IsCode(_CardId.MoonMirrorShield) && !equip.IsDisabled())
Func<ClientCard, bool> defenderRule = card => false;
if (DefenderProtectRule.TryGetValue(protecter.Id, out defenderRule))
{
attacker.RealPower = defender.RealPower + 100;
if (defenderRule(defender)) return false;
}
}
}
if (Enemy.HasInMonstersZone(_CardId.MekkKnightCrusadiaAstram, true) && !(defender).IsCode(_CardId.MekkKnightCrusadiaAstram))
return false;
if (attacker.EquipCards.Any(equip => equip.IsCode(_CardId.MoonMirrorShield) && !equip.IsDisabled()))
attacker.RealPower = defender.RealPower + 100;
if (Enemy.HasInMonstersZone(_CardId.DupeFrog, true) && !(defender).IsCode(_CardId.DupeFrog))
return false;
if (!defender.IsDisabled())
{
Func<ClientCard, List<ClientCard>, bool> defenderRule = (card, monsterList) => false;
if (DefenderInvisbleRule.TryGetValue(defender.Id, out defenderRule))
{
if (defenderRule(defender, Enemy.GetMonsters())) return false;
}
}
if (Enemy.HasInMonstersZone(_CardId.MaraudingCaptain, true) && !defender.IsCode(_CardId.MaraudingCaptain) && defender.Race == (int)CardRace.Warrior)
if (Enemy.GetMonsters().Any(monster => !monster.Equals(defender) && monster.IsCode(_CardId.HamonLordofStrikingThunder) && !monster.IsDisabled() && monster.IsDefense()))
return false;
if (defender.IsCode(_CardId.UltimayaTzolkin) && !defender.IsDisabled() && Enemy.GetMonsters().Any(monster => !monster.Equals(defender) && monster.HasType(CardType.Synchro)))
if (defender.OwnTargets.Any(card => card.IsCode(_CardId.PhantomKnightsFogBlade) && !card.IsDisabled()))
return false;
if (Enemy.GetMonsters().Any(monster => !monster.Equals(defender) && monster.IsCode(_CardId.HamonLordofStrikingThunder) && !monster.IsDisabled() && monster.IsDefense()))
if (defender.HasSetcode(_Setcode.EarthboundImmortal) && !defender.IsDisabled())
return false;
bool attackHighestMonster =
Enemy.HasInMonstersZone(_CardId.RockOfTheVanquisher, true) && Enemy.GetMonsters().Any(card => card.HasSetcode(_Setcode.VanquishSoul)) ||
Enemy.HasInMonstersZone(_CardId.GladiatorBeastDomitianus, true) || Enemy.HasInMonstersZone(_CardId.PatricianOfDarkness) ||
Enemy.HasInMonstersZone(_CardId.DictatorOfD, true) && Enemy.GetMonsters().Any(card => card.HasSetcode(_Setcode.BlueEyes));
if (attackHighestMonster)
{
if (defender.HasPosition(CardPosition.FaceDown))
return false;
if (Enemy.GetMonsters().Any(card => card.IsFaceup() && card.Attack > defender.Attack))
return false;
}
if (defender.OwnTargets.Any(card => card.IsCode(_CardId.PhantomKnightsFogBlade) && !card.IsDisabled()))
if (Enemy.HasInSpellZone(_CardId.SpiralDischarge, true) && Enemy.HasInMonstersZone(_CardId.GaiaTheDragonChampion) && !defender.IsCode(_CardId.GaiaTheDragonChampion))
return false;
if (Enemy.HasInSpellZone(_CardId.CrusadiaVanguard, true) && Enemy.GetMonsters().Any(card => card.HasSetcode(_Setcode.Crusadia) && card.HasType(CardType.Link)) && !defender.HasType(CardType.Link))
return false;
if (defender.IsCode(_CardId.RescueACEHydrant) && !defender.IsDisabled() && Enemy.GetMonsters().Any(monster => monster.HasSetcode(_Setcode.RescueACE) && !monster.IsCode(_CardId.RescueACEHydrant)))
return false;
if (Enemy.HasInSpellZone(_CardId.SilenforcingBarrier, true) && Enemy.HasInMonstersZone(_CardId.NovoxTheSilenforcerDisciple, faceUp: true) && !defender.HasType(CardType.Ritual))
return false;
return true;
}
......@@ -862,6 +1042,8 @@ namespace WindBot.Game.AI
if (Util.ChainContainsCard(destroyAllList)) return true;
if (Enemy.HasInSpellZone(destroyAllOpponentSpellList, true) && Card.Location == CardLocation.SpellZone) return true;
if (lightningStormOption == 0 && Card.Location == CardLocation.MonsterZone && Card.IsAttack()) return true;
if (lightningStormOption == 1 && Card.Location == CardLocation.SpellZone) return true;
// TODO: ChainContainsCard(id, player)
return false;
}
......@@ -957,12 +1139,11 @@ namespace WindBot.Game.AI
bool nontuner = false;
foreach (ClientCard monster in monsters)
{
if (monster.HasType(CardType.Tuner))
tuner = true;
else if (!monster.HasType(CardType.Xyz) && !monster.HasType(CardType.Link))
if (!monster.HasType(CardType.Xyz | CardType.Link))
{
nontuner = true;
levels[monster.Level] = levels[monster.Level] + 1;
if (monster.HasType(CardType.Tuner)) tuner = true;
else nontuner = true;
if (!monster.HasType(CardType.Token)) levels[monster.Level] = levels[monster.Level] + 1;
}
if (monster.IsOneForXyz())
......@@ -993,7 +1174,8 @@ namespace WindBot.Game.AI
}
}
ClientCard lastchaincard = Util.GetLastChainCard();
if (Duel.LastChainPlayer == 1 && lastchaincard != null && !lastchaincard.IsDisabled())
if (Duel.LastChainPlayer == 1 && lastchaincard != null && !lastchaincard.IsDisabled()
&& (lastchaincard.HasType(CardType.Spell | CardType.Trap) || lastchaincard.Location == CardLocation.MonsterZone))
{
if (lastchaincard.HasType(CardType.Ritual))
{
......@@ -1235,7 +1417,7 @@ namespace WindBot.Game.AI
if (Card.Location == CardLocation.Hand)
{
return Bot.BattlingMonster.IsAttack() &&
(((Bot.BattlingMonster.Attack < Enemy.BattlingMonster.Attack) || Bot.BattlingMonster.Attack >= Enemy.LifePoints)
((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)));
}
......@@ -1271,13 +1453,13 @@ namespace WindBot.Game.AI
List<ClientCard> targetList = new List<ClientCard>();
List<ClientCard> floodgateCards = monsters
.Where(card => card?.Data != null && card.IsFloodgate() && card.IsFaceup() && !card.IsShouldNotBeTarget())
.OrderBy(card => card.Attack).ToList();
.OrderByDescending(card => card.Attack).ToList();
List<ClientCard> dangerousCards = monsters
.Where(card => card?.Data != null && card.IsMonsterDangerous() && card.IsFaceup() && !card.IsShouldNotBeTarget())
.OrderBy(card => card.Attack).ToList();
.OrderByDescending(card => card.Attack).ToList();
List<ClientCard> attackOrderedCards = monsters
.Where(card => card?.Data != null && card.HasType(CardType.Monster) && card.IsFaceup() && card.IsShouldNotBeTarget())
.OrderBy(card => card.Attack).ToList();
.OrderByDescending(card => card.Attack).ToList();
targetList.AddRange(floodgateCards);
targetList.AddRange(dangerousCards);
......@@ -1292,6 +1474,16 @@ namespace WindBot.Game.AI
return false;
}
public override void OnReceivingAnnouce(int player, int data)
{
if (player == 1 && data == Util.GetStringId(_CardId.LightningStorm, 0) || data == Util.GetStringId(_CardId.LightningStorm, 1))
{
lightningStormOption = data - Util.GetStringId(_CardId.LightningStorm, 0);
}
base.OnReceivingAnnouce(player, data);
}
private enum CustomMessage
{
InDanger,
......@@ -1315,24 +1507,33 @@ namespace WindBot.Game.AI
base.OnNewTurn();
}
public override void OnMove(int cardId, int previousControler, int previousLocation, int currentControler, int currentLocation)
public override void OnChainEnd()
{
if (previousLocation == 0 && currentLocation == (int)CardLocation.MonsterZone)
{
if (!sendEventMsg2 && event2TriggerIdList.Contains(cardId) && currentControler == 1)
{
AI.SendCustomChat((int)CustomMessage.MSG_FOR_EVENT_2);
sendEventMsg2 = true;
}
lightningStormOption = -1;
base.OnChainEnd();
}
if (!sendEventMsg5 && event5TriggerIdList.Contains(cardId) && currentControler == 0 && Duel.Phase == DuelPhase.Standby)
public override void OnMove(ClientCard card, int previousControler, int previousLocation, int currentControler, int currentLocation)
{
if (card != null) {
int cardId = card.Id;
if (previousLocation == 0 && currentLocation == (int)CardLocation.MonsterZone)
{
AI.SendCustomChat((int)CustomMessage.MSG_FOR_EVENT_5);
sendEventMsg5 = true;
if (!sendEventMsg2 && event2TriggerIdList.Contains(cardId) && currentControler == 1)
{
AI.SendCustomChat((int)CustomMessage.MSG_FOR_EVENT_2);
sendEventMsg2 = true;
}
if (!sendEventMsg5 && event5TriggerIdList.Contains(cardId) && currentControler == 0 && Duel.Phase == DuelPhase.Standby)
{
AI.SendCustomChat((int)CustomMessage.MSG_FOR_EVENT_5);
sendEventMsg5 = true;
}
}
}
base.OnMove(cardId, previousControler, previousLocation, currentControler, currentLocation);
base.OnMove(card, previousControler, previousLocation, currentControler, currentLocation);
}
}
}
......@@ -25,6 +25,7 @@
Heart_eartHDragon = 97403510,
DaigustoSphreeze = 29552709,
OhimetheManifestedMikanko = 81260679,
ArahimetheManifestedMikanko = 75771170
ArahimetheManifestedMikanko = 75771170,
YubelDasEwigLiebeWächter = 47172959
}
}
......@@ -71,6 +71,7 @@
ElShaddollConstruct = 20366274,
ElShaddollGrysra = 48424886,
ElShaddollWinda = 94977269,
HotRedDragonArchfiendAbyss = 9753964,
UltimateConductorTytanno = 18940556,
OvertexCoatls = 41782653,
FirePrison = 269510,
......@@ -210,6 +211,7 @@
TGGlaiveBlaster = 95973569,
StellarNemesisTPHON_DoomsdayStar = 93039339,
SPLittleKnight = 29301450,
AngelRing = 40678060
AngelRing = 40678060,
SkullGuardianTheSilenforcingProtector = 10774240
}
}
......@@ -67,6 +67,7 @@
FaceCardFusion = 29062925,
MyutantFusion = 42577802,
MyutantCry = 31855260,
FallenOfAlbaz = 68468459,
GreaterPolymerization = 7614732,
UltimateFusion = 71143015,
BrandedFusion = 44362883,
......
......@@ -109,6 +109,11 @@
NightmareMagician = 40221691,
ArahimetheManifestedMikanko = 75771170,
UFOLight = 9275482,
TaotheGreatChanter = 34541543
TaotheGreatChanter = 34541543,
SpiritOfYubel = 90829280,
DarkGuardian = 26746975,
EnvoyOfTheWaxState = 87462901,
Fluffyfluff = 85401123,
YubelDasEwigLiebeWächter = 47172959
}
}
......@@ -49,6 +49,8 @@
Blackwing_FullArmoredWing = 54082269,
DragunofRedEyes = 37818794,
RedEyesBDragon = 74677422, // sometimes the name of DragunofRedEyes will be changed to RedEyesBDragon
TheArrivalCyberseIgnister = 11738489
TheArrivalCyberseIgnister = 11738489,
MajespecterPorcupineYamaarashi = 51073802,
RaidraptorRisingRebellionFalcon = 71222868
}
}
......@@ -95,10 +95,21 @@ namespace WindBot.Game.AI
// For overriding
}
public virtual void OnChainSolved(int chainIndex)
{
// For overriding
}
public virtual void OnChainEnd()
{
// For overriding
}
public virtual void OnReceivingAnnouce(int player, int data)
{
// For overriding
}
public virtual void OnNewPhase()
{
// Some AI need do something on new phase
......@@ -113,7 +124,7 @@ namespace WindBot.Game.AI
// Some AI need do something on draw
}
public virtual void OnMove(int cardId, int previousControler, int previousLocation, int currentControler, int currentLocation)
public virtual void OnMove(ClientCard card, int previousControler, int previousLocation, int currentControler, int currentLocation)
{
// Some AI need do something on card's moving
}
......
......@@ -57,6 +57,11 @@
ToZone = 571,
Counter = 572,
Disable = 573,
OperateCard = 574;
OperateCard = 574,
RITUAL = 1057,
FUSION = 1056,
SYNCHRO = 1063,
XYZ = 1073,
PENDULUM = 1074;
}
}
\ No newline at end of file
using System.Collections.Generic;
using System.Collections.Generic;
using YGOSharp.OCGWrapper.Enums;
namespace WindBot.Game
......@@ -26,6 +26,8 @@ namespace WindBot.Game
public int LastSummonPlayer { get; set; }
public IList<ClientCard> SummoningCards { get; set; }
public IList<ClientCard> LastSummonedCards { get; set; }
public int SolvingChainIndex { get; set; }
public IList<int> NegatedChainIndexList { get; set; }
public Duel()
{
......@@ -41,6 +43,8 @@ namespace WindBot.Game
LastSummonPlayer = -1;
SummoningCards = new List<ClientCard>();
LastSummonedCards = new List<ClientCard>();
SolvingChainIndex = 0;
NegatedChainIndexList = new List<int>();
}
public ClientCard GetCard(int player, CardLocation loc, int seq)
......@@ -169,5 +173,16 @@ namespace WindBot.Game
{
return IsFirst ? player : 1 - player;
}
public ClientCard GetCurrentSolvingChainCard()
{
if (SolvingChainIndex == 0 || SolvingChainIndex > CurrentChain.Count) return null;
return CurrentChain[SolvingChainIndex - 1];
}
public bool IsCurrentSolvingChainNegated()
{
return SolvingChainIndex > 0 && NegatedChainIndexList.Contains(SolvingChainIndex);
}
}
}
\ No newline at end of file
......@@ -119,9 +119,9 @@ namespace WindBot.Game
Executor.OnNewPhase();
}
public void OnMove(int cardId, int previousControler, int previousLocation, int currentControler, int currentLocation)
public void OnMove(ClientCard card, int previousControler, int previousLocation, int currentControler, int currentLocation)
{
Executor.OnMove(cardId, previousControler, previousLocation, currentControler, currentLocation);
Executor.OnMove(card, previousControler, previousLocation, currentControler, currentLocation);
}
/// <summary>
......@@ -141,6 +141,11 @@ namespace WindBot.Game
{
Executor.OnChaining(player,card);
}
public void OnChainSolved(int chainIndex)
{
Executor.OnChainSolved(chainIndex);
}
/// <summary>
/// Called when a chain has been solved.
......@@ -152,6 +157,16 @@ namespace WindBot.Game
Executor.OnChainEnd();
}
/// <summary>
/// Called when receiving annouce
/// </summary>
/// <param name="player">Player who announce.</param>
/// <param name="data">Annouced info.</param>
public void OnReceivingAnnouce(int player, int data)
{
Executor.OnReceivingAnnouce(player, data);
}
/// <summary>
/// Called when the AI has to do something during the battle phase.
/// </summary>
......@@ -300,6 +315,8 @@ namespace WindBot.Game
// Always select the first available cards and choose the minimum.
IList<ClientCard> selected = new List<ClientCard>();
if (hint == HintMsg.AttackTarget && cancelable) return selected;
if (cards.Count >= min)
{
for (int i = 0; i < min; ++i)
......
......@@ -109,6 +109,10 @@ namespace WindBot.Game
_messages.Add(GameMessage.AttackDisabled, OnAttackDisabled);
_messages.Add(GameMessage.PosChange, OnPosChange);
_messages.Add(GameMessage.Chaining, OnChaining);
_messages.Add(GameMessage.ChainSolving, OnChainSolving);
_messages.Add(GameMessage.ChainNegated, OnChainNegated);
_messages.Add(GameMessage.ChainDisabled, OnChainDisabled);
_messages.Add(GameMessage.ChainSolved, OnChainSolved);
_messages.Add(GameMessage.ChainEnd, OnChainEnd);
_messages.Add(GameMessage.SortCard, OnCardSorting);
_messages.Add(GameMessage.SortChain, OnChainSorting);
......@@ -343,6 +347,10 @@ namespace WindBot.Game
{
_select_hint = data;
}
if (type == 4) // HINT_OPSELECTED
{
_ai.OnReceivingAnnouce(player, data);
}
}
private void OnStart(BinaryReader packet)
......@@ -350,6 +358,11 @@ namespace WindBot.Game
int type = packet.ReadByte();
_duel.IsFirst = (type & 0xF) == 0;
_duel.Turn = 0;
_duel.LastChainLocation = 0;
_duel.LastChainPlayer = -1;
_duel.LastChainTargets.Clear();
_duel.LastSummonedCards.Clear();
_duel.LastSummonPlayer = -1;
int duel_rule = packet.ReadByte();
_ai.Duel.IsNewRule = (duel_rule >= 4);
_ai.Duel.IsNewRule2020 = (duel_rule >= 5);
......@@ -362,6 +375,19 @@ namespace WindBot.Game
extra = packet.ReadInt16();
_duel.Fields[GetLocalPlayer(1)].Init(deck, extra);
// in case of ending duel in chain's solving
_duel.LastChainPlayer = -1;
_duel.LastChainLocation = 0;
_duel.CurrentChain.Clear();
_duel.ChainTargets.Clear();
_duel.LastChainTargets.Clear();
_duel.ChainTargetOnly.Clear();
_duel.LastSummonPlayer = -1;
_duel.SummoningCards.Clear();
_duel.LastSummonedCards.Clear();
_duel.SolvingChainIndex = 0;
_duel.NegatedChainIndexList.Clear();
Logger.DebugWriteLine("Duel started: " + _room.Names[0] + " versus " + _room.Names[1]);
_ai.OnStart();
}
......@@ -636,7 +662,7 @@ namespace WindBot.Game
}
}
_ai.OnMove(cardId, previousControler, previousLocation, currentControler, currentLocation);
_ai.OnMove(card, previousControler, previousLocation, currentControler, currentLocation);
}
private void OnSwap(BinaryReader packet)
......@@ -742,6 +768,30 @@ namespace WindBot.Game
}
private void OnChainSolving(BinaryReader packet)
{
int chainIndex = packet.ReadByte();
_duel.SolvingChainIndex = chainIndex;
}
private void OnChainNegated(BinaryReader packet)
{
int chainIndex = packet.ReadByte();
_duel.NegatedChainIndexList.Add(chainIndex);
}
private void OnChainDisabled(BinaryReader packet)
{
int chainIndex = packet.ReadByte();
_duel.NegatedChainIndexList.Add(chainIndex);
}
private void OnChainSolved(BinaryReader packet)
{
int chainIndex = packet.ReadByte();
_ai.OnChainSolved(chainIndex);
}
private void OnChainEnd(BinaryReader packet)
{
_ai.OnChainEnd();
......@@ -751,6 +801,8 @@ namespace WindBot.Game
_duel.ChainTargets.Clear();
_duel.LastChainTargets.Clear();
_duel.ChainTargetOnly.Clear();
_duel.SolvingChainIndex = 0;
_duel.NegatedChainIndexList.Clear();
}
private void OnCardSorting(BinaryReader packet)
......@@ -1083,7 +1135,7 @@ namespace WindBot.Game
int count = packet.ReadByte();
packet.ReadByte(); // specount
bool forced = packet.ReadByte() != 0;
packet.ReadInt32(); // hint1
int hint1 = packet.ReadInt32(); // hint1
int hint2 = packet.ReadInt32(); // hint2
IList<ClientCard> cards = new List<ClientCard>();
......@@ -1124,7 +1176,7 @@ namespace WindBot.Game
return;
}
Connection.Send(CtosMessage.Response, _ai.OnSelectChain(cards, descs, forced, hint2));
Connection.Send(CtosMessage.Response, _ai.OnSelectChain(cards, descs, forced, hint1 | hint2));
}
private void OnSelectCounter(BinaryReader packet)
......
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
......@@ -104,10 +104,12 @@
<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\LabrynthExecutor.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\SuperheavySamuraiExecutor.cs" />
<Compile Include="Game\AI\Decks\SwordsoulExecutor.cs" />
<Compile Include="Game\AI\Decks\TrickstarExecutor.cs" />
<Compile Include="Game\AI\Decks\WitchcraftExecutor.cs" />
......@@ -186,4 +188,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
</Project>
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