Exemple #1
0
def start(event):
    if event == 1:
        inventory.active(False)
        boysBathroom.unloadRoom()
        darkRoom.loadRoom()
    elif event == 3:
        darkRoom.unloadRoom()
        nexus.loadRoom()
    elif event == 6:
        nexus.unloadRoom()
        juniorHallway.loadRoom()
    if event == 5:
        info = Dialogue(canvas, infoText[event], 'Loudspeaker',
                        sprites.loudspeaker, nexus, None, player, inventory)
        info.show()
        isDialogueGone(event, info)
    elif event < len(infoText):
        info = Infobox(canvas, infoText[event], 3000)
        info.show()
        root.after(3000, start, event + 1)
    else:
        inventory.active(True)
        loop()
        info = Dialogue(canvas, writeObject.chanas1(), 'Mr. Hanas',
                        sprites.hanasface, juniorHallway, mrHanas, player,
                        inventory)
        info.show()
	def get_dialogues(self):

		if self.subs_format == 'ass':
			f = open(self.subs, 'r')
			subs = ass.parse(f)
			return [Dialogue(event.text, self.to_ms(event.start), self.to_ms(event.end)) for event in subs.events]
		
			
		elif self.subs_format == 'srt':
			subs = pysrt.open(self.subs)
			return [Dialogue(sub.text, self.to_ms_srt(sub.start), self.to_ms_srt(sub.end)) for sub in subs]
Exemple #3
0
 def __gen_dlg(self, txt: str):
     if self.__systems.windlg is None:
         fnt = self.config.get('font', 'bold')
         buttons = [DialogueButton(text='New Game',
                                   fmtkwargs={'size': (0.35, 0.1),
                                              'font': fnt,
                                              'text_color': (0, 50, 0, 255),
                                              'down_text_color': (255, 255,
                                                                  255, 255),
                                              'border_thickness': 0.005,
                                              'down_border_thickness': 0.008,
                                              'border_color': (0, 50, 0),
                                              'down_border_color': (255, 255,
                                                                    255),
                                              'corner_radius': 0.05,
                                              'multi_sampling': 2,
                                              'align': 'center'},
                                   callback=self.__new_deal)]
         dlg = Dialogue(text=txt, buttons=buttons, margin=0.01,
                        size=(0.7, 0.7), font=fnt, align='center',
                        frame_color=(40, 120, 20), border_thickness=0.01,
                        corner_radius=0.05, multi_sampling=2)
         dlg.pos = -0.35, -0.35
         dlg.reparent_to(self.ui.center)
         self.__systems.windlg = dlg
     else:
         self.__systems.windlg.text = txt
         self.__systems.windlg.show()
Exemple #4
0
def test_repl_gcd_example_multiline(capsys):
    session = """
    > (define not (boolean) (if boolean 0 1))
    <UserFunction (not boolean)>
    > (define <> (x y) (not (= x y)))
    <UserFunction (<> x y)>
    > (define mod (m n) (- m (* n (/ m n))))
    <UserFunction (mod m n)>
    > (define gcd (m n)
    ...  (begin
    ...      (set r (mod m n))
    ...      (while (<> r 0)
    ...           (begin
    ...                (set m n)
    ...                (set n r)
    ...                (set r (mod m n))))
    ... n))
    <UserFunction (gcd m n)>
    > (gcd 42 56)
    14
    """
    dlg = Dialogue(session)
    repl(dlg.fake_input)
    captured = capsys.readouterr()
    assert dlg.session == captured.out
Exemple #5
0
 def speak(self):
     self.speakMode = 1
     ''' Write code for speaking.    '''
     speech = Dialogue(self._canvas, self.__produceSpeech(), self.__name,
                       self.__icon, self.__room, self, self._player,
                       self.__inventory)
     speech.show()
def test(sett, screen):
    pepe = pygame.image.load('pepe.png')
    borrito = pygame.image.load('borrito.png')
    test_dia = Dialogue(sett, screen, "right", "", pepe)
    test_dia2 = Dialogue(sett, screen, "left", "", borrito)

    dials = Group()
    dials.add(test_dia)
    dials.add(test_dia2)

    backwards = False

    while True:
        gf.events()

        if not sett.paused:
            test_dia.update(backwards)
            test_dia2.update(backwards)
            print(test_dia2.x)
            if test_dia.x == 100:
                ##test dialogue. TODO have file of encounters to refer to

                gf.update_screen(sett, screen, True, dials,
                                 "i am here to slay", 173, 255, 47)
                pygame.time.wait(3000)
                gf.update_screen(sett, screen, True, dials, "prepare urself",
                                 173, 255, 47)
                pygame.time.wait(3000)
                gf.update_screen(sett, screen, True, dials, "no way", 255, 69,
                                 0)
                pygame.time.wait(3000)
                backwards = True
                #test_dia.x = test_dia.x -1  #back()
                #test_dia2.x= test_dia2.x +1 #back()

            if test_dia.x < -200:
                del test_dia
            if test_dia2.x > 800:
                del test_dia2
                dials.empty()

        gf.update_screen(sett, screen, True, dials)
Exemple #7
0
def main():
    last_update_id = None
    global dialogue
    dialogue = Dialogue()
    while True:
        updates = get_updates(last_update_id)
        print(updates)
        if len(updates["result"]) > 0:
            last_update_id = get_last_update_id(updates) + 1
            respond(updates)
        time.sleep(0.5)
Exemple #8
0
    def __init__(self, apikey=None, **kwargs):
        """Construct client.

        :param apikey: Api key
        :param user: User specific infomation
        """
        self.apikey = apikey
        self.apis = {}
        self.last_response = None

        #: Default api call.
        self.register_api('Dialogue', Dialogue(**kwargs))
Exemple #9
0
def test_repl_gcd_example(capsys):
    session = """
    > (define mod (m n) (- m (* n (/ m n))))
    <UserFunction (mod m n)>
    > (define gcd (a b) (if (= b 0) a (gcd b (mod a b))))
    <UserFunction (gcd a b)>
    > (gcd 6 15)
    3
    """
    dlg = Dialogue(session)
    repl(dlg.fake_input)
    captured = capsys.readouterr()
    assert dlg.session == captured.out
Exemple #10
0
def frostingEffect(thisFrosting, thisMsBabbin, clickx, clicky):
    global tookFuel
    if thisMsBabbin.click(clickx, clicky, False):
        thisFrosting._inventory.removeItem(thisFrosting)
        thisFrosting.depopulate
        funkyFrostingFuel.populate()
        tookFuel = True
        info = Dialogue(canvas,
                        Writing("playername", "male").babbin4(), 'Mrs. Babbin',
                        sprites.babbinface, chemRoom, msBabbin, player,
                        inventory)
        info.show()
        return True
    return False
def build_game():
    room = Location(
        "A room",
        "You are in a typical room in a rather generic building of some kind.")

    dog = Item(
        "A dog",
        "A dog",
        "The dog is pretty quiet but looks like he could chat up a storm if engaged.",
        start_at=room,
        gettable=False)

    dialogue = Dialogue()
    start = Node("start",
                 "DOG: You don't look like you're from here.",
                 entry=True)
    bowler = Node("bowler", "DOG: Oh really, Then you must know Mr. Bowler.")
    newton = Node(
        "newton",
        "DOG:Newton, eh? I heard there's trouble brewing down there.")
    liar = Node("liar",
                "DOG: You liar! There ain't no Mr. Bowler, I made him up!")
    starving = Node(
        "starving",
        "DOG: Don't worry about it. Say, do you have something to eat? I'm starving."
    )

    dialogue.add_nodes(start, bowler, newton, liar, starving)

    start_lie = ("I've lived here my whole life!", 'start', 'bowler')
    start_true = ("I came here from Newton.", 'start', 'newton')
    friend_lie = ("Mr. Bowler is a good friend of mine!", 'bowler', 'liar')
    friend_true = ("Who?", 'bowler', 'starving')
    newton_lie = (
        "Did I saw Newton? I meant to say I am from here in Springtown.",
        "newton", "bowler")
    newton_true = ("I haven't heard of any trouble.", "newton", "starving")

    dialogue.add_edges(start_lie, start_true, friend_lie, friend_true,
                       newton_lie, newton_true)

    game = Game(room)
    game.add_dialogue("dog",
                      dialogue,
                      preconditions={"location_has_item": dog})

    return game
Exemple #12
0
    def gamesetup(self):
        # Setting up the Event Handler.
        self.events = EventHandler()
        self.events.calls["keydown"] = self.key_down
        self.events.calls["keyup"] = self.key_up
        self.events.calls["mouseover"] = self.mouse_over
        self.events.eventsetup()

        # Setting up the Menu controller.
        self.menus = Menus(size=self.size)
        self.menus.menusetup()

        # Setting up the NPCs.
        self.npcs = NPCController()
        self.npcs.controllersetup()

        # Setting up the Player.
        self.player = Player()
        self.player.playersetup(Window.size)
        self.player.place(Window.center[0], Window.center[1])

        # Setting up the Dialogue controller.
        self.dialogue = Dialogue()
        self.dialogue.dialoguesetup()

        # Setting up the world.
        self.world = World()
        self.world.worldcenter = self.center
        self.world.setupworld((768 * 3, 608 * 3))

        # Adding everything to the Widget stack
        self.add_widget(self.events)
        self.world.add_npcs(self.npcs.npcgroup)
        self.world.add_widget(self.player)
        self.add_widget(self.world)
        self.add_widget(self.menus)
        self.add_widget(self.dialogue)

        # Centering Screen on the player
        self.center_screen(0.2)
Exemple #13
0
    def Run(self):
        while True:
            if self.s[self.i][2] != "!quit":
                if self.i in self.s:

                    spacer = "." * (5 - len(str(self.i)))
                    print(" " * (73 - len(str(self.i))) +
                          f"<{spacer}{self.i}>")

                    entry = Dialogue(self.s[self.i], self.p)

                    if len(self.s[self.i][0]) > 0:
                        self.p.add_items(self.s[self.i][0])
                        for a in self.s[self.i][0]:
                            print(
                                tw.fill(
                                    f"<The item \"{a}\" was added to your inventory.>"
                                ) + "\n")

                    if len(self.s[self.i][1]) > 0:
                        self.p.remove_items(self.s[self.i][1])
                        for r in self.s[self.i][1]:
                            print(
                                tw.fill(
                                    f"<The item \"{r}\" was removed from your inventory.>"
                                ) + "\n")

                    wait_duration = entry.Say()
                    self.i = entry.Page(wait_duration)

                else:
                    self.i = 0
            else:
                print(
                    f"\n <!quit command recieved>\n\n Exiting Game...\n\n{window_dstrike}"
                )
                quit()
Exemple #14
0
    ckpt = tf.train.get_checkpoint_state('./model')
    model.saver.restore(sess, ckpt.model_checkpoint_path)

    sys.stdout.write("> ")
    sys.stdout.flush()
    line = sys.stdin.readline()
    sentences = []

    while line:
        sentences.append(line.strip())
        response = reply(model, sess, sentences)
        print(response)
        sentences.append(response)
        sys.stdout.write("\n> ")
        sys.stdout.flush()
        line = sys.stdin.readline()


path = './data/conversation.txt'
dialogue = Dialogue(path)

hparams = tf.contrib.training.HParams(total_epochs=1000,
                                      num_units=128,
                                      learning_rate=0.0001,
                                      voc_size=dialogue.voc_size,
                                      embedding_size=100,
                                      total_batch=len(dialogue.dialogues))

model = Hred(hparams, 'infer')
chat(model)
Exemple #15
0
def test_repl(capsys, session):
    dlg = Dialogue(session)
    repl(dlg.fake_input)
    captured = capsys.readouterr()
    assert dlg.session.strip() == captured.out.strip()
Exemple #16
0
def test_uppercaser(capsys):
    dlg = Dialogue('> Xyz\nXYZ\n')
    uppercaser(dlg.fake_input)
    captured = capsys.readouterr()
    assert dlg.session == normalize(captured.out)
Exemple #17
0
def test_repl_quit_other_cases(capsys, session):
    dlg = Dialogue(session)
    repl(dlg.fake_input)
    captured = capsys.readouterr()
    assert dlg.session == captured.out
Exemple #18
0
import json
from dialogue import Dialogue_Adv, Dialogue, Dialogue_Options, Reaction, Response, Postrouting, Gate, Quest, Stats_Effect_Array, Stats_Effect

new_dialogue_adv = Dialogue_Adv()
new_dialogue_chunk = Dialogue()
new_dialogue_chunk.Speaker = "Kristin"
new_dialogue_chunk.text = "Hey, how's it going?"
new_dialogue_adv.Dialogue.append(new_dialogue_chunk)
new_dialogue_chunk.Speaker = "Kristin"
new_dialogue_chunk.text = "Virus times, hey?"
new_dialogue_adv.Dialogue.append(new_dialogue_chunk)
new_dialogue_chunk.Speaker = "Kristin"
new_dialogue_chunk.text = "F****d."
new_dialogue_adv.Dialogue.append(new_dialogue_chunk)
new_response = Response()
new_dialogue_adv.Response.append(new_response)

print(f"{new_dialogue_adv.dict()}")
Exemple #19
0
def test_repl(capsys, session):
    dlg = Dialogue(session)
    repl(dlg.fake_input)
    captured = capsys.readouterr()
    assert dlg.session == normalize(captured.out)
Exemple #20
0
def test_multiline_input(capsys, session, result):
    dlg = Dialogue(session)
    got = multiline_input('1|', '2|', input_fn=dlg.fake_input)
    assert result == got
    captured = capsys.readouterr()
    assert dlg.session == captured.out
Exemple #21
0
def test_uppercaser_multiple(capsys, session):
    dlg = Dialogue(session)
    uppercaser(dlg.fake_input)
    captured = capsys.readouterr()
    assert dlg.session == normalize(captured.out)
