コード例 #1
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()
コード例 #2
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()
コード例 #3
0
ファイル: console.py プロジェクト: freneticmonkey/Epsilon
	def __init__(self, title, lines=10, width=750, max_buffer=400, **kwargs):

		Dialogue.__init__(self, title, **kwargs)

		self._line_num = lines
		self._width = width
		self._lines = []

		for i in range(0, self._line_num):
			self._lines.append(Label('',w=self._width))

		# As there isn't a virtical slider currently implemented in simplui
		# I'm just going to use a horizontal one to save time here.
		self._lines.append(Slider(w=self._width,value=1.0,action=self._on_scroll))
		self._lines.append(TextInput(text='>>>',w=self._width))

		#children = [Label('',w=390) for i in range(0, self._lines)]+[TextInput(w=390),]
		
		content = FoldingBox('Output',
							 collapsed=True,
							 content=VLayout(autosizex=True,
						  		  		     hpadding=0,
						  				     children=self._lines)
							)

		self._set_content(content)

		self._max_buffer = max_buffer
		self._console_text = []

		self._is_scrolling = False
コード例 #4
0
	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]
コード例 #5
0
 def talk(self, name = ''):
     stopLoop = False
     while not stopLoop:
         if name == '':
             print('Who would you like to talk to?')
             self.getLoc().displayInhabs()
             name = input().lower()
         target = self.getLoc().getInhab(name)
         if target != "N/A": stopLoop = True
         else: name = ''
     Dialogue.converse(self, target)
コード例 #6
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
コード例 #7
0
ファイル: repl_test.py プロジェクト: pliba/kaminpy
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
コード例 #8
0
    def __init__(self,
                 transcripts_paths,
                 survey_paths,
                 stats_path,
                 price_tracker_model,
                 liwc_path,
                 max_examples=None):
        transcripts = self._read_transcripts(transcripts_paths, max_examples)
        self.dataset = utils.filter_rejected_chats(transcripts)

        dialogue_scores = self._read_surveys(survey_paths)

        self.price_tracker = PriceTracker(price_tracker_model)

        self.liwc = LIWC.from_pkl(liwc_path)

        # group chats depending on whether the seller or the buyer wins
        #self.buyer_wins, self.seller_wins = self.group_outcomes_and_roles()

        self.stats_path = stats_path
        if not os.path.exists(self.stats_path):
            os.makedirs(self.stats_path)

        self.examples = [
            Dialogue.from_dict(raw, dialogue_scores.get(raw['uuid'], {}),
                               self.price_tracker) for raw in self.dataset
        ]
コード例 #9
0
class Quest_area(Interactif):
    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)

    def interaction(self, player):
        self.dialogue.linkwith(player)
        self.dialogue.run(self.game.screen.copy())

    def accept(self, player):
        if self.quest and not self.quest in player.quest_list:
            player.quest_list.append(self.quest)
        elif self.quest and self.quest.is_complete(player):
            self.quest.congrats(player)
            self.quest = None
コード例 #10
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)
コード例 #11
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))
コード例 #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)
コード例 #13
0
ファイル: repl_test.py プロジェクト: pliba/kaminpy
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
コード例 #14
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()
コード例 #15
0
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)
コード例 #16
0
ファイル: main.py プロジェクト: Exodus111/Projects
    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)
