Пример #1
0
def cmdJunk(ch, cmd, args):
    """
    Disintegrate the object.
    """

    argL = utils.splitArgs(args)
    if len(argL) < 1:
	ch.writeToSelf("What do you want to junk?\r\n")
	return 1

    res = parseGetCarriedObjects(ch, argL, cmd)
    if not res:
	return 1

    objL, i = res

    for o in objL:
	ch.uncarryThing(o)
	o.destroy()


    if len(objL) == 1:
	what = objL[0].getName()
    else:
	what = `len(obj)`+" "+objL[0].getName()

    ch.writeToSelf("You junk "+what+".\r\n")
    ch.writeToOthers(ch.getName()+" junks "+what+".\r\n")
Пример #2
0
def cmdDrop(ch, cmd, args):
    """
    Drop an object in the room.
    Syntax:
    drop obj
    drop i.obj
    drop n obj
    """

    argL = utils.splitArgs(args)
    if len(argL) < 1:
	ch.writeToSelf("What do you want to drop?\r\n")
	return 1

    res = parseGetCarriedObjects(ch, argL, cmd)
    if not res:
	return 1

    objL, i = res

    room = ch.getLocation()

    for o in objL:
	ch.uncarryThing(o)
	room.putThing(o)


    if len(objL) == 1:
	what = objL[0].getName()
    else:
	what = `len(obj)`+" "+objL[0].getName()

    ch.writeToSelf("You drop "+what+".\r\n")
    ch.writeToOthers(ch.getName()+" drops "+what+".\r\n")
Пример #3
0
    def handleCommand(self, performer, command, argument):
        if not self._recipes:
            return 0

        if not command in self._knownCommands:
            return 0

        argL = utils.splitArgs(argument)
        if len(argL) == 0:
            return 0

        container = performer.findCarriedObject(argL[0])

        if not container._contains:
            performer.writeToSelf("You can't " + command + " with an empty " + container.getName() + ".\r\n")
            return 1

        recipes = self._recipeByCommand[command]

        ok = 0
        for r in recipes:
            if container._id in r._container:
                ok = r.make(performer, container, SUC_DISASTER)
                if ok:
                    break

        if ok:
            product = container._contains[0].getName()

            performer.writeToSelf("You cook " + product + ".\r\n")
            performer.writeToOthers(performer.getName() + " cooks " + product + ".\r\n")
        else:
            performer.writeToSelf("Seems like nothing happened.\r\n")

        return 1
Пример #4
0
    def handleCommand(self, performer, command, argument):
	argL = utils.splitArgs(argument)

	if command == "phone":
	    if len(argL) != 2:
		return 0
	elif len(argL) == 0:
	    return 0


	obj = performer.findCarriedObject(argL[0])
	if obj != self:
	    return 0

	if command == "phone":
	    self.performPhone(performer, argL[1])
	elif command == "answer":
	    self.performAnswer(performer)
	elif command == "hangup":
	    self.performHangup(performer)
	else:
	    return 0


	return 1
Пример #5
0
def cmdMkObj(ch, cmd, args):
    
    argL = utils.splitArgs(args)
    if len(argL) == 0:
	ch.writeToSelf("What object do you want to create?\r\n")
	return 1

    if argL[0] == "?":
	ch.writeToSelf(_MkObjHelp)
	return 1

    obj = ch._world.makeObject(argL[0])
    if not obj:
	if not ch._world.getObject(argL[0]):
	    ch.writeToSelf("There's no such object.\r\n")
	else:
	    ch.writeToSelf("Max population of that object was reached.\r\n")
	return 1

    if OBF_NO_GET in obj._flags or not ch.canCarryThing(obj):
	ch.getPlace().putThing(obj)
    else:
	ch.carryThing(obj)

    ch.writeToSelf("You create "+obj.getName()+".\r\n")
    if cmd[0] != '.':
	ch.writeToOthers(ch.getName()+" makes a magical gesture and creates "+obj.getName()+"!\r\n")

    return 1
