def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): probKill = Event.DieOrEscapeProb1v1( mainActor, victims[0], state["settings"], defenseStat=(victims[0].getCombatAbility(mainActor) * 0.25 + victims[0].stats['cleverness'] * 0.15)) tempList = [mainActor, state["items"]["Bow and Arrow"], victims[0]] # Deteriorate relationship of victim toward participant state["allRelationships"].IncreaseFriendLevel(victims[0], mainActor, -2) state["allRelationships"].IncreaseLoveLevel(victims[0], mainActor, -3) lootDict = None destroyedList = None if random.random() < probKill: victims[0].kill() deadList = [victims[0].name] desc = mainActor.name + ' shot an arrow at ' + \ victims[0].name + " and killed " + \ Event.parseGenderObject(victims[0]) + "." lootDict, destroyedList = self.lootForOne(mainActor, victims[0]) else: deadList = [] desc = mainActor.name + ' shot an arrow at ' + \ victims[0].name + ", but missed." # Second entry is the contestants or items named in desc, in desired display. Third is anyone who died. This is in strings. return EventOutput(desc, tempList, deadList, loot_table=lootDict, destroyed_loot_table=destroyedList)
def func(self: Event, mainActor: Contestant, state, participants: Optional[List[Contestant]], victims: List[Contestant], sponsors: Optional[List[Contestant]]=None): probKill = Event.DieOrEscapeProb1v1(mainActor, victims[0], state["settings"], defenseStat=( victims[0].getCombatAbility(mainActor) * 0.75 + victims[0].stats['cleverness'] * 0.25)) spearBroken = random.randint(0, 1) tempList = [mainActor, state["items"]["Spear"], victims[0]] # Deteriorate relationship of victim toward participant state["allRelationships"].IncreaseFriendLevel(victims[0], mainActor, -2) state["allRelationships"].IncreaseLoveLevel(victims[0], mainActor, -3) lootDict = None destroyedList = None if random.random() < probKill: victims[0].kill() deadList = [victims[0].name] desc = mainActor.name + ' threw a spear through ' + \ victims[0].name + "'s neck and killed " + \ Event.parseGenderObject(victims[0]) + "." lootDict, destroyedList = self.lootForOne(mainActor, victims[0]) else: deadList = [] desc = mainActor.name + ' threw a spear at ' + \ victims[0].name + ", but missed." # 50/50 chance the victim gets the spear, if not broken. if not spearBroken and random.randint(0, 1): desc += " " + victims[0].name + " was able to steal the spear!" lootref = mainActor.removeAndGet(state["items"]["Spear"]) victims[0].addItem(lootref) lootDict = {victims[0].name: [lootref]} if spearBroken: desc += " The spear was broken in the process." mainActor.removeItem(state["items"]["Spear"]) # Second entry is the contestants or items named in desc, in desired display. Third is anyone who died. This is in strings. return EventOutput(desc, tempList, deadList, loot_table=lootDict, destroyed_loot_table=destroyedList)
def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): eventPeople = [mainActor] + participants numItems = random.randint(1, 2) itemsFound = [ ItemInstance.takeOrMakeInstance(v) for v in random.sample(list(state['items'].values()), 2) ] descList = eventPeople + itemsFound fightDesc, fightDead, allKillers, lootDict, injuries, destroyedList = self.fight( eventPeople, state["allRelationships"], preexistingLoot=itemsFound) if fightDesc is None: return None desc = Event.englishList( eventPeople) + " stumbled across " + Event.englishList( itemsFound) + " at the same time. A fight broke out. " + fightDesc return EventOutput(desc, descList, [x.name for x in fightDead], allKillers, loot_table=lootDict, injuries=injuries, list_killers=True, destroyed_loot_table=destroyedList)
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): # 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 func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): desc = CLIFF_DESCRIPTIONS[random.randint(0, len(CLIFF_DESCRIPTIONS) - 1)](mainActor, victims[0]) state["allRelationships"].IncreaseFriendLevel(victims[0], mainActor, -4) state["allRelationships"].IncreaseLoveLevel(victims[0], mainActor, -6) victims[0].kill() if mainActor.stats["stability"] < 3: desc += ' ' + Event.parseGenderSubject(mainActor).capitalize() + ' smiled as ' + Event.parseGenderSubject( mainActor) + ' watched ' + Event.parseGenderObject(victims[0]) + ' die.' mainActor.permStatChange({'stability': -1}) tempList = [mainActor, victims[0]] lootDict, destroyedList = self.lootForOne(mainActor, victims[0]) # Second entry is the contestants or items named in desc, in desired display. Third is anyone who died. This is in strings. return EventOutput(desc, tempList, [victims[0].name], loot_table=lootDict, destroyed_loot_table=destroyedList)
def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): probKill = Event.DieOrEscapeProb1v1( mainActor, victims[0], state["settings"], defenseStat=(victims[0].getCombatAbility(mainActor) * 0.15 + victims[0].stats['cleverness'] * 0.10)) tempList = [mainActor, state["items"]["Rifle"], victims[0]] # Deteriorate relationship of victim toward participant state["allRelationships"].IncreaseFriendLevel(victims[0], mainActor, -2) state["allRelationships"].IncreaseLoveLevel(victims[0], mainActor, -3) # RNG ammo use, this is unique to the rifle. actualItem = mainActor.hasThing("Rifle")[0] currentAmmo = actualItem.data.get("currentammo", actualItem.rawData["ammo"]) ammoUsed = min( random.randint(actualItem.rawData["ammouse"][0], actualItem.rawData["ammouse"][1]), currentAmmo) currentAmmo -= ammoUsed lootDict = None destroyedList = None if random.random() < probKill: victims[0].kill() deadList = [victims[0].name] desc = mainActor.name + ' fired at ' + \ victims[0].name + " from long range and killed " + \ Event.parseGenderObject(victims[0]) + "." lootDict, destroyedList = self.lootForOne(mainActor, victims[0]) else: deadList = [] desc = mainActor.name + ' fired at ' + \ victims[0].name + " from long range, but missed." if currentAmmo > 0: desc += "\nAmmo remaining: " + str(currentAmmo) + " (" + str( ammoUsed) + " used)" actualItem.data["currentammo"] = currentAmmo else: desc += "\nThe Rifle belonging to " + mainActor.name + " exhausted its ammo." mainActor.removeItem("Rifle") # Second entry is the contestants or items named in desc, in desired display. Third is anyone who died. This is in strings. return EventOutput(desc, tempList, deadList, loot_table=lootDict, destroyed_loot_table=destroyedList)
def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): desc = mainActor.name + " recovered from " + \ Event.parseGenderPossessive(mainActor) + " fever." if mainActor.hasThing("Medicine"): mainActor.removeItem(state["items"]["Medicine"]) desc = "Thanks to " + \ Event.parseGenderPossessive(mainActor) + " medicine, " + desc mainActor.removeStatus("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], [])
def cornucopiaEndPhaseCallback(thisPhase, PRINTHTML, state): if thisPhase == "Cornucopia": state["events"]["DoNothing"].eventStore.setdefault( "CornucopiaDoNothing", []) skippers = state["events"]["DoNothing"].eventStore[ "CornucopiaDoNothing"] if skippers: thisWriter = state.get("thisWriter") if thisWriter is not None: state["thisWriter"].addEvent( "The following contestants chose to skip the Cornucopia: " + Event.englishList(skippers), skippers) else: print( "The following contestants chose to skip the Cornucopia: " + Event.englishList(skippers)) skippers.clear()
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 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 self.eventStore["trapCounter"] == 0: return None everyone = [mainActor] + participants # First determine who this trap belongs to. trapSource = weightedDictRandom(self.eventStore["trapMakerCounter"])[0] desc = Event.englishList( everyone ) + " stumbled into an explosive trap set by " + trapSource + ", " # If the maker of this trap is anywhere in the group, chance that they warn the group. found = False for person in everyone: if str(person) == trapSource: found = True notBeingStupidRatio = (mainActor.stats["stability"] + mainActor.stats["cleverness"] * 3) / 40 if random.random() < notBeingStupidRatio: if len(everyone) > 1: desc += " but they were able to escape thanks to " + str( person) + "'s warning!" else: desc += " but excaped from " + Event.parseGenderPossessive( mainActor) + " own trap." return (desc, everyone, []) break desc += " and they all died in the ensuing detonation!" if ( len(everyone) > 1) else " and " + Event.parseGenderSubject( mainActor) + " died in the ensuing detonation!" for person in everyone: person.kill() self.eventStore["trapCounter"] -= 1 self.eventStore["trapMakerCounter"][trapSource] -= 1 descList = [mainActor] + participants if not found: descList.append(state["contestants"][trapSource]) return (desc, descList, [str(x) for x in everyone], {str(x): trapSource for x in everyone}, everyone)
def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): desc = mainActor.name + ' stalked ' + \ victims[0].name + ' from the shadows, building an understanding of ' + Event.parseGenderPossessive(victims[0]) + ' behavior and skills.' mainActor.addItem(state["items"]["Dossier"], isNew=True, target=victims[0]) descList = [mainActor, victims[0]] # If it's evening, mainActor gains hypothermia from not making a fire. if state["curPhase"] == "Evening": desc += " However, " + Event.parseGenderSubject( mainActor) + " sacrificed " + Event.parseGenderPossessive( mainActor) + " ability to make a fire, and became hypothermic." descList.append(state["statuses"]["Hypothermia"]) mainActor.addStatus("Hypothermia") # Second entry is the contestants or items named in desc, in desired display. Third is anyone who died. This is in strings. return (desc, descList, [], None, [mainActor])
def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): mainActor.removeStatus("Fever") desc = mainActor.name + " died from " + \ Event.parseGenderPossessive(mainActor) + " fever!" mainActor.kill() # 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], [mainActor.name])
def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): probSurvival = (1 - Event.DieOrEscapeProb1v1( mainActor, victims[0], state["settings"], defenseStat=(victims[0].getCombatAbility(mainActor) * 0.75 + victims[0].stats['cleverness'] * 0.25)) ) * 0.5 # This event is rigged against defender tempList = [mainActor, state["items"]["MolotovCocktail"], victims[0]] state["allRelationships"].IncreaseFriendLevel(victims[0], mainActor, -4) state["allRelationships"].IncreaseLoveLevel(victims[0], mainActor, -6) if random.random() < probSurvival: desc = mainActor.name + ' threw a molotov cocktail at ' + \ victims[0].name + " but " + \ Event.parseGenderSubject(victims[0]) + " escaped!" return (desc, tempList, []) else: victims[0].kill() desc = mainActor.name + ' threw a molotov cocktail at ' + \ victims[0].name + " and burned " + \ Event.parseGenderObject(victims[0]) + " alive." mainActor.permStatChange({'stability': -2}) if mainActor.stats["stability"] < 3: desc += " " + mainActor.name + " laughed at " + \ Event.parseGenderPossessive(victims[0]) + " agony." mainActor.removeItem(state["items"]["MolotovCocktail"]) lootDict, destroyedList = self.lootForOne(mainActor, victims[0]) if victims[0].removeStatus(state["statuses"]["Hypothermia"]): desc += " " + victims[0].name + " is no longer hypothermic." # Second entry is the contestants or items named in desc, in desired display. Third is anyone who died. This is in strings. return EventOutput(desc, tempList, [victims[0].name], loot_table=lootDict, destroyed_loot_table=destroyedList)
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): # Deteriorate relationship of victim toward participant state["allRelationships"].IncreaseFriendLevel(victims[0], mainActor, -2) state["allRelationships"].IncreaseLoveLevel(victims[0], mainActor, -3) probKill = Event.DieOrEscapeProb1v1( mainActor, victims[0], state["settings"], defenseStat=(victims[0].getCombatAbility(mainActor) * 0.5 + victims[0].stats['cleverness'] )) # this event is mildly rigged against attacker descList = [mainActor, victims[0]] if random.random() < probKill: victims[0].kill() if mainActor.stats['ruthlessness'] > 6: desc = mainActor.name + ' lay in wait for ' + \ victims[0].name + ', surprising and gutting ' + \ Event.parseGenderObject(victims[0]) + '.' else: desc = mainActor.name + ' lay in wait for ' + \ victims[0].name + ', surprising and killing ' + \ Event.parseGenderObject(victims[0]) + '.' lootDict, destroyedList = self.lootForOne(mainActor, victims[0]) return EventOutput(desc, descList, [victims[0].name], loot_table=lootDict, destroyed_loot_table=destroyedList) else: desc = mainActor.name + ' lay in wait for ' + \ victims[0].name + ', but ' + \ Event.parseGenderSubject(victims[0]) + ' managed to see it coming.' # Second entry is the contestants or items named in desc, in desired display. Third is anyone who died. This is in strings. return (desc, descList, [])
def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): mainActor.permStatChange({ "gregariousness": -1, "endurance": -1, "stability": -2 }) desc = mainActor.name + " was haunted by images of the things " + \ Event.parseGenderSubject(mainActor) + " had seen." return (desc, [mainActor], [])
def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): success = random.randint(0, 1) if success: mainActor.kill() desc = sponsors[0].name + ' struck down ' + mainActor.name + " for " + \ Event.parseGenderPossessive(mainActor) + " blasphemous beliefs." tempList = [sponsors[0], mainActor] del state["events"]["AWorshipsB"].eventStore[mainActor.name] deadList = [mainActor.name] else: desc = sponsors[ 0].name + ' tried to strike down ' + mainActor.name + " for " + Event.parseGenderPossessive( mainActor ) + " blasphemous beliefs, but Akuma Homura was able to intervene successfully." tempList = [sponsors[0], mainActor, state["sponsors"]["Akuma Homura"]] deadList = [] # Second entry is the contestants or items named in desc, in desired display. Third is anyone who died. This is in strings. return (desc, tempList, deadList)
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): mainActor.permStatChange({ 'stability': -1, 'endurance': -1, 'loneliness': 1 }) desc = mainActor.name + ' questions ' + \ Event.parseGenderPossessive(mainActor) + ' sanity.' # Second entry is the contestants named in desc, in order. Third is anyone who died. return (desc, [mainActor], [])
def killWrite(state): from Objs.Events.Event import Event killWriter = HTMLWriter(state["statuses"]) killWriter.addTitle("Day " + str(state["turnNumber"][0]) + " Kills") for contestant, kills in state["callbackStore"]["killCounter"].items(): desc = html.escape(str(contestant)) + '<br/>Kills: ' + str( len(kills)) + '<br/>' + html.escape(Event.englishList( kills, False)) descContestant = state["contestants"][contestant] if not descContestant.alive: desc = '(DEAD) ' + desc killWriter.addEvent(desc, [descContestant], escape=False) killWriter.finalWrite( os.path.join("Assets", str(state["turnNumber"][0]) + " Kills.html"), state) return False
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): if not participants[0].removeItem(state["items"]["Medicine"]): return None # In a rare scenario, the person giving the medicine uses it before this event happens. In that case, the event is waived. mainActor.addItem(state["items"]["Medicine"]) state["allRelationships"].IncreaseFriendLevel(mainActor, participants[0], random.randint(3, 4)) state["allRelationships"].IncreaseLoveLevel(mainActor, participants[0], random.randint(0, 2)) desc = participants[0].name + ' gave Medicine to ' + mainActor.name + \ " to help with " + Event.parseGenderPossessive(mainActor) + " 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, [participants[0], state["items"]["Medicine"], mainActor], [])
def medkitHealing(thisPhase, printHTML, state): if thisPhase != "Evening": return for contestant in state["contestants"].values(): if contestant.alive and contestant.hasThing("Medical Kit"): removedStatuses = set() if contestant.removeStatus( "Injury" ): # If this is False, they never had it to start with. removedStatuses.add(state["statuses"]["Injury"]) if contestant.removeStatus( "Fever" ): # If this is False, they never had it to start with. removedStatuses.add(state["statuses"]["Fever"]) if removedStatuses and printHTML: desc = contestant.name + " used their Medical Kit to heal their " + Event.englishList( removedStatuses) + "." descContestants = [contestant, *removedStatuses] state['thisWriter'].addEvent(desc, descContestants)
def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): attackers = [mainActor] + participants desc = Event.englishList( attackers ) + " worked together to ambush and attack " + victims[0].name + "." descList = attackers + victims fightDesc, fightDead, allKillers, lootDict, injuries, destroyedList = self.factionFight( attackers, victims, state["allRelationships"]) # Second entry is the contestants or items named in desc, in desired display. Third is anyone who died. This is in strings. return EventOutput(desc + fightDesc, descList, sorted([x.name for x in fightDead]), allKillers, loot_table=lootDict, injuries=injuries, destroyed_loot_table=destroyedList)
def func(self, mainActor, state=None, participants=None, victims=None, sponsors=None): mainActor.permStatChange({'stability': 3}) desc = mainActor.name + " spends a night with " + participants[0].name try: del state["events"]["ShareIntimateConversation"].eventStore[ mainActor.name] except: warnings.warn("I have no idea why this happens...") if participants[0].name in state["events"][ "ShareIntimateConversation"].eventStore: participants[0].permStatChange({'stability': 3}) del state["events"]["ShareIntimateConversation"].eventStore[ participants[0].name] desc += " and they talk out their feelings." else: desc += " and resolves " + \ Event.parseGenderPossessive(mainActor) + " confusion" # 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 ContestantStatWrite(state): from Objs.Events.Event import Event statWriter = HTMLWriter(state["statuses"]) statWriter.addTitle("Contestant Summary") for contestant in state["contestants"].values(): if not contestant.alive: continue # Construct stats and items line eventLine = html.escape(str(contestant)) + "<br/>" + \ html.escape(Event.englishList(contestant.inventory + contestant.statuses)) for statname, curstat in contestant.stats.items(): origstat = contestant.originalStats[statname] eventLine += "<br/>" + statname + ": " + str(origstat) diff = curstat - origstat if diff > 0: eventLine += " " + HTMLWriter.wrap("+" + str(diff), "positive") elif diff < 0: eventLine += " " + HTMLWriter.wrap("-" + str(-diff), "negative") statWriter.addEvent(eventLine, [contestant], escape=False) statWriter.finalWrite( os.path.join("Assets", str(state["turnNumber"][0]) + " Stats.html"), state)
from ..Utilities.ArenaUtils import weightedDictRandom, DictToOrderedDict from Objs.Events.Event import Event import collections import random import math def setupDiesFromExplosiveTrap(state): state["events"]["DiesFromExplosiveTrap"].eventStore.setdefault( "trapCounter", 0) state["events"]["DiesFromExplosiveTrap"].eventStore.setdefault( "trapMakerCounter", collections.OrderedDict()) Event.registerInsertedCallback("startup", setupDiesFromExplosiveTrap) # Manipulate the weight of the event based on the number of traps and who it is def modifyExplosiveTrapChance(actor, baseEventActorWeight, event): if event.name == "DiesFromExplosiveTrap": trapCounter = event.eventStore["trapCounter"] if trapCounter == 0: return 0, False return (1 + math.log(trapCounter, 2)) * baseEventActorWeight, True return baseEventActorWeight, True Event.registerInsertedCallback("modifyIndivActorWeights", modifyExplosiveTrapChance)
return baseEventActorWeight, True return 0, False return baseEventActorWeight, True def checkParticipantLove(actor, participant, baseEventActorWeight, event): if event.name != "FriendGivesMedicine": return baseEventActorWeight, True possible_love = actor.hasThing("Love") if not possible_love or str(possible_love[0].target) != str(participant): return baseEventActorWeight, True return baseEventActorWeight * event.stateStore[0]["settings"][ "relationInfluence"], True Event.registerInsertedCallback("modifyIndivActorWeightsWithParticipants", checkParticipantMedicine) Event.registerInsertedCallback("modifyIndivActorWeightsWithParticipants", checkParticipantLove) def checkActorLove(actor, origWeight, event): if event.name == "FriendGivesMedicine" and actor.hasThing("Love"): return (origWeight * event.stateStore[0]["settings"]["relationInfluence"] / 3, True) Event.registerEvent("modifyIndivActorWeights", checkActorLove) def func(self, mainActor,