コード例 #17
0
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
コード例 #18
0
ファイル: script.py プロジェクト: AMelchior/BokuNoKen
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)
コード例 #19
0
ファイル: main.py プロジェクト: Exodus111/Projects
class Game(Widget):
    temp_text = StringProperty("")
    temp_textlist = ListProperty(["", "", "", ""])


    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)

    def center_screen(self, delay=0.1):
        Clock.schedule_once(self.world.center_screen, delay)

    def update(self, dt):
        self.menus.update(dt)
        self.npcs.update(dt)
        self.player.update(dt)

    def mouse_over(self, pos):
        pass

    def key_down(self, key, mod):
        if key[1] in ("w", "a", "s", "d", "up", "down", "left", "right"):
            self.player.keydown(key[1])
        elif key[1] == "spacebar":
            print(self.player.pos, self.player.center)

    def key_up(self, key):
        if key[1] in ("w", "a", "s", "d", "up", "down", "left", "right"):
            self.player.keyup(key[1])

    def begin_conv(self, npc):
        self.dialogue.npc = npc
        self.dialogue.start_conv()
        self.menus.menu_on = not self.menus.menu_on

    def change_top_text(self, txt):
        """
          Top text area contains only one piece of text at a time.
        """
        self.temp_text = txt
        self.menus.fade_out_top = True

    def change_bottom_text(self, txtlist):
        """
         Bottom Text contains 4 question areas.
        """
        for num, _ in enumerate(self.menus.bottomtext):
            try:
                self.menus.bottomtext[num] = txtlist[num]
            except IndexError:
                self.menus.bottomtext[num] = ""
        self.menus.fade_out_bottom = True
コード例 #20
0
ファイル: treedit.py プロジェクト: izzycecil/72
parser.add_argument('treename', type=str, help="Name of tree to edit or create")
parser.add_argument('-c', action='store_true', help="Create a new tree")

args = parser.parse_args()

if args.c == True:
    if os.path.exists(args.treename):
        print "Err: dialog tree to be created already exists!"
        sys.exit(1)
    else:
        initresponse = raw_input("initial response > ")
        root = Dialogue(initresponse)
else:
    try:
        with open(args.treename, 'rb') as f:
            root = Dialogue.load(f)
    except IOError:
        print "Err: dialog tree could not be loaded. Perhaps create it?"
        sys.exit(2)

# Root must now exist, whether we just created it or loaded it in
# We now start up the main loop
print "TREEDIT - '?' for help, 'x' to exit"

# set up the history thing
history = []
current = root
filename = args.treename

### MAIN LOOP
コード例 #21
0
def test_repl(capsys, session):
    dlg = Dialogue(session)
    repl(dlg.fake_input)
    captured = capsys.readouterr()
    assert dlg.session.strip() == captured.out.strip()
コード例 #22
0
ファイル: chat.py プロジェクト: JaytenJeon/tf-chatbot
    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)
コード例 #23
0
ファイル: repl_test.py プロジェクト: pliba/kaminpy
def test_repl_quit_other_cases(capsys, session):
    dlg = Dialogue(session)
    repl(dlg.fake_input)
    captured = capsys.readouterr()
    assert dlg.session == captured.out