Пример #6
0
def cmdReject(ch, cmd, args):

    argL = utils.splitArgs(args)
    if len(argL) == 0:
	ch.writeToSelf("Whose heart do you want to break?\r\n")
	return 1


    victim = ch.findVictim(argL[0])
    if not victim:
	ch.writeToSelf(argL[0]+" is not here!\r\n")
	return 1

    if not basicChecks(ch, victim, "reject proposals from"):
	return 1


    if ch._engagementStatus in [ENG_SINGLE,ENG_DATING,ENG_ENGAGED,ENG_MARRIED]\
	    or ch._engagedTo != victim.getName():
	ch.writeToSelf("You have no pending proposals from "+victim.him()
		+".\r\n")
	return 1


    if ch._engagementStatus in [ENG_ASKING_OUT, ENG_PROPOSING]:
	ch.writeToSelf("You're the one asking out, not "+victim.him()+".\r\n"
			+"Try to breakup, if you changed your mind.\r\n")
	return 1

    room = ch.getLocation()

    if ch._engagementStatus == ENG_PROPOSED:
	ch.writeToSelf("You tell "+victim.getName()+" that you'd rather not marry yet.\r\n")
	victim.writeToSelf(victim.getName()+" tells you "+ch.he()+" doesn't want to get married yet.\r\n")
	room.writeToRoom(ch.getName()+" hands "+victim.getName()+"'s engagement ring back.\r\n",
			[ch, victim])

	ch._engagementStatus = ENG_DATING
	victim._engagementStatus = ENG_DATING

	return 1

    if ch._engagementStatus == ENG_ASKED_OUT:
	ch.writeToSelf("You tell "+victim.getName()
		+" that you'd rather just be friends.\r\n")
	victim.writeToSelf(ch.getName()+" tells you "+ch.he()+"'d rather be "
		+"just friends, but you feel your heart shattering into a "
		+"thousand pieces :~(\r\n")
	room.writeToRoom(ch.getName()+" has rejected "+victim.getName()+".\r\n",
			[ch, victim])

	ch._engagementStatus = ENG_SINGLE
	victim._engagementStatus = ENG_SINGLE
	ch._engagedTo = None
	victim._engagedTo = None

	return 1
Пример #7
0
def cmdSit(ch, cmd, args):

    argL = utils.splitArgs(args)

    if not argL:
	if ch._position == POS_RESTING:
	    ch.writeToSelf("Please stand up first.\r\n")
	    return 1

	if ch._position == POS_SITTING:
	    ch.writeToSelf("You're already sitting.\r\n")
	    return 1
			
	if ch._position == POS_SLEEPING:
	    ch.writeToSelf("In your dreams or what?.\r\n")
	    return 1

	if ch._position == POS_STANDING:
	    ch._position = POS_SITTING
	    ch.writeToSelf("You sit down on the floor.\r\n")
	    event = Event(EVN_POSITION, ch)
	    event.position = POS_SITTING
	    ch.getLocation().handleEvent(event)
		
	return 1

    if argL[0] != 'on' or len(argL) < 2:
	ch.writeToSelf("What do you want to sit ON?\r\n")
	return 1

    sitting = ch.findObject(argL[1])
    if not sitting:
	ch.writeToSelf("You cant find a "+argL[1]+" here.\r\n")
	return 1
    if ch._position == POS_RESTING:
	ch.writeToSelf("Please stand up first.\r\n")
    if ch._position == POS_SITTING:
	ch.writeToSelf("You're already sitting.\r\n")
	return 1
    if ch._position == POS_SLEEPING:
	ch.writeToSelf("In your dreams or what?\r\n")
	return 1
    if ch._position == POS_STANDING:
	if sitting.performSit(ch):
	    ch._position = POS_SITTING
	    ch.writeToSelf("You sit on "+sitting.getName()+".\r\n")
	    ch.writeToOthers(ch.getName()+" sits down on "+sitting.getName()
			+".\r\n")
	    event = Event(EVN_POSITION, ch)
	    event.position = POS_SITTING
	    ch.getPlace().handleEvent(event)

    return 1
