示例#1
0
文件: editor.py 项目: catseye/MARYSUE
def describe_costumes(ast, described=None):
    if described is None:
        described = set()

    if isinstance(ast, Scene):
        described = set()

    if isinstance(ast, Event):
        if isinstance(ast.subject, State) and isinstance(
                ast.subject.object, Character):
            if ast.subject.object not in described:
                if isinstance(ast.subject.object,
                              MarySue) or random.chance(50):
                    described.add(ast.subject.object)
                    return EventSequence(
                        ast,
                        TorsoCostumeReminder(subject=ast.subject)
                        if random.chance(10) else TorsoCostumeDescription(
                            subject=ast.subject),
                        FeetCostumeReminder(subject=ast.subject)
                        if random.chance(10) else FeetCostumeDescription(
                            subject=ast.subject))

    return ast.__class__(
        *[describe_costumes(c, described=described) for c in ast],
        **dict(ast.iteritems()))
示例#2
0
文件: plot.py 项目: catseye/MARYSUE
 def create_events(self):
     e = [BecomeHappyEvent(subject=s) for s in self.subject]
     seen = set()
     for s in self.subject:
         if not seen or random.chance(66):
             if random.chance(85):
                 e.append(PoseDescription(subject=s))
             else:
                 e.append(random.choice((
                     OutOfEggsEvent(subject=s),
                     GenericHyperCrystalUsageEvent(subject=s),
                 )))
         if seen and random.chance(66):
             e.append(GreetEvent(subject=s, object=random.choice(seen)))
         seen.add(s)
     return e
示例#3
0
 def costume_decoration(self):
     if random.chance(75):
         return ''
     return random.choice(self.costume_decorations).format(
         colour=self.colour,
         costume_material=random.choice(self.costume_materials),
     )
示例#4
0
文件: editor.py 项目: catseye/MARYSUE
def describe_characters(ast, described, newly_introduced):
    """Describes them as if we are meeting them for the first time.
    `described` is a set of characters who have already been described.

    `described` persists across several stories, but anyone we do
    describe here, we put in newly_introduced (it's essentially output
    only) so that we can tell not to e.g. remind the reader of their
    appearance overmuch.
    """

    if isinstance(ast, Event):
        if isinstance(ast.subject, State) and isinstance(
                ast.subject.object, Character):
            if ast.subject.object not in described:
                if isinstance(ast.subject.object,
                              MarySue) or random.chance(50):
                    described.add(ast.subject.object)
                    newly_introduced.add(ast.subject.object)
                    return EventSequence(
                        ast, CharacterDescription(subject=ast.subject),
                        CharacterFeaturesDescription(subject=ast.subject))

    return ast.__class__(
        *[describe_characters(c, described, newly_introduced) for c in ast],
        **dict(ast.iteritems()))
示例#5
0
 def costume_decoration(self):
     if random.chance(75):
         return ''
     return random.choice(self.costume_decorations).format(
         colour=self.colour,
         costume_material=random.choice(self.costume_materials),
     )
示例#6
0
文件: editor.py 项目: catseye/MARYSUE
def describe_costumes(ast, described=None):
    if described is None:
        described = set()

    if isinstance(ast, Scene):
        described = set()

    if isinstance(ast, Event):
        if isinstance(ast.subject, State) and isinstance(ast.subject.object, Character):
            if ast.subject.object not in described:
                if isinstance(ast.subject.object, MarySue) or random.chance(50):
                    described.add(ast.subject.object)
                    return EventSequence(
                        ast,
                        TorsoCostumeReminder(subject=ast.subject) if random.chance(10) else TorsoCostumeDescription(subject=ast.subject),
                        FeetCostumeReminder(subject=ast.subject) if random.chance(10) else FeetCostumeDescription(subject=ast.subject)
                    )

    return ast.__class__(*[describe_costumes(c, described=described) for c in ast], **dict(ast.iteritems()))
