Example #1
0
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
Example #2
0
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
Example #3
0
def needs_help(request, puzzle_piece):
    puzzle = PuzzlePiece(id=puzzle_piece)
    puzzle.needs_help = True
    puzzle.save()
    pass