コード例 #1
0
def get_game_variables(constants, kolors, current_roster, current_mm):
    fighter_component = Fighter(hp=30, protection=2, power=5)
    inventory_component = Inventory(26)
    player = Entity(0,
                    0,
                    '@',
                    tcod.black,
                    'Player',
                    blocks=True,
                    render_order=RenderOrder.ACTOR,
                    fighter=fighter_component,
                    inventory=inventory_component)
    entities = [player]

    map_type = 'Dungeon'  #Choices: Dungeon, Cave, World

    if map_type == 'Dungeon':
        indoors = True
        game_map = Dungeon(constants['map_width'], constants['map_height'])
        game_map.make_map(constants['max_rooms'], constants['room_min_size'],
                          constants['room_max_size'], constants['map_width'],
                          constants['map_height'], player, entities,
                          constants['max_monsters_per_room'],
                          constants['max_items_per_room'], kolors,
                          current_roster, current_mm)
    elif map_type == 'Cave':
        indoors = True
        game_map = Cave(constants['map_width'], constants['map_height'])
        game_map.make_cave(constants['map_width'], constants['map_height'],
                           player, entities,
                           constants['max_monsters_per_cave'],
                           constants['max_items_per_cave'], kolors,
                           current_roster, current_mm)
    elif map_type == 'World':
        indoors = False
        game_map = World(constants['map_width'], constants['map_height'])
        game_map.make_world(constants['map_width'], constants['map_height'],
                            player, entities,
                            constants['max_monsters_per_spawn'], kolors,
                            current_roster, current_mm)

    #Initialize the message log
    message_log = MessageLog(constants['message_x'],
                             constants['message_width'],
                             constants['message_height'])

    game_state = GameStates.PLAYERS_TURN

    return player, entities, game_map, indoors, message_log, game_state
コード例 #2
0
from dungeons import Dungeon

dungeon = Dungeon({'style': 'dungeon', 'purpose': 'stronghold'})

dungeon.base_dungeon()

dungeon.populate_dungeon('immortal guardians', 3, 'haunted')
dungeon.populate_dungeon('hideout', 2, 'bandits')

dungeon.write_module()

dungeon.save_dungeon_image()