示例#1
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()
示例#2
0
def get_player_list_by_contest_id(contest_id):
	return PlayerList.objects(contestId = contest_id)[0]