Esempio n. 1
0
def SE(gc, event):
    if gui.ynbox(event.description):
        p1 = ""
        p2 = p1

        while p1 == p2:
            p1 = getRandomPEC()
            p2 = getRandomPEC()

        deal = None
        while deal == None:
            deal = gui.buttonbox("The merchant offers two deals:\n\nDeal 1: We can give 1 "+p1+" Component and get 1 "+p2+" in exchange.\nDeal 2: We can give 2 "+p1+" Component and get 3 "+p2+" Components in exchange.","Offer",
                                 ["Check Supplies","Deal 1","Deal 2","No Deal!"])
            if deal == "Check Supplies":
                gc.ShipStatus()
                deal = None
                continue
            elif deal == "Deal 1":
                if gc.inv[p1] >= 1:
                    gc.inv[p1] -= 1
                    gc.inv[p2] += 1
                    gui.msgbox("The merchant smiles, \"Pleasure doing business with you, traveler. Good luck on the trail!\"")
                else:
                    gui.msgbox("We don't have enough resources for this deal!")
                    deal = None
            elif deal == "Deal 2":
                if gc.inv[p1] >= 2:
                    gc.inv[p1] -= 2
                    gc.inv[p2] += 3
                    gui.msgbox("The merchant smiles, \"Pleasure doing business with you, traveler. Good luck on the trail!\"")
                else:
                    gui.msgbox("We don't have enough resources for this deal!")
                    deal = None
            elif deal == "No Deal!":
                gui.msgbox("The merchant shakes his head, \"What a shame... Perhaps you'll have changed your mind the next time we meet!\"")
Esempio n. 2
0
def MYS(gc,event):
    msg = event.description
    if gui.ynbox(msg):
        check = RollD(6)
        if check == 1:
            sys = systemDamage(gc)
            return gui.msgbox("It's a trap! An unidentified assailant struck our ship, then fled. Damaging the "+sys.name+" Area.\n\nSo rude.")
        else:
            posEve = ["Derilict Probe","Abandoned spacecraft","Asteroid Field"]
            posEve = posEve[RollD(3)-1]
            event = gc.sector.eventTables[1].getEvent(posEve)
            gui.msgbox("Investigating the mysterious signal revealed a previously unnoticed "+event.title)
            return RCO(gc,event)
Esempio n. 3
0
    def InitGame(self):
        def SetCrewNames():
            msg = "What are your crew members' names?"
            title = "Crew Names"
            fieldNames = [
                "Medbay Specialist", "Engines Specialist", "Comms Specialist",
                "Systems Specialist"
            ]
            fieldValues = []  # we start with blanks for the values
            fieldValues = gui.multenterbox(msg, title, fieldNames)

            # make sure that none of the fields were left blank
            while True:
                if fieldValues is None: break
                errmsg = ""
                for i in range(len(fieldNames)):
                    if fieldValues[i].strip() == "":
                        errmsg += ('"%s" is a required field.\n\n' %
                                   fieldNames[i])
                if errmsg == "":
                    break  # no problems found
                fieldValues = gui.multenterbox(errmsg, title, fieldNames,
                                               fieldValues)
            return fieldValues

        for label in MECS_LABELS:
            self.mecs[label[:1]] = MECS(label)

        #init Crew
        while None in self.crew:
            qs = gui.ynbox("Quick Start?")

            #Name crew members manually
            if qs == False:

                #returns array of str names or None if cancelled
                cnames = SetCrewNames()

                #Don't try to create Crew objects if name population was cancelled
                if cnames == None: continue

                #Otherwise, create Crew objects from the list of provided names
                for i in range(0, len(self.crew)):
                    self.crew[i] = Crew(cnames[i],
                                        self.mecs[MECS_LABELS[i][:1]])

            #If quickstart is selected, auto-name crew members
            if qs == True:
                for i in range(0, len(self.crew)):
                    self.crew[i] = Crew("Jenkins " + str(i + 1),
                                        self.mecs[MECS_LABELS[i][:1]])
