# # Level.py # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # Copyright # Author: Salvatore S. Gionfriddo # Contributors: # Created: 2007.07.04 # Last Modified: 2007.07.17 # class Level: def __init__(self, name, reward, description, background = (100,160,100)): self.spawners = [] self.goals = [] self.name = name self.reward = reward self.description = description self.background = background def reset(self): for spawner in self.spawners: spawner.reset() def isLevelComplete(self): complete = True for goal in self.goals: if goal.getCurrent() < goal.target: complete = False return complete def getGoalStatus(self): status = [] for goal in self.goals: progress = goal.target - goal.getCurrent() if progress < 0: progress = 0 status.append( (progress, goal.goalType) ) return status def addSpawner(self, spawner): self.spawners.append(spawner) def addGoal(self, target, getCurrent, goalType = "More Kills"): self.goals.append(Goal(target, getCurrent, goalType)) class Goal: def __init__(self, target, getCurrent, goalType): self.target = target self.getCurrent = getCurrent self.goalType = goalType