diff demos/rpg/scripts/quests/basequest.py @ 542:67f6f3538e88

Refactored the Quest class a bit. Made it a base class for other possible quest types. Added the RETURN_ITEM quest type.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Tue, 01 Jun 2010 21:38:14 +0000
parents 2e739ae9a8bc
children d0282579668c
line wrap: on
line diff
--- a/demos/rpg/scripts/quests/basequest.py	Tue Jun 01 19:19:08 2010 +0000
+++ b/demos/rpg/scripts/quests/basequest.py	Tue Jun 01 21:38:14 2010 +0000
@@ -29,14 +29,41 @@
 
 from fife import fife
 
+QuestTypes = {'DEFAULT':0,
+		   'RETURN_ITEM':1}
+
 class Quest(object):
-	"""
-	@todo: do a little refactoring here to split out the type of quests.
-	"""
 	def __init__(self, owner, questname, questtext):
 		self._owner = owner
 		self._name = questname
 		self._text = questtext
+		
+	def checkQuestCompleted(self, actor):
+		pass
+
+	def _getOwner(self):
+		return self._owner
+	
+	def _getName(self):
+		return self._name
+		
+	def _setName(self, questname):
+		self._name = questname
+		
+	def _getText(self):
+		return self._text
+		
+	def _setText(self, questtext):
+		self._text = questtext
+
+	owner = property(_getOwner)
+	name = property(_getName, _setName)
+	text = property(_getText, _setText)
+
+class ReturnItemQuest(Quest):
+	def __init__(self, owner, questname, questtext):
+		super(ReturnItemQuest, self).__init__(owner, questname, questtext)
+
 		self._requireditems = []
 		self._requiredgold = 0
 		
@@ -59,30 +86,11 @@
 				
 		return completed
 	
-	def _getOwner(self):
-		return self._owner
-	
-	def _getName(self):
-		return self._name
-		
-	def _setName(self, questname):
-		self._name = questname
-		
-	def _getText(self):
-		return self._text
-		
-	def _setText(self, questtext):
-		self._text = questtext
-	
 	def _getRequiredGold(self):
 		return self._requiredgold
 	
 	def _getRequiredItems(self):
 		return self._requireditems
 	
-	owner = property(_getOwner)
-	name = property(_getName, _setName)
-	text = property(_getText, _setText)
 	requiredgold = property(_getRequiredGold)
 	requireditems = property(_getRequiredItems)
-