def main(cls, args): """ generated source for method main """ if not args[0].endsWith(".kif") or len(args): print "Please enter the path of a .kif file as an argument." return filename = args[0] theGame = Game.createEphemeralGame(Game.preprocessRulesheet(FileUtils.readFileAsString(File(filename)))) if theGame.getRules() == None or theGame.getRules().size() == 0: System.err.println("Problem reading the file " + filename + " or parsing the GDL.") return try: StaticValidator().checkValidity(theGame) except ValidatorException as e: System.err.println("GDL validation error: " + e.__str__()) return transformedDescription = DeORer.run(theGame.getRules()) newFilename = filename.substring(0, filename.lastIndexOf(".kif")) + "_DEORED.kif" try: for gdl in transformedDescription: out.write(gdl.__str__()) out.newLine() out.close() except IOException as e: System.err.println("There was an error writing the translated GDL file " + newFilename + ".") e.printStackTrace()
def createPreview(self, gamer, list_): """ generated source for method createPreview """ if len(list_) != 3: raise IllegalArgumentException("Expected exactly 2 arguments!") arg1 = list_.get(1) arg2 = list_.get(2) theRulesheet = arg1.__str__() previewClock = Integer.valueOf(arg2.getValue()) theReceivedGame = Game.createEphemeralGame(theRulesheet) return PreviewRequest(gamer, theReceivedGame, previewClock)
def createStart(self, gamer, list_): """ generated source for method createStart """ if len(list_) < 6: raise IllegalArgumentException("Expected at least 5 arguments!") arg1 = list_.get(1) arg2 = list_.get(2) arg3 = list_.get(3) arg4 = list_.get(4) arg5 = list_.get(5) matchId = arg1.getValue() roleName = GdlFactory.createTerm(arg2) theRulesheet = arg3.__str__() startClock = Integer.valueOf(arg4.getValue()) playClock = Integer.valueOf(arg5.getValue()) # For now, there are only five standard arguments. If there are any # new standard arguments added to START, they should be added here. theReceivedGame = Game.createEphemeralGame(theRulesheet) return StartRequest(gamer, matchId, roleName, theReceivedGame, startClock, playClock)