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)
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
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.")
def getEvent(self, label=None, ind=None): #select random event when no args provided if ind == None and label == None: ind = RollD(len(self.events)) - 1 #print("D6ish: "+str(ind)) #get event by index if ind != None: return self.events[ind] elif label != None: for event in self.events: if event.title == label: return event
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)
def SystemCheck(self): total = 0 sysScore = self.getScore() crew = self.checkAssigned() if crew != None: effMod = crew.effMod else: effMod = 0 if sysScore >= 1: for i in range(0, sysScore): total += RollD(6) total += effMod if total < 0: total = 0 return total
def getResources(gc, resource): rolls = [] for crew in gc.crew: if crew.state == "ACTIVE": rolls.append(RollD(6)) print("Rolls: ",rolls) rich = 6 in rolls and 1 not in rolls print("Is Rich? "+str(rich)) print(len(rolls)) resNum = 0 for i in range(0, len(rolls)): if rolls[i] >= 4: resNum += 1 gc.inv[resource] += resNum return resNum
def getTable(self, label=None, ind=None): eventTables = self.eventTables #select random table when no args provided if ind == None and label == None: #get the largest range of all the tables maxRange = 0 for table in eventTables: if table.maxVal > maxRange: maxRange = table.minVal ind = RollD(maxRange) #get table by index then label for table in eventTables: if ind != None: if table.minVal <= ind and table.maxVal >= ind: return table elif label != None: if table.name == label: return table
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.")
def GetRandomPECs(self): roll = RollD(3) key = PECS_LABELS[roll - 1] return key, self.inv[key[:1]]
def GetRandomCrew(self): return self.crew[RollD(4) - 1]
def getRandomSystem(gc): sysNames = ["M","E","C","S"] result = RollD(4)-1 result = sysNames[result] sys = gc.mecs[result] return sys
def getRandomPEC(): pecNames = ["P","E","C"] result = RollD(3)-1 result = pecNames[result] return result
def getRandomSub(system): pecNames = ["P","E","C"] result = RollD(3)-1 result = pecNames[result] pec = system.subsystems[result[:1]] return pec