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 return Event(self
,d
,[],t
)
119 """If hp is greater than 0... return true"""
120 return (self
.getStat("hp").getCurrent() > 0)
122 def getEventTypes(self
):
123 """Return list of events available to fighter."""
124 if self
.__jobType
== "blackmage":
125 return ["attack","fire1","ice1","harm","poison","quit"]
126 elif self
.__jobType
== "swordsman":
127 return ["attack","cure1","quit"]
128 elif self
.__name
== "Roc":
129 return ["attack","ice1"]
130 elif self
.__name
== "Imp":
135 def receiveExp(self
,exp
):
136 """Fighter receives experience for leveling up."""
138 exp_s
= self
.getStat("exp")
139 exp_s
.setCurrent(exp_s
.getCurrent() + exp
)
141 # Tax off exp from expTillNextLevel
142 exptnl_s
= self
.getStat("exptnl")
143 exptnl_s
.setCurrent(exptnl_s
.getCurrent() - exp
)
146 while exptnl_s
.getCurrent() <= 0:
147 # Increase level number
148 level_s
= self
.getStat("level")
149 level_s
.setMax(level_s
.getMax() + 1)
155 hp
= self
.getStat("hp")
156 if x
<= hp
.getChance() * 100:
157 hp
.setMax(hp
.getMax() + hp
.getPlus())
161 str = self
.getStat("str")
162 if x
<= str.getChance() * 100:
163 str.setMax(str.getMax() + str.getPlus())
164 str.setCurrent(str.getCurrent() + str.getPlus())
169 spd
= self
.getStat("spd")
170 if x
<= spd
.getChance() * 100:
171 spd
.setMax(spd
.getMax() + spd
.getPlus())
172 spd
.setCurrent(spd
.getCurrent() + spd
.getPlus())
174 # Increase dexterity?
176 dex
= self
.getStat("dex")
177 if x
<= dex
.getChance() * 100:
178 dex
.setMax(dex
.getMax() + dex
.getPlus())
179 dex
.setCurrent(dex
.getCurrent() + dex
.getPlus())
183 agl
= self
.getStat("agl")
184 if x
<= agl
.getChance() * 100:
185 agl
.setMax(agl
.getMax() + agl
.getPlus())
186 agl
.setCurrent(agl
.getCurrent() + agl
.getPlus())
190 wis
= self
.getStat("wis")
191 if x
<= wis
.getChance() * 100:
192 wis
.setMax(wis
.getMax() + wis
.getPlus())
193 wis
.setCurrent(wis
.getCurrent() + wis
.getPlus())
197 wil
= self
.getStat("wil")
198 if x
<= wil
.getChance() * 100:
199 wil
.setMax(wil
.getMax() + wil
.getPlus())
200 wil
.setCurrent(wil
.getCurrent() + wil
.getPlus())
202 # Set new exp till next level maximum
203 exptnl_s
.setMax(int(exptnl_s
.getMax() * exptnl
.getGrowthRate()))
205 # Carry over any experience that didn't go towards getting the last level
206 exptnl_s
.setCurrent(int(exptnl
.getMax() + exptnl
.getCurrent()))
208 def getElemModifier(self
,elem
):
211 def getStatusModifier(self
,stat
):
215 """Get status(es) of fighter."""
218 def setStatus(self
,s
):
219 """Set status(es) of fighter."""
222 def addStatus(self
,s
):
223 """Add a status to status list for fighter."""
225 for i
in self
.__status
:
231 self
.__status
.append(s
)
234 print 'ERROR: Status already in list!'
236 def removeStatus(self
,s
):
237 """Remove status s from status list for fighter."""
238 for i
in self
.__status
:
244 self
.__status
.remove(s
)
247 print 'ERROR: Status was not in list!'
249 def getStat(self
,statName
):
250 for stat
in self
.__stats
:
251 if stat
.getName() == statName
:
253 print 'ERROR: No such Fighter stat.'
255 def getAllStats(self
):
258 def setAllStats(self
,stats
):