Commit bdd2c5de authored by nanahira's avatar nanahira

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

parents e6585bbf 94847929
Pipeline #2697 failed with stages
in 26 seconds
......@@ -2,22 +2,32 @@
# !name
# command
# description
# flags (avail flags: SUPPORT_MASTER_RULE_3, SUPPORT_NEW_MASTER_RULE, SUPPORT_MASTER_RULE_2020)
# flags (avail flags: SUPPORT_MASTER_RULE_3, SUPPORT_NEW_MASTER_RULE, SUPPORT_MASTER_RULE_2020, SELECT_DECKFILE)
!随机-非常简单
Random=AI_LV1
主要是一些沙包。
SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
SUPPORT_MASTER_RULE_2020
!随机-简单
Random=AI_LV2
一些比较弱的卡组。
SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
SUPPORT_MASTER_RULE_2020
!随机-普通
Random=AI_LV3
一些环境里可以看到的卡组。
SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
SUPPORT_MASTER_RULE_2020
!随机-报社
Random=AI_ANTI_META
一些报复社会(针对主流卡组的弱点)的卡组。
SUPPORT_MASTER_RULE_2020
!P2-自选卡组
Name=P2 Deck=Lucky Dialog=gugugu.zh-CN
人机卡组由你选择。随缘出牌。可将你的卡组文件(.ydk)复制到WindBot的对应文件夹。
SELECT_DECKFILE SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!谜之剑士LV4-龙骑星爆
Name=谜之剑士LV4 Deck=Dragunity Dialog=swordsman.zh-CN
......@@ -27,12 +37,12 @@ AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!谜之剑士LV4-R5
Name=谜之剑士LV4 Deck='Rank V' Dialog=swordsman.zh-CN
5阶超量卡组。
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020
!谜之剑士LV4-异热同心武器
Name=谜之剑士LV4 Deck='Zexal Weapons' Dialog=swordsman.zh-CN
神装电光皇卡组。
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020
!谜之剑士LV4-8星同调
Name=谜之剑士LV4 Deck='Level VIII' Dialog=swordsman.zh-CN
......@@ -42,7 +52,7 @@ AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!琪露诺-彩虹
Name=琪露诺 Deck=Rainbow Dialog=cirno.zh-CN
全属性凡骨卡组。
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020
!琪露诺-饼蛙
Name=琪露诺 Deck='Toadally Awesome' Dialog=cirno.zh-CN
......@@ -52,7 +62,7 @@ AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020
!复制植物-青眼
Name=复制植物 Deck=Blue-Eyes Dialog=copy.zh-CN
青眼卡组。
AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020
!复制植物-十二兽
Name=复制植物 Deck=Zoodiac Dialog=copy.zh-CN
......
{
"welcome": [
"大家好我是新人",
"游戏王是怎么玩来着?",
"还好我不玩游戏王"
],
"deckerror": [
"卡组里{0}鸽了"
],
"duelstart": [
"不想干活怎么办",
"智商欠费不想干活怎么办"
],
"newturn": [
"好多可怕的新卡啊",
"这游戏好难玩",
"so lazy cant move"
],
"endturn": [
"搞得我只能鸽了",
"不是在此时,不知在何时",
"too hot need ice cream"
],
"directattack": [
"听起来很鸽",
"老鸽,稳"
],
"attack": [
"听起来不是很鸽",
"可怕"
],
"ondirectattack": [
"哇!",
"这么可怕的吗",
"听起来非常鸽",
"承受不住"
],
"facedownmonstername": "鸽子",
"activate": [
"不明觉鸽",
"鸽了,爽"
],
"summon": [
"可怕",
"不关我事",
"那还是不关我事",
"鸽了,爽"
],
"setmonster": [
"摸鱼中,不想更新",
"那还是鸽置吧"
],
"chaining": [
"那是什么",
"但我鸽了",
"无此服务",
"可怕"
]
}
......@@ -11,7 +11,9 @@ namespace WindBot.Game.AI
/// </summary>
public static bool IsMonsterInvincible(this ClientCard card)
{
return !card.IsDisabled() && Enum.IsDefined(typeof(InvincibleMonster), card.Id);
return !card.IsDisabled() &&
(card.Controller == 0 && Enum.IsDefined(typeof(InvincibleBotMonster), card.Id) ||
card.Controller == 1 && Enum.IsDefined(typeof(InvincibleEnemyMonster), card.Id));
}
/// <summary>
......
......@@ -2742,8 +2742,6 @@ namespace WindBot.Game.AI.Decks
public override IList<ClientCard> OnSelectCard(IList<ClientCard> cards, int min, int max, int hint, bool cancelable)
{
int HIINT_TOGRAVE = 504;
if (max == 1 && cards[0].Location == CardLocation.Deck
&& Util.GetLastChainCard() != null && Util.GetLastChainCard().IsCode(23002292) && Bot.GetRemainingCount(CardId.WakingtheDragon,1) > 0)
{
......@@ -2764,7 +2762,7 @@ namespace WindBot.Game.AI.Decks
Logger.DebugWriteLine("EvenlyMatched: min=" + min.ToString() + ", max=" + max.ToString());
}
else if (cards[0].Location == CardLocation.Hand && cards[cards.Count - 1].Location == CardLocation.Hand
&& (hint == 501 || hint == HIINT_TOGRAVE) && min == max)
&& (hint == HintMsg.Discard || hint == HintMsg.ToGrave) && min == max)
{
if (Duel.LastChainPlayer == 0 && Util.GetLastChainCard().IsCode(CardId.OneForOne)) return null;
Logger.DebugWriteLine("Hand drop except OneForOne");
......
using YGOSharp.OCGWrapper.Enums;
using System.Collections.Generic;
using System.Linq;
using WindBot;
using WindBot.Game;
using WindBot.Game.AI;
......@@ -18,7 +19,7 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.SpSummon, ImFeelingUnlucky);
AddExecutor(ExecutorType.Activate, ImFeelingUnlucky);
AddExecutor(ExecutorType.SummonOrSet, DefaultMonsterSummon);
AddExecutor(ExecutorType.SummonOrSet, ImFeelingLazy);
AddExecutor(ExecutorType.SpellSet, DefaultSpellSet);
AddExecutor(ExecutorType.Repos, DefaultMonsterRepos);
......@@ -63,8 +64,31 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.SpSummon, _CardId.EvilswarmExcitonKnight, DefaultEvilswarmExcitonKnightSummon);
AddExecutor(ExecutorType.Activate, _CardId.EvilswarmExcitonKnight, DefaultEvilswarmExcitonKnightEffect);
AddExecutor(ExecutorType.Summon, _CardId.SandaionTheTimelord);
AddExecutor(ExecutorType.Summon, _CardId.GabrionTheTimelord);
AddExecutor(ExecutorType.Summon, _CardId.MichionTheTimelord);
AddExecutor(ExecutorType.Summon, _CardId.ZaphionTheTimelord);
AddExecutor(ExecutorType.Summon, _CardId.HailonTheTimelord);
AddExecutor(ExecutorType.Summon, _CardId.RaphionTheTimelord);
AddExecutor(ExecutorType.Summon, _CardId.SadionTheTimelord);
AddExecutor(ExecutorType.Summon, _CardId.MetaionTheTimelord);
AddExecutor(ExecutorType.Summon, _CardId.KamionTheTimelord);
AddExecutor(ExecutorType.Summon, _CardId.LazionTheTimelord);
AddExecutor(ExecutorType.Summon, _CardId.LeftArmofTheForbiddenOne, JustDontIt);
AddExecutor(ExecutorType.Summon, _CardId.RightLegofTheForbiddenOne, JustDontIt);
AddExecutor(ExecutorType.Summon, _CardId.LeftLegofTheForbiddenOne, JustDontIt);
AddExecutor(ExecutorType.Summon, _CardId.RightArmofTheForbiddenOne, JustDontIt);
AddExecutor(ExecutorType.Summon, _CardId.ExodiaTheForbiddenOne, JustDontIt);
}
private List<int> HintMsgForRemove = new List<int>
{
HintMsg.Release, HintMsg.Destroy, HintMsg.Remove, HintMsg.ToGrave, HintMsg.ReturnToHand, HintMsg.ToDeck,
HintMsg.FusionMaterial, HintMsg.SynchroMaterial, HintMsg.XyzMaterial, HintMsg.LinkMaterial, HintMsg.Disable
};
public override IList<ClientCard> OnSelectCard(IList<ClientCard> _cards, int min, int max, int hint, bool cancelable)
{
if (Duel.Phase == DuelPhase.BattleStart)
......@@ -72,14 +96,27 @@ namespace WindBot.Game.AI.Decks
if (AI.HaveSelectedCards())
return null;
IList<ClientCard> cards = new List<ClientCard>(_cards);
IList<ClientCard> selected = new List<ClientCard>();
IList<ClientCard> cards = new List<ClientCard>(_cards);
if (max > cards.Count)
max = cards.Count;
if (HintMsgForRemove.Contains(hint))
{
IList<ClientCard> enemyCards = cards.Where(card => card.Controller == 1).ToList();
// select enemy's card first
while (enemyCards.Count > 0 && selected.Count < max)
{
ClientCard card = enemyCards[Program.Rand.Next(enemyCards.Count)];
selected.Add(card);
enemyCards.Remove(card);
cards.Remove(card);
}
}
// select random cards
while (selected.Count < max)
while (selected.Count < min)
{
ClientCard card = cards[Program.Rand.Next(cards.Count)];
selected.Add(card);
......@@ -107,12 +144,24 @@ namespace WindBot.Game.AI.Decks
private bool ImFeelingLucky()
{
return Program.Rand.Next(9) >= 6 && DefaultDontChainMyself();
return Program.Rand.Next(10) >= 5 && DefaultDontChainMyself();
}
private bool ImFeelingUnlucky()
{
return DefaultDontChainMyself();
}
private bool ImFeelingLazy()
{
if (Executors.Any(exec => (exec.Type == ExecutorType.SummonOrSet || exec.Type == ExecutorType.Summon || exec.Type == ExecutorType.MonsterSet) && exec.CardId == Card.Id))
return false;
return DefaultMonsterSummon();
}
private bool JustDontIt()
{
return false;
}
}
}
\ No newline at end of file
......@@ -309,8 +309,8 @@ namespace WindBot.Game.AI.Decks
// overwrite OnSelectCard to act normally in SelectUnselect
public override IList<ClientCard> OnSelectCard(IList<ClientCard> cards, int min, int max, int hint, bool cancelable)
{
// Patronus HINTMSG_ATOHAND
if (hint == 506)
// Patronus
if (hint == HintMsg.AddToHand)
{
bool flag = true;
foreach(ClientCard card in cards)
......@@ -334,8 +334,8 @@ namespace WindBot.Game.AI.Decks
return selected;
}
}
// MaxxC HINTMSG_SPSUMMON
if (hint == 509 && enemy_activate_MaxxC)
// MaxxC solution
if (hint == HintMsg.SpSummon && enemy_activate_MaxxC)
{
// check whether SS from deck while using effect
bool flag = true;
......@@ -392,8 +392,8 @@ namespace WindBot.Game.AI.Decks
}
}
}
// MadameVerre HINTMSG_CONFIRM
if (hint == 526)
// MadameVerre
if (hint == HintMsg.Confirm)
{
Logger.DebugWriteLine("** min-max: " + min.ToString() + " / " + max.ToString());
foreach (ClientCard card in cards)
......
......@@ -21,6 +21,23 @@ namespace WindBot.Game.AI
public const int GamecieltheSeaTurtleKaiju = 55063751;
public const int SuperAntiKaijuWarMachineMechaDogoran = 84769941;
public const int SandaionTheTimelord = 33015627;
public const int GabrionTheTimelord = 6616912;
public const int MichionTheTimelord = 7733560;
public const int ZaphionTheTimelord = 28929131;
public const int HailonTheTimelord = 34137269;
public const int RaphionTheTimelord = 60222213;
public const int SadionTheTimelord = 65314286;
public const int MetaionTheTimelord = 74530899;
public const int KamionTheTimelord = 91712985;
public const int LazionTheTimelord = 92435533;
public const int LeftArmofTheForbiddenOne = 7902349;
public const int RightLegofTheForbiddenOne = 8124921;
public const int LeftLegofTheForbiddenOne = 44519536;
public const int RightArmofTheForbiddenOne = 70903634;
public const int ExodiaTheForbiddenOne = 33396948;
public const int UltimateConductorTytanno = 18940556;
public const int ElShaddollConstruct = 20366274;
public const int AllyOfJusticeCatastor = 26593852;
......@@ -99,6 +116,7 @@ namespace WindBot.Game.AI
public const int RedDragonArchfiend = 70902743;
public const int ImperialOrder = 61740673;
public const int RoyalDecreel = 51452091;
public const int NaturiaBeast = 33198837;
public const int AntiSpellFragrance = 58921041;
......@@ -146,9 +164,6 @@ namespace WindBot.Game.AI
/// <returns>false if the attack shouldn't be done.</returns>
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
{
if (attacker.RealPower <= 0)
return false;
if (!attacker.IsMonsterHasPreventActivationEffectInBattle())
{
if (defender.IsMonsterInvincible() && defender.IsDefense())
......@@ -199,6 +214,12 @@ namespace WindBot.Game.AI
if (attacker.IsCode(_CardId.NumberS39UtopiaTheLightning) && !attacker.IsDisabled() && attacker.HasXyzMaterial(2, _CardId.Number39Utopia))
attacker.RealPower = 5000;
if (attacker.IsCode(_CardId.EaterOfMillions) && !attacker.IsDisabled())
attacker.RealPower = 9999;
if (attacker.IsMonsterInvincible())
attacker.RealPower = 9999;
foreach (ClientCard equip in attacker.EquipCards)
{
if (equip.IsCode(_CardId.MoonMirrorShield) && !equip.IsDisabled())
......@@ -229,6 +250,29 @@ namespace WindBot.Game.AI
return true;
}
public override bool OnPreActivate(ClientCard card)
{
ClientCard LastChainCard = Util.GetLastChainCard();
if (LastChainCard != null && Duel.Phase == DuelPhase.Standby &&
LastChainCard.IsCode(
_CardId.SandaionTheTimelord,
_CardId.GabrionTheTimelord,
_CardId.MichionTheTimelord,
_CardId.ZaphionTheTimelord,
_CardId.HailonTheTimelord,
_CardId.RaphionTheTimelord,
_CardId.SadionTheTimelord,
_CardId.MetaionTheTimelord,
_CardId.KamionTheTimelord,
_CardId.LazionTheTimelord
))
return false;
if ((card.Location == CardLocation.Hand || card.Location == CardLocation.SpellZone && card.IsFacedown()) &&
(card.IsSpell() && DefaultSpellWillBeNegated() || card.IsTrap() && DefaultTrapWillBeNegated()))
return false;
return true;
}
/// <summary>
/// Called when the AI has to select a card position.
/// </summary>
......@@ -266,7 +310,7 @@ namespace WindBot.Game.AI
/// </summary>
public override bool OnSelectMonsterSummonOrSet(ClientCard card)
{
return card.Level <= 4 && Util.IsAllEnemyBetter(true) && Util.IsAllEnemyBetterThanValue(card.Attack + 300, false);
return card.Level <= 4 && Bot.GetMonsters().Count(m => m.IsFaceup()) == 0 && Util.IsAllEnemyBetterThanValue(card.Attack, true);
}
/// <summary>
......@@ -644,7 +688,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultSpellSet()
{
return (Card.IsTrap() || Card.HasType(CardType.QuickPlay)) && Bot.GetSpellCountWithoutField() < 4;
return (Card.IsTrap() || Card.HasType(CardType.QuickPlay) || DefaultSpellMustSetFirst()) && Bot.GetSpellCountWithoutField() < 4;
}
/// <summary>
......@@ -681,8 +725,13 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultMonsterRepos()
{
if (Card.IsFaceup() && Card.IsDefense() && Card.Attack == 0)
return false;
if (Card.Attack == 0)
{
if (Card.IsFaceup() && Card.IsAttack())
return true;
if (Card.IsFaceup() && Card.IsDefense())
return false;
}
if (Enemy.HasInMonstersZone(_CardId.BlueEyesChaosMAXDragon, true) &&
Card.IsAttack() && (4000 - Card.Defense) * 2 > (4000 - Card.Attack))
......@@ -695,7 +744,7 @@ namespace WindBot.Game.AI
bool enemyBetter = Util.IsAllEnemyBetter(true);
if (Card.IsAttack() && enemyBetter)
return true;
if (Card.IsDefense() && !enemyBetter && Card.Attack >= Card.Defense)
if (Card.IsDefense() && !enemyBetter && (Card.Attack >= Card.Defense || Card.Attack >= Util.GetBestPower(Enemy)))
return true;
return false;
......@@ -706,7 +755,15 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultSpellWillBeNegated()
{
return Bot.HasInSpellZone(_CardId.ImperialOrder, true, true) || Enemy.HasInSpellZone(_CardId.ImperialOrder, true) || Enemy.HasInMonstersZone(_CardId.NaturiaBeast, true);
return (Bot.HasInSpellZone(_CardId.ImperialOrder, true, true) || Enemy.HasInSpellZone(_CardId.ImperialOrder, true)) && !Util.ChainContainsCard(_CardId.ImperialOrder);
}
/// <summary>
/// If trap will be negated
/// </summary>
protected bool DefaultTrapWillBeNegated()
{
return (Bot.HasInSpellZone(_CardId.RoyalDecreel, true, true) || Enemy.HasInSpellZone(_CardId.RoyalDecreel, true)) && !Util.ChainContainsCard(_CardId.RoyalDecreel);
}
/// <summary>
......@@ -714,15 +771,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultSpellMustSetFirst()
{
ClientCard card = null;
foreach (ClientCard check in Bot.GetSpells())
{
if (check.IsCode(_CardId.AntiSpellFragrance) && !check.IsDisabled())
card = check;
}
if (card != null && card.IsFaceup())
return true;
return Bot.HasInSpellZone(_CardId.AntiSpellFragrance, true, true) || Enemy.HasInSpellZone(_CardId.AntiSpellFragrance, true);
return Bot.HasInSpellZone(_CardId.AntiSpellFragrance, true, true) || Enemy.HasInSpellZone(_CardId.AntiSpellFragrance, true);
}
/// <summary>
......
namespace WindBot.Game.AI.Enums
{
/// <summary>
/// Cards that are invincible to battle and should always attack to use effect.
/// </summary>
public enum InvincibleBotMonster
{
YubelTheUltimateNightmare = 31764700,
YubelTerrorIncarnate = 4779091,
SandaionTheTimelord = 33015627,
GabrionTheTimelord = 6616912,
MichionTheTimelord = 7733560,
ZaphionTheTimelord = 28929131,
HailonTheTimelord = 34137269,
RaphionTheTimelord = 60222213,
SadionTheTimelord = 65314286,
MetaionTheTimelord = 74530899,
KamionTheTimelord = 91712985,
LazionTheTimelord = 92435533,
TimelordProgenitorVorpgate = 67508932,
RocketWarrior = 30860696,
GoDDDDivineZeroKingRage = 40227329,
BloomDivaTheMelodiousChoir = 84988419,
BlackwingArmorMaster = 69031175,
DaigustoSphreez = 29552709,
Number92HearteartHDragon = 97403510,
NumberC96DarkStorm = 77205367,
Number54LionHeart = 54366836
}
/// <summary>
/// Cards that are invincible to battle.
/// </summary>
public enum InvincibleMonster
public enum InvincibleEnemyMonster
{
SpiritReaper = 23205979,
YubelTheUltimateNightmare = 31764700,
......
......@@ -73,13 +73,19 @@ namespace WindBot.Game.AI
public virtual BattlePhaseAction OnSelectAttackTarget(ClientCard attacker, IList<ClientCard> defenders)
{
// Overrided in DefalultExecutor
// Overrided in DefaultExecutor
return null;
}
public virtual bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
{
// Overrided in DefalultExecutor
// Overrided in DefaultExecutor
return true;
}
public virtual bool OnPreActivate(ClientCard card)
{
// Overrided in DefaultExecutor
return true;
}
......@@ -178,13 +184,13 @@ namespace WindBot.Game.AI
public virtual CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions)
{
// Overrided in DefalultExecutor
// Overrided in DefaultExecutor
return 0;
}
public virtual bool OnSelectBattleReplay()
{
// Overrided in DefalultExecutor
// Overrided in DefaultExecutor
return false;
}
......@@ -194,7 +200,7 @@ namespace WindBot.Game.AI
/// <returns>True if select to set the monster.</returns>
public virtual bool OnSelectMonsterSummonOrSet(ClientCard card)
{
// Overrided in DefalultExecutor
// Overrided in DefaultExecutor
return false;
}
......
namespace WindBot.Game.AI
{
public static class HintMsg
{
public const int Release = 500,
Discard = 501,
Destroy = 502,
Remove = 503,
ToGrave = 504,
ReturnToHand = 505,
AddToHand = 506,
ToDeck = 507,
Summon = 508,
SpSummon = 509,
Set = 510,
FusionMaterial = 511,
SynchroMaterial = 512,
XyzMaterial = 513,
Faceup = 514,
Facedown = 515,
Attack = 516,
Defense = 517,
Equip = 518,
RemoveXyz = 519,
Control = 520,
DestroyReplace = 521,
FaceupAttack = 522,
FaceupDefense = 523,
FacedownAttack = 524,
FacedownDefense = 525,
Confirm = 526,
ToField = 527,
PosChange = 528,
Self = 529,
Oppo = 530,
Tribute = 531,
DeattachFrom = 532,
LinkMaterial = 533,
AttackTarget = 549,
Effect = 550,
Target = 551,
Coin = 552,
Dice = 553,
CardType = 554,
Option = 555,
ResolveEffect = 556,
Select = 560,
Position = 561,
Attribute = 562,
Race = 563,
Code = 564,
Number = 565,
LvRank = 567,
ResolveCard = 568,
Zone = 569,
DisableZone = 570,
ToZone = 571,
Counter = 572,
Disable = 573,
OperateCard = 574;
}
}
\ No newline at end of file
......@@ -32,7 +32,7 @@ namespace WindBot.Game
public int RealPower { get; set; }
public List<int> Overlays { get; private set; }
public int Owner { get; private set; }
public int Controller { get; private set; }
public int Controller { get; set; }
public int Disabled { get; private set; }
public int ProcCompleted { get; private set; }
public int SelectSeq { get; set; }
......
......@@ -96,30 +96,8 @@ namespace WindBot.Game
public void AddCard(CardLocation loc, int cardId, int player, int seq, int pos)
{
switch (loc)
{
case CardLocation.Hand:
Fields[player].Hand.Add(new ClientCard(cardId, loc, -1, pos));
break;
case CardLocation.Grave:
Fields[player].Graveyard.Add(new ClientCard(cardId, loc,-1, pos));
break;
case CardLocation.Removed:
Fields[player].Banished.Add(new ClientCard(cardId, loc, -1, pos));
break;
case CardLocation.MonsterZone:
Fields[player].MonsterZone[seq] = new ClientCard(cardId, loc, seq, pos);
break;
case CardLocation.SpellZone:
Fields[player].SpellZone[seq] = new ClientCard(cardId, loc, seq, pos);
break;
case CardLocation.Deck:
Fields[player].Deck.Add(new ClientCard(cardId, loc, -1, pos));
break;
case CardLocation.Extra:
Fields[player].ExtraDeck.Add(new ClientCard(cardId, loc, -1, pos));
break;
}
ClientCard card = new ClientCard(cardId, loc, seq, pos);
AddCard(loc, card, player, seq, pos, cardId);
}
public void AddCard(CardLocation loc, ClientCard card, int player, int seq, int pos, int id)
......@@ -127,6 +105,7 @@ namespace WindBot.Game
card.Location = loc;
card.Sequence = seq;
card.Position = pos;
card.Controller = player;
card.SetId(id);
switch (loc)
{
......
......@@ -231,18 +231,12 @@ namespace WindBot.Game
/// <returns>A new list containing the selected cards.</returns>
public IList<ClientCard> OnSelectCard(IList<ClientCard> cards, int min, int max, int hint, bool cancelable)
{
const int HINTMSG_FMATERIAL = 511;
const int HINTMSG_SMATERIAL = 512;
const int HINTMSG_XMATERIAL = 513;
const int HINTMSG_LMATERIAL = 533;
const int HINTMSG_SPSUMMON = 509;
// Check for the executor.
IList<ClientCard> result = Executor.OnSelectCard(cards, min, max, hint, cancelable);
if (result != null)
return result;
if (hint == HINTMSG_SPSUMMON && min == 1 && max > min) // pendulum summon
if (hint == HintMsg.SpSummon && min == 1 && max > min) // pendulum summon
{
result = Executor.OnSelectPendulumSummon(cards, max);
if (result != null)
......@@ -250,7 +244,7 @@ namespace WindBot.Game
}
CardSelector selector = null;
if (hint == HINTMSG_FMATERIAL || hint == HINTMSG_SMATERIAL || hint == HINTMSG_XMATERIAL || hint == HINTMSG_LMATERIAL)
if (hint == HintMsg.FusionMaterial || hint == HintMsg.SynchroMaterial || hint == HintMsg.XyzMaterial || hint == HintMsg.LinkMaterial)
{
if (m_materialSelector != null)
{
......@@ -259,13 +253,13 @@ namespace WindBot.Game
}
else
{
if (hint == HINTMSG_FMATERIAL)
if (hint == HintMsg.FusionMaterial)
result = Executor.OnSelectFusionMaterial(cards, min, max);
if (hint == HINTMSG_SMATERIAL)
if (hint == HintMsg.SynchroMaterial)
result = Executor.OnSelectSynchroMaterial(cards, 0, min, max);
if (hint == HINTMSG_XMATERIAL)
if (hint == HintMsg.XyzMaterial)
result = Executor.OnSelectXyzMaterial(cards, min, max);
if (hint == HINTMSG_LMATERIAL)
if (hint == HintMsg.LinkMaterial)
result = Executor.OnSelectLinkMaterial(cards, min, max);
if (result != null)
......@@ -533,16 +527,13 @@ namespace WindBot.Game
/// <returns></returns>
public IList<ClientCard> OnSelectSum(IList<ClientCard> cards, int sum, int min, int max, int hint, bool mode)
{
const int HINTMSG_RELEASE = 500;
const int HINTMSG_SMATERIAL = 512;
IList<ClientCard> selected = Executor.OnSelectSum(cards, sum, min, max, hint, mode);
if (selected != null)
{
return selected;
}
if (hint == HINTMSG_RELEASE || hint == HINTMSG_SMATERIAL)
if (hint == HintMsg.Release || hint == HintMsg.SynchroMaterial)
{
if (m_materialSelector != null)
{
......@@ -552,10 +543,10 @@ namespace WindBot.Game
{
switch (hint)
{
case HINTMSG_SMATERIAL:
case HintMsg.SynchroMaterial:
selected = Executor.OnSelectSynchroMaterial(cards, sum, min, max);
break;
case HINTMSG_RELEASE:
case HintMsg.Release:
selected = Executor.OnSelectRitualTribute(cards, sum, min, max);
break;
}
......@@ -1111,10 +1102,12 @@ namespace WindBot.Game
private bool ShouldExecute(CardExecutor exec, ClientCard card, ExecutorType type, int desc = -1)
{
if (card.Id != 0 && type == ExecutorType.Activate &&
_activatedCards.ContainsKey(card.Id) && _activatedCards[card.Id] >= 9)
if (card.Id != 0 && type == ExecutorType.Activate)
{
return false;
if (_activatedCards.ContainsKey(card.Id) && _activatedCards[card.Id] >= 9)
return false;
if (!Executor.OnPreActivate(card))
return false;
}
Executor.SetCard(type, card, desc);
bool result = card != null && exec.Type == type &&
......
......@@ -125,6 +125,7 @@
<Compile Include="Game\AI\Enums\InvincibleMonster.cs" />
<Compile Include="Game\AI\Enums\Floodgate.cs" />
<Compile Include="Game\AI\Executor.cs" />
<Compile Include="Game\AI\HintMsg.cs" />
<Compile Include="Game\AI\Opcodes.cs" />
<Compile Include="Game\AI\Zones.cs" />
<Compile Include="Game\AI\ExecutorType.cs" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment