Mercurial > parpg-source
changeset 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 | ba85e5aff370 |
children | 535801aec63e |
files | gamestate.py |
diffstat | 1 files changed, 18 insertions(+), 1 deletions(-) [+] |
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