示例#7
0
文件: editor.py 项目: catseye/MARYSUE
def remove_mood_modifier_events(ast):
    children = []
    for child in ast:
        if isinstance(child, MoodModifierEvent):
            if random.chance(10) and isinstance(child.subject.object, TheOptimist) and child.mood() != 'happy':
                children.append(CharacterStaysHappyEvent(subject=child.subject))
        else:
            children.append(remove_mood_modifier_events(child))

    return ast.__class__(*children, **dict(ast.iteritems()))
示例#8
0
文件: editor.py 项目: catseye/MARYSUE
def remove_mood_modifier_events(ast):
    children = []
    for child in ast:
        if isinstance(child, MoodModifierEvent):
            if random.chance(10) and isinstance(
                    child.subject.object,
                    TheOptimist) and child.mood() != 'happy':
                children.append(
                    CharacterStaysHappyEvent(subject=child.subject))
        else:
            children.append(remove_mood_modifier_events(child))

    return ast.__class__(*children, **dict(ast.iteritems()))
示例#9
0
文件: editor.py 项目: catseye/MARYSUE
def remind_characters(ast, reminded):
    """Describes them assuming we have already been introduced to them,
    by subtly (hah) reminding us about what they look like."""

    if isinstance(ast, Event):
        if isinstance(ast.subject, State) and isinstance(ast.subject.object, Character):
            if ast.subject.object not in reminded:
                if random.chance(20):
                    reminded.add(ast.subject.object)
                    return EventSequence(
                        ast,
                        CharacterReminder(subject=ast.subject),
                    )

    return ast.__class__(*[remind_characters(c, reminded) for c in ast], **dict(ast.iteritems()))
示例#10
0
文件: editor.py 项目: catseye/MARYSUE
def conjoin_sentences(ast):
    if isinstance(ast, Paragraph):
        children = []
        for child in ast:
            if not children or \
               not child.is_conjoinable or \
               isinstance(children[-1], ConjoinedEvent) or \
               random.chance(100):  # DISABLED because for now it's kind of awful to read
                children.append(child)
            else:
                last = children[-1]
                compound = ConjoinedEvent(event1=last, event2=child)
                children[-1] = compound
    else:
        children = [conjoin_sentences(c) for c in ast]

    return ast.__class__(*children, **dict(ast.iteritems()))
示例#11
0
文件: editor.py 项目: catseye/MARYSUE
def remind_characters(ast, reminded):
    """Describes them assuming we have already been introduced to them,
    by subtly (hah) reminding us about what they look like."""

    if isinstance(ast, Event):
        if isinstance(ast.subject, State) and isinstance(
                ast.subject.object, Character):
            if ast.subject.object not in reminded:
                if random.chance(20):
                    reminded.add(ast.subject.object)
                    return EventSequence(
                        ast,
                        CharacterReminder(subject=ast.subject),
                    )

    return ast.__class__(*[remind_characters(c, reminded) for c in ast],
                         **dict(ast.iteritems()))
示例#12
0
文件: editor.py 项目: catseye/MARYSUE
def conjoin_sentences(ast):
    if isinstance(ast, Paragraph):
        children = []
        for child in ast:
            if not children or \
               not child.is_conjoinable or \
               isinstance(children[-1], ConjoinedEvent) or \
               random.chance(100):  # DISABLED because for now it's kind of awful to read
                children.append(child)
            else:
                last = children[-1]
                compound = ConjoinedEvent(event1=last, event2=child)
                children[-1] = compound
    else:
        children = [conjoin_sentences(c) for c in ast]

    return ast.__class__(*children, **dict(ast.iteritems()))
示例#13
0
文件: plot.py 项目: catseye/MARYSUE
 def create_events(self):
     s = self.subject
     e = [
         BecomeEmbarrassedEvent(subject=self.subject),
         PullAsideEvent(subject=self.subject, object=self.object),
         WantToTalkToYouEvent(subject=self.subject, object=self.object),
         WhatIsItEvent(subject=self.object, object=self.subject),
     ]
     done = False
     while not done:
         e.append(EventSequence(
              FidgetEvent(subject=self.subject, object=self.object),
              BecomeEmbarrassedEvent(subject=self.object),
              WhatIsItEvent(subject=self.object, object=self.subject),
              FacesCloseTogetherEvent(subject=self.object, object=self.subject),
         ))
         if random.chance(33):
             done = True
     e.append(PreludeToKissEvent(subject=self.subject, object=self.object))
     return e