コード例 #24
0
from dialogue import Dialogue
d = Dialogue()
d.character = 'garret_1'
d.dialogue_name = 'garret_1'
d.dialogue = {'camps': 'Garret glances over his shoulder at you, "you seem a bit stressed you should smoke a bowl.\n\n',
 'campschoices': [['you look at your watch and say "no thanks I have to get going" you walk out into the hall',
                   'exit'],
                  ['\nlaughing you say "sure why not its not like I have a job interview any time soon." an hour or two later you lazily wonder out of garrets dorm room.',
                   'exit \n\n']],
 'heya': '"A little bit of coding actually," Garret turns back and starts pondering one screen intently.\n\n',
 'heyachoices': [['You notice the poster that seems a bit out of place and ask "hey whats up with this poster garret"?',
                  'poster'],
                 ["\n'Oh what you working' on?", 'oh\n\n']],
 'interest': '"I will," he says excitedly "if you want you can help me with some of the rooms and dialog?!"\n\n',
 'interestchoices': [['"Uh no thanks I am really busy right now."', 'no'],
                     ['\n"sure why not could be fun."', 'sure\n\n']],
 'no': 'Garret shrugs resignedly, "ok ill send you a copy when its done."\n\n',
 'nochoices': [['lamely you change the subject. "Hey whats that odd poster over there?"',
                'poster\n\n\n\n\n\n\n\n\n\n\n\n']],
 'oh': '"I am creating a old school text based adventure game" he replies jovially. "I just finished creating a combat system and the "shifty little man" monster keeps kicking my ass he\'s just too shifty."\n\n',
 'ohchoices': [['with interest you peer over his shoulder at the screen but all you see is a open python shell and some initeligible text."Oh cool you will have to send it to me when you finish"',
                'interest\n\n']],
 'poster': 'Garret glaces at the poster you are pointing at, "that one? oh its about all the government abductions."\n\n',
 'posterchoices': [['"Uh....the what now?" you disbelievingly as you look at him out of the corner of your eye.',
                    'what\n\n']],
 'start': 'Garret swivels around in his chair, and and through a fit of suspect coughing, says,\n        "WORD...stack (character name), whats happenin."\n\n',
 'startchoices': [['heya Garret plotting the downfall of civilization again or programing',
                   'heya'],
                  ['\nyou start coughing uncontrollably and hurriedly back out of the room.',
                   'exit\n\n']],
コード例 #25
0
ファイル: repl_test.py プロジェクト: pliba/kaminpy
def test_multiline_input_quit(session):
    dlg = Dialogue(session)
    with raises(QuitRequest):
        multiline_input('>', quit_cmd='Q', input_fn=dlg.fake_input)
コード例 #26
0
ファイル: repl_test.py プロジェクト: pliba/kaminpy
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)
コード例 #27
0
ファイル: update_data.py プロジェクト: zhengxin2016/corpus
 def update_dialogue(self):
     print('--------dialogue starting--------')
     d = Dialogue(self.ip, self.port, self.db_name)
     d.update()
     print('--------dialogue ok--------------')
コード例 #28
0
ファイル: repl_test.py プロジェクト: pliba/kaminpy
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
コード例 #29
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)
コード例 #30
0
ファイル: jsontest.py プロジェクト: chhopsky/twine2plural
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()}")
コード例 #31
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()
コード例 #32
0
ファイル: pluralimport.py プロジェクト: chhopsky/twine2plural
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")
コード例 #33
0
def test_repl(capsys, session):
    dlg = Dialogue(session)
    repl(dlg.fake_input)
    captured = capsys.readouterr()
    assert dlg.session == normalize(captured.out)
コード例 #34
0
from dialogue import Dialogue

dialog = Dialogue()

request = input('input some thing:')
response = dialog.Dialogue_manager(request)
print(request)
コード例 #35
0
from dialogue import Dialogue
d = Dialogue()
d.character = 'g_man'
d.dialogue_name = 'g_man'
d.dialogue = {
 'start': 'you approach the official look in man sitting at the table covered in documentation and forms\n\n',
 'startchoices': [
                  ["""
                  you look at the documents on the table they appear to be for a government agency called 
                  NDEP national department of enforcement and protection you inquire as to its purpose'
                  """,'inquire'],
                  ['you glance at the table of documents along with the apparent G man scoff and walk away','exit'],
                 ],
 'inquire': 'Well "Iam glad you asked," the G man exclaimed with a ever broadening smile, "you see, we at the NDEP are ever vigilant in the defense of our great country!"',
 'inquirechoices': [
                    ['what exactly do you defend us from you say sarcastically...aliens?','threat'],
                   ],
 'threat': """
            Unphased,  the g man spreads his arms out, in a wide gesture, we protect and defend against any and every thing, 
            terrorists,spies, gangs. Basically any thing that proves it self a threat\n\n'
           """,
 'threatchoices': [
                   ['asking dubiously "aaaannddd...what exactly are you doing here"','recruit'],
                  ],
 'recruit': """
            Good question! I am here hoping to recruit some candidates to become NDEP operators. 
            Let me tell you its one hell of an opportunity. The pay is phenomenal and benefits are unsurpassed.
            The best part is you get government housing, transport and, gas vouchers!'
            """,
 'recruitchoices': [
コード例 #36
0
def test_repl_quit(capsys):
    dlg = Dialogue('> .q\n')
    repl(dlg.fake_input)
    captured = capsys.readouterr()
    assert dlg.session == normalize(captured.out)
コード例 #37
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()