Created
November 11, 2008 07:33
-
-
Save pol/23774 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# makes sure that all of the monsters and characters have participants | |
def update_participants | |
epm = {} | |
# make sure each character is accounted for, each one is only in there once. | |
self.participants.each do |p| | |
unless p.is_monster? || self.characters.include?(p.character) | |
self.add_participants([p], :type => :character) | |
elsif p.is_monster? | |
epm[p.monster_id] = epm[p.monster_id] ? 0 : epm[p.monster_id] + 1 # build a monster count hash | |
end | |
end | |
# make sure each monster is accounted for, this is tougher since there can be more than one. | |
# strategy: monster lists can only grow here, they are deleted elsewhere | |
self.monster_ids.each do |mid| | |
# if the monster is in the emp list, delete it | |
# otherwise, add it | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment