def interactive(): '''Game interactive mode. Runs the full, user interactive Sudoku game, asking for the player input at each turn. ''' matrix = [[0 for j in range(9)] for i in range(9)] tips = getFromFile('config.txt') addTips(tips, matrix) if validGame(matrix): i = 0 msg = util.ok('Entre sua jogada:') errorcleanup = [0, 0, 0] while i < (81 - len(tips)): util.clearConsole() print(board.build(matrix, tips)) print(msg) r, c, n = errorcleanup if matrix[r][c] < 0: matrix[r][c] = n user_input = formatInput(input()) row, col, num = map(int, user_input.split(':')) inTips = False for t in tips: if user_input[:3] == t[:3]: inTips = True if inTips: msg = util.error('As dicas nao podem ser sobrescritas.') elif validNum(matrix, num, row, col): msg = util.ok('Entre sua jogada:') if matrix[row][col] == 0 and num != 0: i += 1 if matrix[row][col] != 0 and num == 0: i -= 1 matrix[row][col] = num else: if row < 9 and col >= 0 and 10 > num > 0: errorcleanup = row, col, matrix[row][col] matrix[row][col] = -num msg = util.error( 'Jogada invalida. Por favor, jogue novamente.') util.clearConsole() print(board.build(matrix, tips)) print(util.ok('Parabens, voce concluiu o jogo!')) e = input(' Jogar novamente? (Y/n)\n') if e.lower() == 'y' or e == '': interactive() else: util.clearConsole() print(board.build(matrix, tips)) print(util.error('Arquivo de configuracoes invalido.'))
def duty(req, res): req.params = { 'device': req.url_match.group(1) } yield from req.read_form_data() req.params['value'] = int(req.form['value'][0]) model.duty(req.params) yield from ok(res)
def update(req, res): yield from req.read_form_data() req.params = { 'device': req.url_match.group(1), 'pin': int(req.form['pin'][0]), 'default': int(req.form['default'][0]) } model.update(req.params) yield from ok(res)
def list(req, res): yield from ok(res, model.list())
def duty(req, res): req.params = {'device': req.url_match.group(1)} yield from req.read_form_data() req.params['value'] = int(req.form['value'][0]) model.duty(req.params) yield from ok(res)
def set(req, res): yield from req.read_form_data() model.set(req.form) yield from ok(res)
def scan(req, res): nets = model.scan() yield from ok(res, nets)
def read(self, req, res): yield from ok(res, self.model.get(req.params['name']))
def get(req, res): req.parse_qs() yield from ok(res, model.load(req.form['name'][0]))
def reset(req, res): yield from ok(res) model.reset()
def read(req, res): yield from ok(res, model.read(req.params))
def list(self, req, res): yield from ok(res, self.model.list())
def update(self, req, res): yield from req.read_form_data() name = req.params['name'] value = ujson.loads(req.form['value'][0]) yield from ok(res, self.model.set(name, value))
def get(req, res): yield from ok(res, model.get())
def read(self, req, res): yield from ok(res, self.model.get(name))