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 os
import listdir
28 self
.__currentTime
= 0
31 self
.__eventTypes
= []
34 """ Is battle over?"""
36 return not self
.__party
1.isAlive() or not self
.__party
2.isAlive()
39 """ Execute next iteration in gameloop."""
45 # execute all available events
46 while self
.executeNextEvent():
47 # if there was at least one event
49 # generate per-iteration status transactions
50 for f
in self
.__party
1.getFighters():
51 for s
in f
.getStatus():
53 for f
in self
.__party
2.getFighters():
54 for s
in f
.getStatus():
58 self
.__currentTime
+= 1
62 def executeNextEvent(self
):
63 """ Execute next event in event queue. Return true if there were events. """
68 # Try to get an event from party1
69 event
= self
.__party
1.getNextEvent(self
.__party
2,self
.__currentTime
,self
.__controller
)
71 # If there was one, execute and return true
74 self
.__view
.printEvent(event
)
77 # Try to get an event from party2
78 event
= self
.__party
2.getNextEvent(self
.__party
1,self
.__currentTime
,self
.__controller
)
80 # If there was one, execute and return true
83 self
.__view
.printEvent(event
)
86 # Otherwise, notify that there are no more events at this time.
89 def getCurrentTime(self
):
90 """ Retrieve current time."""
91 return self
.__currentTime
93 def setCurrentTime(self
,t
):
94 """ Establish current time."""
95 self
.__currentTime
= t
98 """ Retrieve party1."""
101 def setParty1(self
, p
):
106 """ Retrieve party2."""
109 def setParty2(self
, p
):
114 """ Establish view."""
117 def setController(self
,c
):
118 """ Establish controller."""
119 self
.__controller
= c
121 def getEventTypeList(self
):
122 """ Return list of loaded EventTypes"""
123 return self
.__eventTypes
125 def setEventTypeList(self
,evts
):
126 """ Load a new list of EventTypes """
127 self
.__eventTypes
= evts
129 def getEventType(self
,et_s
):
130 for et
in self
.__eventTypes
:
131 if et
.getName() == et_s
: