def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): probSuccess = mainActor.stats["cleverness"] * 0.03 + 0.3 probNormalFailure = (1 - probSuccess) * 0.8 probHorrifcFailure = 1 - probNormalFailure - probSuccess randValue = random.random() if randValue < probSuccess: mainActor.addItem("MolotovCocktail", isNew=True) desc = mainActor.name + ' crafted a Molotov Cocktail.' return (desc, [mainActor, state["items"]["MolotovCocktail"]], []) elif randValue < probSuccess + probNormalFailure: desc = mainActor.name + ' tried to make a Molotov Cocktail, but burned ' + \ Event.parseGenderReflexive(mainActor) + ' instead.' mainActor.permStatChange({ 'stability': -1, 'endurance': -1, 'combat ability': -1 }) return (desc, [mainActor], []) else: desc = mainActor.name + ' tried to make a Molotov Cocktail, but lit ' + \ Event.parseGenderReflexive(mainActor) + ' on fire, dying horribly.' if mainActor.removeStatus(state["statuses"]["Hypothermia"]): desc += " " + mainActor.name + " is no longer hypothermic." mainActor.kill() return (desc, [mainActor], [mainActor.name])
def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): alt = random.randint(1, 2) if alt == 1: desc = mainActor.name + ' dug a grave and held an elaborate funeral ceremony for ' + \ Event.parseGenderReflexive(mainActor) + ', ' else: desc = mainActor.name + " attempted to hang " + \ Event.parseGenderReflexive(mainActor) + " with a makeshift noose, " possible_love = mainActor.hasThing("Love") if not possible_love: potentialRescuers = [ x for x in state['contestants'].values() if (x.alive and x != mainActor and ( state['allRelationships'].friendships[x.name][mainActor.name] >= 3 or state['allRelationships'].loveships[x.name][ mainActor.name] >= 2)) ] random.shuffle(potentialRescuers) for rescuer in potentialRescuers: if random.random() < 0.25: trueRescuer = rescuer break else: if alt == 1: desc += 'before burying ' + \ Event.parseGenderReflexive(mainActor) + ' alive.' else: desc += "choking " + \ Event.parseGenderReflexive( mainActor) + " in a long, arduous experience." mainActor.kill() return desc, [mainActor], [mainActor.name] else: trueRescuer = possible_love[0].target if alt == 1: desc += 'before trying to bury ' + Event.parseGenderReflexive( mainActor ) + ' alive. However, ' + trueRescuer.name + ' was able to stop ' + Event.parseGenderObject( mainActor) + ' in time.' else: desc += "but " + trueRescuer.name + " was able to stop " + \ Event.parseGenderObject(mainActor) + " in time." state['allRelationships'].IncreaseFriendLevel(mainActor, trueRescuer, 3) state['allRelationships'].IncreaseLoveLevel(mainActor, trueRescuer, random.randint(1, 3)) mainActor.permStatChange({'stability': 2, 'endurance': 2, 'loyalty': 1}) return desc, [mainActor, trueRescuer], []
def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): # First subtract this character's own traps from the trap list, weighted by chance of not being stupid notBeingStupidRatio = mainActor.stats["stability"] / 10 thisTrapDict = self.eventStore["trapCounter"].copy() if str(mainActor) in self.eventStore["trapMakerCounter"]: totSum = 0 for key in thisTrapDict: thisTrapDict[key] -= self.eventStore["trapMakerCounter"][str( mainActor)][key] * notBeingStupidRatio totSum += thisTrapDict[key] if not totSum: # all existing traps were made by this character, cancel event return None chosen = weightedDictRandom(thisTrapDict, 1)[0] trapSourceDict = DictToOrderedDict({ key: self.eventStore["trapMakerCounter"][key][chosen] for key in self.eventStore["trapMakerCounter"] }) if str(mainActor) in trapSourceDict: trapSourceDict[str(mainActor)] *= (1 - notBeingStupidRatio) trapSource = weightedDictRandom(trapSourceDict, 1)[0] if trapSource == str(mainActor): desc = "Delirious and confused, " + str( mainActor) + TRAP_RESULT_SELF[chosen].replace( "VICTIM", Event.parseGenderObject(mainActor)).replace( "VICTRE", Event.parseGenderReflexive(mainActor)).replace( "SOURCE", Event.parseGenderPossessive(mainActor)).replace( "VICTPOS", Event.parseGenderPossessive(mainActor)) descList = [mainActor] else: desc = str(mainActor) + TRAP_RESULT[chosen].replace( "VICTIM", Event.parseGenderObject(mainActor)).replace( "VICTRE", Event.parseGenderReflexive(mainActor)).replace( "SOURCE", trapSource).replace( "VICTPOS", Event.parseGenderPossessive(mainActor)) descList = [mainActor, state["contestants"][trapSource]] mainActor.kill() self.eventStore["trapCounter"][chosen] -= 1 self.eventStore["trapMakerCounter"][trapSource][chosen] -= 1 return (desc, descList, [str(mainActor)], { str(mainActor): trapSource }, [mainActor])
def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): # Random relationship boost state["allRelationships"].IncreaseFriendLevel(mainActor, participants[0], random.randint(1, 2)) state["allRelationships"].IncreaseLoveLevel(mainActor, participants[0], random.randint(2, 3)) state["allRelationships"].IncreaseFriendLevel(participants[0], mainActor, random.randint(1, 2)) state["allRelationships"].IncreaseLoveLevel(participants[0], mainActor, random.randint(2, 3)) desc = mainActor.name + ' and ' + \ participants[0].name + ' had an intimate conversation.' # This leans on the fact that if they _are_ in love, this event will only trigger for the right person. if not mainActor.hasThing("Love"): confused = [] if mainActor.gender == participants[0].gender: if not random.randint(0, 2): confused.append(mainActor) mainActor.permStatChange({'stability': -2}) if not random.randint(0, 2): confused.append(participants[0]) participants[0].permStatChange({'stability': -2}) if len(confused) == 2: desc += ' ' + Event.englishList(confused) + \ ' found themselves confused by their feelings.' weight = 10 elif len(confused) == 1: desc += ' ' + Event.englishList( confused) + ' found ' + Event.parseGenderReflexive( confused[0] ) + ' confused by ' + Event.parseGenderPossessive( confused[0]) + ' feelings.' weight = 20 if confused: eventHandler = IndividualEventHandler(state) eventHandler.banEventForSingleContestant( "ShareIntimateConversation", mainActor.name) eventHandler.banEventForSingleContestant( "ShareIntimateConversation", participants[0].name) for person in confused: eventHandler.bindRoleForContestantAndEvent( "participants", [mainActor if person != mainActor else participants[0]], person, "ResolvesFeelingConfusion") eventHandler.setEventWeightForSingleContestant( "ResolvesFeelingConfusion", person.name, weight, state) self.eventStore[mainActor.name] = eventHandler self.eventStore[ participants[0].name] = eventHandler # Yes, two copies # Second entry is the contestants or items named in desc, in desired display. Third is anyone who died. This is in strings. return (desc, [mainActor, participants[0]], [])
def DossierOnAcquisition(itemInstance, contestant, state): if itemInstance.target == contestant: from Objs.Events.Event import Event # Again, this should really be in Arenautils... # Destroy self-dossiers. announce( contestant.name + " destroyed a Dossier about " + Event.parseGenderReflexive(contestant) + ".", [contestant, itemInstance], state) contestant.removeItem(itemInstance, itemInstance.count)
def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): if mainActor.hasThing("Medicine"): mainActor.removeItem(state["items"]["Medicine"]) desc = mainActor.name + " felt " + Event.parseGenderReflexive( mainActor ) + " getting sick, but was able to ward it off with " + Event.parseGenderPossessive( mainActor) + " medicine." else: desc = mainActor.name + " got sick with a severe fever." mainActor.addStatus("Fever") # Second entry is the contestants or items named in desc, in desired display. Third is anyone who died. This is in strings. return (desc, [mainActor, state["statuses"]["Fever"]], [])
def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): # they shouldn't be practicing combat if injured if state["callbackStore"].setdefault('InjuredDict', defaultdict(bool)): return None desc = mainActor.name + ' practiced combat' practiceAbility = mainActor.stats['combat ability'] injuries = None if random.random() > 1 / (1 + 1.3**practiceAbility): desc += ' but hurt ' + \ Event.parseGenderReflexive(mainActor) + ' doing so.' mainActor.addStatus(state["statuses"]["Injury"]) injuries = [str(mainActor)] else: desc += ' and was successfully able to improve ' + \ Event.parseGenderPossessive(mainActor) + ' skills' mainActor.permStatChange({'combat ability': 1}) return EventOutput(desc, [mainActor], [], injuries=injuries)
def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): desc = "Tired of waiting, the sponsors force two of the remaining contestants to fight. " # Build dict of weights for various possibilities optionDict = collections.OrderedDict() optionDict['fight'] = 1 if state['allRelationships'].friendships[str(mainActor)][str( participants[0])] > 3 and state['allRelationships'].friendships[ str(participants[0])][str(mainActor)] > 3: optionDict['attemptEscape'] = 2 if state['allRelationships'].loveships[str(mainActor)][str( participants[0])] > 3: optionDict['actorSuicide'] = 1 optionDict['actorBegToKill'] = 1 if state['allRelationships'].loveships[str( participants[0])][str(mainActor)] > 3: optionDict['participantSuicide'] = 1 optionDict['participantBegToKill'] = 1 chosen = weightedDictRandom(optionDict, 1)[0] if chosen == 'fight': # Keep running until only neither 0 nor all contestants are dead. fightDead = [] # dummy list. while (len(fightDead) != 1): fightDesc, fightDead, allKillers, lootDict, injuries, destroyedList = self.fight( [mainActor, participants[0]], state['allRelationships'], deferActualKilling=True, forceRelationshipFight=True) # We had to deny Event.fight actually killing anyone because of fact that it might be reset. fightDead[0].kill() desc += "They did so." + fightDesc return EventOutput(desc, [mainActor, participants[0]], [str(x) for x in fightDead], allKillers, loot_table=lootDict, injuries=injuries, destroyed_loot_table=destroyedList) if chosen == 'attemptEscape': escape = bool(random.randint(0, 1)) if escape: mainActor.escape() participants[0].escape() desc += 'Instead of fighting, the two contestants attempt to escape, and do so successfully!' # This is a hack, declaring both of them "Dead" but ending the game immediately with overriding text that suggests they survived. return (desc, [mainActor, participants[0]], [str(mainActor), str(participants[0])], {}, [mainActor, participants[0]], True) dead = mainActor if random.randint(0, 1) else participants[0] desc += 'Instead of fighting, the two contestants attempt to escape, but ' + \ dead.name + ' is caught and killed by the sponsors!' dead.kill() return (desc, [mainActor, participants[0]], [dead.name]) if chosen == 'actorSuicide': desc += "Rather than be forced to fight " + Event.parseGenderPossessive( mainActor) + " loved one, " + str( mainActor) + " committed suicide!" mainActor.kill() return (desc, [mainActor, participants[0]], [mainActor.name]) if chosen == 'participantSuicide': desc += "Rather than be forced to fight " + Event.parseGenderPossessive( participants[0]) + " loved one, " + str( participants[0]) + " committed suicide!" participants[0].kill() return (desc, [mainActor, participants[0]], [participants[0].name]) if chosen == 'actorBegToKill': desc += str(mainActor) + " begged " + \ str(participants[0]) + " to kill " + \ Event.parseGenderObject(mainActor) if state['allRelationships'].loveships[str( participants[0])][str(mainActor)] < 4 or random.random() > 0.5: desc += ', forcing ' + \ str(participants[0]) + ' to go through with it.' mainActor.kill() deadList = [mainActor.name] else: desc += ', but ' + Event.parseGenderSubject( participants[0] ) + ' refused, killing ' + Event.parseGenderReflexive( participants[0]) + ' instead!' participants[0].kill() deadList = [participants[0].name] return (desc, [mainActor, participants[0]], deadList) if chosen == 'participantBegToKill': desc += str(participants[0]) + " begged " + str(mainActor) + \ " to kill " + Event.parseGenderObject(participants[0]) if state['allRelationships'].loveships[str(mainActor)][str( participants[0])] < 4 or random.random() > 0.5: desc += ', forcing ' + str(mainActor) + ' to go through with it.' deadList = [participants[0].name] participants[0].kill() else: desc += ', but ' + Event.parseGenderSubject( mainActor) + ' refused, killing ' + Event.parseGenderReflexive( mainActor) + ' instead!' mainActor.kill() deadList = [mainActor.name] return (desc, [mainActor, participants[0]], deadList) raise AssertionError("This should not happen! " + chosen)