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
,name
):
31 def setName(self
,name
):
36 for f
in self
.__fighters
:
42 def getNextEvent(self
, enemy
, ctime
, cont
):
43 """Check moves for enemy."""
45 ffWithHighestDex
= None
46 efWithHighestDex
= None
48 # The Party should be alive - you never know.
49 if not self
.isAlive():
52 # find the enemy that's ready that has the highest dex
53 for f
in enemy
.getFighters():
54 if f
.getStat("tom").getCurrent() <= ctime
:
55 if efWithHighestDex
== None:
57 elif efWithHighestDex
.getStat("dex").getCurrent() < f
.getStat("dex").getCurrent():
60 #find the friendly fighter that's ready that has the highest dex
61 for f
in self
.__fighters
:
62 if f
.getStat("tom").getCurrent() <= ctime
:
63 if ffWithHighestDex
== None:
65 elif ffWithHighestDex
.getStat("dex").getCurrent() < f
.getStat("dex").getCurrent():
68 # does the friendly or the enemy have the highest dex
69 # if friendly, make event
70 if ffWithHighestDex
== None:
72 elif ffWithHighestDex
.isAlive():
74 if efWithHighestDex
== None:
76 event
= ffWithHighestDex
.makeEvent(enemy
,self
,ctime
,cont
)
78 # recompute the next time they get to move
79 tom
= ffWithHighestDex
.getStat("tom").getMax() + round((1/float(ffWithHighestDex
.getStat("spd").getMax()))*100)
80 ffWithHighestDex
.getStat("tom").setCurrent(tom
)
81 ffWithHighestDex
.getStat("tom").setMax(tom
)
84 elif ffWithHighestDex
.getStat("dex").getCurrent() < efWithHighestDex
.getStat("dex").getCurrent():
87 event
= ffWithHighestDex
.makeEvent(enemy
,self
,ctime
,cont
)
89 # compute the next time they get to move
90 tom
= ffWithHighestDex
.getStat("tom").getMax() + round((1/float(ffWithHighestDex
.getStat("spd").getMax()))*100)
91 ffWithHighestDex
.getStat("tom").setCurrent(tom
)
92 ffWithHighestDex
.getStat("tom").setMax(tom
)
97 # recompute the next time they get to move
98 # this is so that the dead still know when their next turn is
99 tom
= ffWithHighestDex
.getStat("tom").getMax() + round((1/float(ffWithHighestDex
.getStat("spd").getMax()))*100)
100 ffWithHighestDex
.getStat("tom").setCurrent(tom
)
101 ffWithHighestDex
.getStat("tom").setMax(tom
)
105 def addFighter(self
,fighter
):
106 if self
.sizeOfParty() != 6:
107 self
.__fighters
.append(fighter
)
111 def getFighter(self
, n
):
112 """Return fighter."""
113 return self
.__fighters
[n
]
115 def getFighters(self
):
116 return self
.__fighters
118 def sizeOfParty(self
):
119 """Compute party's size."""
120 return len(self
.__fighters
)
122 def giveExp(self
, exp
):
123 """Divy up battle experience among living fighters in party."""
124 fighters
= self
.getFighters()