SotMSteamMods / CauldronMods

Mod adaptations of the Cauldron decks for Sentinels of the Multiverse for Steam Workshop
MIT License
15 stars 9 forks source link

Tango One - Chameleon Armor/Critical Hit Previews with Redirects #1666

Open wrhyme29 opened 8 months ago

wrhyme29 commented 8 months ago

Describe the bug When there are redirects happening, the damage preview for Chameleon Armor freaks out and shows the error message.

What does it affect Card(s): Chameleon Armor Deck(s): Tango One

To Reproduce Steps to reproduce the behavior:

  1. Play with any villain, Tango One, Benchmark, Void Guard Writhe
  2. Play Chameleon Armor, Intervening Path Calculator, Lies of the Shadow, and The Shadow Cloak. Make Tango One the lowest HP.
  3. Play any card that deals damage. Through the redirects and/or targeting, send the damage to Tango One at some point.
  4. See the screenshot error message.

Expected behavior The question mark ambiguous preview appear, as well as showing the redirect options.

Screenshots image

Logs When we look in the Player.log, we see this exception:

Exception calling GetDamagePreviewResults! NullReferenceException: Object reference not set to an instance of an object at Handelabra.Sentinels.View.UIDecisionWindow.UpdateCalculationTable (Handelabra.Sentinels.View.UICardView cardView, System.Int32 damagePage) [0x0049d] in :0 UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object) UnityEngine.DebugLogHandler:LogException(Exception, Object) UnityEngine.Logger:LogException(Exception, Object) UnityEngine.Debug:LogException(Exception, Object) Handelabra.Sentinels.View.UIDecisionWindow:UpdateCalculationTable(UICardView, Int32) Handelabra.Sentinels.View.UIDecisionWindow:OnAnswerSelected(UIDecisionAnswer, Boolean) Handelabra.Sentinels.View.d__28:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

Additional context This is related to implementation in #1664

jamespicone commented 8 months ago
try
        {
            Game game = UIGameView.Instance.GameController.Game;
            string key = UndoManager.BuildKey(game.TurnPhaseIndex, game.ActiveTurnTaker, game.ActiveTurnPhase.Phase);
            string text = MultiplayerManager.ComputeUndoHash(game, key);
            enumerable = UIGameView.Instance.GameController.GetDamagePreviewResults(damageSource, card, 0, func, damageType, isIrreducible.Value, ambiguousChoice, selectCardDecision.CardSource);
            string text2 = MultiplayerManager.ComputeUndoHash(game, key);
            if (text != text2)
            {
                Debug.LogErrorFormat("Game hash changed after GetDamagePreviewResults! This can cause resync issues in multiplayer. Before: {0} after: {1}", text, text2);
                Debug.LogErrorFormat("Damage source: {0} target: {1} card source: {2}", damageSource, card, selectCardDecision.CardSource);
                flag3 = true;
            }
        }
        catch (Exception exception)
        {
            Debug.LogError("Exception calling GetDamagePreviewResults!");
            Debug.LogException(exception, this);
        }

that trace looks like it's not even getting in to GetDamagePreviewResults?

Are you still in game start? I see the debugger environment, if you did stuff before the game properly loaded it might be that issue where damage that occurs during setup breaks GetDamagePreviewResults.

wrhyme29 commented 8 months ago

Good call about the StartOfGame thing - I didn't know that was an issue. When I do the same thing but have the damage initiator be during the Villain Play phase, damage preview resolves as expected. So I think we can probably declare this issue a non-issue?

jamespicone commented 8 months ago

To be a bit more specific about things I think might go wrong, if Tango One does 0 damage or damage that is reduced to 0, but is later increased by Critical Hit, I bet it'll dodge redirects that should have triggered.

I don't have anything immediately in mind that should break with chameleon armour.