Commit cb9047f1 authored by mercury233's avatar mercury233

add ShouldNotBeTarget and ShouldBeDisabledBeforeItUseEffectMonster enum

fix #47
need more changes to executors
parent 3674b020
......@@ -151,14 +151,14 @@ namespace WindBot.Game.AI
return bestMonster;
}
public ClientCard GetOneEnemyBetterThanValue(int value, bool onlyATK = false)
public ClientCard GetOneEnemyBetterThanValue(int value, bool onlyATK = false, bool canBeTarget = false)
{
ClientCard bestCard = null;
int bestValue = value;
for (int i = 0; i < 7; ++i)
{
ClientCard card = Enemy.MonsterZone[i];
if (card == null || card.Data == null) continue;
if (card == null || card.Data == null || (canBeTarget && card.IsShouldNotBeTarget())) continue;
if (onlyATK && card.IsDefense()) continue;
int enemyValue = card.GetDefensePower();
if (enemyValue >= bestValue)
......@@ -170,52 +170,52 @@ namespace WindBot.Game.AI
return bestCard;
}
public ClientCard GetOneEnemyBetterThanMyBest(bool onlyATK = false)
public ClientCard GetOneEnemyBetterThanMyBest(bool onlyATK = false, bool canBeTarget = false)
{
int bestBotPower = GetBestPower(Bot, onlyATK);
return GetOneEnemyBetterThanValue(bestBotPower, onlyATK);
return GetOneEnemyBetterThanValue(bestBotPower, onlyATK, canBeTarget);
}
public ClientCard GetProblematicEnemyCard(int attack = 0)
public ClientCard GetProblematicEnemyCard(int attack = 0, bool canBeTarget = false)
{
ClientCard card = Enemy.MonsterZone.GetFloodgate();
ClientCard card = Enemy.MonsterZone.GetFloodgate(canBeTarget);
if (card != null)
return card;
card = Enemy.SpellZone.GetFloodgate();
card = Enemy.SpellZone.GetFloodgate(canBeTarget);
if (card != null)
return card;
card = Enemy.MonsterZone.GetDangerousMonster();
card = Enemy.MonsterZone.GetDangerousMonster(canBeTarget);
if (card != null)
return card;
card = Enemy.MonsterZone.GetInvincibleMonster();
card = Enemy.MonsterZone.GetInvincibleMonster(canBeTarget);
if (card != null)
return card;
if (attack == 0)
attack = GetBestAttack(Bot);
return GetOneEnemyBetterThanValue(attack, true);
return GetOneEnemyBetterThanValue(attack, true, canBeTarget);
}
public ClientCard GetProblematicEnemyMonster(int attack = 0)
public ClientCard GetProblematicEnemyMonster(int attack = 0, bool canBeTarget = false)
{
ClientCard card = Enemy.MonsterZone.GetFloodgate();
ClientCard card = Enemy.MonsterZone.GetFloodgate(canBeTarget);
if (card != null)
return card;
card = Enemy.MonsterZone.GetDangerousMonster();
card = Enemy.MonsterZone.GetDangerousMonster(canBeTarget);
if (card != null)
return card;
card = Enemy.MonsterZone.GetInvincibleMonster();
card = Enemy.MonsterZone.GetInvincibleMonster(canBeTarget);
if (card != null)
return card;
if (attack == 0)
attack = GetBestAttack(Bot);
return GetOneEnemyBetterThanValue(attack, true);
return GetOneEnemyBetterThanValue(attack, true, canBeTarget);
}
public ClientCard GetProblematicEnemySpell()
......@@ -224,9 +224,9 @@ namespace WindBot.Game.AI
return card;
}
public ClientCard GetBestEnemyCard(bool onlyFaceup = false)
public ClientCard GetBestEnemyCard(bool onlyFaceup = false, bool canBeTarget = false)
{
ClientCard card = GetBestEnemyMonster(onlyFaceup);
ClientCard card = GetBestEnemyMonster(onlyFaceup, canBeTarget);
if (card != null)
return card;
......@@ -237,20 +237,20 @@ namespace WindBot.Game.AI
return null;
}
public ClientCard GetBestEnemyMonster(bool onlyFaceup = false)
public ClientCard GetBestEnemyMonster(bool onlyFaceup = false, bool canBeTarget = false)
{
ClientCard card = GetProblematicEnemyMonster();
ClientCard card = GetProblematicEnemyMonster(0, canBeTarget);
if (card != null)
return card;
card = Enemy.MonsterZone.GetHighestAttackMonster();
card = Enemy.MonsterZone.GetHighestAttackMonster(canBeTarget);
if (card != null)
return card;
List<ClientCard> monsters = Enemy.GetMonsters();
// after GetHighestAttackMonster, the left monsters must be face-down.
if (monsters.Count > 0 && !onlyFaceup)
if (monsters.Count > 0 && !onlyFaceup && (!canBeTarget || !card.IsShouldNotBeTarget()))
return monsters[0];
return null;
......
......@@ -6,13 +6,13 @@ namespace WindBot.Game.AI
{
public static class CardContainer
{
public static ClientCard GetHighestAttackMonster(this IEnumerable<ClientCard> cards)
public static ClientCard GetHighestAttackMonster(this IEnumerable<ClientCard> cards, bool canBeTarget = false)
{
int highestAtk = 0;
ClientCard selected = null;
foreach (ClientCard card in cards)
{
if (card == null || card.Data == null || card.IsFacedown()) continue;
if (card == null || card.Data == null || card.IsFacedown() || (canBeTarget && card.IsShouldNotBeTarget())) continue;
if (card.HasType(CardType.Monster) && card.Attack > highestAtk)
{
highestAtk = card.Attack;
......@@ -22,13 +22,13 @@ namespace WindBot.Game.AI
return selected;
}
public static ClientCard GetHighestDefenseMonster(this IEnumerable<ClientCard> cards)
public static ClientCard GetHighestDefenseMonster(this IEnumerable<ClientCard> cards, bool canBeTarget = false)
{
int highestDef = 0;
ClientCard selected = null;
foreach (ClientCard card in cards)
{
if (card == null || card.Data == null || card.IsFacedown()) continue;
if (card == null || card.Data == null || card.IsFacedown() || (canBeTarget && card.IsShouldNotBeTarget())) continue;
if (card.HasType(CardType.Monster) && card.Defense > highestDef)
{
highestDef = card.Defense;
......@@ -38,13 +38,13 @@ namespace WindBot.Game.AI
return selected;
}
public static ClientCard GetLowestAttackMonster(this IEnumerable<ClientCard> cards)
public static ClientCard GetLowestAttackMonster(this IEnumerable<ClientCard> cards, bool canBeTarget = false)
{
int lowestAtk = 0;
ClientCard selected = null;
foreach (ClientCard card in cards)
{
if (card == null || card.Data == null || card.IsFacedown()) continue;
if (card == null || card.Data == null || card.IsFacedown() || (canBeTarget && card.IsShouldNotBeTarget())) continue;
if (lowestAtk == 0 && card.HasType(CardType.Monster) ||
card.HasType(CardType.Monster) && card.Attack < lowestAtk)
{
......@@ -55,13 +55,13 @@ namespace WindBot.Game.AI
return selected;
}
public static ClientCard GetLowestDefenseMonster(this IEnumerable<ClientCard> cards)
public static ClientCard GetLowestDefenseMonster(this IEnumerable<ClientCard> cards, bool canBeTarget = false)
{
int lowestDef = 0;
ClientCard selected = null;
foreach (ClientCard card in cards)
{
if (card == null || card.Data == null || card.IsFacedown()) continue;
if (card == null || card.Data == null || card.IsFacedown() || (canBeTarget && card.IsShouldNotBeTarget())) continue;
if (lowestDef == 0 && card.HasType(CardType.Monster) ||
card.HasType(CardType.Monster) && card.Defense < lowestDef)
{
......@@ -149,31 +149,31 @@ namespace WindBot.Game.AI
return cardlist;
}
public static ClientCard GetInvincibleMonster(this IEnumerable<ClientCard> cards)
public static ClientCard GetInvincibleMonster(this IEnumerable<ClientCard> cards, bool canBeTarget = false)
{
foreach (ClientCard card in cards)
{
if (card != null && card.IsMonsterInvincible() && card.IsFaceup())
if (card != null && card.IsMonsterInvincible() && card.IsFaceup() && (!canBeTarget || !card.IsShouldNotBeTarget()))
return card;
}
return null;
}
public static ClientCard GetDangerousMonster(this IEnumerable<ClientCard> cards)
public static ClientCard GetDangerousMonster(this IEnumerable<ClientCard> cards, bool canBeTarget = false)
{
foreach (ClientCard card in cards)
{
if (card != null && card.IsMonsterDangerous() && card.IsFaceup())
if (card != null && card.IsMonsterDangerous() && card.IsFaceup() && (!canBeTarget || !card.IsShouldNotBeTarget()))
return card;
}
return null;
}
public static ClientCard GetFloodgate(this IEnumerable<ClientCard> cards)
public static ClientCard GetFloodgate(this IEnumerable<ClientCard> cards, bool canBeTarget = false)
{
foreach (ClientCard card in cards)
{
if (card != null && card.IsFloodgate() && card.IsFaceup())
if (card != null && card.IsFloodgate() && card.IsFaceup() && (!canBeTarget || !card.IsShouldNotBeTarget()))
return card;
}
return null;
......
......@@ -29,6 +29,38 @@ namespace WindBot.Game.AI
return !card.IsDisabled() && Enum.IsDefined(typeof(PreventActivationEffectInBattle), card.Id);
}
/// <summary>
/// Is this card shouldn't be tried to be selected as target?
/// </summary>
public static bool IsShouldNotBeTarget(this ClientCard card)
{
return !card.IsDisabled() && Enum.IsDefined(typeof(ShouldNotBeTarget), card.Id);
}
/// <summary>
/// Is this card shouldn't be tried to be selected as target of monster?
/// </summary>
public static bool IsShouldNotBeMonsterTarget(this ClientCard card)
{
return !card.IsDisabled() && Enum.IsDefined(typeof(ShouldNotBeMonsterTarget), card.Id);
}
/// <summary>
/// Is this card shouldn't be tried to be selected as target of spell & trap?
/// </summary>
public static bool IsShouldNotBeSpellTrapTarget(this ClientCard card)
{
return !card.IsDisabled() && Enum.IsDefined(typeof(ShouldNotBeSpellTrapTarget), card.Id);
}
/// <summary>
/// Is this monster should be disabled (with Breakthrough Skill) before it use effect and release or banish itself?
/// </summary>
public static bool IsMonsterShouldBeDisabledBeforeItUseEffect(this ClientCard card)
{
return !card.IsDisabled() && Enum.IsDefined(typeof(ShouldBeDisabledBeforeItUseEffectMonster), card.Id);
}
public static bool IsFloodgate(this ClientCard card)
{
return Enum.IsDefined(typeof(Floodgate), card.Id);
......
......@@ -292,7 +292,7 @@ namespace WindBot.Game.AI.Decks
}
if (CanDealWithUsedAlternativeWhiteDragon())
{
target = AI.Utils.GetBestEnemyMonster();
target = AI.Utils.GetBestEnemyMonster(false, true);
AI.SelectCard(target);
UsedAlternativeWhiteDragon.Add(Card);
return true;
......
......@@ -497,7 +497,7 @@ namespace WindBot.Game.AI.Decks
ClientCard target = AI.Utils.GetProblematicEnemyMonster();
if (target == null && AI.Utils.IsChainTarget(Card))
{
target = AI.Utils.GetBestEnemyMonster();
target = AI.Utils.GetBestEnemyMonster(true, true);
}
if (target != null)
{
......
......@@ -527,7 +527,7 @@ namespace WindBot.Game.AI.Decks
private bool FairyTailSnowsummon()
{
ClientCard target = AI.Utils.GetBestEnemyMonster(true);
ClientCard target = AI.Utils.GetBestEnemyMonster(true, true);
if(target != null)
{
return true;
......@@ -541,7 +541,7 @@ namespace WindBot.Game.AI.Decks
if (Card.Location == CardLocation.MonsterZone)
{
AI.SelectCard(AI.Utils.GetBestEnemyMonster(true));
AI.SelectCard(AI.Utils.GetBestEnemyMonster(true, true));
return true;
}
else
......
......@@ -310,15 +310,31 @@ namespace WindBot.Game.AI
}
/// <summary>
/// Chain the enemy monster.
/// Chain the enemy monster, or disable monster like Rescue Rabbit.
/// </summary>
protected bool DefaultBreakthroughSkill()
{
if (!DefaultUniqueTrap())
return false;
if (Duel.Player == 1)
{
foreach (ClientCard target in Enemy.GetMonsters())
{
if (target.IsMonsterShouldBeDisabledBeforeItUseEffect())
{
AI.SelectCard(target);
return true;
}
}
}
ClientCard LastChainCard = AI.Utils.GetLastChainCard();
if (LastChainCard == null)
return false;
if (LastChainCard.Controller != 1 || LastChainCard.Location != CardLocation.MonsterZone || !DefaultUniqueTrap())
if (LastChainCard.Controller != 1 || LastChainCard.Location != CardLocation.MonsterZone
|| LastChainCard.IsDisabled() || LastChainCard.IsShouldNotBeTarget() || LastChainCard.IsShouldNotBeSpellTrapTarget())
return false;
AI.SelectCard(LastChainCard);
return true;
......
namespace WindBot.Game.AI.Enums
{
/// <summary>
/// Monsters that release or banish itself to use effect. So them should be disabled (with Breakthrough Skill) before it use effect.
/// </summary>
public enum ShouldBeDisabledBeforeItUseEffectMonster
{
MachinaMegaform = 51617185,
DarkSummoningBeast = 87917187,
GemKnightAlexandrite = 90019393,
RedEyesRetroDragon = 53485634,
DeepSweeper = 8649148,
BeastWarriorPuma = 16796157,
ZefrasaberSwordmasteroftheNekroz = 84388461,
CipherWing = 81974607,
MadolcheAnjelly = 34680482,
PlanetPathfinder = 97526666,
RescueCat = 14878871,
RescueHamster = 50485594,
RescueFerret = 56343672,
RescueRabbit = 85138716,
GalaxyWizard = 98555327,
Backlinker = 71172240,
Merlin = 3580032,
CrystalVanguard = 87475570,
Kuribandit = 16404809,
PhotonLizard = 38973775,
SuperheavySamuraiFlutist = 27978707,
ConstellarRasalhague = 70624184,
CardcarD = 45812361,
UnifloraMysticalBeastoftheForest = 36318200,
BusterWhelpoftheDestructionSwordsman = 49823708,
GalaxyEyesCloudragon = 9260791,
SylvanPrincessprout = 20579538,
AltergeistPixiel = 57769391,
AbyssActorExtras = 88412339,
PerformapalTrumpWitch = 91584698,
RaidraptorLastStrix = 97219708,
TimeMaiden = 27107590,
SuperQuantalFairyAlphan = 58753372,
TheBlackStoneofLegend = 66574418,
PaladinofDarkDragon = 71408082,
PaladinofPhotonDragon = 85346853,
TwinPhotonLizard = 29455728
}
}
namespace WindBot.Game.AI.Enums
{
/// <summary>
/// Cards that are can't be selected as target of monster's effect, or immuned to monster's effect.
/// So them shouldn't be tried to be selected as target of monster at most times.
/// </summary>
public enum ShouldNotBeMonsterTarget
{
TheLegendaryFishermanII = 19801646,
FirstoftheDragons = 10817524,
Tatsunoko = 55863245,
CXyzSimontheGreatMoralLeader = 41147577,
PaleozoicAnomalocaris = 61307542,
PaleozoicOpabinia = 37649320,
BorreloadDragon = 31833038
}
}
namespace WindBot.Game.AI.Enums
{
/// <summary>
/// Cards that are can't be selected as target of spell&trap's effect, or immuned to spell&trap's effect.
/// So them shouldn't be tried to be selected as target of spell&trap at most times.
/// </summary>
public enum ShouldNotBeSpellTrapTarget
{
ApoqliphortTowers = 27279764,
ApoqliphortSkybase = 40061558,
TheLegendaryFishermanIII = 44968687,
ChaosAncientGearGiant = 51788412
}
}
namespace WindBot.Game.AI.Enums
{
/// <summary>
/// Cards that are can't be selected as target, or immuned to most effect.
/// So them shouldn't be tried to be selected as target at most times.
/// </summary>
public enum ShouldNotBeTarget
{
DivineSerpentGeh = 82103466,
ObelisktheTormentor = 10000000,
TheWingedDragonofRaSphereMode = 10000080,
TheWingedDragonofRaImmortalPhoenix = 10000090,
KozmoDarkPlanet = 85991529,
ZushintheSleepingGiant = 67547370,
TheLegendaryExodiaIncarnate = 58604027,
KozmoDarkEclipser = 64063868,
KozmoDarkDestroyer = 55885348,
KozmoForerunner = 20849090,
MajespecterUnicornKirin = 31178212,
WorldLegacyWorldShield = 55787576,
KiwiMagicianGirl = 82627406,
MajespecterFoxKyubi = 94784213,
MajespecterToadOgama = 645794,
MajespecterCrowYata = 68395509,
MajespecterRaccoonBunbuku = 31991800,
MajespecterCatNekomata = 5506791,
HazyFlameHydra = 8696773,
HazyFlameMantikor = 96051150,
HazyFlameHyppogrif = 31303283,
HazyFlameCerbereus = 38525760,
HazyFlameSphynx = 1409474,
HazyFlamePeryton = 37803172,
HazyFlameGriffin = 74010769,
BlueEyesChaosMAXDragon = 55410871,
SupremeKingZARC = 13331639,
CrimsonNovaTrinitytheDarkCubicLord = 72664875,
LunalightLeoDancer = 24550676,
TimaeustheKnightofDestiny = 53315891,
DantePilgrimoftheBurningAbyss = 18386170,
AncientGearHowitzer = 87182127,
InvokedCocytus = 85908279,
LyriluscIndependentNightingale = 76815942,
FlowerCardianLightshower = 42291297,
YaziEviloftheYangZing = 43202238,
RaidraptorUltimateFalcon = 86221741,
DisdainfulBirdofParadise = 27240101
}
}
......@@ -98,6 +98,10 @@
<Compile Include="Game\AI\Dialogs.cs" />
<Compile Include="Game\AI\Enums\DangerousMonster.cs" />
<Compile Include="Game\AI\Enums\FusionSpell.cs" />
<Compile Include="Game\AI\Enums\ShouldBeDisabledBeforeItUseEffectMonster.cs" />
<Compile Include="Game\AI\Enums\ShouldNotBeSpellTarget.cs" />
<Compile Include="Game\AI\Enums\ShouldNotBeMonsterTarget.cs" />
<Compile Include="Game\AI\Enums\ShouldNotBeTarget.cs" />
<Compile Include="Game\AI\Enums\PreventActivationEffectInBattle.cs" />
<Compile Include="Game\AI\Enums\OneForXyz.cs" />
<Compile Include="Game\AI\Enums\InvincibleMonster.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