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
= []
35 """ Is battle over?"""
37 return not self
.__party
1.isAlive() or not self
.__party
2.isAlive()
40 """ Execute next iteration in gameloop."""
46 # execute all available events
47 while self
.executeNextEvent():
48 # if there was at least one event
50 # generate per-iteration status transactions
51 for f
in self
.__party
1.getFighters():
52 for s
in f
.getStatus():
54 for f
in self
.__party
2.getFighters():
55 for s
in f
.getStatus():
59 self
.__currentTime
+= 1
63 def executeNextEvent(self
):
64 """ Execute next event in event queue. Return true if there were events. """
69 # Try to get an event from party1
70 event
= self
.__party
1.getNextEvent(self
.__party
2,self
.__currentTime
,self
.__controller
)
72 # If there was one, execute and return true
75 self
.__view
.printEvent(event
)
78 # Try to get an event from party2
79 event
= self
.__party
2.getNextEvent(self
.__party
1,self
.__currentTime
,self
.__controller
)
81 # If there was one, execute and return true
84 self
.__view
.printEvent(event
)
87 # Otherwise, notify that there are no more events at this time.
90 def getCurrentTime(self
):
91 """ Retrieve current time."""
92 return self
.__currentTime
94 def setCurrentTime(self
,t
):
95 """ Establish current time."""
96 self
.__currentTime
= t
99 """ Retrieve party1."""
102 def setParty1(self
, p
):
107 """ Retrieve party2."""
110 def setParty2(self
, p
):
115 """ Establish view."""
118 def setController(self
,c
):
119 """ Establish controller."""
120 self
.__controller
= c
122 def getEventTypeList(self
):
123 """ Return list of loaded EventTypes"""
124 return self
.__eventTypes
126 def setEventTypeList(self
,evts
):
127 """ Load a new list of EventTypes """
128 self
.__eventTypes
= evts
130 def getEventType(self
,et_s
):
131 for et
in self
.__eventTypes
:
132 if et
.getName() == et_s
:
135 def getMonsters(self
):
136 return self
.__monsters
138 def setMonsters(self
,monsters
):
139 self
.__monsters
= monsters