Closed bastisawesome closed 1 year ago
I'm a dumbass and missed the most basic solution: using Python's built-in casting functions. While this method is not necessarily ideal, in that it relies on the behaviour of the built-in casting, it doesn't require an explicit bias for what happens the the numbers. So either developer bias on how to handle the numbers, or implementation bias on how to handle the numbers.
In line with #21, tests should also be updated to show what happens in this situation.
The database manager currently assumes that when calling
add_X
(e.g.add_tokens
) the amount passed is positive. This is not guaranteed at all, however, and in the event of passing in negative numbers could break the implied constraint that both tokens and score should be positive integers. There are two major flaws with the current logic:The first issue should be made a non-issue, and in fact it would be possible to have the
remove_X
functions just call back toadd_X
. Theadd_X
logic would then account for negatives and adjust the result as necessary. This means theremove_X
functions will have minimal logic and act primarily as a wrapper function to the equivalentadd_X
. Example:This simplifies the codebase greatly and ensures that only one test needs to be made for
remove_X
functions, to ensure that they properly adjust the amount and call theadd_X
functions.The second issue is more complicated and could be resolved in a number of ways: