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
:
104 # Playable fighters have battle menu
105 if self
.getPlayable():
106 # Show battle menu and choose event from battle menu
107 command
= cont
.getCommand(eparty
,self
)
111 # Nonplayable fighters
112 elif currentTime
>= self
.__timeOfMove
:
113 x
= randint(0,eparty
.sizeOfParty()-1)
114 while not eparty
.getFighter(x
).isAlive():
115 x
= randint(0,eparty
.sizeOfParty()-1)
117 d
= eparty
.getFighter(x
)
119 x
= randint(0,len(self
.getEventTypes()))
120 t
= getEventTypes()[x
]
122 self
.__timeOfMove
+= round((1/float(self
.getStat("spd").getMax()))*100)
123 return Event(self
,d
,[],t
)
126 """If hp is greater than 0... return true"""
127 return (self
.getStat("hp").getCurrent() > 0)
129 def getEventTypes(self
):
130 """Return list of events available to fighter."""
131 if self
.__jobType
== "blackmage":
132 return ["attack","fire1","ice1","harm","poison","quit"]
133 elif self
.__jobType
== "swordsman":
134 return ["attack","cure1","sleep","quit"]
135 elif self
.__name
== "Roc":
136 return ["attack","ice1"]
137 elif self
.__name
== "Imp":
142 def receiveExp(self
,exp
):
143 """Fighter receives experience for leveling up."""
145 exp_s
= self
.getStat("exp")
146 exp_s
.setCurrent(exp_s
.getCurrent() + exp
)
148 # Tax off exp from expTillNextLevel
149 exptnl_s
= self
.getStat("exptnl")
150 exptnl_s
.setCurrent(exptnl_s
.getCurrent() - exp
)
153 while exptnl_s
.getCurrent() <= 0:
154 # Increase level number
155 level_s
= self
.getStat("level")
156 level_s
.setMax(level_s
.getMax() + 1)
162 hp
= self
.getStat("hp")
163 if x
<= hp
.getChance() * 100:
164 hp
.setMax(hp
.getMax() + hp
.getPlus())
168 str = self
.getStat("str")
169 if x
<= str.getChance() * 100:
170 str.setMax(str.getMax() + str.getPlus())
171 str.setCurrent(str.getCurrent() + str.getPlus())
176 spd
= self
.getStat("spd")
177 if x
<= spd
.getChance() * 100:
178 spd
.setMax(spd
.getMax() + spd
.getPlus())
179 spd
.setCurrent(spd
.getCurrent() + spd
.getPlus())
181 # Increase dexterity?
183 dex
= self
.getStat("dex")
184 if x
<= dex
.getChance() * 100:
185 dex
.setMax(dex
.getMax() + dex
.getPlus())
186 dex
.setCurrent(dex
.getCurrent() + dex
.getPlus())
190 agl
= self
.getStat("agl")
191 if x
<= agl
.getChance() * 100:
192 agl
.setMax(agl
.getMax() + agl
.getPlus())
193 agl
.setCurrent(agl
.getCurrent() + agl
.getPlus())
197 wis
= self
.getStat("wis")
198 if x
<= wis
.getChance() * 100:
199 wis
.setMax(wis
.getMax() + wis
.getPlus())
200 wis
.setCurrent(wis
.getCurrent() + wis
.getPlus())
204 wil
= self
.getStat("wil")
205 if x
<= wil
.getChance() * 100:
206 wil
.setMax(wil
.getMax() + wil
.getPlus())
207 wil
.setCurrent(wil
.getCurrent() + wil
.getPlus())
209 # Set new exp till next level maximum
210 exptnl_s
.setMax(int(exptnl_s
.getMax() * exptnl
.getGrowthRate()))
212 # Carry over any experience that didn't go towards getting the last level
213 exptnl_s
.setCurrent(int(exptnl
.getMax() + exptnl
.getCurrent()))
215 def getElemModifier(self
,elem
):
218 def getStatModifier(self
,stat
):
222 """Get status(es) of fighter."""
225 def setStatus(self
,s
):
226 """Set status(es) of fighter."""
229 def addStatus(self
,s
):
230 """Add a status to status list for fighter."""
231 for i
in self
.__status
:
237 self
.__status
.append(s
)
240 print 'ERROR: Status already in list!'
242 def removeStatus(self
,s
):
243 """Remove status s from status list for fighter."""
244 for i
in self
.__status
:
250 self
.__status
.remove(s
)
253 print 'ERROR: Status was not in list!'
255 def getStat(self
,statName
):
256 for stat
in self
.__stats
:
257 if stat
.getName() == statName
:
259 print 'ERROR: No such Fighter stat.'
261 def getAllStats(self
):
264 def setAllStats(self
,stats
):