def make_new_puzzle(player, photo): puzzle = Puzzle() puzzle.player1 = player puzzle.save() piece = PuzzlePiece(puzzle=puzzle, owner=player, photo=photo) piece.save() return puzzle.id
def make_move_with_photo(player, puzzle_id, photo): puzzle = get_puzzle(puzzle_id) if(player == puzzle.turn): piece = PuzzlePiece(puzzle=puzzle, owner=player, photo=photo, constraint=generate_constraint()) piece.save() if player == puzzle.player1: puzzle.turn = puzzle.player2 else: puzzle.turn = puzzle.player1 puzzle.save() return True else: return False
def needs_help(request, puzzle_piece): puzzle = PuzzlePiece(id=puzzle_piece) puzzle.needs_help = True puzzle.save() pass