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
#------------------------------------------------------------
#