Fixed tutorial_world to use ev API.

This commit is contained in:
Griatch 2012-03-25 17:39:45 +02:00
parent e7869ed830
commit d3ea942ac8
5 changed files with 29 additions and 33 deletions

View file

@ -8,9 +8,7 @@ object based on that mobile class.
import random, time
from django.conf import settings
from src.objects.models import ObjectDB
from src.utils import utils
from game.gamesrc.scripts.basescript import Script
from ev import search_object, utils, Script
from contrib.tutorial_world import objects as tut_objects
from contrib.tutorial_world import scripts as tut_scripts
@ -228,7 +226,7 @@ class Enemy(Mob):
# analyze result.
if target.db.health <= 0:
# we reduced enemy to 0 health. Whisp them off to the prison room.
tloc = ObjectDB.objects.object_search(self.db.defeat_location, global_search=True)
tloc = search_object(self.db.defeat_location, global_search=True)
tstring = self.db.defeat_text
if not tstring:
tstring = "You feel your conciousness slip away ... you fall to the ground as "

View file

@ -21,11 +21,8 @@ WeaponRack
import time, random
from src.utils import utils, create
from game.gamesrc.objects.baseobjects import Object, Exit
from game.gamesrc.commands.basecommand import Command
from game.gamesrc.commands.basecmdset import CmdSet
from game.gamesrc.scripts.basescript import Script
from ev import utils, create_object
from ev import Object, Exit, Command, CmdSet, Script
#------------------------------------------------------------
#
@ -816,7 +813,7 @@ class CmdGetWeapon(Command):
self.caller.msg("%s has no more to offer." % self.obj.name)
else:
dmg, name, aliases, desc, magic = self.obj.randomize_type()
new_weapon = create.create_object(Weapon, key=name, aliases=aliases,location=self.caller)
new_weapon = create_object(Weapon, key=name, aliases=aliases,location=self.caller)
new_weapon.db.rack_id = rack_id
new_weapon.db.damage = dmg
new_weapon.db.desc = desc

View file

@ -5,13 +5,8 @@ Room Typeclasses for the TutorialWorld.
"""
import random
from src.commands.cmdset import CmdSet
from src.utils import create, utils
from src.objects.models import ObjectDB
from game.gamesrc.scripts.basescript import Script
from game.gamesrc.commands.basecommand import Command
from game.gamesrc.objects.baseobjects import Room
from ev import CmdSet, Script, Command, Room
from ev import utils, create_object, search_object
from contrib.tutorial_world import scripts as tut_scripts
from contrib.tutorial_world.objects import LightSource, TutorialObject
@ -185,7 +180,7 @@ class CmdLookDark(Command):
lightsource = lightsources[0]
else:
# create the light source from scratch.
lightsource = create.create_object(LightSource, key="torch")
lightsource = create_object(LightSource, key="torch")
lightsource.location = caller
string = "Your fingers bump against a piece of wood in a corner. Smelling it you sense the faint smell of tar. A {c%s{n!"
string += "\nYou pick it up, holding it firmly. Now you just need to {wlight{n it using the flint and steel you carry with you."
@ -370,7 +365,7 @@ class TeleportRoom(TutorialRoom):
# passed the puzzle
teleport_to = self.db.success_teleport_to # this is a room name
results = ObjectDB.objects.object_search(teleport_to, global_search=True)
results = search_object(teleport_to, global_search=True)
if not results or len(results) > 1:
# we cannot move anywhere since no valid target was found.
print "no valid teleport target for %s was found." % teleport_to
@ -418,7 +413,7 @@ class CmdEast(Command):
if bridge_step > 4:
# we have reached the far east end of the bridge. Move to the east room.
eexit = ObjectDB.objects.object_search(self.obj.db.east_exit)
eexit = search_object(self.obj.db.east_exit)
if eexit:
caller.move_to(eexit[0])
else:
@ -446,7 +441,7 @@ class CmdWest(Command):
if bridge_step < 0:
# we have reached the far west end of the bridge. Move to the west room.
wexit = ObjectDB.objects.object_search(self.obj.db.west_exit)
wexit = search_object(self.obj.db.west_exit)
if wexit:
caller.move_to(wexit[0])
else:
@ -494,7 +489,7 @@ class CmdLookBridge(Command):
# there is a chance that we fall if we are on the western or central part of the bridge.
if bridge_position < 3 and random.random() < 0.05 and not self.caller.is_superuser:
# we fall on 5% of the times.
fexit = ObjectDB.objects.object_search(self.obj.db.fall_exit)
fexit = search_object(self.obj.db.fall_exit)
if fexit:
string = "\n Suddenly the plank you stand on gives way under your feet! You fall!"
string += "\n You try to grab hold of an adjoining plank, but all you manage to do is to "
@ -597,9 +592,9 @@ class BridgeRoom(TutorialRoom):
if character.has_player:
# we only run this if the entered object is indeed a player object.
# check so our east/west exits are correctly defined.
wexit = ObjectDB.objects.object_search(self.db.west_exit)
eexit = ObjectDB.objects.object_search(self.db.east_exit)
fexit = ObjectDB.objects.object_search(self.db.fall_exit)
wexit = search_object(self.db.west_exit)
eexit = search_object(self.db.east_exit)
fexit = search_object(self.db.fall_exit)
if not wexit or not eexit or not fexit:
character.msg("The bridge's exits are not properly configured. Contact an admin. Forcing west-end placement.")
character.db.tutorial_bridge_position = 0

View file

@ -3,7 +3,7 @@ This defines some generally useful scripts for the tutorial world.
"""
import random
from game.gamesrc.scripts.basescript import Script
from ev import Script
#------------------------------------------------------------
#

View file

@ -30,7 +30,7 @@ Example: To reach the search method 'get_object_with_user'
from django.contrib.contenttypes.models import ContentType
# limit symbol import from API
__all__ = ("search_objects", "search_players", "search_scripts", "search_messages", "search_channels", "search_help_entries")
__all__ = ("search_object", "search_player", "search_script", "search_message", "search_channel", "search_help_entry")
# import objects this way to avoid circular import problems
@ -62,7 +62,8 @@ HelpEntry = ContentType.objects.get(app_label="help", model="helpentry").model_c
# If None, the default 'name' attribute is used.
# """
search_objects = ObjectDB.objects.object_search
search_object = ObjectDB.objects.object_search
search_objects = search_object
objects = search_objects
#
# Search for players
@ -80,7 +81,8 @@ objects = search_objects
# ostring = a string or database id.
# """
search_players = PlayerDB.objects.player_search
search_player = PlayerDB.objects.player_search
search_players = search_player
players = search_players
#
@ -96,7 +98,8 @@ players = search_players
# on a timer.
# """
search_scripts = ScriptDB.objects.script_search
search_script = ScriptDB.objects.script_search
search_scripts = search_script
scripts = search_scripts
#
# Searching for communication messages
@ -115,7 +118,8 @@ scripts = search_scripts
# one of the other arguments to limit the search.
# """
search_messages = Msg.objects.message_search
search_message = Msg.objects.message_search
search_messages = search_message
messages = search_messages
#
@ -128,7 +132,8 @@ messages = search_messages
# ostring - the key or database id of the channel.
# """
search_channels = Channel.objects.channel_search
search_channel = Channel.objects.channel_search
search_channels = search_channel
channels = search_channels
#
@ -142,5 +147,6 @@ channels = search_channels
# category - limit the search to a particular help topic
# """
search_help_entries = HelpEntry.objects.search_help
search_help_entry = HelpEntry.objects.search_help
search_help_entries = search_help_entry
help_entries = search_help_entries