Mercurial > parpg-source
diff gamestate.py @ 58:d4f213b99d41
Added meet and met methods from the old player object to the gamestate.
author | KarstenBock@gmx.net |
---|---|
date | Fri, 09 Sep 2011 15:47:43 +0200 |
parents | 98f26f7636d8 |
children | 5c751b9a3d8b |
line wrap: on
line diff
--- a/gamestate.py Fri Sep 09 15:30:23 2011 +0200 +++ b/gamestate.py Fri Sep 09 15:47:43 2011 +0200 @@ -25,6 +25,7 @@ self.object_ids = {} self.current_map_name = None self.maps = {} + self.npcs_met = set() def addObject(self, map_id, game_object): @@ -121,4 +122,20 @@ self.current_map_name = state["CurrentMap"] self.quest_engine.readQuests() self.quest_engine.restoreFromState(state["Quests"]) - + + def meet(self, npc): + """Record that the PC has met a certain NPC + @type npc: str + @param npc: The NPC's name or id""" + if npc in self.npcs_met: + # we could raise an error here, but should probably be a warn + # raise RuntimeError("I already know %s" % npc) + return + self.npcs_met.add(npc) + + def met(self, npc): + """Indicate whether the PC has met this npc before + @type npc: str + @param npc: The NPC's name or id + @return: None""" + return npc in self.npcs_met