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


Python Player.set_screen_sizes方法代码示例

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


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

示例1: test_wiretap

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import set_screen_sizes [as 别名]
 def test_wiretap(self):
     attic = Location("Attic", "A dark attic.")
     player = Player("fritz", "m")
     io = ConsoleIo(None)
     io.supports_smartquotes = False
     pc = PlayerConnection(player, io)
     player.set_screen_sizes(0, 100)
     julie = NPC("julie", "f")
     julie.move(attic)
     player.move(attic)
     julie.tell("message for julie")
     attic.tell("message for room")
     self.assertEqual(["message for room\n"], player.test_get_output_paragraphs())
     with self.assertRaises(ActionRefused):
         player.create_wiretap(julie)
     player.privileges = {"wizard"}
     player.create_wiretap(julie)
     player.create_wiretap(attic)
     julie.tell("message for julie")
     attic.tell("message for room")
     pubsub.sync()
     output = pc.get_output()
     self.assertTrue("[wiretapped from 'Attic': message for room]" in output)
     self.assertTrue("[wiretapped from 'julie': message for julie]" in output)
     self.assertTrue("[wiretapped from 'julie': message for room]" in output)
     self.assertTrue("message for room " in output)
     # test removing the wiretaps
     player.clear_wiretaps()
     import gc
     gc.collect()
     julie.tell("message for julie")
     attic.tell("message for room")
     self.assertEqual(["message for room\n"], player.test_get_output_paragraphs())
开发者ID:MitsuharuEishi,项目名称:Tale,代码行数:35,代码来源:test_player.py

示例2: test_tell_formatted

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import set_screen_sizes [as 别名]
 def test_tell_formatted(self):
     player = Player("fritz", "m")
     pc = PlayerConnection(player, ConsoleIo(None))
     player.set_screen_sizes(0, 100)
     player.tell("line1")
     player.tell("line2", "\n")
     player.tell("hello\nnewline")
     player.tell("\n")  # paragraph separator
     player.tell("ints", 42, 999)
     self.assertEqual("line1 line2 hello newline\nints 42 999\n", pc.get_output())
     player.tell("para1", end=False)
     player.tell("para2", end=True)
     player.tell("para3")
     player.tell("\n")
     player.tell("para4", "\n", "para5")
     self.assertEqual("para1 para2\npara3\npara4   para5\n", pc.get_output())
     player.tell("word " * 30)
     self.assertNotEqual(("word " * 30).strip(), pc.get_output())
     player.tell("word " * 30, format=False)
     self.assertEqual(("word " * 30) + "\n", pc.get_output())  # when format=False output should be unformatted
     player.tell("   xyz   \n  123", format=False)
     self.assertEqual("   xyz   \n  123\n", pc.get_output())
     player.tell("line1", end=True)
     player.tell("\n")
     player.tell("line2", end=True)
     player.tell("\n")
     player.tell("\n")
     self.assertEqual(["line1\n", "\n", "line2\n", "\n", "\n"], player.test_get_output_paragraphs())
     player.tell("line1", end=True)
     player.tell("\n")
     player.tell("line2", end=True)
     player.tell("\n")
     player.tell("\n")
     self.assertEqual("line1\n\nline2\n\n\n", pc.get_output())
开发者ID:MitsuharuEishi,项目名称:Tale,代码行数:36,代码来源:test_player.py

示例3: test_peek_output

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import set_screen_sizes [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

示例4: test_tell_sep

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import set_screen_sizes [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

示例5: test_peek_output

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import set_screen_sizes [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

示例6: test_tell_formats

# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import set_screen_sizes [as 别名]
 def test_tell_formats(self):
     player = Player("fritz", "m")
     pc = PlayerConnection(player, ConsoleIo(None))
     player.set_screen_sizes(0, 100)
     player.tell("a b c", format=True)
     player.tell("d e f", format=True)
     self.assertEqual(["a b c\nd e f\n"], player.test_get_output_paragraphs())
     player.tell("a b c", format=True)
     player.tell("d e f", format=True)
     self.assertEqual("a b c d e f\n", pc.get_output())
     player.tell("a b c", format=False)
     player.tell("d e f", format=False)
     self.assertEqual(["a b c\nd e f\n"], player.test_get_output_paragraphs())
     player.tell("a b c", format=False)
     player.tell("d e f", format=False)
     self.assertEqual("a b c\nd e f\n", pc.get_output())
     player.tell("a b c", format=True)
     player.tell("d e f", format=False)
     self.assertEqual(["a b c\n", "d e f\n"], player.test_get_output_paragraphs())
     player.tell("a b c", format=True)
     player.tell("d e f", format=False)
     self.assertEqual("a b c\nd e f\n", pc.get_output())
开发者ID:MitsuharuEishi,项目名称:Tale,代码行数:24,代码来源:test_player.py


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