Exemplo n.º 1
0
def AS(gc, event):
    if gc.annoySound:
        gui.msgbox("The annoying sound has finally stopped.\n\nYour crew breathes a sigh of relief and can now more effeciently focus on their work.")
        gc.annoySound = False
    else:
        gui.msgbox("The ship starts making an annoying sound, but nobody can seem to figure out where it's coming from.\n\nThe annoyance puts everyone just slightly more on edge.")
        gc.annoySound = True
Exemplo n.º 2
0
def systemDamage(gc, sys = None):
    targeted = False
    if sys == None:
        sys = getRandomSystem(gc)
        print(sys)
    else:
        targeted = True
        sys = gc.mecs[sys]

    brokenPecs = []
    brokenMecs = []
    while True:
        sub = getRandomSub(sys)
        while sub in brokenPecs and len(brokenPecs) < 3:
            sub = getRandomSub(sys)
        
        if sub.damage == 0:
            dam = RollD(4)
            sub.damage = dam
            return sys
        
        if not targeted and len(brokenMecs) < 4:
            if len(brokenPecs) < 3:
                brokenPecs.append(sub)
                continue
            oldSys = sys
            brokenPecs = []
            while sys == oldSys:
                sys = getRandomSystem(gc)
            brokenMecs.append(oldSys)
        else:
            gui.msgbox("The "+sys.name+" system took damage, but it is already damaged beyond repair.")
            return False
Exemplo n.º 3
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!\"")
Exemplo n.º 4
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.")
Exemplo n.º 5
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)
Exemplo n.º 6
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.")
Exemplo n.º 7
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()
Exemplo n.º 8
0
def MS(gc,event):
    msg = event.description
    room = gc.mecs[event.sysKeys[0]]

    sCheck = room.SystemCheck()
    
    if sCheck >= 6:
        msg += "\n\nDue to our excellent "+room.name+" Area, we were able to fix the problem before any serious damage could be done."
    else:
        for crew in gc.crew:
            if crew.room == room:
                crew.hp -= RollD(2)
        msg += "\n\nAs a result, everyone in the "+room.name+" Area has taken some damage."

    print("sCheck: "+str(sCheck))
    return gui.msgbox(msg)
Exemplo n.º 9
0
    def NextDay(self):
        if self.phase == "END":

            for key, room in self.mecs.items():
                for key, sub in room.subsystems.items():
                    sub.AttemptRepair()

            self.day += 1
            self.phase = "START"
        else:
            #event = self.sector.newDay()
            event = self.sector.newDay()
            print(event.title)
            print(event.func)
            self.phase = "END"
            if event.func != None:
                return getattr(eventhandler, event.func)(self, event)
            else:
                return gui.msgbox(event.description)
Exemplo n.º 10
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())
Exemplo n.º 11
0
 def AttemptRepair(self):
     if self.repair == None or self.damage == 0:
         return
     else:
         roll = RollD(100)
         if roll <= self.repair.chance:
             self.damage -= 1
             if self.damage == 0:
                 gui.msgbox(self.repair.crew.name +
                            " completed repairs on the " + self.name +
                            " Subsystems in the " + self.room.name)
                 self.repair.crew.state = None
                 self.repair.crew.ChangeRoom()
                 self.repair = None
             else:
                 gui.msgbox(self.repair.crew.name +
                            " has reduced the damage level of the " +
                            self.name + " Subsystems in the " +
                            self.room.name + " to " + self.GetSeverity())
         else:
             gui.msgbox(self.repair.crew.name +
                        " is still working on repairs to the " + self.name +
                        " Subsystems in the " + self.room.name + " Area.")
Exemplo n.º 12
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...")
Exemplo n.º 13
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!")