def execute(self, player, args): if locks.authority() is not locks.SYSTEM: # When user code is implemented, this will create an untrusted REPL # under the player's authority. raise utils.UserError("Not yet implemented: for now, sudo is " "required.") player.send("***********") player.send("* WARNING *") player.send("***********") player.send("") player.send("You are working interactively with the actual Python " "process running the game. Careless actions here can " "really permanently foul up important things.") player.send("") def check_password(line): if player.hash(line) == player.password: with locks.authority_of(locks.SYSTEM): player.enter_mode(PythonMode(player)) else: player.send("Incorrect.") d = handler.prompt(player, "To proceed, enter your password:") d.addCallback(check_password)
def handle_input(line): if line == ".": player.send("Canceled.") return inputs[self.phase] = line self.phase += 1 if self.phase < len(prompts): d = handler.prompt(player, prompts[self.phase]) d.addCallback(handle_input) return else: finish(*inputs)
def execute(self, player, args): prompts = [ "Enter the room's name (. to cancel):", "Enter the name of the exit into the room, " "if any (. to cancel):", "Enter the name of the exit back, if any (. to cancel):" ] inputs = [None for i in prompts] self.phase = 0 def handle_input(line): if line == ".": player.send("Canceled.") return inputs[self.phase] = line self.phase += 1 if self.phase < len(prompts): d = handler.prompt(player, prompts[self.phase]) d.addCallback(handle_input) return else: finish(*inputs) def finish(room_name, to_exit_name, from_exit_name): room = db.Room(room_name) db.store(room) if to_exit_name != "": exit_to = db.Exit(to_exit_name, player.location, room) db.store(exit_to) if from_exit_name != "": exit_from = db.Exit(from_exit_name, room, player.location) db.store(exit_from) player.send("Dug room #{}, {}.".format(room.uid, room.name)) if args["name"]: handle_input(args["name"]) else: d = handler.prompt(player, prompts[0]) d.addCallback(handle_input)
def execute(self, player, args): prompts = ["Enter the room's name (. to cancel):", "Enter the name of the exit into the room, " "if any (. to cancel):", "Enter the name of the exit back, if any (. to cancel):"] inputs = [None for i in prompts] self.phase = 0 def handle_input(line): if line == ".": player.send("Canceled.") return inputs[self.phase] = line self.phase += 1 if self.phase < len(prompts): d = handler.prompt(player, prompts[self.phase]) d.addCallback(handle_input) return else: finish(*inputs) def finish(room_name, to_exit_name, from_exit_name): room = db.Room(room_name) db.store(room) if to_exit_name != "": exit_to = db.Exit(to_exit_name, player.location, room) db.store(exit_to) if from_exit_name != "": exit_from = db.Exit(from_exit_name, room, player.location) db.store(exit_from) player.send("Dug room #{}, {}.".format(room.uid, room.name)) if args["name"]: handle_input(args["name"]) else: d = handler.prompt(player, prompts[0]) d.addCallback(handle_input)
def execute(self, player, args): def handle_response(text): player.send(text) d = handler.prompt(player, "Enter text") d.addCallback(handle_response)