Esempio n. 4
0
def __main__():

    GC.InitGame()

    action = ""

    while action != "exit":

        #Return option list depending on phase
        options = GC.GetOptions()

        #Get the user's input
        action = gui.buttonbox("What would you like to do?",
                               "Day " + GC.phase + ": " + str(GC.day), options)

        #Trigger quit prompt if prompt window is closed
        if action == None:
            action = OPTIONS["X"]

        #Take action on given player input:
        if action == OPTIONS["D"] or action == OPTIONS["E"]:
            GC.NextDay()
        elif action == OPTIONS["S"]:
            GC.ShipStatus()
        elif action == OPTIONS["M"]:
            GC.MoveCrew()
        elif action == OPTIONS["REP"]:
            GC.RepairShip()
        elif action == OPTIONS["RS"]:
            eventhandler.systemDamage(GC)
        elif action == OPTIONS["RP"]:
            gui.msgbox(GC.GetRandomPECs())
        elif action == OPTIONS["RES"]:
            if gui.ynbox("Restart Program?", "Restart"):
                os.execl(sys.executable, sys.executable, *sys.argv)
        elif action == OPTIONS["X"]:
            if gui.ynbox("Are you sure you want to quit?", "Quit Program?"):
                sys.exit()
Esempio n. 5
0
    def ChangeRoom(self):
        while True:

            if self.state == "REPAIR":
                gui.msgbox(
                    "This crew member cannot be moved because they are currently in the middle of a repair. "
                    +
                    "If you would like to reassign them, you must first cancel the repair."
                )
                return False
            elif self.state == "ACTIVE":
                if not gui.ynbox(
                        self.name + " is actively manning the " +
                        self.room.name +
                        " Area. Are you sure you'd like to reassign them?"):
                    return False

            where = gui.buttonbox(
                "Where should " + self.name + " be moved?\n\nName: " +
                self.name + "\nCurrent Location: " + self.room.name,
                "Room Reassignment", MECS_LABELS)
            oldState = self.state

            for key, room in GC.mecs.items():
                if where == room.name:

                    crew = room.checkAssigned()
                    if crew != None:
                        if crew != self and crew.state == "ACTIVE":
                            if gui.ynbox("The " + room.name +
                                         " Area is actively being manned by " +
                                         crew.name + ".\n\nWould you like " +
                                         self.name +
                                         " to take over for them?"):
                                crew.state = None
                                self.state = "ACTIVE"
                            else:
                                self.state = None
                    else:
                        self.state = "ACTIVE"
                        if not gui.ynbox(
                                "Nobody is currently stationing the " +
                                room.name + " Area.\n\nWould you like " +
                                self.name + " to station it?"):
                            self.state = None

                    stateText = "ASSIGNED" if self.state == "ACTIVE" else "MOVED"

                    oldRoom = self.room.name
                    self.room = room
                    if oldRoom != self.room.name:
                        gui.msgbox(self.name + " has been " + stateText +
                                   " from " + oldRoom + " to the " +
                                   self.room.name + " Area.")
                    elif oldState != self.state:
                        gui.msgbox(self.name + " has been " + stateText +
                                   " to the " + self.room.name + " Area.")
                    else:
                        gui.msgbox("Move cancelled.")
                    return True
            print("Room not found. Try again...")
