Exemple #1
0
    def __init__(self, rooms, default_room, creatures, use_void=True):
        # init properties
        self.rooms = {}

        # build map
        for r in rooms:
            room = Room(r['uid'], r['name'], r['description'])
            self.rooms[room.uid] = room

        # set up exits and items
        for r in rooms:
            room = self.rooms[r['uid']]

            # add exits
            for e in r['exits']:
                ex = self.rooms.get(e[1], None)
                if ex is not None:
                    room.add_exit(e[0], ex)

            # add items
            for i in r['items']:
                item = Item(i[0], i[2])
                room.add_object(item)

            for n in r['npc']:
                cname = n[0]
                npc = Creature(cname, creatures[cname], n[1])

        self.default_room = self.rooms.get(default_room)
        self.spawn_room = self.default_room

        if use_void and len(self.rooms.keys()) == 0:
            self.__build_void__()
Exemple #2
0
def test_dungeon_build():
    """method to build a dungeon for testing and dev."""
    dungeon_name = "Test Dungeon"
    room_one_date =["Entry Room", "The first room in the test dungeon"]
    room_one = Room(room_one_date)
    roomtwo_data = ["second Room", "The second room of the test dungeon"]
    room_two = Room(roomtwo_data)
    exit1 = Exit("n", room_one, room_two)
    exit2 = Exit("s", room_two, room_one)
    room_one.add_exit(exit1)
    room_two.add_exit(exit2)
    test_dungeon = Dungeon(dungeon_name, room_one)
    test_dungeon.add_room(room_two)
    item_one_stats = ["Apple", "A red Fuji Apple", .2]
    item_one_actions = {"eat": "consume-You eat the apple", "examine": "It's a\
         red apple. It looks really tasty.", "throw": "destroy-You hurl the \
             apple agaisnt the wall. It smashes agaisnt it with a splat."}
    item_one_date = ["Apple", "A red Fuji Apple", 0.2,item_one_actions]
    item_one = item(item_one_date)
    item_two_stats = ["Spoon", "a metal spoon", .01]
    item_two_actions = {"examine": "examine-The spoon is made of some form of lite metal, perhaps tin.", "throw": "remove-You hurl the \
             spoon agaisnt the wall. It clashes against the wall with a clatter."}
    item_two_data = ["Spoon", "a metal spoon", 0.01,item_two_actions]
    item_two = item(item_two_data)
    room_one.add_item(item_one)
    room_one.add_item(item_two)
    return test_dungeon
from thing import Thing
from room import Room
from console import Console

##
## "game" is a special global variable, an object of class Game that holds
## the actual game state.
##
game = Game()
nulspace = Room(
    'nulspace', pref_id=None
)  #"nulspace" is a room for objects that should be deleted. TODO: Automaticly delete items from nulspace every 10 heartbeats.
nulspace.game = game
nulspace.set_description(
    'void',
    'This is an empty void where dead and destroyed things go. Good luck getting out!'
)
nulspace.add_names('void')
nulspace.add_exit('north', 'nulspace')
nulspace.add_exit('south', 'nulspace')
nulspace.add_exit('east', 'nulspace')
nulspace.add_exit('west', 'nulspace')
game.events.schedule(game.time + 5, game.clear_nulspace)
game.nulspace = nulspace

Thing.game = game

start_room_mod = importlib.import_module('domains.school.school.great_hall')
start_room = start_room_mod.load()
game.start_loop()
            return 'Did you mean to write something on the paper?'
        cons.write(
            'You write "%s" on the paper and feel a magical shift occur.' %
            self.written_on)
        self.emit(
            "&nD%s writes something on the paper and vanishes before your eyes!"
            % cons.user.id, cons.user)
        del self.location.exits['west']
        try:
            self.location.exits['west'] = self.written_on
        except KeyError:
            cons.write(
                'The text on the paper morphs back into the word "woods".')
            self.written_on = 'woods'
            self.location.exits['west'] = Thing.ID_dict[self.written_on]
        self.long_desc = 'This magical paper says "%s" on it.' % self.written_on
        return True


