Commit 6ae010e9 authored by xiaoye's avatar xiaoye

fix

parent e122ed32
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
......@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BotWrapper</RootNamespace>
<AssemblyName>Bot</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
......@@ -22,6 +22,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
......@@ -31,6 +32,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject>BotWrapper.BotWrapper</StartupObject>
......
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
#main
60229110
60229110
60229110
37043180
37043180
39168895
39168895
39168895
42386471
47606319
47606319
47606319
70074904
74131780
76305638
76305638
76305638
85306040
97017120
97017120
97017120
79575620
19613556
32807846
32807846
71044499
79571449
97169186
5318639
14087893
73915051
45986603
70828912
27174286
27174286
29401950
29401950
44095762
53582587
97077563
#extra
!side
83986578
83986578
31036355
60082869
60082869
#spare
$1224927$
$1546123$
$3136426$
$3366982$
$3773196$
$3819470$
$4178474$
$4929256$
$5758500$
$7165085$
$9156135$
$9596126$
$9637706$
$10248389$
$12538374$
$13756293$
$15800838$
$16226786$
$17449108$
$17881964$
$22046459$
$22587018$
$23171610$
$23205979$
$23995346$
$24317029$
$26205777$
$26412047$
$27174286$
$28933734$
$29401950$
$30241314$
$30461781$
$30683373$
$31036355$
$31305911$
$32807846$
$33508719$
$34853266$
$35027493$
$36468556$
$37101832$
$38275183$
$41420027$
$41544074$
$41855169$
$42703248$
$45141844$
$46411259$
$46461247$
$47355498$
$47507260$
$48092532$
$49868263$
$51452091$
$51945556$
$56120475$
$57728571$
$58528964$
$59344077$
$60229110$
$60694662$
$62279055$
$63356631$
$63519819$
$64697231$
$65403020$
$66235877$
$66788016$
$67688478$
$68005187$
$69015963$
$69162969$
$69279219$
$70074904$
$70368879$
$71218746$
$71453557$
$72302403$
$73628505$
$73915051$
$74157028$
$76515293$
$76922029$
$77585513$
$77754945$
$78700060$
$80071763$
$81510157$
$81674782$
$82732705$
$83011277$
$83986578$
$85602018$
$85684223$
$85742772$
$86099788$
$86805855$
$87621407$
$87751584$
$87910978$
$88240808$
$90140980$
$90846359$
$93016201$
$93260132$
$94853057$
$95956346$
$97017120$
$97169186$
$98045062$
#representative
$60229110$
$47606319$
$76305638$
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("AI408A", "AI_408A")]
public class AI408AExecutor : DefaultExecutor
{
public AI408AExecutor(GameAI ai, Duel duel)
: base(ai, duel)
{
AddExecutor(ExecutorType.SpSummon);
AddExecutor(ExecutorType.Activate, 19613556, OnSelectActivate);
AddExecutor(ExecutorType.Activate, 45986603, OnSelectActivate);
AddExecutor(ExecutorType.Activate, OnSelectActivate);
AddExecutor(ExecutorType.Summon, 79575620, OnSelectSummon);
AddExecutor(ExecutorType.Summon, 60229110, OnSelectSummon);
AddExecutor(ExecutorType.Summon, 85306040, OnSelectSummon);
AddExecutor(ExecutorType.Summon, 39168895, OnSelectSummon);
AddExecutor(ExecutorType.Summon, 74131780, OnSelectSummon);
AddExecutor(ExecutorType.Summon, 70074904, OnSelectSummon);
AddExecutor(ExecutorType.Summon, 97017120, OnSelectSummon);
AddExecutor(ExecutorType.Summon, 37043180, OnSelectSummon);
AddExecutor(ExecutorType.Summon, 42386471, OnSelectSummon);
AddExecutor(ExecutorType.SpellSet, OnSelectSpellSet);
AddExecutor(ExecutorType.MonsterSet, 37043180);
AddExecutor(ExecutorType.MonsterSet, 70074904);
AddExecutor(ExecutorType.MonsterSet, 97017120);
AddExecutor(ExecutorType.MonsterSet, OnSelectMonsterSet);
}
private bool chk_release_summon = false;
private int summonInTurn = 0;
private int attacked_85306040 = 0
private int[] changePosInTurn;
private int[] attacked = new int[] { 0, 0, 0, 0, 0 };
public override void OnNewTurn()
{
summonInTurn = 0;
changePosInTurn = new int[0];
attacked = new int[] { 0, 0, 0, 0, 0 };
if (attacked_85306040 > 0) attacked_85306040--;
}
public override BattlePhaseAction OnSelectAttackTarget(ClientCard attacker, IList<ClientCard> defenders)
{
if (attacker.CanDirectAttack)
{
attacked[GetSequence(attacker)] = attacker.Id;
return AI.Attack(attacker, null);
}
if (attacker.IsCode({ 37043180, 70074904 }))
{
if (Bot.GetMonsterCount() > Enemy.GetMonsterCount())
{
foreach (ClientCard defender in defenders)
{
attacker.RealPower = attacker.Attack;
defender.RealPower = defender.GetDefensePower();
if (!OnPreBattleBetween(attacker, defender))
continue;
if (attacker.RealPower > defender.RealPower || (attacker.RealPower >= defender.RealPower && attacker.IsLastAttacker && defender.IsAttack()))
{
attacked[GetSequence(attacker)] = attacker.Id;
attacked_85306040 += 2
return AI.Attack(attacker, defender);
}
}
}
}
switch (attacker.Id)
{
case 79575620:
{
foreach (ClientCard defender in defenders)
{
attacker.RealPower = 3400;
defender.RealPower = defender.GetDefensePower();
if (!OnPreBattleBetween(attacker, defender))
continue;
if ((attacker.RealPower >= defender.RealPower && defender.IsAttack()) || (attacker.RealPower > defender.RealPower && !GetZoneCards(CardLocation.MonsterZone, Bot).Any(c => c != null && !c.IsCode(79575620) && c.IsAttack() && (c.Attack > defender.RealPower || (c.IsCode({ 37043180, 70074904 }) && defender.RealPower - c.Attack < Bot.LifePoints + 2000)) && attacked[GetSequence(c)] != c.Id) && defender.IsDefense() && defender.IsFaceup()))
{
attacked[GetSequence(attacker)] = attacker.Id;
return AI.Attack(attacker, defender);
}
}
return null;
}
case 85306040:
{
foreach (ClientCard defender in defenders)
{
attacker.RealPower = attacker.Attack;
defender.RealPower = defender.GetDefensePower();
if (!OnPreBattleBetween(attacker, defender))
continue;
if (attacker.RealPower > defender.RealPower || (attacker.RealPower >= defender.RealPower && attacker.IsLastAttacker && defender.IsAttack()))
{
attacked[GetSequence(attacker)] = attacker.Id;
attacked_85306040 += 2
return AI.Attack(attacker, defender);
}
}
return null;
}
}
foreach (ClientCard defender in defenders)
{
attacker.RealPower = attacker.Attack;
defender.RealPower = defender.GetDefensePower();
if (!OnPreBattleBetween(attacker, defender))
continue;
if (attacker.RealPower > defender.RealPower || (attacker.RealPower >= defender.RealPower && attacker.IsLastAttacker && defender.IsAttack()))
{
attacked[GetSequence(attacker)] = attacker.Id;
return AI.Attack(attacker, defender);
}
}
return null;
}
public override bool OnSelectHand()
{
return true;
}
public override CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions)
{
YGOSharp.OCGWrapper.NamedCard cardData = YGOSharp.OCGWrapper.NamedCard.Get(cardId);
if (cardData != null)
{
if (cardId == 39168895) return CardPosition.Attack;
if (cardId == 85306040)
{
if (attacked_85306040 > 0)
attacked_85306040 = 0
return CardPosition.Attack;
}
}
return base.OnSelectPosition(cardId, positions);
}
public override int OnSelectPlace(int cardId, int player, CardLocation location, int available)
{
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 (max > cards.Count()) max = cards.Count();
ClientCard currentSolvingChain = Duel.GetCurrentSolvingChainCard();
if (currentSolvingChain != null)
{
if (currentSolvingChain.IsCode(new[] { 97077563, 70828912 }))
{
List<ClientCard> res = cards.Where(card => card != null && !cards.Any(c => c != null && c.Attack > card.Attack)).ToList();
return Util.CheckSelectCount(res, cards, min, max);
}
if (currentSolvingChain.IsCode(new[] { 60229110, 71044499 }))
{
List<ClientCard> res = cards.Where(card => card != null && card.Controller == 1).ToList();
return Util.CheckSelectCount(res, cards, min, max);
}
if (currentSolvingChain.IsCode(32807846))
{
if (cards.Any(c => c != null && c.IsCode(new[] { 37043180, 70074904 })) && Bot.GetMonsterCount() >= Enemy.GetMonsterCount())
return Util.CheckSelectCount(cards.Where(c => c != null && c.IsCode(new[] { 37043180, 70074904 })).ToList(), cards, min, max);
if (cards.Any(c => c != null && c.IsCode(74131780) && !GetZoneCards(CardLocation.MonsterZone, Enemy).Any(card => card != null && card.GetDefensePower() < 1000)) && GetZoneCards(CardLocation.MonsterZone, Enemy).Any(card => card != null && !card.IsShouldNotBeTarget()))
return Util.CheckSelectCount(cards.Where(c => c != null && c.IsCode(74131780)).ToList(), cards, min, max);
return Util.CheckSelectCount(cards.Where(card => card != null && !cards.Any(c => c != null && !c.IsCode(card.Id) && c.Attack > card.Attack)).ToList(), cards, min, max);
}
switch (currentSolvingChain.Id)
{
case 27174286:
{
return Util.CheckSelectCount(cards, cards, max, max);
}
case 45986603:
{
List<ClientCard> res = cards.Where(card => card != null && !cards.Any(c => c != null && c.Attack > card.Attack)).ToList();
return Util.CheckSelectCount(res, cards, min, max);
}
}
}
if (chk_release_summon)
{
chk_release_summon = false;
List<ClientCard> res = cards.Where(card => card != null && !card.IsCode(new[] { 79575620, 97017120, 74131780 })).ToList();
if (Bot.LifePoints <= 2000 && cards.Any(card => card != null && !card.IsCode(79575620))) res.AddRange(cards.Where(card => card != null && !card.IsCode(79575620)).ToList());
res = res.Where(card => card != null && !res.Any(c => c != null && c.Attack < card.Attack)).ToList();
return Util.CheckSelectCount(res, cards, min, max);
}
return base.OnSelectCard(cards, min, max, hint, cancelable);
}
public int GetSequence(ClientCard card)
{
if (Card.Location != CardLocation.MonsterZone) return -1;
for (int i = 0; i < 5; ++i)
{
if (Bot.MonsterZone[i] == card) return i;
}
return -1;
}
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 CheckCardsInDeck(int code, int all_ct)
{
int count = 0;
count += GetZoneCards(CardLocation.SpellZone, Bot).Count(card => card != null && card.IsCode(code));
count += GetZoneCards(CardLocation.MonsterZone, Bot).Count(card => card != null && card.IsCode(code));
count += GetZoneCards(CardLocation.Grave, Bot).Count(card => card != null && card.IsCode(code));
count += GetZoneCards(CardLocation.Hand, Bot).Count(card => card != null && card.IsCode(code));
count += GetZoneCards(CardLocation.Removed, Bot).Count(card => card != null && card.IsCode(code));
count += GetZoneCards(CardLocation.Extra, Bot).Count(card => card != null && card.IsCode(code));
return count < all_ct;
}
private bool MonsterRepos()
{
return false;
}
private bool OnSelectActivate()
{
if (Card.IsDisabled()) return false;
IList<int> activate_return_true = new[] { 97017120, 32807846, 79571449, 29401950, 44095762, 70828912, 97077563 };
switch (Card.Id)
{
case 74131780:
{
if (Enemy.GetSpellCount() == 0)
{
if ((Duel.Phase == DuelPhase.Main2 || !Duel.MainPhase.CanBattlePhase) || ((changePosInTurn.Any(card => card == Card.Id) || summonInTurn == Card.Id) && !Card.IsAttack()) || !GetZoneCards(CardLocation.MonsterZone, Enemy).Any(card => card != null && card.GetDefensePower() < Card.Attack))
return GetZoneCards(CardLocation.MonsterZone, Enemy).Any(card => card != null && !card.IsShouldNotBeTarget());
}
else
{
if (GetZoneCards(CardLocation.MonsterZone, Enemy).Any(card => card != null && !card.IsShouldNotBeTarget())) return true;
}
return false;
}
case 97169186:
{
return DefaultSmashingGround();
}
case 71044499:
{
return GetZoneCards(CardLocation.MonsterZone, Enemy).Any(card => card != null && !card.IsShouldNotBeTarget() && card.IsFacedown());
}
case 73915051:
{
return (GetZoneCards(CardLocation.MonsterZone, Bot).Count() == 0 && GetZoneCards(CardLocation.MonsterZone, Enemy).Count() > 0 && Duel.Phase > DuelPhase.Main1 && Duel.Phase < DuelPhase.Main2 && Duel.Player == 1);
}
case 19613556:
{
if (Bot.HasInSpellZone(new[] { 45986603, 70828912 })) return false;
if (Bot.HasInHand(5318639)) return Enemy.GetSpellCount() - Bot.GetSpellCount() > 1;
return DefaultHeavyStorm();
}
case 53582587:
{
return DefaultTorrentialTribute();
}
case 5318639:
{
return DefaultMysticalSpaceTyphoon();
}
case 14087893:
{
return DefaultBookOfMoon();
}
case 79575620:
{
return Bot.LifePoints > 2000;
}
case 27174286:
{
int ct = GetZoneCards(CardLocation.Removed, Bot).Count(c => c != null && c.HasType(CardType.Monster));
if (ct == 0) return false;
if (ct > 5 - Bot.GetMonsterCount()) ct = 5 - Bot.GetMonsterCount();
if (Bot.GetMonsterCount() == 0 && Enemy.GetMonsterCount() > 0 && Duel.Phase > DuelPhase.Main1 && Duel.Phase < DuelPhase.Main2 && Duel.Player == 1)
return true;
if (5 - Bot.GetMonsterCount() >= ct && Duel.Player == 1 && Duel.Phase == DuelPhase.End)
return true;
if ((5 - Bot.GetMonsterCount() >= ct || ct > 2) && Duel.Player == 0 && Duel.Phase == DuelPhase.Standby)
return true;
if (Duel.Phase > DuelPhase.Main1 && Duel.Phase < DuelPhase.Main2 && Duel.Player == 0)
{
List<ClientCard> g = GetZoneCards(CardLocation.Removed, Bot).Where(c => c != null && c.HasType(CardType.Monster)).ToList();
g.Sort(CardContainer.CompareCardAttack);
g.Reverse();
int atk = 0;
for (int i = 0; i < 5 - Bot.GetMonsterCount(); i++)
{
int a;
if (g[i].IsCode(79575620) && Bot.LifePoints > 2000) a = 3400;
else a = g[i].Attack;
atk += a;
}
if (Enemy.GetMonsterCount() == 0 && Enemy.LifePoints <= atk)
return true;
}
break;
}
}
return activate_return_true.IndexOf(Card.Id) >= 0;
}
private bool OnSelectSpellSet()
{
if (Duel.Phase != DuelPhase.Main2 && !Duel.MainPhase.CanBattlePhase) return false;
return Card.HasType(CardType.Trap) || Card.HasType(CardType.QuickPlay);
}
private bool OnSelectMonsterSet()
{
if (!GetZoneCards(CardLocation.Hand, Bot).Any(card => card != null && card.Defense > Card.Defense)) return true;
return false;
}
private bool OnSelectSummon()
{
if (Enemy.GetMonsterCount() > 0 && !GetZoneCards(CardLocation.MonsterZone, Enemy).Any(card => card != null && (Card.IsCode(79575620) ? card.GetDefensePower() < 3400 : card.GetDefensePower() < Card.Attack)) && !GetZoneCards(CardLocation.MonsterZone, Bot).Any(card => card != null && GetZoneCards(CardLocation.MonsterZone, Enemy).Any(c => c != null && c.GetDefensePower() < c.Attack)))
{
if (Card.IsCode(74131780) && GetZoneCards(CardLocation.MonsterZone, Enemy).Any(card => card != null && !card.IsShouldNotBeTarget()))
{
summonInTurn = Card.Id;
return true;
}
}
else
{
switch (Card.Id)
{
case 60229110:
{
if (GetZoneCards(CardLocation.SpellZone, Enemy).Any(card => card != null && !card.IsShouldNotBeTarget() && card.IsFacedown()) && GetZoneCards(CardLocation.MonsterZone, Bot).Any(card => card != null && (!card.IsCode(new[] { 79575620, 97017120, 74131780 }) || (Bot.LifePoints <= 2000 && card.IsCode(79575620)))))
{
chk_release_summon = true;
return true;
}
return false;
}
case 79575620:
{
return Bot.LifePoints > 2000;
}
case 85306040:
{
if (attacked_85306040 > 0)
attacked_85306040 = 0
return true;
}
}
summonInTurn = Card.Id;
return true;
}
return false;
}
}
}
......@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WindBot</RootNamespace>
<AssemblyName>WindBot</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
......@@ -21,6 +21,7 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\Release\</OutputPath>
......@@ -30,6 +31,7 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
......@@ -60,6 +62,7 @@
<Compile Include="Game\AI\CardSelector.cs" />
<Compile Include="Game\AI\DeckAttribute.cs" />
<Compile Include="Game\AI\DecksManager.cs" />
<Compile Include="Game\AI\Decks\AI408AExecutor.cs" />
<Compile Include="Game\AI\Decks\AlbazExecutor.cs" />
<Compile Include="Game\AI\Decks\AltergeistExecutor.cs" />
<Compile Include="Game\AI\Decks\BraveExecutor.cs" />
......
......@@ -233,6 +233,11 @@
"name": "今晚有宵夜吗",
"deck": "SuperheavySamurai",
"dialog": "superheavysamurai.zh-CN"
},
{
"name": "今晚有宵夜吗",
"deck": "AI408A",
"dialog": "superheavysamurai.zh-CN"
}
]
}
\ No newline at end of file
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