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 ########################################################
22 def __init__(self
,target
,stat
,change
,status
):
23 self
.__target
= target
25 self
.__change
= change
26 self
.__status
= status
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:
46 tlistPerTurnOnMove
= []
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
))
67 def setTarget(self
,target
):
68 self
.__target
= target
73 def setStat(self
,stat
):
79 def setChange(self
,change
):
80 self
.__change
= change
85 def setStatus(self
,status
):
86 self
.__status
= status