Пример #8
0
def cmdAccept(ch, cmd, args):

    argL = utils.splitArgs(args)
    if len(argL) == 0:
	ch.writeToSelf("Accept what?\r\n")
	return 1


    victim = ch.findVictim(argL[0])
    if not victim:
	ch.writeToSelf(argL[0]+" is not here!\r\n")
	return 1

    if not basicChecks(ch, victim, "accept proposals from"):
	return 1


    if ch._engagementStatus in [ENG_SINGLE,ENG_DATING,ENG_ENGAGED,ENG_MARRIED]\
	    or ch._engagedTo != victim.getName():
	ch.writeToSelf("You have no pending proposals from "+victim.him()
		+".\r\n")
	return 1

    if ch._engagementStatus in [ENG_ASKING_OUT, ENG_PROPOSING]:
	ch.writeToSelf("You must wait "+victim.him()
		+" accept or reject your proposal.\r\n")
	return 1

    room = ch.getLocation()

    if ch._engagementStatus == ENG_PROPOSED:
	ch.writeToSelf("You accept "+victim.getName()+"'s marriage proposal!\r\n")
	victim.writeToSelf(ch.getName()+" has accepted your proposal!\r\n")
	room.writeToRoom(ch.getName()+" has agreed to marry "+victim.getName()+"!\r\n",
			[ch, victim])

	ch._engagementStatus = ENG_ENGAGED
	victim._engagementStatus = ENG_ENGAGED

	return 1

    if ch._engagementStatus == ENG_ASKED_OUT:
	ch.writeToSelf("You accept "+victim.getName()+"'s dating offer!\r\n")
	victim.writeToSelf(ch.getName()+" has agreed to date you!\r\n")
	room.writeToRoom(ch.getName()+" will date "+victim.getName()+".\r\n"
		    +"Another happy couple in the world.\r\n", [ch, victim])

	ch._engagementStatus = ENG_DATING
	victim._engagementStatus = ENG_DATING

	return 1
Пример #9
0
def cmdStudy(ch, cmd, args):

    argL = utils.splitArgs(args)

    if len(argL) == 0:
	ch.writeToSelf("What do you want to learn?\r\n")
	return 1


    if ch.checkLevel(LEV_ADMIN):
	#
	# Admins can study <speciality-name>
	#
	_learnArea(ch, argL[0], 100)
Пример #10
0
def cmdFollow(ch, cmd, args):
    """
    Make the character follow some other mobile.
    """
    argL = utils.splitArgs(args)
    if not argL:
	ch.writeToSelf("Who do you want to follow?\r\n")
	return 1


    master = ch.findVictim(argL[0])
    if not master:
	ch.writeToSelf(argL[0]+" is not around.\r\n")
	return 1
    
    oldMaster = ch._follows

    if oldMaster == master:
	ch.writeToSelf("You're already following "+master.him()+".\r\n")
	return 1

    room = ch.getLocation()

    if ch.follow(master):
	if oldMaster != None: # change master
	    ch.writeToSelf("You stop following "+oldMaster.getName()
		    +" and start following "+master.getName()+", instead.\r\n")
	    master.writeToSelf(ch.getName()+" starts following you.\r\n",
				WRI_SLEEPING)
	    oldMaster.writeToSelf(ch.getName()+" stops following you.\r\n",
				WRI_SLEEPING)
	    room.writeToRoom(ch.getName()+" stops following "
			+oldMaster.getName()+" and starts following "
			+master.getName()+".\r\n", [ch, oldMaster, master])
	elif master == ch: # stop following
	    ch.writeToSelf("You stop following "+oldMaster.getName()+".\r\n")
	    oldMaster.writeToSelf(ch.getName()+" stops following you.\r\n",
				WRI_SLEEPING)
	    room.writeToRoom(ch.getName()+" stops following "
			+oldMaster.getName()+".\r\n", [ch, oldMaster])
	else: # start following
	    ch.writeToSelf("You start following "+master.getName()+".\r\n")
	    master.writeToSelf(ch.getName()+" starts following you.\r\n",
				WRI_SLEEPING)
	    room.writeToRoom(ch.getName()+" starts following "
			+master.getName()+".\r\n", [ch, master])
    else:
	ch.writeToSelf("You can't follow "+master.getName()+".\r\n")

    return 1
