hseager / you-are-merlin

You are Merlin - A Rust text adventure game
https://hseager.github.io/you-are-merlin-www/
GNU General Public License v3.0
25 stars 1 forks source link

Sometime, the attack turn gets skipped #5

Closed tolik518 closed 5 months ago

tolik518 commented 5 months ago

So I just had a round where I was attacked multiple times without having the possibility to attack back:

Your equiped items:
Weapon: Sting - Elven Dagger - (Legendary Weapon) / 3 Power / 211 Attack Speed / 1.2 Crit Multiplier / 9.7% Crit Chance
Armor: Gondor Shield - (Epic Armour) / 34 Max Life / 19.5% Parry / 13.5% Dodge
Artifact: Palantír - (Legendary Artifact) / 6 Power / 202 Attack Speed / 38 Max Life / 8.3% Dodge
You are currently visiting The Shire.
A peaceful land of green hills and hobbit-holes, home to the simple folk of the hobbits.
What would you like to do?

> Travel

Where would you like to go?

> Gondor

You are currently visiting Gondor.
A realm of noble warriors and ancient cities, standing as a bulwark against the darkness of Mordor.
What would you like to do?

> Explore

A Haradrim Warrior appears! Warriors from the South, skilled in desert combat and wielding scimitars.
They pose little threat and should be dispatched with ease.

> Attack
You attack Haradrim Warrior for 12 damage. (Enemy life: 8)
Haradrim Warrior attacks you for 6 damage. (Your life: 166)
Haradrim Warrior CRITS you for 6 damage. (Your life: 160)
Haradrim Warrior attacks you for 8 damage. (Your life: 152)
Haradrim Warrior attacks you for 6 damage. (Your life: 146)
Haradrim Warrior attacks you for 5 damage. You parry and reflect 2 damage. (Your life: 143)
Haradrim Warrior attacks you for 5 damage. (Your life: 138)
Haradrim Warrior attacks you for 6 damage. (Your life: 132)
Haradrim Warrior attacks you for 9 damage. (Your life: 123)
Haradrim Warrior attacks you for 8 damage. (Your life: 115)
Haradrim Warrior attacks you for 6 damage. But you dodged! (Your life: 115)
Haradrim Warrior attacks you for 7 damage. You parry and reflect 3 damage. (Your life: 111)
Haradrim Warrior attacks you for 5 damage. (Your life: 106)
Haradrim Warrior attacks you for 6 damage. (Your life: 100)
Haradrim Warrior attacks you for 6 damage. (Your life: 94)
Haradrim Warrior attacks you for 7 damage. (Your life: 87)
Haradrim Warrior attacks you for 5 damage. You parry and reflect 2 damage. (Your life: 84)
Haradrim Warrior attacks you for 6 damage. (Your life: 78)
You attack Haradrim Warrior for 12 damage. (Enemy life: -11)
You defeated Haradrim Warrior!

A Nazgûl Knight appears! Mounted servants of the Dark Lord, clad in black armor and wielding deadly weapons.
The battlefield awaits with bated breath, offering a stern test for those bold enough to step forward.

I don't know if I was being extremely unlucky, but I think the changes should be rather small, I guess?
I had the same issue in my next fight and died.

I played the wasm version over here: https://hseager.github.io/you-are-merlin-www/

hseager commented 5 months ago

Hey, thanks for reporting this with all the info!

Wow you've got some nice items there, that's a lot of attack speed! I may have forgotten that Artifacts can have attack speed too when tweaking the stats... whoops...

The issue is that you have a combined attack speed of more than 400, as the base attack speed is 4 seconds (4000). The attack speed is calculated as (base_attack - (x * 10)), so 20 attack speed makes attacks 200ms quicker. Having an attack speed more than the base_attack speed causes an attempt to subtract with overflow error in the CLI version, but the wasm version doesn't catch errors in the same way it seems.

I'll get a fix in for this by nerfing the attack speed to 175 for each.

tolik518 commented 5 months ago

@hseager yeah that makes sense - maybe there also should be a check so you won't get a value below 0?

hseager commented 4 months ago

@hseager yeah that makes sense - maybe there also should be a check so you won't get a value below 0?

yeah you're right. I actually woke up this morning and thought the same thing about fixing it properly!

I've added an attack_speed cap in the config and a unit test to check it.