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 ########################################################
20 from equiption
import *
25 def __init__(self
,name
,jobType
,plyble
,stats
,equip
,statuses
):
28 self
.__jobType
= jobType
29 self
.__playable
= plyble
31 self
.__equiption
= equip
32 self
.__status
= statuses
35 """Get fighter's name."""
39 """Change fighter's name."""
43 """Get Fighter's job type"""
46 def setJobType(self
,jobType
):
47 """ Set Fighter's job type"""
48 self
.__jobType
= jobType
50 def getEquiption(self
):
51 """Get equiption for fighter."""
52 return self
.__equiption
54 def setEquiption(self
, eq
):
55 """Set equiption for fighter."""
58 def getPlayable(self
):
59 """Is fighter playable?"""
60 return self
.__playable
62 def setPlayable(self
, plyble
):
63 """Set fighter's playability."""
64 self
.__playable
= plyble
67 """Compute value of attack."""
68 return self
.getStat("str").getCurrent() + self
.__equiption
.computeAtkMod()
71 """Compute value of defense."""
72 return self
.__equiption
.computeDefMod()
75 """Compute value of evade."""
76 return self
.getStat("agl").getCurrent() + self
.__equiption
.computeEvaMod()
79 def makeEvent(self
, eparty
, currentTime
, cont
):
80 """ Check if ready to make move.
82 If so, select random fighter from enemy party and return.
85 if not self
.isAlive():
88 if self
.getStat("tom").getCurrent() != currentTime
:
91 # Generate per-turn status transactions
92 for s
in self
.__status
:
97 # Playable fighters have battle menu
98 if self
.getPlayable():
99 # Show battle menu and choose event from battle menu
100 command
= cont
.getCommand(eparty
,self
)
104 # Nonplayable fighters
105 elif currentTime
>= self
.getStat("tom").getCurrent():
106 x
= randint(0,eparty
.sizeOfParty()-1)
107 while not eparty
.getFighter(x
).isAlive():
108 x
= randint(0,eparty
.sizeOfParty()-1)
110 d
.append(eparty
.getFighter(x
))
112 x
= randint(0,len(self
.getEventTypes())-1)
113 t
= cont
.getBattle().getEventType(self
.getEventTypes()[x
])
115 self
.getStat("tom").setCurrent(self
.getStat("tom").getMax() + round((1/float(self
.getStat("spd").getMax()))*100))
116 self
.getStat("tom").setMax(self
.getStat("tom").getCurrent())
117 return Event(self
,d
,[],t
)
120 """If hp is greater than 0... return true"""
121 return (self
.getStat("hp").getCurrent() > 0)
123 def getEventTypes(self
):
124 """Return list of events available to fighter."""
125 if self
.__jobType
== "blackmage":
126 return ["attack","fire1","ice1","cure1","fog","poison","quit"]
127 elif self
.__jobType
== "swordsman":
128 return ["attack","quit"]
129 elif self
.__name
== "Roc":
130 return ["attack","ice1"]
131 elif self
.__name
== "Imp":
136 def receiveExp(self
,exp
):
137 """Fighter receives experience for leveling up."""
139 exp_s
= self
.getStat("exp")
140 exp_s
.setCurrent(exp_s
.getCurrent() + exp
)
142 # Tax off exp from expTillNextLevel
143 exptnl_s
= self
.getStat("exptnl")
144 exptnl_s
.setCurrent(exptnl_s
.getCurrent() - exp
)
147 while exptnl_s
.getCurrent() <= 0:
148 # Increase level number
149 level_s
= self
.getStat("level")
150 level_s
.setCurrent(level_s
.getCurrent() + 1)
156 hp
= self
.getStat("hp")
157 if x
<= hp
.getChance() * 100:
158 hp
.setMax(hp
.getMax() + hp
.getPlus())
162 str = self
.getStat("str")
163 if x
<= str.getChance() * 100:
164 str.setMax(str.getMax() + str.getPlus())
165 str.setCurrent(str.getMax())
170 spd
= self
.getStat("spd")
171 if x
<= spd
.getChance() * 100:
172 spd
.setMax(spd
.getMax() + spd
.getPlus())
173 spd
.setCurrent(spd
.getMax())
175 # Increase dexterity?
177 dex
= self
.getStat("dex")
178 if x
<= dex
.getChance() * 100:
179 dex
.setMax(dex
.getMax() + dex
.getPlus())
180 dex
.setCurrent(dex
.getMax())
184 agl
= self
.getStat("agl")
185 if x
<= agl
.getChance() * 100:
186 agl
.setMax(agl
.getMax() + agl
.getPlus())
187 agl
.setCurrent(agl
.getMax())
191 wis
= self
.getStat("wis")
192 if x
<= wis
.getChance() * 100:
193 wis
.setMax(wis
.getMax() + wis
.getPlus())
194 wis
.setCurrent(wis
.getMax())
198 wil
= self
.getStat("wil")
199 if x
<= wil
.getChance() * 100:
200 wil
.setMax(wil
.getMax() + wil
.getPlus())
201 wil
.setCurrent(wil
.getMax())
203 # Set new exp till next level maximum
204 exptnl_s
.setMax(int(exptnl_s
.getMax() * exptnl_s
.getGrowthRate()))
206 # Carry over any experience that didn't go towards getting the last level
207 exptnl_s
.setCurrent(int(exptnl_s
.getMax() + exptnl_s
.getCurrent()))
209 def getElemModifier(self
,elem
):
212 def getStatusModifier(self
,stat
):
216 """Get status(es) of fighter."""
219 def setStatus(self
,s
):
220 """Set status(es) of fighter."""
223 def addStatus(self
,s
):
224 """Add a status to status list for fighter."""
226 for i
in self
.__status
:
232 self
.__status
.append(s
)
235 print 'ERROR: Status already in list!'
237 def removeStatus(self
,s
):
238 """Remove status s from status list for fighter."""
239 for i
in self
.__status
:
245 self
.__status
.remove(s
)
248 print 'ERROR: Status was not in list!'
250 def getStat(self
,statName
):
251 for stat
in self
.__stats
:
252 if stat
.getName() == statName
:
254 print 'ERROR: No such Fighter stat.'
256 def getAllStats(self
):
259 def setAllStats(self
,stats
):