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 ########################################################
22 """ Model: Party Class """
25 """ List of 1-6 fighters that represents a party. """
27 def __init__(self
,name
):
28 """ Instantiates Party object. """
34 """ Gets name of party. """
38 def setName(self
,name
):
39 """ Sets name of party. """
44 """ Does the party have any live fighters? If so, the party is alive. """
46 for f
in self
.__fighters
:
52 def getNextEvent(self
, enemy
, ctime
, cont
):
53 """ Find the fighter in the party who is ready to generate an
54 event and whose dexterity stat is the highest. Return that event. If no events
55 are available, return the None object. """
57 ffWithHighestDex
= None
58 efWithHighestDex
= None
60 # The Party should be alive - you never know.
61 if not self
.isAlive():
64 # find the enemy that's ready that has the highest dex
65 for f
in enemy
.getFighters():
66 if f
.getStat("tom").getCurrent() <= ctime
:
67 if efWithHighestDex
== None:
69 elif efWithHighestDex
.getStat("dex").getCurrent() < f
.getStat("dex").getCurrent():
72 #find the friendly fighter that's ready that has the highest dex
73 for f
in self
.__fighters
:
74 if f
.getStat("tom").getCurrent() <= ctime
:
75 if ffWithHighestDex
== None:
77 elif ffWithHighestDex
.getStat("dex").getCurrent() < f
.getStat("dex").getCurrent():
80 # does the friendly or the enemy have the highest dex
81 # if friendly, make event
82 if ffWithHighestDex
== None:
84 elif ffWithHighestDex
.isAlive():
86 if efWithHighestDex
== None:
88 event
= ffWithHighestDex
.makeEvent(enemy
,self
,ctime
,cont
)
90 # recompute the next time they get to move
91 tom
= ffWithHighestDex
.getStat("tom").getMax() + round((1/float(ffWithHighestDex
.getStat("spd").getMax()))*100)
92 ffWithHighestDex
.getStat("tom").setCurrent(tom
)
93 ffWithHighestDex
.getStat("tom").setMax(tom
)
96 elif ffWithHighestDex
.getStat("dex").getCurrent() < efWithHighestDex
.getStat("dex").getCurrent():
99 event
= ffWithHighestDex
.makeEvent(enemy
,self
,ctime
,cont
)
101 # compute the next time they get to move
102 tom
= ffWithHighestDex
.getStat("tom").getMax() + round((1/float(ffWithHighestDex
.getStat("spd").getMax()))*100)
103 ffWithHighestDex
.getStat("tom").setCurrent(tom
)
104 ffWithHighestDex
.getStat("tom").setMax(tom
)
109 # recompute the next time they get to move
110 # this is so that the dead still know when their next turn is
111 tom
= ffWithHighestDex
.getStat("tom").getMax() + round((1/float(ffWithHighestDex
.getStat("spd").getMax()))*100)
112 ffWithHighestDex
.getStat("tom").setCurrent(tom
)
113 ffWithHighestDex
.getStat("tom").setMax(tom
)
117 def addFighter(self
,fighter
):
118 """ Add a fighter to the party. """
120 if self
.sizeOfParty() != 6:
121 self
.__fighters
.append(fighter
)
125 def getFighter(self
, n
):
126 """ Get a fighter from the party. """
128 return self
.__fighters
[n
]
130 def getFighters(self
):
131 """ Get list of all fighters from party. """
133 return self
.__fighters
135 def sizeOfParty(self
):
136 """ Computes the number of live AND dead fighters in the party. """
138 return len(self
.__fighters
)
140 def giveExp(self
, exp
):
141 """ Takes an amount of experience (presumably the total
142 experience of a defeated party), and divides it evenly among the party's
143 surviving fighters by calling Fighter.receiveExp(). """
145 fighters
= self
.getFighters()