Esempio n. 6
0
    def RepairShip(self):
        noRepNeeded = True
        for key, room in self.mecs.items():
            for key, sub in room.subsystems.items():

                if sub.repair != None:
                    noRepNeeded = False
                    while True:
                        modRepair = gui.buttonbox(
                            "There is currently a repair in progress.\n\n" +
                            "Location: " + room.name + "\n" +
                            " ---- Subsystem: " + sub.name + "\n" +
                            " ---- Damage: " + sub.GetSeverity() + "\n\n" +
                            "Crew assigned to repair: " +
                            str(sub.repair.crew.name) + "\n" + "Number of " +
                            sub.sid + " components to use: " +
                            str(sub.repair.dice) + "\n" +
                            "Chance of repair per day: " +
                            str(sub.repair.chance) + "%\n\n" +
                            "What would you like to do?",
                            "Repair in Progress: (" + room.name + "," +
                            sub.name + ")",
                            ["Move Repairer", "Add Resources", "Continue"])

                        if modRepair == "Move Repairer":
                            conf = gui.ynbox(
                                "WARNING! Moving the crew member performing the repairs will keep your repair progress,"
                                +
                                " but you will lose any resources dedicated to the repair so far.\n\nAre your sure you would like to reassign "
                                + sub.repair.crew.name + "?")
                            if conf:
                                crew = sub.repair.crew
                                sub.repair = None
                                crew.state = None
                                crew.ChangeRoom()
                                break
                        elif modRepair == "Add Resources":
                            addRes = gui.integerbox(
                                "How many " + sub.name +
                                " Components should be allocated for repair?\n"
                                + "(Currently " + str(self.inv[sub.sid]) +
                                " " + sub.name + " Components in Inventory)",
                                "Pick Components", 0, 0, self.inv[sub.sid])
                            if addRes == None or addRes == 0:
                                continue
                            else:
                                self.inv[sub.sid] -= addRes
                                sub.repair.dice += addRes
                                sub.repair.chance = sub.repair.GetChance(
                                    sub.sid)
                            break
                        else:
                            break

                if (sub.damage != 0 and sub.repair == None):
                    noRepNeeded = False
                    startRepair = False
                    while startRepair != True:
                        if gui.ynbox(
                                "The " + sub.name + " Subsystems in the " +
                                room.name +
                                " area appear to have taken damage.\n\n" +
                                "Damage: " + sub.GetSeverity() +
                                "\n\nWould you like to try and repair it?"):
                            crewNames = []
                            repStr = ""
                            for crew in self.crew:
                                crewNames.append(crew.name)
                                repStr += crew.GetRepairStats(sub.sid)

                            while True:
                                repairCrew = self.GetCrewByName(
                                    gui.buttonbox(
                                        "Who should be moved to repair the damage?\n\n"
                                        + repStr, "Pick Crew", crewNames))
                                if repairCrew.state == "REPAIR":
                                    gui.msgbox(
                                        "This crew member cannot be removed because they are already repairing another system. To move this crew member, finish or cancel the other repair."
                                    )
                                    continue
                                else:
                                    break
                            repairDice = gui.integerbox(
                                "How many " + sub.name +
                                " Components should be allocated for repair?\n"
                                + "(Currently " + str(self.inv[sub.sid]) +
                                " " + sub.name + " Components in Inventory)",
                                "Pick Components", 0, 0, self.inv[sub.sid])

                            while repairDice == 0:
                                if not gui.ynbox(
                                        "The number of resources allocated must be greater than 0 to start a repair. Would you like to cancel this repair?",
                                        "Insufficent Resources Allocated!"):
                                    repairDice = gui.integerbox(
                                        "How many " + sub.name +
                                        " Components should be allocated for repair?\n"
                                        + "(Currently " +
                                        str(self.inv[sub.sid]) + " " +
                                        sub.name + " Components in Inventory)",
                                        "Pick Components", 0, 0,
                                        self.inv[sub.sid])
                                else:
                                    continue

                            if repairDice == None:
                                continue

                            startRepair = gui.ynbox(
                                "The following repair will take place:\n\n" +
                                "Location: " + room.name + "\n" +
                                " ---- Subsystem: " + sub.name + "\n" +
                                " ---- Damage: " + sub.GetSeverity() + "\n\n" +
                                "Crew assigned to repair: " +
                                str(repairCrew.name) + "\n" + "Number of " +
                                sub.sid + " components to use: " +
                                str(repairDice) + "\n" +
                                "Chance of repair per day: " + str(
                                    int(100 * repairDice *
                                        (repairCrew.pecProf[sub.sid] / 6))) +
                                "%" + "\n\nBegin Repair?", "Begin Repair?")

                            if startRepair:
                                repairCrew.room = room
                                repairCrew.state = "REPAIR"
                                sub.repair = Repair(repairCrew, repairDice,
                                                    sub.sid)
                                self.inv[sub.sid] -= repairDice

                        else:
                            break

        if noRepNeeded:
            return gui.msgbox("No repairs are needed. Keep up the good work!")