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 ########################################################
23 def __init__(self
,target
):
32 def setStatus(self
,status
):
38 def setTarget(self
,target
):
41 class TransactionStatistic(Transaction
):
42 def __init__(self
,target
,stat
,change
):
43 Transaction
.__init
__(self
,target
)
45 self
.__change
= change
48 """ execute the transaction; based on provided information """
50 # If a Stat is supposed to be modified
51 if self
.__stat
!= None:
52 alive_before_transaction
= self
.target
.isAlive()
54 # Retrieve that Stat from the target
55 stat_to_change
= self
.target
.getStat(self
.__stat
)
57 # change the value of that stat by the amount in "change"
58 stat_to_change
.setCurrent(stat_to_change
.getCurrent() + self
.__change
)
60 if self
.target
.getStat("hp").getCurrent() <= 0 and alive_before_transaction
:
61 deathT
= TransactionStatus(self
.target
,"death",True)
63 elif self
.target
.getStat("hp").getCurrent() > self
.target
.getStat("hp").getMax():
64 self
.target
.getStat("hp").setCurrent(self
.target
.getStat("hp").getMax())
69 def setStat(self
,stat
):
75 def setChange(self
,change
):
76 self
.__change
= change
78 class TransactionStatus(Transaction
):
79 def __init__(self
,target
,status
,add
):
80 Transaction
.__init
__(self
,target
)
81 self
.__status
= status
85 """ execute the status transaction; based on provided information """
91 tlistPerTurnOnMove
= []
94 self
.target
.removeStatus(self
.__status
)
97 if self
.__status
== "poison":
98 # remove 5% of hp per turn; this is lame and should be more dynamic
99 trans
= TransactionStatistic(self
.target
,"hp",int(-1 * self
.target
.getStat("hp").getMax()*.05))
100 tlistPerTurnOnMove
.append(trans
)
101 elif self
.__status
== "aglup":
102 trans
= TransactionStatistic(self
.target
,"agl",10)
103 tlistEntrance
.append(trans
)
104 trans
= TransactionStatistic(self
.target
,"agl",-10)
105 tlistExit
.append(trans
)
106 elif self
.__status
== "sleep":
107 tlistEntrance
.append(TransactionStatistic(self
.target
,"canMove",-1))
108 tlistExit
.append(TransactionStatistic(self
.target
,"canMove",1))
109 elif self
.__status
== "death":
110 tlistEntrance
.append(TransactionStatistic(self
.target
,"canMove",-1))
111 tlistEntrance
.append(TransactionStatistic(self
.target
,"hp",self
.target
.getStat("hp").getCurrent()*-1))
112 tlistExit
.append(TransactionStatistic(self
.target
,"canMove",1))
113 tlistExit
.append(TransactionStatistic(self
.target
,"hp",int(self
.target
.getStat("hp").getMax() * .25)))
114 elif self
.__status
== "paralysis":
115 tlistEntrance
.append(TransactionStatistic(self
.target
,"canMove",-1))
116 tlistExit
.append(TransactionStatistic(self
.target
,"canMove",1))
117 elif self
.__status
== "madness":
118 ai
= self
.target
.getStat("ai").getCurrent()
120 tlistEntrance
.append(TransactionStatistic(self
.target
,"ai",2))
121 tlistExit
.append(TransactionStatistic(self
.target
,"ai",-2))
123 tlistEntrance
.append(TransactionStatistic(self
.target
,"ai",1))
124 tlistExit
.append(TransactionStatistic(self
.target
,"ai",-1))
126 # create the status object and add it to the target
127 self
.target
.addStatus(Status(self
.__status
,tlistEntrance
,tlistPerTurn
,tlistPerIter
,tlistExit
,tlistPerTurnOnMove
))
133 def setStatus(self
,status
):
134 self
.__status
= status
139 def setAdd(self
, add
):