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 payRent(position, player, owner): rent = dbfunctions.getRent(position) if (dbfunctions.monopolCheck(owner) and not dbfunctions.isBuildUp(position)): rent = rent * 2 dbfunctions.updateAccountBalance(owner, rent) if (dbfunctions.updateAccountBalance(player, -rent)): return "Zaplaciles " + str(rent) + " graczowi " + str(player) else: # TO DO # Opcja zastaw return "Nie masz wystarczajacych srodkow"
def newPosition(position, player): messeage = "" if (position in specialPositions): if (position == 2): if (dbfunctions.updateAccountBalance(player, -200)): scholarship = scholarship + 200 messeage = "[info],Zaplaciles za prace dyplomowa" else: print("Nie masz srodkow") elif (position == 8): messeage = "[info],Odwiedzasz spadochroniarzy" elif (position == 16): dbfunctions.updateAccountBalance(player, scholarship) scholarship = 0 messeage = "[info],Dostales " + \ str(scholarship) + "za stypendium naukowe" elif (position == 24): if (passExam): messeage = "[info],Zdałeś" else: messeage = "[blocked]" elif (position == 30): if (dbfunctions.updateAccountBalance(player, -200)): scholarship = scholarship + 200 messeage = "[info],Zaplaciles za projekt zaliczeniowy" else: print('nie masz srodkow') elif (position in spaceshipPositions): owner = dbfunctions.getSpaceshipOwner(position) if (owner != player & owner != 0): messeage = payTicket(position, player, owner) else: messeage = generateOptions(position, player) else: owner = dbfunctions.getOwner(position) if (owner != player & owner != 0): messeage = payRent(position, player, owner) else: messeage = generateOptions(position, player) return messeage
def buySpaceship(position, player): name = dbfunctions.getSpaceshipName(position) price = dbfunctions.getSpaceshipPrice(position) dbfunctions.updateAccountBalance(player, -price) dbfunctions.changeSpaceshipOwner(position, player) return "[info],Kupiles " + str(name)
def buyHouse(player, name): position = dbfunctions.getPosition(name) price = dbfunctions.getHousePrice(position) dbfunctions.updateAccountBalance(player, -price) dbfunctions.updateHouseCount(position) return "[info],Kupiles domek"
def buyStreet(position, player): name = dbfunctions.getName(position) price = dbfunctions.getPrice(position) dbfunctions.updateAccountBalance(player, -price) dbfunctions.changeOwner(position, player) return "[info],Kupiles " + str(name)
def test_changeAccount(self): prev = dbfunctions.getAccountBalance(1) dbfunctions.updateAccountBalance(1, -200) curr = dbfunctions.getAccountBalance(1) self.assertEqual(prev - 200, curr)
def test_changeAccount2(self): dbfunctions.updateAccountBalance(1, -200) self.assertEqual(dbfunctions.getAccountBalance(1), 1300)