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()))
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
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), )
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()))
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()))
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()))
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()))
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()))
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()))
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()))
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
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)
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()))
def costume_adjective(self): if random.chance(4): return 'WICKED AWESOME' else: return random.choice(self.costume_adjectives)
def motion(self): if random.chance(80): return '' return 'with a {} motion, '.format(self.yet)
def costume_adjective(self): if random.chance(60): return '' else: return random.choice(self.costume_adjectives)