Ejemplo 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!\"")
Ejemplo n.º 2
0
def SF(gc,event):
    aux = None
    while aux == None:
        aux = gui.buttonbox(event.description,event.title,event.actions)
        if aux == None:
            continue
        for i in range(0, len(event.sysKeys)):
            if aux == event.actions[i]:
                sys = event.sysKeys[i]
                break
            elif aux == event.actions[3]:
                sys = None

        sChecks = [gc.mecs["M"].SystemCheck(),gc.mecs["E"].SystemCheck(),gc.mecs["S"].SystemCheck()]
        if sys == None:
            for check in sChecks:
                check += 2
        elif sys == "M":
            sChecks[0] += 4
        elif sys == "E":
            sChecks[1] += 4
        elif sys == "C":
            sChecks[2] += 4

        for check in sChecks:
            if check >= 10:
                gui.msgbox("We were able to successfully avoid any harmful radiation.")
                return

        for crew in gc.crew:
            crew.hp -= RollD(2)

        gui.msgbox("We were unable to avoid the radiation, damaging everyone's health on board.")
Ejemplo n.º 3
0
    def ShipStatus(self):
        choice = gui.buttonbox("What do you want to check on?",
                               "Status Report",
                               ["Ship", "Crew", "Inventory", "Done"])
        while choice != "Done":
            #This will be our report output
            textStr = ""

            #Get MECS status and any damaged subsystems
            if choice == "Ship":
                for room in self.mecs.items():
                    print(room)
                    room = room[1]
                    print(room.name)
                    textStr += ("-----\n" + room.name + "\n-----\n")
                    damStr = ""
                    for sub in room.subsystems.items():
                        sub = sub[1]
                        if sub.damage != 0:
                            damStr += ("\n" + sub.name + " Subsystems:\n" +
                                       "    Damage: " + sub.GetSeverity() +
                                       "\n")
                    if damStr == "":
                        textStr += "Nothing to report...\n"
                    else:
                        textStr += damStr
                    textStr += "\n"

            #Get crew status
            elif choice == "Crew":
                for crew in self.crew:
                    stateText = "IDLE" if crew.state == None else crew.state
                    textStr += ("\n" + crew.name + "\n-- Room: " +
                                crew.room.name + "\n-- Health: " +
                                crew.GetHealth() + "\n-- State: " + stateText +
                                "\n")

            #Get inventory status
            elif choice == "Inventory":
                for name, number in self.inv.items():
                    textStr += (str(number) + " " + name + " Components\n")

            #Print report and check for another
            textStr += "\n\n"
            choice = gui.buttonbox(
                textStr + "What else do you want to check on?",
                choice + " Status", ["Ship", "Crew", "Inventory", "Done"])
Ejemplo n.º 4
0
def FP(gc, event):
    crewList = []
    for crew in gc.crew:
        if crew.hp != 10:
            crewList.append(crew.name)

    if len(crewList) == 0:
        gui.msgbox("Your crew found a flavor packet, but nobody seems to want it. So they decide to give it to you!\n\nHow thoughtful :)")
    else:
        who = None
        while who == None:
            who = gui.buttonbox(event.description,event.title,crewList)
            who = gc.GetCrewByName(who)
            who.hp += 1
            gui.msgbox("You decide to give "+who.name+" the flavor packet. They look slightly better than before this divine gift entered their life.")
Ejemplo n.º 5
0
    def MoveCrew(self):
        crewNames = []
        for crew in self.crew:
            crewNames.append(crew.name)

        while True:
            who = gui.buttonbox("Who would you like to move?", "Pick Crew",
                                crewNames)

            for crew in self.crew:
                if who == crew.name:
                    break

            if who == None:
                continue

            if crew.ChangeRoom():
                return

            print("Not a valid selection! Try again...")
Ejemplo n.º 6
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()
Ejemplo n.º 7
0
def RCO(gc,event):
    
    choice = None
    title = event.title
    msg = event.description
    actions = event.actions
    sysKeys = event.sysKeys
    resource = event.resource

    while choice == None:
        
        choice = gui.buttonbox(
            msg,
            title,
            actions
        )

        if choice == "Avoid":
            sCheck = gc.mecs["E"].SystemCheck()
            if sCheck >= 5:
                gui.msgbox("Successfully avoided the "+title+".")
            else:
                sys = systemDamage(gc)
                if sys != False:
                    gui.msgbox("We were unable to avoid the "+title+" and received damage to the "+sys.name+" area.")
            print("sysCheck result: "+str(sCheck), "\nSystem Scores (E,"+sysKeys[0]+"): ",gc.mecs["E"].getScore(), gc.mecs["S"].getScore())

        elif choice == "Search":
            sCheck = gc.mecs[sysKeys[0]].SystemCheck()
            if sCheck >= 6:
                gui.msgbox("We gathered "+str(getResources(gc, resource))+" "+resource+" components from the "+title)
            else:
                sys = systemDamage(gc)
                if sys != False:
                    gui.msgbox("While investigating the "+title+", there was an accident, damaging the "+sys.name+" area.")
            print("sysCheck result: "+str(sCheck), "\nSystem Scores (E,"+sysKeys[0]+"): ",gc.mecs["E"].getScore(), gc.mecs["S"].getScore())
Ejemplo n.º 8
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...")
Ejemplo n.º 9
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!")