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
In playing with my own Warrior I decided I wanted to teach him how to recognize individual monsters and remember them from turn to turn. I checked the RubyWarrior source and discovered that the monster objects persist from turn to turn but that they don't offer #hash methods to remember them by. I monkeypatched Unit and Space and it had the desired effect. I'd like to submit a pull request to add this functionality (with specs) but before I do I'd like confirmation from a maintainer that this won't violate the spirit of the game. Sample monkey patches are below
Thanks!
require'securerandom'moduleRubyWarriormoduleUnitsclassBasedefunique_id@uuid ||= SecureRandom.uuidenddefeql?(other_unit)self.hash == other_unit.hashenddefhashself.unique_id.hashendendendclassSpacedefunique_id@uuid ||= SecureRandom.uuidenddefeql?(other_space)self.hash == other_space.hashend# Not sure about this part but my code didn't work when # I tried to only put the monster hashes on the units themselves.#defhashself.unit.hash || self.unique_id.hashendendend
The text was updated successfully, but these errors were encountered:
In playing with my own Warrior I decided I wanted to teach him how to recognize individual monsters and remember them from turn to turn. I checked the RubyWarrior source and discovered that the monster objects persist from turn to turn but that they don't offer #hash methods to remember them by. I monkeypatched Unit and Space and it had the desired effect. I'd like to submit a pull request to add this functionality (with specs) but before I do I'd like confirmation from a maintainer that this won't violate the spirit of the game. Sample monkey patches are below
Thanks!
The text was updated successfully, but these errors were encountered: