Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid putting the game in a broken state if invalid turbo settings are submitted for fire-assisted attack #2972

Conversation

cgolubi1
Copy link
Contributor

@cgolubi1 cgolubi1 commented Jul 31, 2024

This is the simplest possible fix for the root cause.

Background:

  • Fire-assisted attacks are performed in two parts, first setting up the attack for fire turndown, and then the fire turndown happens and the attack is committed
  • Setting turbo values always happens after the attack is resolved.
  • Because in the UI the turbo values are set on the first screen, we cache those values from submitTurn, and then get them out of the cache and apply them when we adjust fire dice.

The reason we get games into a broken state, is simply that the fire-adjusted path has its own implementation of applying turbo values, and it doesn't check the return value from set_turbo_sizes(), such that if set_turbo_sizes() fails, we just plow on ahead, and importantly, we plow on ahead to save_game(), committing the broken state in the DB.

This is the simplest possible fix --- it checks the return value, and tells the player if it failed. And it does work (i'm attaching some screencaps below), because if the player abandons the fire turndown, that abandons the cached turbo values, and the player can start over.

It's not the most user-friendly --- it would be marginally more friendly if we rejected the turbo values on the initial screen, rather than making the player back their attack out. However, i think we should stick with this, because:

  • This is the first time we've heard of a player actually running into this case, and we're several years into supporting Turbo+Fire
  • Detecting the problem on the first screen would require something different would require something like the BMAttackTrip::attacker_apply_turbo() workflow where we optimistically apply the turbo changes on cloned dice just to test them. That's more complexity and more opportunity to introduce errors; since the player can rescue themselves with this fix, it doesn't seem worth it.

[dev site: https://2967-invalid-turbo-swing-fire.cgolubi1.dev.buttonweavers.com/ui/ ]

@blackshadowshade
Copy link
Contributor

This looks like a pretty simple fix. I figure we fire up a dev site for it and take a look.

@cgolubi1
Copy link
Contributor Author

Demonstrating this fix, in six screencaps:

01_invalid_turbo 02_fire_turndown 03_error_message 04_back_to_turbo_screen 05_fire_turndown_again 06_success

@blackshadowshade
Copy link
Contributor

Looks good. If we can get testers on the dev site to replicate that behaviour, I'm happy to approve this as-is.

@cgolubi1
Copy link
Contributor Author

Dev site is up at https://2967-invalid-turbo-swing-fire.cgolubi1.dev.buttonweavers.com/ui/ --- please take a look!

@blackshadowshade
Copy link
Contributor

Still looking for testers to give this a go.

@PoshFrosh
Copy link

Dev site is up at https://2967-invalid-turbo-swing-fire.cgolubi1.dev.buttonweavers.com/ui/ --- please take a look!

@blackshadowshade @cgolubi1
I learned about this on discord and gave it a shot. Game 502:

image

image

image

image

image

image

@dwvanstone
Copy link
Contributor

I've tested this as well -- including the case of fire overshooting on a power attack (with turbo). It looks good.

@blackshadowshade
Copy link
Contributor

Thank you for testing, both of you!

@cgolubi1
Copy link
Contributor Author

cgolubi1 commented Aug 9, 2024

@blackshadowshade what else does this need before you'd be good to merge it?

@blackshadowshade
Copy link
Contributor

Thank you for the reminder, merging now.

@blackshadowshade blackshadowshade merged commit ace380f into buttonmen-dev:master Aug 9, 2024
@cgolubi1 cgolubi1 deleted the 2967_invalid_turbo_swing_fire branch October 27, 2024 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants