예제 #1
0
def new_contest(contest_info):
	ncontest = Contest(title = contest_info['title'], format = contest_info['format'], totalPlayers = contest_info['totalPlayers'], description = contest_info['description'], game = contest_info['game'], adminId = contest_info['adminId'], currentPlayers = 0, progress = "")
	ncontest.save()
	new_player_list(ncontest.id, contest_info['totalPlayers'])
	generate_match_list(ncontest.id)
	generate_graph(ncontest.id)
	return ncontest
예제 #2
0
def register_player(contest_id, user_id):
	contest = Contest.objects(id = contest_id)[0]
	player_list = PlayerList.objects(contestId = contest_id)[0]
	user_id_to_substitute = player_list.userIds[contest.currentPlayers]
	player_list.userIds[contest.currentPlayers] = user_id
	player_list.save()
	match_list = get_match_list_by_contest_id(contest_id)
	contest.currentPlayers += 1
	contest.save()
	for i in Match.objects(player1Id = user_id_to_substitute):
		if not i.id in match_list.matches: 
			print "OK!"
			continue
		print "YEAH"
		i.player1Id = user_id
		i.save()

	print "HAHA"
	for i in Match.objects(player2Id = user_id_to_substitute):
		if not i.id in match_list.matches:
			print "OK!"
			continue
		print "YEAH"
		i.player2Id = user_id
		i.save()
	if contest.format == "Single Round-Robin":
		graph1 = get_graph_by_contest_id(contest_id)
		for i in graph1.items:
			if i.playerId == user_id_to_substitute:
				i.playerId = user_id
				break
		graph1.save()
예제 #3
0
def get_contest_by_id(contest_id):
	return Contest.objects(id = contest_id)[0]
예제 #4
0
def get_contest_list():
	return Contest.objects()