You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With a game with a set end year, entering the SC counts for that year causes a division by zero exception. The backtrace is something like this:
game_scoring.py:239 GScoringSumOfSquares.save()
models.py:802 Game.scores()
models.py:1166 Game.save()
models.py:1552 CentreCount.save()
views.py:1232 sc_counts()
It seems that local variable sum_of_squares is zero.
The text was updated successfully, but these errors were encountered:
I think we hit the error because the first CentreCount added is for an eliminated power. Because the year is the final year for the game, we set the game to is_finished and save it. That means recalculating the scores for the game, which retrieves the centre counts for the final year from the db, most of which don't exist. The one that does exist is zero, giving a score of 0/0.
We actually don't want to recalculate the scores until we have the centre counts for all 7 powers saved to the database, which I think means setting the game to finished from the view code instead.
The same bug probably exists if somebody solos, and I suspect things wouldn't be correct if there were no eliminated powers, too, although we might not get an exception in that case).
Added a test for issue #44.
Removed CentreCount.save() - we need a full set of CentreCounts before
we can calculate scores for a Game, and Game.save() will recalculate the
scores if is_finished is now True.
Added TODOs to add tests for all the other save() methods, and for where
we may be doing redundant stuff in tests.
In the views, set Game.is_finished (and call Game.save()) when we either
have added CentreCounts for the final game year or have added CentreCounts
including a solo victor.
Also, add an exception handler to Game.news() because when after making the
changes above, some tests were failing because Game.is_finished is now
False when it was previously True.
With a game with a set end year, entering the SC counts for that year causes a division by zero exception. The backtrace is something like this:
game_scoring.py:239 GScoringSumOfSquares.save()
models.py:802 Game.scores()
models.py:1166 Game.save()
models.py:1552 CentreCount.save()
views.py:1232 sc_counts()
It seems that local variable sum_of_squares is zero.
The text was updated successfully, but these errors were encountered: