crudkit/muck/init.py

39 lines
967 B
Python

from muck.models.room import Room
from muck.models.player import Player
def bootstrap_world(session):
if session.query(Room).first() or session.query(Player).first():
print("World already initialized.")
return
print("Bootstrapping world...")
room_zero = Room(
id=0,
name="Room Zero",
props={"_": {"de": "You are in Room Zero. It is very dark in here."}}
)
the_one = Player(
id=1,
name="One",
password="potrzebie",
props={"_": {"de": "You see The One."}}
)
the_one.location = room_zero
the_one.home = room_zero
the_one.creator = the_one
the_one.owner = the_one
the_one.modifier = the_one
the_one.last_user = the_one
room_zero.owner = the_one
room_zero.creator = the_one
room_zero.modifier = the_one
room_zero.last_user = the_one
session.add_all([room_zero, the_one])
session.commit()
print("World initialized.")