waterfall = Room('waterfall')
waterfall.set_description(
    'beautiful waterfall base',
    'This is a beautiful waterfall base. From here you can stand and look at the rushing waterfall. This place makes you feel peaceful inside and happy. You will always remember this place.'
)
waterfall.add_adjectives('waterfall', 'beautiful', 'special')
waterfall.add_names('place', 'base')
waterfall.add_exit('west', 'woods')

paper = PlaceChooser('magic paper', 'trunk of a tree')
paper.move_to(waterfall)
famlyroom = Room("family room")
dungeon = Room("dungeon")
aviary = Room("aviary")

dock.set_description("dock", "A long wooden dock covered in moss.")
water1.set_description("ocean", "A blue ocean.")
water2.set_description("ocean", "Ablue ocean.")
water3.set_description("water", "A blue ocean.")
hall.set_description("big hall", "A big long hall.")
entryway.set_description("wonderfull entryway",
                         "This entryway is good. You don't want to leave it.")
stairs.set_description(
    "pair of steep stair",
    "Theese stairs are great! They are made of fancey oak.")
bedroom.set_description(
    "normal bedroom",
    "This is an ordinary bedroom. It has white walls and a bed.")
famlyroom.set_description("nice family room",
                          "This is a nice family room with a couch.")
dungeon.set_description(
    "dungeon",
    "This is a scary dungeon like the ones from movies. You are scared.")
aviary.set_description(
    "aviary",
    "This is a beutiful and large aviary. You see many birds and poles for them to perch on."
)

dock.add_exit('east', water1.id)
dock.add_exit('west', water2.id)
dock.add_exit('north', water3.id)
Exemple #6
0
from domains.wizardry.deep_pocket import DeepPocketSignUpWizard
from domains.wizardry.gems import *

central_fountain = Room('square', safe=True)
government_entrences = Room('cobbled street', safe=True)
south_shopping_one = Room('shopping', safe=True)
restraunt_one = Room('gathernia', safe=True)

wizardry_transporter = TransportRoom('learn wizardry', central_fountain)

central_fountain.set_description('central square', 'This is a central square at the intersection of two major roads. You see stores to the south, government buildings to the north, houses to the east, and a sign for a wizardry school to the west.')
government_entrences.set_description('cobbled street', 'This is a cobbled street with many government buildings on the side. There are many doors to a variety of buildings. To the south you see the central fountain, while to the north the street continues.')
south_shopping_one.set_description('street covered with shops', 'This is a street covered with shops on two stories--ground floor and the floor above. To get to the higher shops you must fly, which is made possible by the sapphires you see mounted in the roadway. A restaurant called "Gathernia" catches your eye.') #TODO: Auto generate more shops (like books on the bookshelf)
restraunt_one.set_description('busy restaurant named Gathernia', 'This is a busy restaurant named "Gathernia". Here you see many people eating and talking.')

central_fountain.add_exit('north', government_entrences.id)
central_fountain.add_exit('south', south_shopping_one.id)
government_entrences.add_exit('south', central_fountain.id)
south_shopping_one.add_exit('north', central_fountain.id)
restraunt_one.add_exit('out', south_shopping_one.id)

south_shopping_one.add_enter('gathernia', restraunt_one.id)

central_fountain.add_adjectives('busy', 'central')
government_entrences.add_adjectives('dark', 'cobbled')
south_shopping_one.add_adjectives('lively', 'bright', 'busy')

government_entrences.add_names('street')

fountain = Scenery('fountain', 'crystal clear fountain', 'This is studded with gems in the center. All of the water coming out of the fountain is crystal clear.')
fountain.add_adjectives('gem-studded', 'crystal','clear')
Exemple #7
0
def create_world():
    a = Room("You are in room 1")
    b = Room("You are in room 2")
    c = Room("You are in room 3")
    d = Room("You are in room 4")
    e = Room("You are in room 5")
    f = Room("You are in room 6")
    g = Room("You are in room 7")
    a.add_exit(b, "east")
    b.add_exit(c, "east")
    c.add_exit(d, "east")
    d.add_exit(e, "south")
    e.add_exit(f, "west")
    f.add_exit(g, "west")
    g.add_exit(b, "north")
    player.location = a
    mob = Mob("Goblin")
    b.add_monster(mob)