Пример #11
0
def cmdGet(ch, cmd, args):
    """
    Get something from the room or from a container or furniture.
    get object
    get object from container
    get i.object
    get i.object from container
    # XXX    get n object
    # XXX get n object from container
    """

    argL = utils.splitArgs(args)
    if len(argL) == 0:
	ch.writeToSelf("What do you want to get?\r\n")
	return 1


    if len(argL) == 3:
	if argL[1] != 'from':
	    ch.writeToSelf("Do you want to get something FROM there?\r\n")
	    return 1
	_getFrom(ch, argL[0], argL[2])
	return 1


    obj = ch.findObject(argL[0])

    if not obj:
	ch.writeToSelf("You don't see a "+argL[0]+" here.\r\n")
	return 1

    if OBF_NO_GET in obj._flags:
	ch.writeToSelf("You can't get that!\r\n")
	return 1

    if not ch.canCarryThing(None):
	ch.writeToSelf("Your arms are too full to carry anything else!\r\n")
	return 1

    if not ch.canCarryThing(obj):
	ch.writeToSelf("You can't carry that much weight.\r\n")
	return 1

    ch.writeToSelf("You get "+obj.getName()+".\r\n")
    ch.writeToOthers(ch.getName()+" gets "+obj.getName()+".\r\n")

    obj.getPlace().removeThing(obj)
    ch.carryThing(obj)

    return 1
Пример #12
0
def cmdSet(ch, cmd, args):
    
    argL = utils.splitArgs(args)
    if len(argL) != 3:
	ch.writeToSelf("What do you want set?\r\n")
	return 1

    
    victim = ch.findVictim(argL[0])
    if not victim:
	ch.writeToSelf("There's noone called "+argL[0]+" around.\r\n")
	return 1

    if not _MobileAttributes.has_key(argL[1]):
	ch.writeToSelf("That's not a valid attribute. Try one of these:\r\n")

	for k, _ in _MobileAttributes.items():
	    ch.writeToSelf(string.ljust(k, 10))
	ch.writeToSelf("\r\n")

	return 1

    type = _MobileAttributes[argL[1]]

    if type == _INTEGER:
	if not utils.isnumber(argL[2]):
	    ch.writeToSelf("Value must be a integer number.\r\n")
	    return 1

	value = int(argL[2])


    if argL[1] == "level":
	value = max(min(value, LEV_ADMIN), 1)
	victim._level = value
    elif argL[1] == "title":
	victim._title = value


    ch.writeToSelf("You set "+victim.getName()+"'s "+argL[1]+" to "
	+`value`+".\r\n")

    if cmd[0] != ".":
	victim.writeToSelf(ch.getName()+" puts "+ch.his()
		+" hand over your head and as "+ch.he()+" lifts it,\r\nyou "
		+"feel something different about your "+argL[1]+".\r\n",
		WRI_ANYONE)
Пример #13
0
def cmdPropose(ch, cmd, args):

    argL = utils.splitArgs(args)
    if len(argL) == 0:
	ch.writeToSelf("Propose to whom?\r\n")
	return 1

    victim = ch.findVictim(argL[0])
    if not victim:
	ch.writeToSelf("You should propose to "+argL[0]+" personally!\r\n")
	return 1

    if not basicChecks(ch, victim, "propose"):
	return 1



    if ch._engagementStatus < ENG_DATING:
	ch.writeToSelf("You're not dating "+victim.him()+".\r\n")
	return 1

    if ch._engagedTo != victim.getName():
	ch.writeToSelf("I don't think "+ch._engagedTo+" would be too happy about that.\r\n")
	return 1

    if ch._engagementStatus > ENG_DATING:
	ch.writeToSelf("But you're already "+ch.getEngagement()+".\r\n")
	return 1


    assert ch._engagementStatus == ENG_DATING
    assert victim._engagementStatus == ENG_DATING
    assert ch._engagedTo == victim.getName()


    ch.writeToSelf("You ask "+victim.his()+" hand in marriage.\r\n")
    victim.writeToSelf(ch.getName()+" knees before you and asks your hand in marriage!\r\n")
    room = ch.getLocation()
    room.writeToRoom(ch.getName()+" knees before "+victim.getName()
		    +" and asks "+victim.him()+" to marry "+ch.him()+".\r\n",
		    [ch, victim])

    ch._engagementStatus = ENG_PROPOSING
    victim._engagementStatus = ENG_PROPOSED
    ch._engagedTo = victim.getName()
    victim._engagedTo = ch.getName()
Пример #14
0
def cmdZView(ch, cmd, args):
    """
    View player's current zone.
    """

    argL = utils.splitArgs(args)
    if len(argL) == 1:
	zone = ch._world.getZone(argL[0])
	if not zone:
	    ch.writeToSelf("Zone "+argL[0]+" does not exist.\r\n")
	    return 1
    else:
	zone = ch.getRoom()._zone
    
    zone.displayInfo(ch)

    return 1
