Remove some whitespace in a file.
This commit is contained in:
parent
760865f26f
commit
5d22bbe39f
1 changed files with 18 additions and 19 deletions
|
|
@ -95,7 +95,6 @@ from evennia.utils import utils
|
||||||
# Add the necessary imports for your instructions here.
|
# Add the necessary imports for your instructions here.
|
||||||
from evennia import create_object
|
from evennia import create_object
|
||||||
from typeclasses import rooms, exits
|
from typeclasses import rooms, exits
|
||||||
from evennia.utils import utils
|
|
||||||
from random import randint
|
from random import randint
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
|
@ -131,13 +130,13 @@ def example1_build_mountains(x, y, **kwargs):
|
||||||
|
|
||||||
# Create the room.
|
# Create the room.
|
||||||
room = create_object(rooms.Room, key="mountains" + str(x) + str(y))
|
room = create_object(rooms.Room, key="mountains" + str(x) + str(y))
|
||||||
|
|
||||||
# Generate a description by randomly selecting an entry from a list.
|
# Generate a description by randomly selecting an entry from a list.
|
||||||
room_desc = ["Mountains as far as the eye can see",
|
room_desc = ["Mountains as far as the eye can see",
|
||||||
"Your path is surrounded by sheer cliffs",
|
"Your path is surrounded by sheer cliffs",
|
||||||
"Haven't you seen that rock before?"]
|
"Haven't you seen that rock before?"]
|
||||||
room.db.desc = random.choice(room_desc)
|
room.db.desc = random.choice(room_desc)
|
||||||
|
|
||||||
# Create a random number of objects to populate the room.
|
# Create a random number of objects to populate the room.
|
||||||
for i in xrange(randint(0, 3)):
|
for i in xrange(randint(0, 3)):
|
||||||
rock = create_object(key="Rock", location=room)
|
rock = create_object(key="Rock", location=room)
|
||||||
|
|
@ -172,12 +171,12 @@ def example1_build_temple(x, y, **kwargs):
|
||||||
|
|
||||||
# This is generally mandatory.
|
# This is generally mandatory.
|
||||||
return room
|
return room
|
||||||
|
|
||||||
# Include your trigger characters and build functions in a legend dict.
|
# Include your trigger characters and build functions in a legend dict.
|
||||||
EXAMPLE1_LEGEND = {("♣", "♠"): example1_build_forest,
|
EXAMPLE1_LEGEND = {("♣", "♠"): example1_build_forest,
|
||||||
("∩", "n"): example1_build_mountains,
|
("∩", "n"): example1_build_mountains,
|
||||||
("▲"): example1_build_temple}
|
("▲"): example1_build_temple}
|
||||||
|
|
||||||
# ---------- EXAMPLE 2 ---------- #
|
# ---------- EXAMPLE 2 ---------- #
|
||||||
# @mapbuilder/two evennia.contrib.mapbuilder.EXAMPLE2_MAP EXAMPLE2_LEGEND
|
# @mapbuilder/two evennia.contrib.mapbuilder.EXAMPLE2_MAP EXAMPLE2_LEGEND
|
||||||
|
|
||||||
|
|
@ -322,7 +321,7 @@ class CmdMapBuilder(COMMAND_DEFAULT_CLASS):
|
||||||
|
|
||||||
def func(self):
|
def func(self):
|
||||||
"""Starts the processor."""
|
"""Starts the processor."""
|
||||||
|
|
||||||
caller = self.caller
|
caller = self.caller
|
||||||
args = self.args.split()
|
args = self.args.split()
|
||||||
|
|
||||||
|
|
@ -337,11 +336,11 @@ class CmdMapBuilder(COMMAND_DEFAULT_CLASS):
|
||||||
legend = None
|
legend = None
|
||||||
|
|
||||||
# OBTAIN MAP FROM MODULE
|
# OBTAIN MAP FROM MODULE
|
||||||
|
|
||||||
# Breaks down path_to_map into [PATH, VARIABLE]
|
# Breaks down path_to_map into [PATH, VARIABLE]
|
||||||
path_to_map = args[0]
|
path_to_map = args[0]
|
||||||
path_to_map = path_to_map.rsplit('.', 1)
|
path_to_map = path_to_map.rsplit('.', 1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Retrieves map variable from module or raises error.
|
# Retrieves map variable from module or raises error.
|
||||||
game_map = utils.variable_from_module(path_to_map[0],
|
game_map = utils.variable_from_module(path_to_map[0],
|
||||||
|
|
@ -351,22 +350,22 @@ class CmdMapBuilder(COMMAND_DEFAULT_CLASS):
|
||||||
"Path to map variable failed.\n"
|
"Path to map variable failed.\n"
|
||||||
"Usage: @mapbuilder <path.to.module."
|
"Usage: @mapbuilder <path.to.module."
|
||||||
"VARNAME> <path.to.module.MAP_LEGEND>")
|
"VARNAME> <path.to.module.MAP_LEGEND>")
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
# Or relays error message if fails.
|
# Or relays error message if fails.
|
||||||
caller.msg(exc)
|
caller.msg(exc)
|
||||||
return
|
return
|
||||||
|
|
||||||
# OBTAIN MAP_LEGEND FROM MODULE
|
# OBTAIN MAP_LEGEND FROM MODULE
|
||||||
|
|
||||||
# Breaks down path_to_legend into [PATH, VARIABLE]
|
# Breaks down path_to_legend into [PATH, VARIABLE]
|
||||||
path_to_legend = args[1]
|
path_to_legend = args[1]
|
||||||
path_to_legend = path_to_legend.rsplit('.', 1)
|
path_to_legend = path_to_legend.rsplit('.', 1)
|
||||||
|
|
||||||
# If no path given default to path_to_map's path
|
# If no path given default to path_to_map's path
|
||||||
if len(path_to_legend) == 1:
|
if len(path_to_legend) == 1:
|
||||||
path_to_legend.insert(0, path_to_map[0])
|
path_to_legend.insert(0, path_to_map[0])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Retrieves legend variable from module or raises error if fails.
|
# Retrieves legend variable from module or raises error if fails.
|
||||||
legend = utils.variable_from_module(path_to_legend[0],
|
legend = utils.variable_from_module(path_to_legend[0],
|
||||||
|
|
@ -376,7 +375,7 @@ class CmdMapBuilder(COMMAND_DEFAULT_CLASS):
|
||||||
"Path to legend variable failed.\n"
|
"Path to legend variable failed.\n"
|
||||||
"Usage: @mapbuilder <path.to.module."
|
"Usage: @mapbuilder <path.to.module."
|
||||||
"VARNAME> <path.to.module.MAP_LEGEND>")
|
"VARNAME> <path.to.module.MAP_LEGEND>")
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
# Or relays error message if fails.
|
# Or relays error message if fails.
|
||||||
caller.msg(exc)
|
caller.msg(exc)
|
||||||
|
|
@ -396,7 +395,7 @@ class CmdMapBuilder(COMMAND_DEFAULT_CLASS):
|
||||||
# Pass map and legend to the build function.
|
# Pass map and legend to the build function.
|
||||||
build_map(caller, game_map, legend, iterations, build_exits)
|
build_map(caller, game_map, legend, iterations, build_exits)
|
||||||
|
|
||||||
|
|
||||||
def build_map(caller, game_map, legend, iterations=1, build_exits=True):
|
def build_map(caller, game_map, legend, iterations=1, build_exits=True):
|
||||||
"""
|
"""
|
||||||
Receives the fetched map and legend vars provided by the player. The map
|
Receives the fetched map and legend vars provided by the player. The map
|
||||||
|
|
@ -405,18 +404,18 @@ def build_map(caller, game_map, legend, iterations=1, build_exits=True):
|
||||||
finding a match. The map is iterated over according to the `iterations`
|
finding a match. The map is iterated over according to the `iterations`
|
||||||
value and exits are optionally generated between adjacent rooms according
|
value and exits are optionally generated between adjacent rooms according
|
||||||
to the `build_exits` value.
|
to the `build_exits` value.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Split map string to list of rows and create reference list.
|
# Split map string to list of rows and create reference list.
|
||||||
caller.msg("Creating Map...")
|
caller.msg("Creating Map...")
|
||||||
caller.msg(game_map)
|
caller.msg(game_map)
|
||||||
game_map = _map_to_list(game_map)
|
game_map = _map_to_list(game_map)
|
||||||
|
|
||||||
# Create a reference dictionary which be passed to build functions and
|
# Create a reference dictionary which be passed to build functions and
|
||||||
# will store obj returned by build functions so objs can be referenced.
|
# will store obj returned by build functions so objs can be referenced.
|
||||||
room_dict = {}
|
room_dict = {}
|
||||||
|
|
||||||
caller.msg("Creating Landmass...")
|
caller.msg("Creating Landmass...")
|
||||||
for iteration in xrange(iterations):
|
for iteration in xrange(iterations):
|
||||||
for y in xrange(len(game_map)):
|
for y in xrange(len(game_map)):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue