changeset 525:19db5a8619a4

Added the GoldStack item class. The scene now loads the goldstack and assigns it's value based on the maps objects file.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 27 May 2010 21:34:36 +0000
parents 6037f79b0dcf
children c916d7b7de1c
files demos/rpg/scripts/objects/items.py demos/rpg/scripts/scene.py
diffstat 2 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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)
--- 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, {})