def payTicket(position, player, owner): playerMoney = dbfunctions.getAccountBalance(player) price = dbfunctions.getTicketPrice(position, owner) if (playerMoney > price): dbfunctions.updateAccountBalance(player, -price) dbfunctions.updateAccountBalance(owner, price) return "Zaplaciles " + str(price) + " graczowi " + str(player) else: # TO DO # Opcja zastaw return "Nie masz wystarczajacych srodkow"
def test_payRent(self): game.payRent(6, 2, 3) self.assertEqual(dbfunctions.getAccountBalance(2), 1494) self.assertEqual(dbfunctions.getAccountBalance(3), 1506)
def test_changeAccount(self): prev = dbfunctions.getAccountBalance(1) dbfunctions.updateAccountBalance(1, -200) curr = dbfunctions.getAccountBalance(1) self.assertEqual(prev - 200, curr)
def test_buyStreet(self): game.buyStreet(7, 3) self.assertEqual(dbfunctions.getAccountBalance(3), 1500 - 120) self.assertEqual(dbfunctions.getOwner(7), 3)
def test_changeAccount2(self): dbfunctions.updateAccountBalance(1, -200) self.assertEqual(dbfunctions.getAccountBalance(1), 1300)