本文整理汇总了Python中game.Room类的典型用法代码示例。如果您正苦于以下问题:Python Room类的具体用法?Python Room怎么用?Python Room使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Room类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_room_paths
def test_room_paths():
center = Room("Center", "Test room in the center.")
north = Room("North", "Test room in the north.")
south = Room("South", "Test room in the south.")
center.add_paths({'north': north, 'south': south})
assert_equal(center.go('north'), north)
assert_equal(center.go('south'), south)
示例2: test_add_item
def test_add_item(self):
rock = Item("rock")
room = Room()
before = len(room.items)
self.assertNotIn(rock, room.items)
room.add_item(rock)
self.assertEqual(len(room.items), before + 1)
self.assertIn(rock, room.items)
示例3: test_map
def test_map():
start = Room("Start", "You can go west and down a hole.")
west = Room("Trees", "There are trees here, you can go east")
down = Room("Dungeon", "It`s dark down here, you can go up.")
start. add_paths({'west' : west, 'down' : down})
west.add_paths({'east' : start})
down.add_paths({'up' : start})
assert_equal(start. go('west'), west)
assert_equal(start. go('west'). go('east'), start)
assert_equal(start. go('down'). go('up'), start)
示例4: test_map
def test_map():
start = Room("Start", "You can go west and down a hole.")
west = Room("Trees", "There are trees here, you can go east.")
down = Room("Dungeon", "It's dark down here, you can go up.")
start.add_paths({"west": west, "down": down})
west.add_paths({"east": start})
down.add_paths({"up": start})
assert_equal(start.go("west"), west)
assert_equal(start.go("west").go("east"), start)
assert_equal(start.go("down").go("up"), start)
示例5: int
import datetime
import logic
from game import Room
from random import randint
from sys import exit
now = datetime.datetime.now()
future_year = int(now.year) + 63
intro = Room("being stubborn. Just do what the game asks.",
"""The year is %i. The secrets of interstellar transport was discovered 25 years
ago. Mega-corporations reveled at the chance to dip their vile and slimy
hands into the stakes for the moon, then mars, then entire solar systems; Space
was colonized in under 10 years. The human civilization flourished while others
were crushed under the ruthless conviction of manifest destiny. Technological
advancements expanded like never before, and the Earthling Human of over half
a century ago was no more...""" % future_year, "Press Enter to Continue...")
character = Room("not reading the instructions are you? Just do what the game asks",
"""You are Klae LosForeve: Orphan. Hacker. Derelict.
A 28 year old genius who spent most his life dedicated to one thing - an oddity
in this world of up-to-the-millisecond updates of information and communication.
However, your skills are second to none when it comes to anything electronic.
Naturally, this has allowed you to build a respectable corporation known for
the sales of star-vessel necessities and arms, despite your growing agoraphobia
and despite the fact that some of these sales sometimes blurred the line between
right and wrong...""", "Press Enter to Continue...")
articles = randint(550, 780) # Why? Pure randomness, that's why!
apartment = Room("in your Apartment",
"""You emerge from your bedroom in the spacious living room of your \'sky-rise\'
示例6: test_show_no_items
def test_show_no_items(self):
room = Room()
room.items = []
self.assertEqual(room.show_items(), "")
示例7: test_show_items
def test_show_items(self):
room = Room()
room.items = [Item("rock"), Item("egg"), Item("gun")]
self.assertIn("rock", room.show_items())
self.assertIn("egg", room.show_items())
self.assertIn("gun", room.show_items())