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
We'd like to create a helper method to avoid doing this. This is what I had in mind:
We'd have to create a function with the signature:
template<classT>
T RandomEvent(int denominator, vector<int> numerators, vector<T> outcomes)
where it must be that sum(numerators) == denominator and numerators.size() == outcomes.size(). The function takes in generic outcomes, so that even things like functions could be decided randomly.
With this helper function, the GiantCrab function could be rewritten as:
This helper function should be placed in the Common class. If you have another design in mind, or know any existing STL libraries that can do this, let me know - we can probably do better than this 😛
The text was updated successfully, but these errors were encountered:
I'd like to work on this.
I'm sure that there might be better ways to do this depending from case to case but it sounds like a good solution for a generalised situation.
Here is how we currently calculate random damage (from
GiantCrab.cpp
):This basically means:
We'd like to create a helper method to avoid doing this. This is what I had in mind:
We'd have to create a function with the signature:
where it must be that
sum(numerators) == denominator
andnumerators.size() == outcomes.size()
. The function takes in generic outcomes, so that even things like functions could be decided randomly.With this helper function, the GiantCrab function could be rewritten as:
This helper function should be placed in the
Common
class. If you have another design in mind, or know any existing STL libraries that can do this, let me know - we can probably do better than this 😛The text was updated successfully, but these errors were encountered: