当前位置: 首页>>代码示例>>Python>>正文


Python Player.tell方法代码示例

本文整理汇总了Python中tale.player.Player.tell方法的典型用法代码示例。如果您正苦于以下问题:Python Player.tell方法的具体用法?Python Player.tell怎么用?Python Player.tell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tale.player.Player的用法示例。


在下文中一共展示了Player.tell方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: welcome

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import tell [as 别名]
 def welcome(self, player: Player) -> str:
     """
     Welcome text when player enters a new game
     If you return a string, it is used as an input prompt before continuing (a pause).
     """
     player.tell("<bright>Hello, %s!</> Welcome to the land of `%s'.  May your visit here be... interesting."
                 % (player.title, self.config.name), end=True)
     player.tell("--", end=True)
     return ""
开发者ID:irmen,项目名称:Tale,代码行数:11,代码来源:story.py

示例2: test_peek_output

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import tell [as 别名]
 def test_peek_output(self):
     player = Player("fritz", "m")
     player.io = ConsoleIo(None)
     player.set_screen_sizes(0, 100)
     player.tell("line1")
     player.tell("line2", 42)
     self.assertEqual(["line1\nline2\n42\n"], player.peek_output_paragraphs_raw())
     self.assertEqual("line1 line2 42\n", player.get_output())
     self.assertEqual([], player.peek_output_paragraphs_raw())
开发者ID:jordanaycamara,项目名称:Tale,代码行数:11,代码来源:test_player.py

示例3: test_tell_sep

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import tell [as 别名]
 def test_tell_sep(self):
     player = Player("fritz", "m")
     pc = PlayerConnection(player, ConsoleIo(None))
     player.set_screen_sizes(0, 10)
     player.tell("apple", "bee", "zinc", "rose")
     self.assertEqual(["apple bee zinc rose\n"], player.test_get_output_paragraphs())
     pc.get_output()
     player.tell("apple", "bee", "zinc", "rose", format=False)
     self.assertEqual("apple\nbee\nzinc\nrose\n", pc.get_output())
开发者ID:MitsuharuEishi,项目名称:Tale,代码行数:11,代码来源:test_player.py

示例4: test_input

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import tell [as 别名]
 def test_input(self):
     player = Player("julie", "f")
     with WrappedConsoleIO(None) as io:
         pc = PlayerConnection(player, io)
         player.tell("first this text")
         player.store_input_line("      input text     \n")
         x = pc.input_direct("inputprompt")
         self.assertEqual("input text", x)
         self.assertEqual("  first this text\ninputprompt ", sys.stdout.getvalue())  # should have outputted the buffered text
开发者ID:MitsuharuEishi,项目名称:Tale,代码行数:11,代码来源:test_player.py

示例5: test_write_output

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import tell [as 别名]
 def test_write_output(self):
     player = Player("julie", "f")
     with WrappedConsoleIO(None) as io:
         pc = PlayerConnection(player, io)
         player.tell("hello 1", end=True)
         player.tell("hello 2", end=True)
         pc.write_output()
         self.assertEqual("  hello 2", pc.last_output_line)
         self.assertEqual("  hello 1\n  hello 2\n", sys.stdout.getvalue())
开发者ID:MitsuharuEishi,项目名称:Tale,代码行数:11,代码来源:test_player.py

示例6: test_peek_output

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import tell [as 别名]
 def test_peek_output(self):
     player = Player("fritz", "m")
     pc = PlayerConnection(player, ConsoleIo(None))
     player.set_screen_sizes(0, 100)
     player.tell("line1")
     player.tell("line2", 42)
     self.assertEqual(["line1\nline2 42\n"], player.test_peek_output_paragraphs())
     self.assertEqual("line1 line2 42\n", pc.get_output())
     self.assertEqual([], player.test_peek_output_paragraphs())
开发者ID:MitsuharuEishi,项目名称:Tale,代码行数:11,代码来源:test_player.py

示例7: test_write_output

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import tell [as 别名]
 def test_write_output(self):
     player = Player("julie", "f")
     player.io = ConsoleIo(None)
     old_stdout = sys.stdout
     sys.stdout = StringIO()
     try:
         player.tell("hello 1", end=True)
         player.tell("hello 2", end=True)
         player.write_output()
         self.assertEqual("  hello 1\n  hello 2\n", sys.stdout.getvalue())
     finally:
         sys.stdout = old_stdout
开发者ID:jordanaycamara,项目名称:Tale,代码行数:14,代码来源:test_player.py

示例8: test_input

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import tell [as 别名]
 def test_input(self):
     player = Player("julie", "f")
     player.io = ConsoleIo(None)
     old_stdout = sys.stdout
     sys.stdout = StringIO()
     try:
         player.tell("first this text")
         player.store_input_line("input text\n")
         x = player.input("inputprompt")
         self.assertEqual("input text", x)
         self.assertEqual("  first this text\ninputprompt", sys.stdout.getvalue())  # should have outputted the buffered text
     finally:
         sys.stdout = old_stdout
