def drawRepairScreen(screen, ShipLv, currentStats, totalStats, homeInventory, mode): graphics.drawInventory(screen, homeInventory) #draws fuel and armor and shots currentarmor, currentfuel, ammunition = currentStats totalarmor, totalfuel, totalammunition = totalStats graphics.InfoBars.draw(screen, currentfuel, totalfuel, currentarmor, totalarmor, ammunition, totalammunition) Texthelper.write(screen, [("center", 540 - 180), "repair & refill shop", 6]) status = "shop" timedFlip(mode) #armor buttonRow(screen, 0, 360, 480, currentStats, totalStats, homeInventory) timedFlip(mode) #fuel buttonRow(screen, 1, 360, 580, currentStats, totalStats, homeInventory) timedFlip(mode) #ammunition buttonRow(screen, 2, 360, 680, currentStats, totalStats, homeInventory) timedFlip(mode) if Texthelper.writeButton(screen, [("center", 820), "back", 3]): status = "homeinit" if mode: pygame.display.flip() return status
def drawSpecialUpgrade(screen, mode, shipLv, index, title, cost, status, inventory): graphics.drawInventory(screen, inventory) Texthelper.write(screen, [("center", 540 - 235), title, 6]) timedFlip(mode) if shipLv[index] > 0: Texthelper.write(screen, [("center", 540), "max level", 3]) else: Texthelper.write(screen, [("center", 450), upgrade_explanations[index], 2]) timedFlip(mode) drawCostSquare(screen, (600, 540), cost, mode) if inventory[0] >= cost[0] and inventory[1] >= cost[1] and inventory[ 2] >= cost[2] and inventory[3] >= cost[3]: if Texthelper.writeButton(screen, [("center", 540 + 220), "Upgrade", 3]): inventory[0] -= cost[0] inventory[1] -= cost[1] inventory[2] -= cost[2] inventory[3] -= cost[3] shipLv[index] += 1 filehelper.set(inventory, 2) filehelper.set(shipLv, 3) else: Texthelper.write(screen, [("center", 540 + 220), "sorry", 3]) timedFlip(mode) if Texthelper.writeButton(screen, [("center", 540 + 275), "back", 3]): status = "garageinit" return status
def homeinitUI(screen, inventory): pygame.mouse.set_visible(True) graphics.drawInventory(screen, inventory) Texthelper.write(screen, [("center", 540 - 180), "home base", 6]) pygame.display.flip() pygame.time.wait(waitTime) Texthelper.write(screen, [("center", 540 - 55), "upgrade shop", 3]) pygame.display.flip() pygame.time.wait(waitTime) Texthelper.write(screen, [("center", 540), "repair & refill shop", 3]) pygame.display.flip() pygame.time.wait(waitTime) Texthelper.write(screen, [("center", 540 + 55), "market", 3]) pygame.display.flip() pygame.time.wait(waitTime) Texthelper.write(screen, [("center", 540 + 110), "empty ship inventory", 3]) pygame.display.flip() pygame.time.wait(waitTime) Texthelper.write(screen, [("center", 540 + 165), "resume", 3]) pygame.display.flip()
def marketUI(screen, inventory, mode): if mode: marketStorage() metalbox = marketStorage.metal gasbox = marketStorage.gas circuitbox = marketStorage.circuits graphics.drawInventory(screen, inventory) Texthelper.write(screen, [("center", 540-235), "market", 6]) timedFlip(mode) status = "market" Texthelper.write(screen, [(500, 430), "metal:", 3], color=(120,120,120)) plusminusrow(screen, metalbox, 430) timedFlip(mode) Texthelper.write(screen, [(500, 485), "gas:", 3], color=(185,20,20)) plusminusrow(screen, gasbox, 485) timedFlip(mode) Texthelper.write(screen, [(500, 540), "circuits:", 3], color=(20,185,20)) plusminusrow(screen, circuitbox, 540) timedFlip(mode) ableToSell = isoverfull(metalbox, inventory[0]) and isoverfull(gasbox, inventory[1]) and isoverfull(circuitbox, inventory[2]) sellvalue = metalbox.getIntText()*SELLVALUE[0] + gasbox.getIntText() * SELLVALUE[1] + circuitbox.getIntText() * SELLVALUE[2] buyvalue = metalbox.getIntText()*BUYVALUE[0] + gasbox.getIntText() * BUYVALUE[1] + circuitbox.getIntText() *BUYVALUE[2] if (sellvalue > 0): if not ableToSell: Texthelper.write(screen, [("center", 670), "you cannot sell what you do not have", 1], color=(178,34,34)) Texthelper.writeBox(screen, [("center", 625), "sell for " + str(sellvalue) + " credits", 3], color=(178,34,34)) elif Texthelper.writeButtonBox(screen, [("center", 625), "sell for " + str(sellvalue) + " credits", 3], color=(34, 178, 34)): inventory[0] -= metalbox.getIntText() inventory[1] -= gasbox.getIntText() inventory[2] -= circuitbox.getIntText() inventory[3] += sellvalue marketStorage() timedFlip(mode) if buyvalue > inventory[3]: Texthelper.write(screen, [("center", 745), "you cannot afford this", 1], color=(178,34,34)) Texthelper.writeBox(screen, [("center", 700), "buy for " + str(buyvalue) + " credits", 3], color=(178,34,34)) elif Texthelper.writeButtonBox(screen, [("center", 700), "buy for " + str(buyvalue) + " credits", 3], color=(34, 178, 34)): inventory[0] += metalbox.getIntText() inventory[1] += gasbox.getIntText() inventory[2] += circuitbox.getIntText() inventory[3] -= buyvalue marketStorage() else: #text is blue if all inputs are zero Texthelper.writeBox(screen, [("center", 625), "sell for " + str(sellvalue) + " credits", 3], color=(34, 34, 178)) timedFlip(mode) Texthelper.writeBox(screen, [("center", 700), "buy for " + str(buyvalue) + " credits", 3], color=(34, 34, 178)) timedFlip(mode) if Texthelper.writeButton(screen, [("center", 780), "back", 3]): status = "homeinit" return status
def homeUI(screen, homeInventory, freeStuff, currentStats, totalStats): status = "home" graphics.drawInventory(screen, homeInventory) Texthelper.write(screen, [("center", 540-180), "home base", 6]) if Texthelper.writeButton(screen, [("center", 540-55), "upgrade shop", 3]): status = "garageinit" if Texthelper.writeButton(screen, [("center", 540), "repair & refill shop", 3]): status = "shopinit" if Texthelper.writeButton(screen, [("center", 540+55), "market", 3]): status = "marketinit" if Texthelper.writeButton(screen, [("center", 540+110), "Resume Flying", 3]): status = "game" pygame.mouse.set_visible(False) #draws fuel and armor and shots currentarmor, currentfuel, ammunition = currentStats totalarmor, totalfuel, totalammunition = totalStats graphics.InfoBars.draw(screen, currentfuel, totalfuel, currentarmor, totalarmor, ammunition, totalammunition) if freeStuff: spacing = 60 if Texthelper.writeButtonBox(screen, [("left+100", 200), "Free Metal", 3], color = (125, 15, 198)): homeInventory[0] += 10 if Texthelper.writeButtonBox(screen, [("left+100", 200 + spacing), "Free Gas", 3], color = (125, 15, 198)): homeInventory[1] += 10 if Texthelper.writeButtonBox(screen, [("left+100", 200 + spacing * 2), "Free Circuts", 3], color = (125, 15, 198)): homeInventory[2] += 10 if Texthelper.writeButtonBox(screen, [("left+100", 200 + spacing * 3), "Free Credits", 3], color = (125, 15, 198)): homeInventory[3] += 10 #Quests #refueling the airmans ship if filehelper.get(0)[3] == 3: if homeInventory[1] >= 20: if Texthelper.writeButtonBox(screen, [("center", 540+220), "send 20 gas to the airman", 3], color=(34,178,34)): homeInventory[1] -= 20 filehelper.setElement(4, 0, 3) game.deleteObject(110, 11, screen.get_width(), screen.get_height()) else: Texthelper.writeBox(screen, [("center", 540+220), "send 20 gas to the airman", 3], color=(178,34,34)) #getting the airman his circuits if filehelper.get(0)[3] == 5: if homeInventory[2] >= 10: if Texthelper.writeButtonBox(screen, [("center", 540+220), "send 10 circuits to the airman", 3], color=(34,178,34)): homeInventory[2] -= 10 filehelper.setElement(6, 0, 3) else: Texthelper.writeBox(screen, [("center", 540+220), "send 10 circuits to the airman", 3], color=(178,34,34)) return status
def garageUI(screen, ShipLv, homeInventory, mode): status = "garage" inventory = homeInventory graphics.drawInventory(screen, inventory) Texthelper.write(screen, [("center", 540 - 180), "upgrade shop", 6]) timedFlip(mode) Texthelper.write(screen, [(600, 540 - 55), "Armor: lv " + str(ShipLv[0]), 3]) if Texthelper.writeButton(screen, [(1000, 540 - 55), "Upgrade", 3]): status = "armorUpgradeinit" timedFlip(mode) Texthelper.write(screen, [(635, 540), "Fuel: lv " + str(ShipLv[1]), 3]) if Texthelper.writeButton(screen, [(1000, 540), "Upgrade", 3]): status = "fuelUpgradeinit" timedFlip(mode) Texthelper.write(screen, [(470, 540 + 55), "torpedoes: lv " + str(ShipLv[2]), 3]) if ShipLv[2] != 0: if Texthelper.writeButton(screen, [(1000, 540 + 55), "Upgrade", 3]): status = "ammoUpgradeinit" else: Texthelper.write(screen, [(1000, 540 + 55), "locked", 3]) timedFlip(mode) if ShipLv[3] == 0: Texthelper.write(screen, [(1200, 660), "[onetime]", 1]) if Texthelper.writeButton( screen, [("center", 675), "upgrade scavenging module", 3]): status = "scavengeUpgradeinit" else: Texthelper.write(screen, [("center", 675), "superior scavenging module", 3]) if ShipLv[4] == 0: Texthelper.write(screen, [(1200, 740), "[onetime]", 1]) if Texthelper.writeButton( screen, [("center", 755), "upgrade main engines", 3]): status = "engineUpgradeinit" else: Texthelper.write(screen, [("center", 755), "superior engine", 3]) if Texthelper.writeButton(screen, [("center", 850), "back", 3]): status = "homeinit" return status
def drawUpgradeScreen( screen, ShipLv, inventory, mode, upgradeType, status, currentStats, totalStats): #mode = true/false init, upgradeType = fuel/armor/etc. if mode: #whether it should be init-ing or not if upgradeType == "armor": editingIndex = 0 pointName = "hp" if upgradeType == "fuel": editingIndex = 1 pointName = "fp" if upgradeType == "torpedo": editingIndex = 2 pointName = "ammo" driveHead = editingIndex * maxLevel UpgradeScreenStorage.currentStat = upgrades.get(ShipLv[editingIndex] + driveHead)[4] UpgradeScreenStorage.cost = upgrades.get(ShipLv[editingIndex] + driveHead + 1) UpgradeScreenStorage.addedStat = UpgradeScreenStorage.cost[ 4] - UpgradeScreenStorage.currentStat UpgradeScreenStorage.editingIndex = editingIndex UpgradeScreenStorage.pointName = pointName currentStat = UpgradeScreenStorage.currentStat cost = UpgradeScreenStorage.cost addedStat = UpgradeScreenStorage.addedStat editingIndex = UpgradeScreenStorage.editingIndex pointName = UpgradeScreenStorage.pointName pygame.mouse.set_visible(True) #necessary? graphics.drawInventory(screen, inventory) Texthelper.write(screen, [("center", 540 - 235), upgradeType + " upgrade", 6]) timedFlip(mode) if ShipLv[editingIndex] >= maxLevel: Texthelper.write(screen, [("center", 540), "max level", 3]) else: Texthelper.write( screen, [("center", 540 - 110), "lv: " + str(ShipLv[editingIndex]) + " +1 " + "Stats: " + str(currentStat) + " +" + str(addedStat) + " " + pointName, 3]) timedFlip(mode) drawCostSquare(screen, (600, 540), cost, mode) if inventory[0] >= cost[0] and inventory[1] >= cost[1] and inventory[ 2] >= cost[2] and inventory[3] >= cost[3]: if Texthelper.writeButton(screen, [("center", 540 + 220), "Upgrade", 3]): inventory[0] -= cost[0] inventory[1] -= cost[1] inventory[2] -= cost[2] inventory[3] -= cost[3] ShipLv[editingIndex] += 1 filehelper.set(inventory, 2) filehelper.set(ShipLv, 3) #prevents bug with stats not updating totalStats[editingIndex] = upgrades.get(ShipLv[editingIndex] + editingIndex * maxLevel)[4] currentStats[editingIndex] = totalStats[editingIndex] UpgradeScreenStorage.currentStat = upgrades.get( ShipLv[editingIndex] + editingIndex * maxLevel)[4] UpgradeScreenStorage.cost = upgrades.get(ShipLv[editingIndex] + editingIndex * maxLevel + 1) UpgradeScreenStorage.addedStat = UpgradeScreenStorage.cost[ 4] - UpgradeScreenStorage.currentStat UpgradeScreenStorage.editingIndex = editingIndex UpgradeScreenStorage.pointName = pointName else: Texthelper.write(screen, [("center", 540 + 220), "sorry", 3]) timedFlip(mode) if Texthelper.writeButton(screen, [("center", 540 + 275), "back", 3]): status = "garageinit" if mode: pygame.display.flip() return status
def homeUI(screen, shipInventory, homeInventory, freeStuff): status = "home" graphics.drawInventory(screen, homeInventory) Texthelper.write(screen, [("center", 540 - 180), "home base", 6]) if Texthelper.writeButton(screen, [("center", 540 - 55), "upgrade shop", 3]): status = "garageinit" if Texthelper.writeButton(screen, [("center", 540), "repair & refill shop", 3]): status = "shopinit" if Texthelper.writeButton(screen, [("center", 540 + 55), "market", 3]): status = "marketinit" message = "empty ship inventory" if shipInventory != [0, 0, 0, 0]: message = "-+-empty ship inventory-+-" if Texthelper.writeButton(screen, [("center", 540 + 110), message, 3]): homeInventory[0] += shipInventory[0] homeInventory[1] += shipInventory[1] homeInventory[2] += shipInventory[2] homeInventory[3] += shipInventory[3] for i in range( 4): #can't just do = [0,0,0,0] because of scope and lists shipInventory[i] = 0 status = "homeinit" if Texthelper.writeButton(screen, [("center", 540 + 165), "Resume", 3]): status = "game" pygame.mouse.set_visible(False) if freeStuff: spacing = 60 if Texthelper.writeButtonBox(screen, [("left+100", 200), "Free Metal", 3], color=(125, 15, 198)): homeInventory[0] += 10 if Texthelper.writeButtonBox( screen, [("left+100", 200 + spacing), "Free Gas", 3], color=(125, 15, 198)): homeInventory[1] += 10 if Texthelper.writeButtonBox( screen, [("left+100", 200 + spacing * 2), "Free Circuts", 3], color=(125, 15, 198)): homeInventory[2] += 10 if Texthelper.writeButtonBox( screen, [("left+100", 200 + spacing * 3), "Free Credits", 3], color=(125, 15, 198)): homeInventory[3] += 10 #Quests #refueling the airmans ship if filehelper.get(0)[3] == 3: if homeInventory[1] >= 20: if Texthelper.writeButtonBox( screen, [("center", 540 + 220), "send 20 gas to the airman", 3], color=(34, 178, 34)): homeInventory[1] -= 20 filehelper.setElement(4, 0, 3) game.deleteObject(110, 11, screen.get_width(), screen.get_height()) else: Texthelper.writeBox( screen, [("center", 540 + 220), "send 20 gas to the airman", 3], color=(178, 34, 34)) #getting the airman his circuits if filehelper.get(0)[3] == 5: if homeInventory[2] >= 10: if Texthelper.writeButtonBox( screen, [("center", 540 + 220), "send 10 circuits to the airman", 3], color=(34, 178, 34)): homeInventory[2] -= 10 filehelper.setElement(6, 0, 3) else: Texthelper.writeBox( screen, [("center", 540 + 220), "send 10 circuits to the airman", 3], color=(178, 34, 34)) return status