Пример #15
0
def cmdWake(ch, cmd, args): 

    argL = utils.splitArgs(args)

    if not argL:
	if ch._position in [POS_RESTING, POS_SITTING, POS_STANDING]:
	    ch.writeToSelf("You're already awake and standing.\r\n")
	    return 1

	if ch._position == POS_SLEEPING:
	    ch._position = POS_RESTING

	    ch.writeToSelf("You wake up.\r\n")
	    ch.writeToOthers(ch.getName()+" wakes up.\r\n")

	    event = Event(EVN_POSITION, ch)
	    event.position = POS_RESTING
	    ch.getLocation().handleEvent(event)


	return 1


    marmote = ch.findVictim(argL[0])
    if not marmote:
	ch.writeToSelf(argL[0]+" is not around.\r\n")
	return 1

    if marmote._position  in [POS_RESTING, POS_SITTING, POS_STANDING]:
	ch.writeToSelf(string.capitalize(marmote.he())+"'s already awake.\r\n")
	return 1

    if marmote._position == POS_SLEEPING:
	marmote._position = POS_RESTING
	location = ch.getLocation()
	if isinstance(location, Furniture):
	    location.performStand(ch)
	ch.writeToSelf("You wake "+marmote.getName()+".\r\n")
	marmote.writeToSelf(ch.getName()+" wakes you up.\r\n", WRI_SLEEPING)

	event = Event(EVN_POSITION, ch)
	event.position = POS_RESTING
	ch.getLocation().handleEvent(event)


    return 1
Пример #16
0
def cmdAskout(ch, cmd, args):

    argL = utils.splitArgs(args)
    if len(argL) == 0:
	ch.writeToSelf("Askout whom?\r\n")
	return 1

    victim = ch.findVictim(argL[0])
    if not victim:
	ch.writeToSelf("You should ask "+argL[0]+" out personally!\r\n")
	return 1

    if not basicChecks(ch, victim, "date"):
	return 1


    if ch._engagementStatus != ENG_SINGLE:
	if ch._engagedTo != victim.getName():
	    ch.writeToSelf("That wouldn't be nice to "+ch._engagedTo+" :/\r\n")
	else:
	    ch.writeToSelf("But you're already "+ch.getEngagement()+".\r\n")
	    if ch._engagementStatus == ENG_ASKED_OUT:
		ch.writeToSelf("You may 'accept' "+victim.his()+" proposal.\r\n")
	return 1

    if victim._engagementStatus != ENG_SINGLE:
	ch.writeToSelf(":( "+victim.he()+" is already "+ch.getEngagement()+".\r\n")
	return 1


    assert ch._engagementStatus == ENG_SINGLE
    assert victim._engagementStatus == ENG_SINGLE
    assert ch._engagedTo == None
    assert victim._engagedTo == None

    ch.writeToSelf("You ask "+victim.him()+" out for a date.\r\n")
    victim.writeToSelf(ch.getName()+" is asking you out!\r\n")
    room = ch.getLocation()
    room.writeToRoom(ch.getName()+" asks "+victim.getName()+" out for a date.\r\n",
		    [ch, victim])

    ch._engagementStatus = ENG_ASKING_OUT
    victim._engagementStatus = ENG_ASKED_OUT
    ch._engagedTo = victim.getName()
    victim._engagedTo = ch.getName()
Пример #17
0
def cmdPut(ch, cmd, args):
    """
    Put something in a container or on a furniture.
    put obj in container
    put i.obj in container
    put n obj in container
    """

    argL = utils.splitArgs(args)
    if len(argL) < 3:
	ch.writeToSelf("What do you want to put in what?\r\n")
	return 1


    res = parseGetCarriedObjects(ch, argL, cmd)
    if not res:
	return 1

    objL, i = res
    i = i+1

    if len(argL) != 3+i-1 or argL[i] not in ['in', 'on']:
	ch.writeToSelf("You can only put things in or on other things.\r\n")
	return 1
    i = i+1

    cont = ch.findCarriedObject(argL[i])
    if not cont:
	cont = ch.findObject(argL[i])

    if not cont:
	ch.writeToSelf("You don't have a "+argL[i]+".\r\n")
	return 1

    if cont in objL:
	ch.writeToSelf("How will you put "+cont.getName()+" inside itself!?\r\n")
	return 1

    if isinstance(cont, Container) and argL[i-1] == 'in':
	_putIn(ch, objL, cont)
    elif isinstance(cont, Furniture) and argL[i-1] == 'on':
	_putOn(ch, objL, cont)


    return 1
