enemy pointers are now actually enemy clones. (3 rocs = 3 entirely separate rocs)
[asgard.git] / transaction.py
blob6e8878941754fee41e7710b92c7388ded413e25a
1 ########################################################
2 #Copyright (c) 2006 Russ Adams, Sean Eubanks, Asgard Contributors
3 #This file is part of Asgard.
5 #Asgard is free software; you can redistribute it and/or modify
6 #it under the terms of the GNU General Public License as published by
7 #the Free Software Foundation; either version 2 of the License, or
8 #(at your option) any later version.
10 #Asgard is distributed in the hope that it will be useful,
11 #but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 #GNU General Public License for more details.
15 #You should have received a copy of the GNU General Public License
16 #along with Asgard; if not, write to the Free Software
17 #Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 ########################################################
19 from status import *
21 class Transaction:
22 def __init__(self,target,stat,change,status):
23 self.__target = target
24 self.__stat = stat
25 self.__change = change
26 self.__status = status
28 def execute(self):
29 """ execute the transaction; based on provided information """
31 # If a Stat is supposed to be modified
32 if self.__stat != None:
33 # Retrieve that Stat from the target
34 stat_to_change = self.__target.getStat(self.__stat)
36 # change the value of that stat by the amount in "change"
37 stat_to_change.setCurrent(stat_to_change.getCurrent() + self.__change)
38 # otherwise this must be a status transaction
39 elif self.__status != None:
42 tlistPerTurn = []
43 tlistPerIter = []
44 tlistExit = []
45 tlistEntrance =[]
46 tlistPerTurnOnMove = []
48 # poison status
49 if self.__status == "poison":
50 # remove 5% of hp per turn; this is lame and should be more dynamic
51 trans = Transaction(self.__target,"hp",int(-1 * self.__target.getStat("hp").getMax()*.05),"")
52 tlistPerTurnOnMove.append(trans)
53 elif self.__status == "aglup":
54 trans = Transaction(self.__target,"agl",10,"")
55 tlistEntrance.append(trans)
56 trans = Transaction(self.__target,"agl",-10,"")
57 tlistExit.append(trans)
60 # create the status object and add it to the target
61 self.__target.addStatus(Status(self.__status,tlistEntrance,tlistPerTurn,tlistPerIter,tlistExit,tlistPerTurnOnMove))
64 def getTarget(self):
65 return self.__target
67 def setTarget(self,target):
68 self.__target = target
70 def getStat(self):
71 return self.__stat
73 def setStat(self,stat):
74 self.__stat = stat
76 def getChange(self):
77 return self.__change
79 def setChange(self,change):
80 self.__change = change
82 def getStatus(self):
83 return self.__status
85 def setStatus(self,status):
86 self.__status = status