2007-04-25 19:39:15 +00:00
|
|
|
from django.contrib.auth.models import User, Group
|
2008-12-15 04:35:00 +00:00
|
|
|
from src.objects.models import Object
|
|
|
|
|
from src.config.models import ConfigValue
|
2009-01-18 03:14:52 +00:00
|
|
|
from src import comsys, defines_global
|
2007-04-25 19:39:15 +00:00
|
|
|
|
|
|
|
|
def handle_setup():
|
2008-06-13 19:52:29 +00:00
|
|
|
# Set the initial user's username on the #1 object.
|
2009-01-18 03:14:52 +00:00
|
|
|
god_user = User.objects.get(id=1)
|
|
|
|
|
god_user_obj = Object(id=1, type=defines_global.OTYPE_PLAYER)
|
2008-06-13 19:52:29 +00:00
|
|
|
god_user_obj.set_name(god_user.username)
|
2009-01-18 03:14:52 +00:00
|
|
|
god_user_obj.save()
|
|
|
|
|
|
|
|
|
|
limbo_obj = Object()
|
|
|
|
|
limbo_obj.type = defines_global.OTYPE_ROOM
|
|
|
|
|
limbo_obj.owner = god_user_obj
|
|
|
|
|
limbo_obj.set_name('Limbo')
|
|
|
|
|
limbo_obj.save()
|
|
|
|
|
|
|
|
|
|
god_user_obj.home = limbo_obj
|
|
|
|
|
god_user_obj.save()
|
2007-04-25 19:39:15 +00:00
|
|
|
|
2008-06-13 19:52:29 +00:00
|
|
|
groups = ("Immortals", "Wizards", "Builders", "Player Helpers")
|
|
|
|
|
for group in groups:
|
|
|
|
|
newgroup = Group()
|
|
|
|
|
newgroup.name = group
|
|
|
|
|
newgroup.save()
|
2007-04-25 19:39:15 +00:00
|
|
|
|
2009-01-18 03:14:52 +00:00
|
|
|
chan_pub = comsys.create_channel("Public", god_user_obj, description="Public Discussion")
|
|
|
|
|
chan_pub.is_joined_by_default = True
|
|
|
|
|
chan_pub.save()
|
|
|
|
|
comsys.create_channel("Errors", god_user_obj, description="Error log")
|
|
|
|
|
comsys.create_channel("Info", god_user_obj, description="Informative messages")
|
|
|
|
|
|
2008-06-13 19:52:29 +00:00
|
|
|
# We don't want to do initial setup tasks every startup, only the first.
|
2008-06-15 17:21:02 +00:00
|
|
|
ConfigValue.objects.set_configvalue('game_firstrun', '0')
|