Пример #18
0
def cmdWear(ch, cmd, args):

    argL = utils.splitArgs(args)
    if len(argL) == 0:
	ch.writeToSelf("What do you want to wear?\r\n")
	return 1

    obj = ch.findCarriedObject(argL[0])
    if not obj:
	ch.writeToSelf("You don't have that.\r\n")
	return 1

    if not isinstance(obj, Things.Cloth.Cloth):
	ch.writeToSelf("You can only wear clothes.\r\n")
	return 1

    obj.performWear(ch)

    return 1
Пример #19
0
def cmdUnlock(ch, cmd, args):

    argL = utils.splitArgs(args)
    if len(argL) == 0:
	ch.writeToSelf("What do you want to unlock?\r\n")
	return 1

    obj = ch.findCarriedObject(argL[0])
    if not obj:
	ch.writeToSelf("You don't have that.\r\n")
	return 1

    if not isinstance(obj, Things.Container.Container):
	ch.writeToSelf("You can't unlock that.\r\n")
	return 1

    obj.performUnlock(ch)

    return 1
Пример #20
0
def cmdMkMoney(ch, cmd, args):
    argL = utils.splitArgs(args)
    if len(argL) == 0:
	ch.writeToSelf("How much money do you want to create?\r\n")
	return 1

    money = utils.parseMoney(argL)
    if not money:
	ch.writeToSelf("Format of money must be 10 dollar, 10 dollars, U$10 or U$ 10.\r\n")
	return

    amount, currency = money

    mon = Money(ch._world, amount, currency)

    ch.writeToSelf("You create "+mon.getMoneyText(1)+".\r\n")
    ch.carryThing(mon)

    return 1
Пример #21
0
def cmdRemove(ch, cmd, args):

    argL = utils.splitArgs(args)
    if len(argL) == 0:
	ch.writeToSelf("What do you want to remove?\r\n")
	return 1

    obj = ch.findWornObject(argL[0])
    if not obj:
	ch.writeToSelf("You arent't wearing that.\r\n")
	return 1

    if not isinstance(obj, Things.Cloth.Cloth):
	ch.writeToSelf("You can't remove that.\r\n")
	return 1

    obj.performRemove(ch)

    return 1
Пример #22
0
def cmdSleep(ch, cmd, args):

    if ch._position == POS_SLEEPING:
	ch.writeToSelf("You're already sleeping.\r\n", WRI_SLEEPING)
	return 1

    argL = utils.splitArgs(args)

    if not argL:
	if ch._position in [POS_SITTING, POS_RESTING, POS_STANDING]:
	    ch.writeToSelf("You go to sleep.\r\n")
	    ch.writeToOthers(ch.getName()+" goes to sleep.\r\n")
	    ch._position = POS_SLEEPING
	    ch.sleep()

	    event = Event(EVN_POSITION, ch)
	    event.position = POS_SLEEPING
	    ch.getLocation().handleEvent(event)

	return 1


    if argL[0] != 'on' or len(argL) < 2:
	ch.writeToSelf("What do you want to sleep ON?\r\n")
	return 1

    obj = ch.findObject(argL[1])
    if not obj:
	ch.writeToSelf("You cant find a "+argL[1]+" here.\r\n")
	return 1

    if ch._position in [POS_SITTING, POS_RESTING, POS_STANDING]:
	if obj.performSleep(ch):
	    ch.writeToSelf("You sleep on "+obj.getName()+".\r\n")
	    ch.writeToOthers(ch.getName()+" sleeps on "+obj.getName()+".\r\n")
	    ch._position = POS_SLEEPING
	    event = Event(EVN_POSITION, ch)
	    event.position = POS_SLEEPING
	    ch.getPlace().handleEvent(event)

    return 1
Пример #23
0
def cmdOpen(ch, cmd, args):

    argL = utils.splitArgs(args)
    if len(argL) == 0:
	ch.writeToSelf("What do you want to open?\r\n")
	return 1

    obj = ch.findCarriedObject(argL[0])
    if not obj:
	obj = ch.findObject(argL[0])
    if not obj:
	ch.writeToSelf("You don't have that.\r\n")
	return 1

    if not isinstance(obj, Things.Container.Container):
	ch.writeToSelf("Try with an axe or something.\r\n")
	return 1

    obj.performOpen(ch)

    return 1
