Exemple #1
0
    def final_challenge(self, request, queryset):
        profiles = UserProfile.objects.filter(user__is_superuser=False, 
            user__is_active=True, current_bot__isnull=False).all()
        if not queryset:
		    return HttpResponseRedirect('/admin')
		    
        final_challenge = queryset[0]
        for up_player1, up_player2 in itertools.product(profiles, repeat=2):
            if up_player1 == up_player2:
                continue
                
            challenge = Challenge()
            challenge.requested_by = up_player1
            challenge.challenger_bot = up_player1.current_bot
            challenge.challenged_bot = up_player2.current_bot
            challenge.final_challenge = final_challenge
            challenge.save()
            final_challenge.challenge_set.add(challenge)
            # dispatch the new task
            players = {up_player1.user.username: up_player1.current_bot.code,
                       up_player2.user.username: up_player2.current_bot.code,
            }
            run_match.delay(challenge.id, players)

        final_challenge.save()
        return HttpResponseRedirect('/admin')
Exemple #2
0
    def _test_run_match(self, bot1_code, bot2_code, checkChallenge):
        def save_bot(user_profile, bot_code):
            aBot = Bot()
            aBot.owner = user_profile
            aBot.code = bot_code
            aBot.save()
            return aBot

        bot1 = save_bot(self.user1_profile, bot1_code)
        bot2 = save_bot(self.user2_profile, bot2_code)

        aChallenge = Challenge()
        aChallenge.challenger_bot = bot1
        aChallenge.challenged_bot = bot2
        aChallenge.requested_by = self.user1_profile
        aChallenge.save()

        players = {
            'bot1': aChallenge.challenger_bot.code,
            'bot2': aChallenge.challenged_bot.code
        }

        run_match.delay(aChallenge.id, players)

        #Refresh challenge
        aChallenge = Challenge.objects.get(pk=aChallenge.id)
        checkChallenge(aChallenge)
Exemple #3
0
    def final_challenge(self, request, queryset):
        profiles = UserProfile.objects.filter(user__is_superuser=False,
                                              user__is_active=True,
                                              current_bot__isnull=False).all()
        if not queryset:
            return HttpResponseRedirect('/admin')

        final_challenge = queryset[0]
        for up_player1, up_player2 in itertools.product(profiles, repeat=2):
            if up_player1 == up_player2:
                continue

            challenge = Challenge()
            challenge.requested_by = up_player1
            challenge.challenger_bot = up_player1.current_bot
            challenge.challenged_bot = up_player2.current_bot
            challenge.final_challenge = final_challenge
            challenge.save()
            final_challenge.challenge_set.add(challenge)
            # dispatch the new task
            players = {
                up_player1.user.username: up_player1.current_bot.code,
                up_player2.user.username: up_player2.current_bot.code,
            }
            run_match.delay(challenge.id, players)

        final_challenge.save()
        return HttpResponseRedirect('/admin')
Exemple #4
0
    def _test_run_match(self, bot1_code, bot2_code, checkChallenge):
        def save_bot(user_profile, bot_code):
            aBot = Bot()
            aBot.owner = user_profile
            aBot.code = bot_code
            aBot.save()
            return aBot

        bot1 = save_bot(self.user1_profile, bot1_code)
        bot2 = save_bot(self.user2_profile, bot2_code)

        aChallenge = Challenge()
        aChallenge.challenger_bot = bot1
        aChallenge.challenged_bot = bot2
        aChallenge.requested_by = self.user1_profile
        aChallenge.save()

        players = {'bot1': aChallenge.challenger_bot.code,
                   'bot2': aChallenge.challenged_bot.code}

        run_match.delay(aChallenge.id, players)

        #Refresh challenge
        aChallenge = Challenge.objects.get(pk=aChallenge.id)
        checkChallenge(aChallenge)