# HG changeset patch # User prock@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1274996076 0 # Node ID 19db5a8619a43cd02e24176b782760bea4bf630a # Parent 6037f79b0dcf0138a705f8d81955f0389d874a9e Added the GoldStack item class. The scene now loads the goldstack and assigns it's value based on the maps objects file. diff -r 6037f79b0dcf -r 19db5a8619a4 demos/rpg/scripts/objects/items.py --- a/demos/rpg/scripts/objects/items.py Thu May 27 21:11:37 2010 +0000 +++ b/demos/rpg/scripts/objects/items.py Thu May 27 21:34:36 2010 +0000 @@ -32,7 +32,7 @@ class BaseItem(BaseGameObject): - def __init__(self, gamecontroller, itemname, itemtype="unknown"): + def __init__(self, gamecontroller, itemtype, itemname): self._type = GameObjectTypes["ITEM"] super(BaseItem, self).__init__(gamecontroller, itemtype, itemname, True) @@ -53,3 +53,17 @@ itemtype = property(_getItemType) itemname = property(_getItemName) + +class GoldStack(BaseItem): + def __init__(self, gamecontroller, itemtype, itemname): + super(GoldStack, self).__init__(gamecontroller, itemtype, itemname) + + self._value = 0 + + def _getValue(self): + return self._value + + def _setValue(self, value): + self._value = value + + value = property(_getValue, _setValue) diff -r 6037f79b0dcf -r 19db5a8619a4 demos/rpg/scripts/scene.py --- a/demos/rpg/scripts/scene.py Thu May 27 21:11:37 2010 +0000 +++ b/demos/rpg/scripts/scene.py Thu May 27 21:34:36 2010 +0000 @@ -34,7 +34,7 @@ from scripts.actors.baseactor import QuestGiver, Quest from scripts.actors.player import Player from scripts.objects.baseobject import GameObjectTypes -from scripts.objects.items import BaseItem +from scripts.objects.items import BaseItem, GoldStack class Scene(object): def __init__(self, gamecontroller): @@ -75,7 +75,14 @@ itemdict = objectsettings.get("items", item, {}) modeldict = itemsettings.get("models", itemdict["typename"]) - newitem = BaseItem(self._gamecontroller, item, modeldict["model"]) + if itemdict["typename"] == "GoldStack": + newitem = GoldStack(self._gamecontroller, modeldict["model"], item) + #newitem.value = itemdict["value"] + print itemdict["value"] + else: + newitem = BaseItem(self._gamecontroller, modeldict["model"], item) + + self._objectlist[newitem.instance.getId()] = newitem for npc in objectsettings.get("npcs", "npclist", []): objdict = objectsettings.get("npcs", npc, {})