def generateOptions(position, player): response = "" if (position in spaceshipPositions): owner = dbfunctions.getSpaceshipOwner(position) if (owner == 0): response = response + getSpaceshipOffer(position) else: owner = dbfunctions.getOwner(position) if (owner == 0): response = response + getStreetOffer(position) kits = dbfunctions.getHouseAviliableStreets(player) if (kits != 0): response = response + "[buyHousesOption],Kupic domki?," if (response == ""): response = "[exit]" else: response = "[options]" + response + "[exit],Nic" return response
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 test_changeOwner(self): dbfunctions.changeOwner(3, 2) self.assertEqual(dbfunctions.getOwner(3), 2)
def test_buyStreet(self): game.buyStreet(7, 3) self.assertEqual(dbfunctions.getAccountBalance(3), 1500 - 120) self.assertEqual(dbfunctions.getOwner(7), 3)
def test_owner(self): self.assertEqual(dbfunctions.getOwner(3), 0)