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
,tom
,stats
,equip
,statuses
):
28 self
.__jobType
= jobType
29 self
.__playable
= plyble
30 self
.__timeOfMove
= tom
32 self
.__equiption
= equip
33 self
.__status
= statuses
36 """Get fighter's name."""
40 """Change fighter's name."""
44 """Get Fighter's job type"""
47 def setJobType(self
,jobType
):
48 """ Set Fighter's job type"""
49 self
.__jobType
= jobType
51 def getTimeOfMove(self
):
52 """Get fighter's time of move."""
53 return self
.__timeOfMove
55 def setTimeOfMove(self
, tMv
):
56 """Change fighter's time of move."""
57 self
.__timeOfMove
= tMv
59 def getEquiption(self
):
60 """Get equiption for fighter."""
61 return self
.__equiption
63 def setEquiption(self
, eq
):
64 """Set equiption for fighter."""
67 def getPlayable(self
):
68 """Is fighter playable?"""
69 return self
.__playable
71 def setPlayable(self
, plyble
):
72 """Set fighter's playability."""
73 self
.__playable
= plyble
76 """Compute value of attack."""
77 return self
.getStat("str").getCurrent() + self
.__equiption
.computeAtkMod()
80 """Compute value of defense."""
81 return self
.__equiption
.computeDefMod()
84 """Compute value of evade."""
85 return self
.getStat("agl").getCurrent() + self
.__equiption
.computeEvaMod()
88 def makeEvent(self
, eparty
, currentTime
, cont
, ):
89 """ Check if ready to make move.
91 If so, select random fighter from enemy party and return.
94 if not self
.isAlive():
97 if self
.__timeOfMove
!= currentTime
:
100 # Generate per-turn status transactions
101 for s
in self
.__status
:
106 # Playable fighters have battle menu
107 if self
.getPlayable():
108 # Show battle menu and choose event from battle menu
109 command
= cont
.getCommand(eparty
,self
)
113 # Nonplayable fighters
114 elif currentTime
>= self
.__timeOfMove
:
115 x
= randint(0,eparty
.sizeOfParty()-1)
116 while not eparty
.getFighter(x
).isAlive():
117 x
= randint(0,eparty
.sizeOfParty()-1)
119 d
= eparty
.getFighter(x
)
121 x
= randint(0,len(self
.getEventTypes())-1)
122 t
.append(cont
.getBattle().getEventType(self
.getEventTypes()[x
]))
124 self
.__timeOfMove
+= round((1/float(self
.getStat("spd").getMax()))*100)
125 return Event(self
,d
,[],t
)
128 """If hp is greater than 0... return true"""
129 return (self
.getStat("hp").getCurrent() > 0)
131 def getEventTypes(self
):
132 """Return list of events available to fighter."""
133 if self
.__jobType
== "blackmage":
134 return ["attack","fire1","ice1","harm","poison","quit"]
135 elif self
.__jobType
== "swordsman":
136 return ["attack","cure1","sleep","quit"]
137 elif self
.__name
== "Roc":
138 return ["attack","ice1"]
139 elif self
.__name
== "Imp":
144 def receiveExp(self
,exp
):
145 """Fighter receives experience for leveling up."""
147 exp_s
= self
.getStat("exp")
148 exp_s
.setCurrent(exp_s
.getCurrent() + exp
)
150 # Tax off exp from expTillNextLevel
151 exptnl_s
= self
.getStat("exptnl")
152 exptnl_s
.setCurrent(exptnl_s
.getCurrent() - exp
)
155 while exptnl_s
.getCurrent() <= 0:
156 # Increase level number
157 level_s
= self
.getStat("level")
158 level_s
.setMax(level_s
.getMax() + 1)
164 hp
= self
.getStat("hp")
165 if x
<= hp
.getChance() * 100:
166 hp
.setMax(hp
.getMax() + hp
.getPlus())
170 str = self
.getStat("str")
171 if x
<= str.getChance() * 100:
172 str.setMax(str.getMax() + str.getPlus())
173 str.setCurrent(str.getCurrent() + str.getPlus())
178 spd
= self
.getStat("spd")
179 if x
<= spd
.getChance() * 100:
180 spd
.setMax(spd
.getMax() + spd
.getPlus())
181 spd
.setCurrent(spd
.getCurrent() + spd
.getPlus())
183 # Increase dexterity?
185 dex
= self
.getStat("dex")
186 if x
<= dex
.getChance() * 100:
187 dex
.setMax(dex
.getMax() + dex
.getPlus())
188 dex
.setCurrent(dex
.getCurrent() + dex
.getPlus())
192 agl
= self
.getStat("agl")
193 if x
<= agl
.getChance() * 100:
194 agl
.setMax(agl
.getMax() + agl
.getPlus())
195 agl
.setCurrent(agl
.getCurrent() + agl
.getPlus())
199 wis
= self
.getStat("wis")
200 if x
<= wis
.getChance() * 100:
201 wis
.setMax(wis
.getMax() + wis
.getPlus())
202 wis
.setCurrent(wis
.getCurrent() + wis
.getPlus())
206 wil
= self
.getStat("wil")
207 if x
<= wil
.getChance() * 100:
208 wil
.setMax(wil
.getMax() + wil
.getPlus())
209 wil
.setCurrent(wil
.getCurrent() + wil
.getPlus())
211 # Set new exp till next level maximum
212 exptnl_s
.setMax(int(exptnl_s
.getMax() * exptnl
.getGrowthRate()))
214 # Carry over any experience that didn't go towards getting the last level
215 exptnl_s
.setCurrent(int(exptnl
.getMax() + exptnl
.getCurrent()))
217 def getElemModifier(self
,elem
):
220 def getStatModifier(self
,stat
):
224 """Get status(es) of fighter."""
227 def setStatus(self
,s
):
228 """Set status(es) of fighter."""
231 def addStatus(self
,s
):
232 """Add a status to status list for fighter."""
233 for i
in self
.__status
:
239 self
.__status
.append(s
)
242 print 'ERROR: Status already in list!'
244 def removeStatus(self
,s
):
245 """Remove status s from status list for fighter."""
246 for i
in self
.__status
:
252 self
.__status
.remove(s
)
255 print 'ERROR: Status was not in list!'
257 def getStat(self
,statName
):
258 for stat
in self
.__stats
:
259 if stat
.getName() == statName
:
261 print 'ERROR: No such Fighter stat.'
263 def getAllStats(self
):
266 def setAllStats(self
,stats
):