Exemple #22
0
def test_reverser(monkeypatch, capsys, session):
    dlg = Dialogue(session)
    reverser(dlg.fake_input)
    captured = capsys.readouterr()
    assert dlg.session == normalize(captured.out)
Exemple #23
0
 def update_dialogue(self):
     print('--------dialogue starting--------')
     d = Dialogue(self.ip, self.port, self.db_name)
     d.update()
     print('--------dialogue ok--------------')
Exemple #24
0
 def __init__(self, game, x, y, ID):
     super(Quest_area, self).__init__(game, x, y)
     self.key = pg.K_e
     self.quest = QUEST_DICT[ID]
     self.dialogue = Dialogue(game, self, self.quest)
Exemple #25
0
            "notre élément, et je suis le scientifique",
            "qui vous  a conçu ."
        ],
        [
            "Scientifique : Finissez le niveau et",
            "venez avec moi écrire une nouvelle",
            "page de l’humanité !"
        ],
        [
            "Cobaye : J’aimerais mieux en effet !"
        ],
        [
            "Scientifique : Allez courage !"
        ]
    ]
]


dial = []

for D in texte:
    dial.append(Dialogue())
    for R in D:
        dial[len(dial) - 1].addReplique()
        for L in R:
            dial[len(dial) - 1].addLigne(L)

def draw(i):
    if not dial[i].done:
        dial[i].draw()
Exemple #26
0
def test_multiline_input_quit(session):
    dlg = Dialogue(session)
    with raises(QuitRequest):
        multiline_input('>', quit_cmd='Q', input_fn=dlg.fake_input)
from dialogue import Dialogue

dialog = Dialogue()

request = input('input some thing:')
response = dialog.Dialogue_manager(request)
print(request)
Exemple #28
0
def test_multiline_input_unexpected_close_paren(session, error_str):
    dlg = Dialogue(session)
    with raises(errors.UnexpectedCloseParen) as excinfo:
        multiline_input(input_fn=dlg.fake_input)
    assert f"Unexpected close parenthesis: '{error_str}'." == str(
        excinfo.value)
Exemple #29
0
def test_repl_quit(capsys):
    dlg = Dialogue('> .q\n')
    repl(dlg.fake_input)
    captured = capsys.readouterr()
    assert dlg.session == normalize(captured.out)
Exemple #30
0
def twine_v2():
    with open(f"{args.filename}", "r") as f:
        dialogue_adv = []
        page = f.read()
        soup = BeautifulSoup(page, "html.parser")
        items = soup.findAll('tw-passagedata')
        for item in items:
            dialogue_map[item["name"]] = f"line_{item['pid']}"

        for item in items:
            new_dialogue_row = Dialogue_Adv()
            new_dialogue_chunk = Dialogue()
            for line in item.string.splitlines():
                # handle responses
                if line.startswith("[["):
                    row_map = line.lstrip("[").rstrip(" ").rstrip("]")
                    row_map = row_map.split("][")

                    new_response = Response()
                    new_response.response_text = row_map[0]
                    new_postrouting = Postrouting()
                    new_postrouting.target_dialogue = dialogue_map[row_map[0]]
                    new_response.post_routing.append(new_postrouting)

                    # TODO: handle post-response routing requirements
                    new_dialogue_row.Response.append(new_response)

                # set speaker
                elif line.startswith("@"):
                    line = line.lstrip("@")
                    new_dialogue_chunk.Speaker = line

                # handle effects
                elif line.startswith("##"):
                    parse_effects(line, new_dialogue_row.Effects)

                # handle twine user variables
                # TODO: rewrite this
                elif line.startswith("<<"):
                    parse_inline_set(line, new_dialogue_row.Effects.user_vars)

                # handle dialogue text chunks
                # TODO: continue rewriting this
                elif line.startswith("--") or line.startswith("++"):
                    if line.startswith("++"):
                        new_dialogue_chunk.append = True
                    new_dialogue_row.Dialogue_Text.append(new_dialogue_chunk)
                    new_dialogue_chunk = Dialogue()
                else:
                    new_dialogue_chunk.text += line
            # TODO: rewrite this
            new_dialogue_chunk.text = new_dialogue_chunk.text.rstrip("\n")
            new_dialogue_row.Dialogue_Text.append(new_dialogue_chunk)
            new_dialogue_row.Name = f"line_{item['pid']}"
            dialogue_adv.append(new_dialogue_row)

        f.close

        with open(f"{args.filename}.json", "w") as of:
            output_as_list_of_dicts = []
            for row in dialogue_adv:
                add_dict = row.dict()
                output_as_list_of_dicts.append(add_dict)

            of.write(json.dumps(output_as_list_of_dicts, indent=4))
            print(f"Saved to {args.filename}.json")