Ejemplo n.º 1
0
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):
    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 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]], [])
Ejemplo n.º 4
0
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])
Ejemplo n.º 5
0
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])
Ejemplo n.º 6
0
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)
Ejemplo n.º 7
0
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], [])
Ejemplo n.º 8
0
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], [])
Ejemplo n.º 9
0
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"]], [])
Ejemplo n.º 10
0
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)
Ejemplo n.º 11
0
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)
Ejemplo n.º 12
0
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):
    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]], [])
Ejemplo n.º 14
0
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)
Ejemplo n.º 15
0
from Objs.Utilities.ArenaEnumsAndNamedTuples import EventOutput
from Objs.Events.Event import Event
import random


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)

CLIFF_DESCRIPTIONS = [
    lambda mainActor, victim : mainActor.name + ' invited ' + str(victim) + ' up to the top of a gorge to admire the view, but betrayed ' + Event.parseGenderObject(
        victim) + ', pushing ' + Event.parseGenderObject(victim) + ' off the cliff to ' + Event.parseGenderPossessive(victim) + ' death.',
    lambda mainActor, victim : mainActor.name + ' invited ' + str(victim) + ' to spar together, but betrayed ' + Event.parseGenderObject(
        victim) + ', stabbing them during an opportune moment in the fight.',
    lambda mainActor, victim : mainActor.name + ' offered to watch ' + str(victim) + "'s back while sneaking up on a clearing, then betrayed " + Event.parseGenderObject(
        victim) + ', stabbing ' + Event.parseGenderObject(victim) + ' in the back.'      
]

Event.registerEvent("BetrayFriendGuaranteedDeath", func)