示例#14
0
文件: editor.py 项目: catseye/MARYSUE
def assign_costumes(ast, context=None):
    if context is None:
        context = {}

    # reset costumes in each scene
    if isinstance(ast, Scene):
        context = {}

    attrs = {}
    for role, state in ast.iteritems():
        if isinstance(state, State) and isinstance(state.object, Character):
            character = state.object
            if state.object not in context:
                context[character] = {
                    'feet': make_feet_costume(character),
                }
                if random.chance(66):
                    context[character].update({
                        'torso':
                        make_torso_costume(character),
                        'legs':
                        make_legs_costume(character)
                    })
                else:
                    context[character].update({
                        'torso':
                        make_onesie_costume(character),
                        'legs':
                        None
                    })

            entry = context[character]
            state = state.clone(
                torso_costume=entry['torso'],
                legs_costume=entry['legs'],
                feet_costume=entry['feet'],
            )
        attrs[role] = state

    return ast.__class__(*[assign_costumes(c, context) for c in ast], **attrs)
示例#15
0
文件: editor.py 项目: catseye/MARYSUE
def describe_characters(ast, described, newly_introduced):
    """Describes them as if we are meeting them for the first time.
    `described` is a set of characters who have already been described.

    `described` persists across several stories, but anyone we do
    describe here, we put in newly_introduced (it's essentially output
    only) so that we can tell not to e.g. remind the reader of their
    appearance overmuch.
    """

    if isinstance(ast, Event):
        if isinstance(ast.subject, State) and isinstance(ast.subject.object, Character):
            if ast.subject.object not in described:
                if isinstance(ast.subject.object, MarySue) or random.chance(50):
                    described.add(ast.subject.object)
                    newly_introduced.add(ast.subject.object)
                    return EventSequence(
                        ast,
                        CharacterDescription(subject=ast.subject),
                        CharacterFeaturesDescription(subject=ast.subject)
                    )

    return ast.__class__(*[describe_characters(c, described, newly_introduced) for c in ast], **dict(ast.iteritems()))
示例#16
0
文件: editor.py 项目: catseye/MARYSUE
def assign_costumes(ast, context=None):
    if context is None:
        context = {}

    # reset costumes in each scene
    if isinstance(ast, Scene):
        context = {}

    attrs = {}
    for role, state in ast.iteritems():
        if isinstance(state, State) and isinstance(state.object, Character):
            character = state.object
            if state.object not in context:
                context[character] = {
                    'feet': make_feet_costume(character),
                }
                if random.chance(66):
                    context[character].update({
                        'torso': make_torso_costume(character),
                        'legs': make_legs_costume(character)
                    })
                else:
                    context[character].update({
                        'torso': make_onesie_costume(character),
                        'legs': None
                    })

            entry = context[character]
            state = state.clone(
                torso_costume=entry['torso'],
                legs_costume=entry['legs'],
                feet_costume=entry['feet'],
            )
        attrs[role] = state

    return ast.__class__(*[assign_costumes(c, context) for c in ast], **attrs)
示例#17
0
 def costume_adjective(self):
     if random.chance(4):
         return 'WICKED AWESOME'
     else:
         return random.choice(self.costume_adjectives)
示例#18
0
 def costume_adjective(self):
     if random.chance(4):
         return 'WICKED AWESOME'
     else:
         return random.choice(self.costume_adjectives)
示例#19
0
 def motion(self):
     if random.chance(80):
         return ''
     return 'with a {} motion, '.format(self.yet)
示例#20
0
 def motion(self):
     if random.chance(80):
         return ''
     return 'with a {} motion, '.format(self.yet)
示例#21
0
 def costume_adjective(self):
     if random.chance(60):
         return ''
     else:
         return random.choice(self.costume_adjectives)
示例#22
0
 def costume_adjective(self):
     if random.chance(60):
         return ''
     else:
         return random.choice(self.costume_adjectives)