Commit 6d4d8bbc authored by wind2009's avatar wind2009 Committed by GitHub

AI_Labrynth (#181)

parent eec2779c
......@@ -99,6 +99,11 @@ Name=尼亚 Deck=Altergeist Dialog=near.zh-CN
幻变骚灵卡组。
AI_LV3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!尼亚-拉比林斯迷宫
Name=尼亚 Deck=Labrynth Dialog=near.zh-CN
拉比林斯迷宫卡组。
AI_LV3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!复制梁龙-闪刀姬
Name=复制梁龙 Deck=SkyStriker Dialog=anothercopy.zh-CN
旧式闪刀姬卡组。
......
#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
......@@ -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,7 +1093,7 @@ namespace WindBot.Game.AI.Decks
}
}
base.OnMove(cardId, previousControler, previousLocation, currentControler, currentLocation);
base.OnMove(card, previousControler, previousLocation, currentControler, currentLocation);
}
public override BattlePhaseAction OnBattle(IList<ClientCard> attackers, IList<ClientCard> defenders)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -125,6 +125,7 @@ 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;
......@@ -223,6 +224,8 @@ namespace WindBot.Game.AI
AddExecutor(ExecutorType.Activate, _CardId.SantaClaws);
}
protected int lightningStormOption = -1;
/// <summary>
/// Defined:
/// if monster with code as KEY, other monsters with rules as VALUE won't be targeted for attack.
......@@ -395,6 +398,9 @@ namespace WindBot.Game.AI
}
}
if (attacker.EquipCards.Any(equip => equip.IsCode(_CardId.MoonMirrorShield) && !equip.IsDisabled()))
attacker.RealPower = defender.RealPower + 100;
if (!defender.IsDisabled())
{
Func<ClientCard, List<ClientCard>, bool> defenderRule = (card, monsterList) => false;
......@@ -430,6 +436,9 @@ namespace WindBot.Game.AI
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;
......@@ -1025,6 +1034,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;
}
......@@ -1120,12 +1131,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())
......@@ -1156,7 +1166,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))
{
......@@ -1454,5 +1465,21 @@ 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);
}
public override void OnChainEnd()
{
lightningStormOption = -1;
base.OnChainEnd();
}
}
}
......@@ -71,6 +71,7 @@
ElShaddollConstruct = 20366274,
ElShaddollGrysra = 48424886,
ElShaddollWinda = 94977269,
HotRedDragonArchfiendAbyss = 9753964,
UltimateConductorTytanno = 18940556,
OvertexCoatls = 41782653,
FirePrison = 269510,
......
......@@ -67,6 +67,7 @@
FaceCardFusion = 29062925,
MyutantFusion = 42577802,
MyutantCry = 31855260,
FallenOfAlbaz = 68468459,
GreaterPolymerization = 7614732,
UltimateFusion = 71143015,
BrandedFusion = 44362883,
......
......@@ -104,6 +104,12 @@ namespace WindBot.Game.AI
{
// For overriding
}
public virtual void OnReceivingAnnouce(int player, int data)
{
// For overriding
}
public virtual void OnNewPhase()
{
// Some AI need do something on new phase
......@@ -118,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
......@@ -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>
......@@ -157,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>
......
......@@ -347,6 +347,10 @@ namespace WindBot.Game
{
_select_hint = data;
}
if (type == 4) // HINT_OPSELECTED
{
_ai.OnReceivingAnnouce(player, data);
}
}
private void OnStart(BinaryReader packet)
......@@ -354,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);
......@@ -653,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)
......
......@@ -103,6 +103,7 @@
<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" />
......
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