开发者ID:jordanaycamara,项目名称:Tale,代码行数:15,代码来源:test_player.py

示例9: welcome

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import tell [as 别名]
 def welcome(self, player: Player) -> str:
     player.tell("<bright>Welcome to `%s'.</>" % self.config.name, end=True)
     player.tell("This is a tiny embedded story to check out a running Tale environment.")
     player.tell("Try to communicate with your pet, and exit the house to win the game.")
     player.tell("\n")
     player.tell("\n")
     return ""
开发者ID:irmen,项目名称:Tale,代码行数:9,代码来源:story.py

示例10: test_tell_emptystring

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import tell [as 别名]
 def test_tell_emptystring(self):
     player = Player("fritz", "m")
     player.tell("", end=False)
     self.assertEqual([], player.test_get_output_paragraphs())
     player.tell("", end=True)
     self.assertEqual(["\n"], player.test_get_output_paragraphs())
     player.tell("", end=True)
     player.tell("", end=True)
     self.assertEqual(["\n", "\n"], player.test_get_output_paragraphs())
开发者ID:MitsuharuEishi,项目名称:Tale,代码行数:11,代码来源:test_player.py

示例11: welcome_savegame

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import tell [as 别名]
 def welcome_savegame(self, player: Player) -> str:
     """
     Welcome text when player enters the game after loading a saved game
     If you return a string, it is used as an input prompt before continuing (a pause).
     """
     player.tell("<bright>Welcome back to `%s'.</>" % self.config.name, end=True)
     player.tell("\n")
     player.tell_text_file(self.driver.resources["messages/welcome.txt"])
     player.tell("\n")
     return "<bright>Press enter to continue where you were before.</>"
开发者ID:irmen,项目名称:Tale,代码行数:12,代码来源:story.py

示例12: spawn_cvnum

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import tell [as 别名]
def spawn_cvnum(player: Player, parsed: ParseResult, ctx: util.Context) -> None:
    """Spawn an item or monster with the given circle-vnum (or both if the circle-vnum is the same)."""
    if len(parsed.args) != 1:
        raise ParseError("You have to give the item or monster's circle-vnum.")
    vnum = int(parsed.args[0])
    try:
        item = make_item(vnum)
    except KeyError:
        player.tell("There's no item with that circle-vnum.")
    else:
        player.tell("Spawned " + repr(item) + " (into your inventory)")
        item.move(player, actor=player)
    try:
        mob = make_mob(vnum)
    except KeyError:
        player.tell("There's no monster with that circle-vnum.")
    else:
        player.tell("Spawned " + repr(mob) + " (into your current location)")
        mob.move(player.location, actor=player)
开发者ID:irmen,项目名称:Tale,代码行数:21,代码来源:__init__.py

示例13: show_cvnum

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import tell [as 别名]
def show_cvnum(player: Player, parsed: ParseResult, ctx: util.Context) -> None:
    """Show the circle-vnum of a location (.) or an object/living,
    or when you provide a circle-vnum as arg, show the object(s) with that circle-vnum."""
    if not parsed.args:
        raise ParseError("From what should I show the circle-vnum?")
    name = parsed.args[0]
    obj = None  # type: Union[Location, Living, Item, Exit]
    if name == ".":
        obj = player.location
    elif parsed.who_info:
        obj = parsed.who_1
    else:
        try:
            vnum = int(parsed.args[0])
        except ValueError as x:
            raise ActionRefused(str(x))
        objects = []   # type: List[Union[Location, Living, Item, Exit]]
        try:
            objects.append(make_item(vnum))
        except KeyError:
            pass
        try:
            objects.append(make_location(vnum))
        except KeyError:
            pass
        try:
            objects.append(make_mob(vnum))
        except KeyError:
            pass
        player.tell("Objects with circle-vnum %d:" % vnum + " " + (lang.join(str(o) for o in objects) or "none"))
        return
    try:
        vnum = obj.circle_vnum
        player.tell("Circle-Vnum of %s = %d." % (obj, vnum))
    except AttributeError:
        player.tell(str(obj) + " has no circle-vnum.")
开发者ID:irmen,项目名称:Tale,代码行数:38,代码来源:__init__.py

示例14: do_demo

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import tell [as 别名]
def do_demo(player: Player, parsed: ParseResult, ctx: Context) -> None:
    """demo wizard command"""
    player.tell("DEMO WIZARD COMMAND")
开发者ID:irmen,项目名称:Tale,代码行数:5,代码来源:__init__.py

示例15: goodbye

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import tell [as 别名]
 def goodbye(self, player: Player) -> None:
     player.tell("Thanks for trying out Tale!")
开发者ID:irmen,项目名称:Tale,代码行数:4,代码来源:story.py


注:本文中的tale.player.Player.tell方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。