From 383b972a470454d506613dc23cdf058803626711 Mon Sep 17 00:00:00 2001 From: Wind2009-Louse Date: Tue, 10 Oct 2023 20:17:34 +0800 Subject: [PATCH] Fix --- Game/AI/Decks/DogmatikaExecutor.cs | 88 +++++++++++++++++++++++++----- Game/AI/DefaultExecutor.cs | 10 ++++ Game/ClientCard.cs | 3 + 3 files changed, 87 insertions(+), 14 deletions(-) diff --git a/Game/AI/Decks/DogmatikaExecutor.cs b/Game/AI/Decks/DogmatikaExecutor.cs index 7b231bb6..4b6f5f78 100644 --- a/Game/AI/Decks/DogmatikaExecutor.cs +++ b/Game/AI/Decks/DogmatikaExecutor.cs @@ -119,7 +119,7 @@ public DogmatikaExecutor(GameAI ai, Duel duel) AddExecutor(ExecutorType.Activate, CardId.DogmatikaMacabre, DogmatikaMacabreActivate); // other - AddExecutor(ExecutorType.Activate, CardId.DogmatikaFleurdelis, DogmatikaFleurdelisActivateDelay); + AddExecutor(ExecutorType.Activate, CardId.DogmatikaFleurdelis, DogmatikaFleurdelisDelayActivate); AddExecutor(ExecutorType.Repos, MonsterRepos); AddExecutor(ExecutorType.Summon, SummonForTYPHONCheck); AddExecutor(ExecutorType.SpSummon, CardId.DiabellstarTheBlackWitch, DiabellstarTheBlackWitchSpSummon); @@ -145,7 +145,7 @@ public DogmatikaExecutor(GameAI ai, Duel duel) 58699500, 20343502 }; List discardEnemyExtraIdList = new List{ - _CardId.DivineArsenalAAZEUS_SkyThunder, CardId.SuperStarslayerTYPHON, CardId.SPLittleKnight, CardId.Number41BagooskatheTerriblyTiredTapir, + _CardId.DivineArsenalAAZEUS_SkyThunder, CardId.SPLittleKnight, CardId.Number41BagooskatheTerriblyTiredTapir, 70534340, 60465049, 24094258, 86066372 }; @@ -803,11 +803,11 @@ public bool CheckLastChainShouldNegated() return true; } - public bool CheckHasExtraOnField() + public bool CheckHasExtraOnField(ClientCard exceptCard = null) { List fieldMonsterList = Bot.GetMonsters(); fieldMonsterList.AddRange(Enemy.GetMonsters()); - bool hasExtraOnField = fieldMonsterList.Any(card => card.HasType(CardType.Fusion | CardType.Synchro | CardType.Xyz | CardType.Link)); + bool hasExtraOnField = fieldMonsterList.Any(card => card.HasType(CardType.Fusion | CardType.Synchro | CardType.Xyz | CardType.Link) && card != exceptCard); return hasExtraOnField; } @@ -861,7 +861,7 @@ public override CardPosition OnSelectPosition(int cardId, IList po return CardPosition.FaceUpAttack; } int cardAttack = cardData.Attack; - if (cardId == CardId.DogmatikaFleurdelis && !activatedCardIdList.Contains(cardId + 1)) cardAttack += 500; + if (cardId == CardId.DogmatikaFleurdelis && !activatedCardIdList.Contains(cardId + 1) && Duel.Player == 0) cardAttack += 500; int bestBotAttack = Math.Max(Util.GetBestAttack(Bot), cardAttack); if (Util.IsAllEnemyBetterThanValue(bestBotAttack, true)) { @@ -1042,6 +1042,17 @@ public override IList OnSelectCard(IList cards, int min, public override void OnNewTurn() { + if (Duel.Turn <= 1) + { + calledbytheGraveCount.Clear(); + banSpSummonFromExTurn = 0; + checkedEnemyExtra = false; + avoid2Monster = true; + dimensionShifterCount = 0; + + enemySpSummonFromExLastTurn = 0; + enemySpSummonFromExThisTurn = 0; + } enemyActivateMaxxC = false; enemyActivateLockBird = false; omegaActivateCount = 0; @@ -1085,6 +1096,31 @@ public override void OnMove(int cardId, int previousControler, int previousLocat base.OnMove(cardId, previousControler, previousLocation, currentControler, currentLocation); } + public override ClientCard OnSelectAttacker(IList attackers, IList defenders) + { + if (attackers.Count() > 0) return attackers[attackers.Count() - 1]; + return null; + } + + public override BattlePhaseAction OnSelectAttackTarget(ClientCard attacker, IList defenders) + { + foreach (ClientCard defender in defenders) + { + attacker.RealPower = attacker.Attack; + defender.RealPower = defender.GetDefensePower(); + if (!OnPreBattleBetween(attacker, defender)) + continue; + + if (attacker.RealPower > defender.RealPower) + return AI.Attack(attacker, defender); + } + + if (attacker.CanDirectAttack) + return AI.Attack(attacker, null); + + return null; + } + public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender) { if (!defender.IsMonsterHasPreventActivationEffectInBattle()) @@ -1122,7 +1158,6 @@ public override void OnChaining(int player, ClientCard card) { if (Enemy.SpellZone[i] == card) { - Logger.DebugWriteLine("Enemy activate InfiniteImpermanence at " + i.ToString()); infiniteImpermanenceList.Add(4-i); break; } @@ -1159,6 +1194,7 @@ public override void OnChainEnd() /// Whether need to avoid set in this place public void SelectSTPlace(ClientCard card = null, bool avoidImpermanence = false, List avoidList = null) { + if (card == null) card = Card; List list = new List(); for (int seq = 0; seq < 5; ++seq) { @@ -1289,7 +1325,7 @@ public bool DogmatikaFleurdelisActivate() } // for avoid lose if (Duel.Player == 1 && Bot.GetMonsterCount() == 0 && Util.GetTotalAttackingMonsterAttack(1) >= Bot.LifePoints - && Duel.Phase == DuelPhase.Main1 && (CurrentTiming & hintTimingMainEnd) != 0) + && Duel.Phase == DuelPhase.Main1 && (CurrentTiming & hintTimingMainEnd) != 0 && Duel.Turn > 1) { activatedCardIdList.Add(CardId.DogmatikaFleurdelis); List enemyTargetList = ShuffleCardList(Enemy.GetMonsters().Where(card => card.IsFaceup() && !card.IsDisabled()).ToList()); @@ -1314,20 +1350,22 @@ public bool DogmatikaFleurdelisActivate() return false; } - public bool DogmatikaFleurdelisActivateDelay() + public bool DogmatikaFleurdelisDelayActivate() { if (CheckWhetherNegated()) return false; if (Card.Location == CardLocation.Hand) { bool checkFlag = false; - if (Duel.Player == 0 && Duel.Phase == DuelPhase.Main1) + bool notQuickTiming = Duel.LastChainPlayer == -1 && CurrentTiming <= 0; + if (Duel.Player == 0 && Duel.Phase == DuelPhase.Main1 && notQuickTiming && Duel.Turn > 1) { + Logger.DebugWriteLine("=== timing: " + CurrentTiming.ToString()); int attack = Util.GetBestAttack(Bot); List currentBetterList = Enemy.MonsterZone.GetMonsters().Where(card => card.GetDefensePower() >= attack).ToList(); List newBetterList = Enemy.MonsterZone.GetMonsters().Where(card => card.GetDefensePower() >= 3000).ToList(); if (currentBetterList.Count() > newBetterList.Count()) checkFlag = true; } - if ((Bot.HasInHandOrInSpellZone(CardId.SinfulSpoilsOfDoom_Rciela) && Duel.Player == 0) + if ((Bot.HasInHandOrInSpellZone(CardId.SinfulSpoilsOfDoom_Rciela) && Duel.Player == 0 && notQuickTiming) || Bot.GetSpells().Any(card => card.IsCode(CardId.SinfulSpoilsOfDoom_Rciela) && card.IsFacedown())) { if (!Bot.GetMonsters().Any(card => card.IsFaceup() && card.Level >= 7 && card.HasRace(CardRace.SpellCaster))) checkFlag = true; @@ -1398,7 +1436,7 @@ public bool DogmatikaMaximusActivate() CardId.TitanikladTheAshDragon, CardId.GranguignolTheDuskDragon, CardId.PSYFramelordOmega, CardId.DespianLuluwalilith }; foreach (int checkId in checkDiscardIdList) { - if (Bot.HasInExtra(checkId) && !discardExtraThisTurn.Contains(checkId) && !activatedCardIdList.Contains(checkId)) + if (Bot.HasInExtra(checkId) && !activatedCardIdList.Contains(checkId)) { if (checkId == CardId.ElderEntityNtss) { @@ -1531,10 +1569,21 @@ public bool DiabellstarTheBlackWitchSpSummon() return true; } } + List extraCheckList = Bot.GetMonsters().Where(card => card.HasType(CardType.Fusion | CardType.Synchro | CardType.Link)) + .OrderBy(card => card.Attack).ToList(); + foreach (ClientCard checkCard in extraCheckList) + { + if (!Bot.HasInHand(CardId.DogmatikaFleurdelis) || CheckHasExtraOnField(checkCard)) + { + AI.SelectCard(checkCard); + return true; + } + } } - if (Bot.GetMonsterCount() == 0) + if (Bot.GetMonsterCount() == 0 || CheckRemainInDeck(CardId.SinfulSpoilsOfDoom_Rciela) > 0) { - List spellIdList = new List{ _CardId.InfiniteImpermanence, CardId.CrossoutDesignator, CardId.DogmatikaPunishment, _CardId.CalledByTheGrave }; + List spellIdList = new List{ CardId.CrossoutDesignator, _CardId.InfiniteImpermanence, _CardId.CalledByTheGrave, + CardId.DogmatikaPunishment, CardId.DogmatikaMacabre, CardId.DogmatikaLamity }; foreach (int spellId in spellIdList) { if (Bot.HasInHandOrInSpellZone(spellId)) @@ -1578,7 +1627,14 @@ public bool DogmatikaEcclesiaActivate() // sp summon if (Card.Location == CardLocation.Hand) { - if (CheckShouldNoMoreSpSummon() || activatedCardIdList.Contains(Card.Id)) return false; + if (activatedCardIdList.Contains(Card.Id)) return false; + if (CheckShouldNoMoreSpSummon()) + { + if (!Bot.HasInHand(CardId.DogmatikaFleurdelis) || Bot.GetMonsters().Any(card => card.IsFaceup() && card.HasSetcode(SetcodeDogmatika))) + { + return false; + } + } if (enemyActivateLockBird) { if (Bot.HasInHand(CardId.DogmatikaFleurdelis) && !Bot.GetMonsters().Any(card => card.IsFaceup() && card.HasSetcode(SetcodeDogmatika))) @@ -2520,6 +2576,7 @@ public bool DespianLuluwalilithActivate() AI.SelectYesNo(true); AI.SelectCard(currentChainEnemyCard); } + else AI.SelectYesNo(false); return true; } return false; @@ -2589,6 +2646,8 @@ public bool SuperStarslayerTYPHONSpSummon() if (material == null || material.Attack >= 3000) return false; bool checkFlag = GetProblematicEnemyMonster(material.Attack) != null; + checkFlag |= material.HasType(CardType.Link); + checkFlag |= material.Level <= 4; if (checkFlag) { AI.SelectMaterials(material); @@ -2600,6 +2659,7 @@ public bool SuperStarslayerTYPHONSpSummon() public bool SuperStarslayerTYPHONActivate() { + if (CheckWhetherNegated()) return false; List targetList = new List(); targetList.AddRange(Enemy.GetMonsters().Where(c => !currentDestroyCardList.Contains(c) && c.IsFloodgate() && c.IsFaceup()).OrderByDescending(card => card.Attack)); diff --git a/Game/AI/DefaultExecutor.cs b/Game/AI/DefaultExecutor.cs index 30c20fd5..fe1ac360 100644 --- a/Game/AI/DefaultExecutor.cs +++ b/Game/AI/DefaultExecutor.cs @@ -125,6 +125,13 @@ protected class _CardId public const int VaylantzWorld_ShinraBansho = 49568943; public const int VaylantzWorld_KonigWissen = 75952542; public const int DivineArsenalAAZEUS_SkyThunder = 90448279; + + public const int RescueACEHydrant = 37617348; + } + + protected class _Setcode + { + public const int RescueACE = 0x18b; } protected DefaultExecutor(GameAI ai, Duel duel) @@ -252,6 +259,9 @@ public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender if (defender.OwnTargets.Any(card => card.IsCode(_CardId.PhantomKnightsFogBlade) && !card.IsDisabled())) return false; + + if (defender.IsCode(_CardId.RescueACEHydrant) && !defender.IsDisabled() && Enemy.GetMonsters().Any(monster => monster.HasSetcode(_Setcode.RescueACE) && !monster.IsCode(_CardId.RescueACEHydrant))) + return false; return true; } diff --git a/Game/ClientCard.cs b/Game/ClientCard.cs index 1eec6b7b..970e0f6e 100644 --- a/Game/ClientCard.cs +++ b/Game/ClientCard.cs @@ -82,6 +82,9 @@ public void SetId(int id) Name = Data.Name; if (Data.Alias != 0) Alias = Data.Alias; + } else { + Name = null; + Alias = 0; } }