Пример #24
0
def cmdEat(ch, cmd, args):

    argL = utils.splitArgs(args)
    if len(argL) == 0:
	ch.writeToSelf("What do you want to eat?\r\n")
	return 1

    obj = ch.findCarriedObject(argL[0])
    if not obj:
	ch.writeToSelf("You don't have that.\r\n")
	return 1

    if not isinstance(obj, Things.Food.Food):
	ch.writeToSelf("You can't eat that!\r\n")
	return 1

    if obj.performEat(ch):
	ch.uncarryThing(obj)
	obj.destroy()

    return 1
Пример #25
0
def cmdGoto(ch, cmd, args):
    """
    Bring the player (immortal) to the specified room or to the room
    where the named player is.
    """

    argL = utils.splitArgs(args)
    if len(argL) == 0:
	ch.writeToSelf("Where do you want to go to?\r\n")
	return 1
    
    room = None    
    for p in ch._world._players:
	if p.matchAlias(argL[0]):
	    room = p.getLocation()
	    break

    
    if not room:
	if "@" in argL[0]:
	    room = ch._world.getRoom(argL[0])
	else:
	    room = ch.getLocation()._zone.getRoom(argL[0])

    if not room:
	ch.writeToSelf("That room or player doesn't exist in this world.\r\n")
	return 1

    if cmd[0] != '.':
	ch.writeToOthers(ch.getName()+" suddenly disappears!\r\n")

    ch._world.moveTo(ch, room)
    ch._world.execute(ch, "look")

    if cmd[0] != '.':
	ch.writeToOthers(ch.getName()+" suddenly appears from nowhere!\r\n")


    return 1
Пример #26
0
def cmdCookie(ch, cmd, args):
    
    argL = utils.splitArgs(args)
    if len(argL) < 1:
	ch.writeToSelf("Syntax: cookie <player> [add|del <cookie>]\r\n")
	return 1

    
    victim = ch.findVictim(argL[0])
    if not victim:
	ch.writeToSelf("There's noone called "+argL[0]+" around.\r\n")
	return 1


    if len(argL) == 1:
    	ch.writeToSelf("Cookies in "+victim.getName()+": "+`victim._cookies`+"\r\n")
	return 1

    elif argL[1] == 'add':
	if len(argL) < 3:
	    ch.writeToSelf("You need to supply a cookie name.\r\n")
	    return 1

	victim.putCookie(argL[2])
	ch.writeToSelf("Cookie "+argL[2]+" added to "+victim.getName()+".\r\n")

    elif argL[1] == 'del':
	if len(argL) < 3:
	    ch.writeToSelf("You need to supply a cookie name.\r\n")
	    return 1

	victim.removeCookie(argL[2])
	ch.writeToSelf("Cookie "+argL[2]+" deleted from "+victim.getName()+".\r\n")

    else:
	ch.writeToSelf("Syntax: cookie <player> [add|del <cookie>]\r\n")


    return 1
Пример #27
0
def cmdMkMob(ch, cmd, args):

    argL = utils.splitArgs(args)
    if len(argL) == 0:
	ch.writeToSelf("What mobile do you want to create?\r\n")
	return 1

    mob = ch._world.makeMobile(argL[0])
    if not mob:
	if not ch._world.getMobile(argL[0]):
	    ch.writeToSelf("There's no such mobile.\r\n")
	else:
	    ch.writeToSelf("Max population of that mobile was reached.\r\n")
	return 1

    ch.getLocation().putThing(mob)

    ch.writeToSelf("You create "+mob.getName()+".\r\n")
    if cmd[0] != '.':
	ch.writeToOthers("A large smoke cloud appears in front of "+ch.getName()+".\r\n")
	ch.writeToOthers(mob.getName()+" appears from the cloud.\r\n")

    return 1
