Beispiel #1
0
def personalize_text_for_narrator( explo, msg ):
    mygram = grammar.base_grammar( None, None, explo )
    for p in explo.camp.active_plots():
        pgram = p.get_dialogue_grammar( None, explo )
        if pgram:
            grammar.absorb( mygram, pgram )
    return grammar.convert_tokens( msg, mygram )
Beispiel #2
0
def personalize_text_for_narrator( explo, msg ):
    mygram = grammar.base_grammar( None, None, explo )
    for p in explo.camp.active_plots():
        pgram = p.get_dialogue_grammar( None, explo )
        if pgram:
            grammar.absorb( mygram, pgram )
    return grammar.convert_tokens( msg, mygram )
Beispiel #3
0
def personalize_text_for_character( explo, speaker, msg ):
    # Generates the speaker voice and the grammar database, then calls
    # the above function.
    mygram = grammar.base_grammar( speaker, None, explo )
    for p in explo.camp.active_plots():
        pgram = p.get_dialogue_grammar( speaker, explo )
        if pgram:
            grammar.absorb( mygram, pgram )
    speaker_voice = speaker.get_voice()
    return personalize_text( msg , speaker_voice, mygram )
Beispiel #4
0
def personalize_text_for_character( explo, speaker, msg ):
    # Generates the speaker voice and the grammar database, then calls
    # the above function.
    mygram = grammar.base_grammar( speaker, None, explo )
    for p in explo.camp.active_plots():
        pgram = p.get_dialogue_grammar( speaker, explo )
        if pgram:
            grammar.absorb( mygram, pgram )
    speaker_voice = speaker.get_voice()
    return personalize_text( msg , speaker_voice, mygram )
Beispiel #5
0
def converse( explo, pc, npc, cue ):
    # The party is going to converse with someone.
    # During the conversation, the Exploration object will have an attribute
    # called "convo" which is a tuple containing the pc, npc, and conversation.
    crd = ConvoRedraw( npc, screen = explo.screen, predraw = explo.view )

    offers = list()
    mygram = grammar.base_grammar( pc, npc, explo )

    for p in explo.camp.active_plots():
        offers += p.get_dialogue_offers( npc, explo )
        pgram = p.get_dialogue_grammar( npc, explo )
        if pgram:
            grammar.absorb( mygram, pgram )

    # Add special offers- Job Training. That's it for now.
    if npc.mr_level and npc.mr_level.__class__ in characters.PC_CLASSES:
        add_ok = False
        for chara in explo.camp.party:
            if chara.xp >= chara.xp_for_next_level() and npc.mr_level.can_take_level( chara ):
                add_ok = True
        if add_ok:
            offers.append( Offer( "[TRAINING]", context = context.ContextTag([context.TRAINING]), effect=services.JobTraining([npc.mr_level.__class__]) ) )

    conversation = build_conversation( cue , offers )
    coff = conversation

    explo.convo = (pc,npc,conversation)

    pc_voice = pc.get_voice()
    npc_voice = npc.get_voice()


    while coff:
        crd.text = personalize_text( coff.msg , npc_voice, mygram )
        mymenu = rpgmenu.Menu( explo.screen, crd.menu_rect.x, crd.menu_rect.y, crd.menu_rect.width, crd.menu_rect.height, border=None, predraw=crd )
        for i in coff.replies:
            mymenu.add_item( personalize_text( i.msg, pc_voice, mygram ), i.destination )
        if crd.text and not mymenu.items:
            mymenu.add_item( "[Continue]", None )
        else:
            mymenu.sort()
        nextfx = coff.effect

        coff = mymenu.query()

        if nextfx:
            nextfx( explo )

    del explo.convo
Beispiel #6
0
def converse(explo, pc, npc, cue):
    # The party is going to converse with someone.
    # During the conversation, the Exploration object will have an attribute
    # called "convo" which is a tuple containing the pc, npc, and conversation.
    crd = ConvoRedraw(npc, screen=explo.screen, predraw=explo.view)

    offers = list()
    mygram = grammar.base_grammar(pc, npc, explo)

    for p in explo.camp.active_plots():
        offers += p.get_dialogue_offers(npc, explo)
        pgram = p.get_dialogue_grammar(npc, explo)
        if pgram:
            grammar.absorb(mygram, pgram)

    # Add special offers- Job Training. That's it for now.
    if npc.mr_level and npc.mr_level.__class__ in characters.PC_CLASSES:
        add_ok = False
        for chara in explo.camp.party:
            if chara.xp >= chara.xp_for_next_level(
            ) and npc.mr_level.can_take_level(chara):
                add_ok = True
        if add_ok:
            offers.append(
                Offer("[TRAINING]",
                      context=context.ContextTag([context.TRAINING]),
                      effect=services.JobTraining([npc.mr_level.__class__])))

    conversation = build_conversation(cue, offers)
    coff = conversation

    explo.convo = (pc, npc, conversation)

    pc_voice = pc.get_voice()
    npc_voice = npc.get_voice()

    while coff:
        crd.friendliness = npc.get_friendliness(explo.camp)
        crd.text = personalize_text(coff.msg, npc_voice, mygram)
        mymenu = rpgmenu.Menu(explo.screen,
                              crd.menu_rect.x,
                              crd.menu_rect.y,
                              crd.menu_rect.width,
                              crd.menu_rect.height,
                              border=None,
                              predraw=crd)
        for i in coff.replies:
            mymenu.add_item(personalize_text(i.msg, pc_voice, mygram),
                            i.destination)
        if crd.text and not mymenu.items:
            mymenu.add_item("[Continue]", None)
        else:
            mymenu.sort()
        nextfx = coff.effect

        coff = mymenu.query()

        if nextfx:
            nextfx(explo)

    del explo.convo