def testUpdatePoints(self): Coin.add('points') Coin.add('gold') Formula.objects.create(id='level-gold', formula='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)
def testUpdatePoints(self): Coin.add("points") Coin.add("gold") Formula.objects.create(id="level-gold", formula="gold=10*{level}", owner=None) player = self._get_player() player.points = 420 player.level_no = 1 player.save() update_points(player, None) coins = History.user_coins(player.user) self.assertIn("gold", coins) self.assertEqual(coins["gold"], 60)
def coins(self): # TODO check usage and deprecate this function from wouso.core.scoring.models import History return History.user_coins(self.user)
def inf(self): return History.user_coins(user=self)['penalty']
def user_coins(user): """ Returns a dictionary with user coins """ if not isinstance(user, User): user = user.user return History.user_coins(user)
def gold_amount(player): """ Return player's amount of gold """ coins = History.user_coins(player) return coins['gold']
def test_user_coins(self): Coin.add('points') Coin.add('gold') player = self._get_player() self.assertIn('points', History.user_coins(player.user))
def test_user_coins(self): Coin.add("points") Coin.add("gold") player = self._get_player() self.assertIn("points", History.user_coins(player.user))