updated blackmage stats
[asgard.git] / party.py
blob5a2d69f7f28be691f03091f72c82e28d5b0d7712
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 ########################################################
19 from event import *
21 class Party:
23 def __init__(self,name):
24 """Constructor."""
25 self.__fighters = []
26 self.__name = name
28 def getName(self):
29 return self.__name
31 def setName(self,name):
32 self.__name = name
34 def isAlive(self):
35 """Is party alive?"""
36 for f in self.__fighters:
37 if f.isAlive():
38 return True
40 return False
42 def getNextEvent(self, enemy, ctime, cont):
43 """Check moves for enemy."""
45 ffWithHighestDex = None
46 efWithHighestDex = None
48 if not self.isAlive():
49 return None
51 # find the enemy that's ready that has the highest dex
52 for f in enemy.getFighters():
53 if f.getStat("tom").getCurrent() <= ctime and f.isAlive():
54 if efWithHighestDex == None:
55 efWithHighestDex = f
56 elif efWithHighestDex.getStat("dex").getCurrent() < f.getStat("dex").getCurrent():
57 efWithHighestDex = f
59 #find the friendly fighter that's ready that has the highest dex
60 for f in self.__fighters:
61 if f.getStat("tom").getCurrent() <= ctime and f.isAlive():
62 if ffWithHighestDex == None:
63 ffWithHighestDex = f
64 elif ffWithHighestDex.getStat("dex").getCurrent() < f.getStat("dex").getCurrent():
65 ffWithHighestDex = f
67 # does the friendly or the enemy have the highest dex
68 # if friendly, make event
69 if ffWithHighestDex == None:
70 return None
71 elif efWithHighestDex == None:
72 return ffWithHighestDex.makeEvent(enemy,ctime,cont)
73 elif ffWithHighestDex.getStat("dex").getCurrent() < efWithHighestDex.getStat("dex").getCurrent():
74 return ffWithHighestDex.makeEvent(enemy,ctime,cont)
76 #otherwise, return none
77 return None
79 def addFighter(self,fighter):
80 if self.sizeOfParty() != 6:
81 self.__fighters.append(fighter)
82 return True
83 return False
85 def getFighter(self, n):
86 """Return fighter."""
87 return self.__fighters[n]
89 def getFighters(self):
90 return self.__fighters
92 def sizeOfParty(self):
93 """Compute party's size."""
94 return len(self.__fighters)
96 def giveExp(self, exp):
97 """Divy up battle experience among living fighters in party."""
98 fighters = self.getFighters()
100 numLeft = 0
101 for f in fighters:
102 if f.isAlive():
103 numLeft += 1
105 exp = exp/numLeft
107 for f in fighters:
108 f.receiveExp(exp)