本文整理汇总了Python中tale.player.Player.get_output_paragraphs_raw方法的典型用法代码示例。如果您正苦于以下问题:Python Player.get_output_paragraphs_raw方法的具体用法?Python Player.get_output_paragraphs_raw怎么用?Python Player.get_output_paragraphs_raw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tale.player.Player
的用法示例。
在下文中一共展示了Player.get_output_paragraphs_raw方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_look_brief
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import get_output_paragraphs_raw [as 别名]
def test_look_brief(self):
player = Player("fritz", "m")
attic = Location("Attic", "A dark attic.")
cellar = Location("Cellar", "A gloomy cellar.")
julie = NPC("julie", "f")
julie.move(attic, silent=True)
player.move(attic, silent=True)
player.brief = 0 # default setting: always long descriptions
player.look()
self.assertEqual(["[Attic]\n", "A dark attic.\n", "Julie is here.\n"], player.get_output_paragraphs_raw())
player.look()
self.assertEqual(["[Attic]\n", "A dark attic.\n", "Julie is here.\n"], player.get_output_paragraphs_raw())
player.look(short=True) # override
self.assertEqual(["[Attic]\n", "Present: julie\n"], player.get_output_paragraphs_raw())
player.brief = 1 # short for known, long for new locations
player.look()
self.assertEqual(["[Attic]\n", "Present: julie\n"], player.get_output_paragraphs_raw())
player.move(cellar, silent=True)
player.look()
self.assertEqual(["[Cellar]\n", "A gloomy cellar.\n"], player.get_output_paragraphs_raw())
player.look()
self.assertEqual(["[Cellar]\n"], player.get_output_paragraphs_raw())
player.brief = 2 # short always
player.known_locations.clear()
player.look()
self.assertEqual(["[Cellar]\n"], player.get_output_paragraphs_raw())
player.move(attic, silent=True)
player.look()
self.assertEqual(["[Attic]\n", "Present: julie\n"], player.get_output_paragraphs_raw())
player.look(short=True) # override
self.assertEqual(["[Attic]\n", "Present: julie\n"], player.get_output_paragraphs_raw())
player.look(short=False) # override
self.assertEqual(["[Attic]\n", "A dark attic.\n", "Julie is here.\n"], player.get_output_paragraphs_raw())
示例2: test_wiretap
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import get_output_paragraphs_raw [as 别名]
def test_wiretap(self):
attic = Location("Attic", "A dark attic.")
player = Player("fritz", "m")
player.io = ConsoleIo(None)
player.io.supports_smartquotes = False
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.get_output_paragraphs_raw())
with self.assertRaises(SecurityViolation):
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")
output = player.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.get_output_paragraphs_raw())
示例3: test_tell_emptystring
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import get_output_paragraphs_raw [as 别名]
def test_tell_emptystring(self):
player = Player("fritz", "m")
player.tell("", end=False)
self.assertEqual([], player.get_output_paragraphs_raw())
player.tell("", end=True)
self.assertEqual(["\n"], player.get_output_paragraphs_raw())
player.tell("", end=True)
player.tell("", end=True)
self.assertEqual(["\n", "\n"], player.get_output_paragraphs_raw())
示例4: test_look
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import get_output_paragraphs_raw [as 别名]
def test_look(self):
player = Player("fritz", "m")
attic = Location("Attic", "A dark attic.")
player.look()
self.assertEqual(["[Limbo]\n", "The intermediate or transitional place or state. There's only nothingness.\nLiving beings end up here if they're not in a proper location yet.\n"], player.get_output_paragraphs_raw())
player.move(attic, silent=True)
player.look(short=True)
self.assertEqual(["[Attic]\n"], player.get_output_paragraphs_raw())
julie = NPC("julie", "f")
julie.move(attic, silent=True)
player.look(short=True)
self.assertEqual(["[Attic]\n", "Present: julie\n"], player.get_output_paragraphs_raw())
示例5: test_tell_formatted
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import get_output_paragraphs_raw [as 别名]
def test_tell_formatted(self):
player = Player("fritz", "m")
player.io = 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", player.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", player.get_output())
player.tell("word " * 30)
self.assertNotEqual(("word " * 30).strip(), player.get_output())
player.tell("word " * 30, format=False)
self.assertEqual(("word " * 30) + "\n", player.get_output()) # when format=False output should be unformatted
player.tell(" xyz \n 123", format=False)
self.assertEqual(" xyz \n 123\n", player.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.get_output_paragraphs_raw())
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", player.get_output())
示例6: test_tell_formats
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import get_output_paragraphs_raw [as 别名]
def test_tell_formats(self):
player = Player("fritz", "m")
player.io = 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.get_output_paragraphs_raw())
player.tell("a b c", format=True)
player.tell("d e f", format=True)
self.assertEqual("a b c d e f\n", player.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.get_output_paragraphs_raw())
player.tell("a b c", format=False)
player.tell("d e f", format=False)
self.assertEqual("a b c\nd e f\n", player.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.get_output_paragraphs_raw())
player.tell("a b c", format=True)
player.tell("d e f", format=False)
self.assertEqual("a b c\nd e f\n", player.get_output())
示例7: test_others
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import get_output_paragraphs_raw [as 别名]
def test_others(self):
attic = Location("Attic", "A dark attic.")
player = Player("merlin", "m")
player.title = "wizard Merlin"
julie = MsgTraceNPC("julie", "f", "human")
fritz = MsgTraceNPC("fritz", "m", "human")
julie.move(attic, silent=True)
fritz.move(attic, silent=True)
player.move(attic, silent=True)
player.tell_others("one", "two", "three")
self.assertEqual([], player.get_output_paragraphs_raw())
self.assertEqual(["one", "two", "three"], fritz.messages)
self.assertEqual(["one", "two", "three"], julie.messages)
fritz.clearmessages()
julie.clearmessages()
player.tell_others("{title} and {Title}")
self.assertEqual(["wizard Merlin and Wizard Merlin"], fritz.messages)
示例8: test_print_location
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import get_output_paragraphs_raw [as 别名]
def test_print_location(self):
p = Player("julie", "f")
key = Item("key")
bag = Container("bag")
room = Location("room")
bag.insert(key, p)
p.insert(bag, p)
room.insert(p, p)
with self.assertRaises(Exception):
util.print_object_location(p, None, None)
util.print_object_location(p, key, None)
self.assertEqual(["(It's not clear where key is).\n"], p.get_output_paragraphs_raw())
util.print_object_location(p, key, None, print_parentheses=False)
self.assertEqual(["It's not clear where key is.\n"], p.get_output_paragraphs_raw())
util.print_object_location(p, key, bag)
result = "".join(p.get_output_paragraphs_raw())
self.assertTrue("in bag" in result and "in your inventory" in result)
util.print_object_location(p, key, room)
self.assertTrue("in your current location" in "".join(p.get_output_paragraphs_raw()))
util.print_object_location(p, bag, p)
self.assertTrue("in your inventory" in "".join(p.get_output_paragraphs_raw()))
util.print_object_location(p, p, room)
self.assertTrue("in your current location" in "".join(p.get_output_paragraphs_raw()))
示例9: test_tell_chain
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import get_output_paragraphs_raw [as 别名]
def test_tell_chain(self):
player = Player("fritz", "m")
player.tell("hi").tell("there")
self.assertEqual(["hi\nthere\n"], player.get_output_paragraphs_raw())
示例10: test_tell
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import get_output_paragraphs_raw [as 别名]
def test_tell(self):
player = Player("fritz", "m")
player.tell(None)
self.assertEqual(["None\n"], player.get_output_paragraphs_raw())
player.tell("")
self.assertEqual([], player.get_output_paragraphs_raw())
player.tell("")
player.tell("")
self.assertEqual([], player.get_output_paragraphs_raw())
player.tell("")
player.tell("line1")
player.tell("line2")
player.tell("")
self.assertEqual(["line1\nline2\n"], player.get_output_paragraphs_raw())
player.tell("", format=False)
player.tell("line1", format=False)
player.tell("", format=False)
player.tell("line2", format=False)
player.tell("", format=False)
self.assertEqual(["\nline1\n\nline2\n\n"], player.get_output_paragraphs_raw())
player.tell("\n")
self.assertEqual(["\n"], player.get_output_paragraphs_raw())
player.tell("line1")
player.tell("line2")
player.tell("hello\nnewline")
player.tell("\n")
player.tell("ints", 42, 999)
self.assertEqual(["line1\nline2\nhello\nnewline\n", "ints\n42\n999\n"], player.get_output_paragraphs_raw())
self.assertEqual([], player.get_output_paragraphs_raw())
player.tell("para1", end=False)
player.tell("para2", end=True)
player.tell("para3")
player.tell("\n")
player.tell("para4", "\n", "para5")
self.assertEqual(["para1\npara2\n", "para3\n", "para4\n\npara5\n"], player.get_output_paragraphs_raw())
player.tell(" xyz \n 123", format=False)
self.assertEqual([" xyz \n 123\n"], player.get_output_paragraphs_raw())
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.get_output_paragraphs_raw())