WarFrontIO / client

Real-time strategy game played in the browser
https://dev.warfront.io
MIT License
22 stars 6 forks source link

Attacking causes target to lose 100 more troops #18

Closed Riprefro54 closed 1 month ago

Riprefro54 commented 1 month ago

Expected Behavior

When attacked, target should lose only Math.ceil((1 + attackCost) / 2); amount of troops

Actual Behavior

When the target reaches it's maximum troops (which is territory100), for every pixel that attacker conquered target loses 100 more troops because a player cant have more than territory100 troops. Problably because of this: addTroops(amount: number) { this.troops = Math.min(this.territorySize * 100, this.troops + amount); } in player.ts

Steps to Reproduce

Attack a bot that has reached maximum troops, or wait until you have maximum troops and get attacked

Which browser are you using?

Chrome

If you selected "Other", please specify

No response

Additional Information

Maybe instead of checking in addTroops it can be checked in income (add income if player has less troops than territory*100) I would just try fixing it and make a pull req but im busy lately, sorry.

Riprefro54 commented 1 month ago

Oops didnt know adding 2 stars (*) makes it italic

platz1de commented 1 month ago

The troops being reduced to the cap is intended behaviour, this should still not happen though. The attack cost formula requires tweaking (it is to be expected that at least the troops on that tile help defending) like most troop-based formulas. I'll keep this open until the formulas finally make some sense

Riprefro54 commented 1 month ago

Using troop density instead of troops for attack cost might work. I found this bug when a 15K bot killed 30K me

platz1de commented 1 month ago

Formula adjusted in 137cb3e