lijim / monks-and-mages

Monks and Mages is a TCG-game built on React and socket.io
https://www.monksandmages.com
MIT License
17 stars 0 forks source link

Fix: fix 3-player/4-player games bonuses for not going 1st #466

Closed lijim closed 1 year ago

lijim commented 1 year ago

Modulo doesn't work with negative numbers in Javascript, causing some issues with players in 3/4 player games not getting their starting bonuses for not going 1st.

So trying to calculate the "starting position" by subtracting indexes can result in negative positions.

Example: starting player is index 2 player A is index 0. player B is index 1 player C is index 3

While player C will be correctly calculated as having a "positionAfterStartingPlayer" of 1, player B would be -1

This change fixes that by adding the total number of players before doing the modulo operator