Esempio n. 1
0
 def test_update_points_level_upgrade_first_time(self):
     level_up_points = 80
     IntegerListSetting.get('level_limits').set_value(str(level_up_points))
     Coin.add('points')
     Coin.add('gold')
     Formula.add('level-gold', expression='gold=10*{level}', owner=None)
     # Upgrade player's level
     player = self._get_player()
     player.points = level_up_points + 1
     player.level_no = 1
     player.save()
     update_points(player, None)
     coins = History.user_coins(player.user)
     self.assertEqual(coins['gold'], 10 * player.max_level)
Esempio n. 2
0
 def test_update_points_level_upgrade_first_time(self):
     level_up_points = 80
     IntegerListSetting.get('level_limits').set_value(str(level_up_points))
     Coin.add('points')
     Coin.add('gold')
     Formula.add('level-gold', expression='gold=10*{level}', owner=None)
     # Upgrade player's level
     player = self._get_player()
     player.points = level_up_points + 1
     player.level_no = 1
     player.save()
     update_points(player, None)
     coins = History.user_coins(player.user)
     self.assertEqual(coins['gold'], 10 * player.max_level)
Esempio n. 3
0
    def test_first_login_points(self):
        f = Formula.add('start-points', expression='points=10')
        Coin.add('points')
        player = self._get_player()

        self.assertEqual(player.points, 0)

        # this won't work, since the activity is sent in our custom view
        #self.client.login(username=player.user.username, password='******')
        # using this instead
        signals.addActivity.send(sender=None, user_from=player, action="login", game=None, public=False)

        player = Player.objects.get(pk=player.pk)
        self.assertEqual(player.points, 10)
Esempio n. 4
0
    def test_first_login_points(self):
        f = Formula.add('start-points', definition='points=10')
        Coin.add('points')
        player = self._get_player()

        self.assertEqual(player.points, 0)

        # this won't work, since the activity is sent in our custom view
        #self.client.login(username=player.user.username, password='******')
        # using this instead
        signals.addActivity.send(sender=None, user_from=player, action="login", game = None, public=False)

        player = Player.objects.get(pk=player.pk)
        self.assertEqual(player.points, 10)
Esempio n. 5
0
 def testUpdatePoints(self):
     Coin.add('points')
     Coin.add('gold')
     Formula.add('level-gold', expression='gold=10*{level}', owner=None)
     player = self._get_player()
     player.points = 82
     player.level_no = 1
     player.save()
     update_points(player, None)
     coins = History.user_coins(player.user)
     self.assertIn('gold', coins)
     self.assertEqual(coins['gold'], 20)
     player.points = 10
     player.save()
     update_points(player, None)
     coins = History.user_coins(player.user)
     self.assertIn('gold', coins)
     self.assertEqual(coins['gold'], 0)
Esempio n. 6
0
 def testUpdatePoints(self):
     Coin.add('points')
     Coin.add('gold')
     Formula.add('level-gold', definition='gold=10*{level}', owner=None)
     player = self._get_player()
     player.points = 82
     player.level_no = 1
     player.save()
     update_points(player, None)
     coins = History.user_coins(player.user)
     self.assertIn('gold', coins)
     self.assertEqual(coins['gold'], 20)
     player.points = 10
     player.save()
     update_points(player, None)
     coins = History.user_coins(player.user)
     self.assertIn('gold', coins)
     self.assertEqual(coins['gold'], 0)
Esempio n. 7
0
    def test_user_points(self):
        coin = Coin.add('points')
        player = self._get_player()

        scoring.score_simple(player, 'points', 10)

        up = History.user_points(user=player.user)
        self.assertTrue('wouso' in up)
        self.assertTrue(coin.name in up['wouso'])
        self.assertEqual(up['wouso'][coin.name], 10)
Esempio n. 8
0
    def test_user_points(self):
        coin = Coin.add('points')
        player = self._get_player()

        scoring.score_simple(player, 'points', 10)

        up = History.user_points(user=player.user)
        self.assertTrue(up.has_key('wouso'))
        self.assertTrue(up['wouso'].has_key(coin.name))
        self.assertEqual(up['wouso'][coin.name], 10)
Esempio n. 9
0
    def testUpdatePoints(self):
        IntegerListSetting.get('level_limits').set_value("80 125 180 245 320 450")

        Coin.add('points')
        Coin.add('gold')
        Formula.add('level-gold', expression='gold=10*{level}', owner=None)
        player = self._get_player()
        player.points = 82
        player.level_no = 1
        player.save()
        update_points(player, None)
        coins = History.user_coins(player.user)
        self.assertIn('gold', coins)
        self.assertEqual(coins['gold'], 20)
        player.points = 10
        player.save()
        update_points(player, None)
        coins = History.user_coins(player.user)
        self.assertIn('gold', coins)
        self.assertEqual(coins['gold'], 0)
Esempio n. 10
0
    def testUpdatePoints(self):
        IntegerListSetting.get('level_limits').set_value(
            "80 125 180 245 320 450")

        Coin.add('points')
        Coin.add('gold')
        Formula.add('level-gold', expression='gold=10*{level}', owner=None)
        player = self._get_player()
        player.points = 82
        player.level_no = 1
        player.save()
        update_points(player, None)
        coins = History.user_coins(player.user)
        self.assertIn('gold', coins)
        self.assertEqual(coins['gold'], 20)
        player.points = 10
        player.save()
        update_points(player, None)
        coins = History.user_coins(player.user)
        self.assertIn('gold', coins)
        self.assertEqual(coins['gold'], 0)
Esempio n. 11
0
    def test_sync_methods(self):
        player = self._get_player()
        coin = Coin.add('points')

        History.objects.create(user=player.user, coin=coin, amount=10)
        self.assertEqual(player.points, 0)
        scoring.sync_user(player)
        self.assertEqual(player.points, 10)

        History.objects.create(user=player.user, coin=coin, amount=10)
        self.assertEqual(player.points, 10)
        scoring.sync_all_user_points()
        player = Player.objects.get(pk=player.pk)
        self.assertEqual(player.points, 20)
Esempio n. 12
0
    def test_sync_methods(self):
        player = self._get_player()
        coin = Coin.add('points')

        History.objects.create(user=player.user, coin=coin, amount=10)
        self.assertEqual(player.points, 0)
        scoring.sync_user(player)
        self.assertEqual(player.points, 10)

        History.objects.create(user=player.user, coin=coin, amount=10)
        self.assertEqual(player.points, 10)
        scoring.sync_all_user_points()
        player = Player.objects.get(pk=player.pk)
        self.assertEqual(player.points, 20)
Esempio n. 13
0
 def test_user_coins(self):
     Coin.add('points')
     Coin.add('gold')
     player = self._get_player()
     scoring.score_simple(player, 'points', 10)
     self.assertIn('points', History.user_coins(player.user))
Esempio n. 14
0
 def setUp(self):
     self.user, new = User.objects.get_or_create(username='******')
     self.game = Game.get_instance()
     self.coin = Coin.add('_test')
Esempio n. 15
0
 def test_user_coins(self):
     Coin.add('points')
     Coin.add('gold')
     player = self._get_player()
     scoring.score_simple(player, 'points', 10)
     self.assertIn('points', History.user_coins(player.user))
Esempio n. 16
0
 def setUp(self):
     self.user, new = User.objects.get_or_create(username='******')
     self.game = Game.get_instance()
     self.coin = Coin.add('_test')