def play_edit_level(self, *args): if not self.edit_level: return level = Level() try: level.init_from_level(self.edit_level) except ValueError as e: self._show_error(str(e), "Cannot play map") return self.mode = "play" self._game_state = "stopped" self._finish_event = None self.level = level self.level.add_event_listener(self.game_event) self.play_ctrl.level = self.level self.game_window.use_level(self.level, grid=False) sc = functools.partial(self.score.update_score, self.level) self.level.add_event_listener(sc) self._game_state = "running" self.level.start()
def load_level(self, fname): self.auto_play = None edit_level = EditableLevel() level = Level() try: edit_level.load_level(fname) except IOError as e: self._show_error(str(e), "Cannot load map") return try: level.init_from_level(edit_level) except (IOError, ValueError) as e: if self.mode != "edit": self._show_error(str(e), "Cannot play map!") return level = None self._game_state = "stopped" self.edit_level = edit_level self.edit_mctrl.level = edit_level self.play_ctrl.edit_level = edit_level if level: self.level = level self.level.add_event_listener(self.game_event) self.play_ctrl.level = level self.play_mctrl.level = level sc = functools.partial(self.score.update_score, self.level) lvl = edit_level grid = True if self.mode == "play": lvl = level grid = False self.game_window.use_level(lvl, grid=grid) if level: level.add_event_listener(sc) # must be done after game_window.use_level level.start() self._game_state = "running"
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ import argparse import sys from chrono.model.campaign import JikibanCampaign from chrono.model.level import Level if __name__ == "__main__": parser = argparse.ArgumentParser(description="Check ChronoShift campaigns") parser.add_argument('campaigns', type=str, nargs='+', help="The campaigns files to check") args = parser.parse_args() for campaign in args.campaigns: jc = JikibanCampaign() jc.load_campaign(campaign) for lvlfile in jc: lvl = Level() lvl.load_level(lvlfile) try: lvl.check_lvl(require_solution=1) except TimeParadoxError, e: print " ".join(e.args) sys.exit(1)