Пример #28
0
def cmdRegPhone(ch, cmd, args):

    argL = utils.splitArgs(args)

    if len(argL) != 3:
	ch.writeToSelf(_RegPhoneHelp)
	return
    
    phone = ch.findCarriedObject(argL[0])
    if not phone:
	phone = ch.findObject(argL[0])

    if not phone:
	ch.writeToSelf("There aren't any "+argL[0]+" around.\r\n")
	return

    if not isinstance(phone, Phone):
	ch.writeToSelf("That's not a telephone.\r\n")
	return

    if len(argL[2]) != 5 and not utils.isnumber(argL[2]):
	ch.writeToSelf("The phone number must have 5 digits.\r\n")
	return

    if ch._world._phones.has_key(argL[2]):
	ch.writeToSelf("That number is already taken.\r\n")
	return

    if phone._number:
	ch.writeToSelf("That phone is already registered for "+phone._owner
	    +", as "+phone._number+".\r\n")
	return

    phone.registerFor(argL[1], argL[2])
    ch.writeToSelf("The "+phone.getTheName()+" is now registered for "+argL[1]
	    +" as "+argL[2]+".\r\n")
Пример #29
0
def cmdDitch(ch, cmd, args):
    """
    Make the named follower stop following the character. 
    """
    argL = utils.splitArgs(args)
    if not argL:
	ch.writeToSelf("Who do you want to stop from following you?\r\n")
	return 1
    
    follower = ch.findVictim(argL[0])
    if not follower:
	ch.writeToSelf(argL[0]+" is not around.\r\n")
	return 1
    
    if follower._follows != ch:
	ch.writeToSelf(string.capitalize(follower.he())+"'s not following you.\r\n")
	return 1

    follower.follow(None)

    ch.writeToSelf("You ditch "+follower.getName()+".\r\n")
    follower.writeToSelf(ch.getName()+" has ditched you!\r\n")

    return 1
Пример #30
0
def cmdLook(ch, cmd, args):
    """
    Look at something, in something or the current room.
    """

    argL = utils.splitArgs(args)

    room = ch.getPlace()

    if argL == []:
	_lookAround(ch)

	event = Event(EVN_LOOK, ch)
	event.target = None
	room.handleEvent(event)

	return 1

    if argL[0] == "in":
	if len(argL) < 2:
	    ch.writeToSelf("Look in what?\r\n")
	else:
	    obj = ch.findCarriedObject(argL[1])
	    if not obj:
		obj = ch.findObject(argL[1])
	    if obj:
		descr = obj.getDescriptionForLookIn()
		if not descr:
		    ch.writeToSelf("You can't look inside that.\r\n")
		else:
		    ch.writeToSelf(descr+"\r\n")
		    ch.writeToOthers(ch.getName()+" looks in "
			    +obj.getName()+".\r\n")
	    else:
		ch.writeToSelf("You don't see that here.\r\n")

    else:
	if argL[0] == "at":
	    i = 1
	    if len(argL) < 2:
		ch.writeToSelf("Look at what?\r\n")
		return 1
	else:
	    i = 0

	found = 0

	# character
	if argL[i][-2:] == "'s":
	    name = argL[i][:-2]
	else:
	    name = argL[i]

	target = ch.findVictim(name)
	if target:
	    _lookAtCharacter(ch, target, argL[i+1:])
	    found = 1

	# room description
	if not found:
	    descr = room.getDescriptionForLookAt(argL[i])
	    if descr:
		ch.writeToSelf(descr+"\r\n")
		found = 1

	# worn objects
	if not found:
	    r = ch.findDescriptionForWornObject(argL[i])
	    if r:
		target, descr = r
		ch.writeToSelf(descr+"\r\n")
		found = 1

	# carried objects
	if not found:
	    r = ch.findDescriptionForCarriedObject(argL[i])
	    if r:
		target, descr = r
		ch.writeToSelf(descr+"\r\n")
		found = 1

	# objects in room
	if not found:
	    r = room.findDescriptionForContainedObject(argL[i])
	    if r:
		target, descr = r
		ch.writeToSelf(descr+"\r\n")
		found = 1

	if not found:
	    # worn objects
	    target = ch.findWornObject(argL[i])
	    # carried objects
	    if not target:
		target = ch.findCarriedObject(argL[i])
	    # room objects
	    if not target:
		target = ch.findObject(argL[i])
	    if target:
		ch.writeToSelf("You don't see anything special about it.\r\n")
		found = 1

	if found:
	    event = Event(EVN_LOOK, ch)
	    event.target = target
	    room.handleEvent(event)
	else:
	    ch.writeToSelf("You don't see that here.\r\n")


    return 1