"at the altar.")
return test
-def command_ttid(id_string):
- id = id_setter(id_string, "ThingTypes", command_ttid)
- if None != id:
- world_db["ThingTypes"][id] = {
- "TT_NAME": "(none)",
- "TT_TOOLPOWER": 0,
- "TT_LIFEPOINTS": 0,
- "TT_PROLIFERATE": 0,
- "TT_START_NUMBER": 0,
- "TT_STORAGE": 0,
- "TT_SYMBOL": "?",
- "TT_CORPSE_ID": id,
- "TT_TOOL": ""
- }
-
def command_worldactive(worldactive_string):
val = integer_test(worldactive_string, 0, 1)
if None != val:
import server.config.world_data
server.config.world_data.symbols_passable += ":_"
-from server.config.world_data import thing_defaults
+from server.config.world_data import thing_defaults, thingtype_defaults
thing_defaults["T_PLAYERDROP"] = 0
+thingtype_defaults["TT_STORAGE"] = 0
import server.config.actions
server.config.actions.action_db["actor_move"] = actor_move
server.config.actions.actor_move_attempts_hook = actor_move_attempts_hook
from server.config.commands import commands_db
-commands_db["TT_ID"] = (1, False, command_ttid)
commands_db["GOD_FAVOR"] = (1, False, setter(None, "GOD_FAVOR", -32768, 32767))
commands_db["TT_STORAGE"] = (1, False, setter("ThingType", "TT_STORAGE", 0, 255))
commands_db["T_PLAYERDROP"] = (1, False, setter("Thing", "T_PLAYERDROP", 0, 1))
Default new Thing's type to the first available ThingType, others: zero.
"""
- id = id_setter(id_string, "Things", command_tid)
- if None != id:
+ tid = id_setter(id_string, "Things", command_tid)
+ if None != tid:
if world_db["ThingTypes"] == {}:
print("Ignoring: No ThingType to settle new Thing in.")
return
- type = list(world_db["ThingTypes"].keys())[0]
+ ty = list(world_db["ThingTypes"].keys())[0]
from server.new_thing import new_Thing
- world_db["Things"][id] = new_Thing(type)
+ world_db["Things"][tid] = new_Thing(ty)
def command_ttid(id_string):
"""Set ID of ThingType to manipulate. ID unused? Create new one.
- Default new ThingType's TT_SYMBOL to "?", TT_CORPSE_ID to self, TT_TOOL to
- "", others: 0.
+ Set new type's TT_CORPSE_ID to self, other fields to thingtype_defaults.
"""
- id = id_setter(id_string, "ThingTypes", command_ttid)
- if None != id:
- world_db["ThingTypes"][id] = {
- "TT_NAME": "(none)",
- "TT_TOOLPOWER": 0,
- "TT_LIFEPOINTS": 0,
- "TT_PROLIFERATE": 0,
- "TT_START_NUMBER": 0,
- "TT_SYMBOL": "?",
- "TT_CORPSE_ID": id,
- "TT_TOOL": ""
- }
+ ttid = id_setter(id_string, "ThingTypes", command_ttid)
+ if None != ttid:
+ from server.config.world_data import thingtype_defaults
+ world_db["ThingTypes"][ttid] = {}
+ for key in thingtype_defaults:
+ world_db["ThingTypes"][ttid][key] = thingtype_defaults[key]
+ world_db["ThingTypes"][ttid]["TT_CORPSE_ID"] = ttid
def command_taid(id_string):
Default new ThingAction's TA_EFFORT to 1, its TA_NAME to "wait".
"""
- id = id_setter(id_string, "ThingActions", command_taid, True)
- if None != id:
- world_db["ThingActions"][id] = {
+ taid = id_setter(id_string, "ThingActions", command_taid, True)
+ if None != taid:
+ world_db["ThingActions"][taid] = {
"TA_EFFORT": 1,
"TA_NAME": "wait"
}
"west": "s", "north-west": "w", "north-east": "e"}
thing_defaults = {
- "T_ARGUMENT": 0,
- "T_PROGRESS": 0,
- "T_SATIATION": 0,
- "T_COMMAND": 0,
- "T_CARRIES": [],
- "carried": False,
- "T_MEMTHING": [],
- "T_MEMMAP": False,
- "T_MEMDEPTHMAP": False,
- "fovmap": False
+ "T_ARGUMENT": 0,
+ "T_PROGRESS": 0,
+ "T_SATIATION": 0,
+ "T_COMMAND": 0,
+ "T_CARRIES": [],
+ "carried": False,
+ "T_MEMTHING": [],
+ "T_MEMMAP": False,
+ "T_MEMDEPTHMAP": False,
+ "fovmap": False
+}
+
+thingtype_defaults = {
+ "TT_NAME": "(none)",
+ "TT_TOOLPOWER": 0,
+ "TT_LIFEPOINTS": 0,
+ "TT_PROLIFERATE": 0,
+ "TT_START_NUMBER": 0,
+ "TT_SYMBOL": "?",
+ "TT_TOOL": ""
}
symbols_passable = "."
def id_setter(id, category, id_store=False, start_at_1=False):
- """Set ID of object of category to manipulate ID. Unused? Create new one.
+ """Set ID of object of category to manipulate. ID unused? Create new one.
+
The ID is stored as id_store.id (if id_store is set). If the integer of the
input is valid (if start_at_1, >= 0, else >= -1), but <0 or (if start_at_1)
<1, calculate new ID: lowest unused ID >=0 or (if start_at_1) >= 1. None is