Exemplo n.º 1
0
def tell(params, mud, playersDB, players, rooms, npcsDB, npcs, itemsDB, items,
         envDB, env, eventDB, eventSchedule, id, fights, corpses):
    told = False
    target = params.partition(' ')[0]
    message = params.replace(target, "")[1:]
    if len(target) != 0 and len(message) != 0:
        for p in players:
            if players[p]['authenticated'] != None and players[p][
                    'name'].lower() == target.lower():
                #print("sending a tell")
                if players[id]['name'].lower() == target.lower():
                    mud.send_message(
                        id,
                        "It'd be pointless to send a tell message to yourself")
                    told = True
                    break
                else:
                    addToScheduler(
                        "0|msg|<f90>From " + players[id]['name'] + ": " +
                        message, p, eventSchedule, eventDB)
                    mud.send_message(
                        id, "<f90>To " + players[p]['name'] + ": " + message)
                    told = True
                    break
        if told == False:
            mud.send_message(
                id, "<f32>" + target +
                "<r> does not appear to be reachable at this moment.")
    else:
        mud.send_message(id, "Huh?")
Exemplo n.º 2
0
def go(params, mud, playersDB, players, rooms, npcsDB, npcs, itemsDB, items,
       envDB, env, eventDB, eventSchedule, id, fights, corpses):
    if players[id]['canGo'] == 1:
        # store the exit name
        ex = params.lower()

        # store the player's current room
        rm = rooms[players[id]['room']]

        # if the specified exit is found in the room's exits list
        if ex in rm['exits']:
            # go through all the players in the game
            for (pid, pl) in list(players.items()):
                # if player is in the same room and isn't the player
                # sending the command
                if players[pid]['room'] == players[id]['room'] \
                 and pid != id:
                    # send them a message telling them that the player
                    # left the room
                    mud.send_message(
                        pid, '<f32>{}<r> left via exit {}'.format(
                            players[id]['name'], ex))

            # Trigger old room eventOnLeave for the player
            if rooms[players[id]['room']]['eventOnLeave'] is not "":
                addToScheduler(int(rooms[players[id]['room']]['eventOnLeave']),
                               id, eventSchedule, eventDB)

            # update the player's current room to the one the exit leads to
            players[id]['room'] = rm['exits'][ex]
            rm = rooms[players[id]['room']]

            # Clear player's target
            players[id]['target'] = None

            # Stop any fights where player is the aggressor
            #players[id]['isInCombat'] = 0
            fightsCopy = deepcopy(fights)
            for (fid, pl) in list(fightsCopy.items()):
                if fightsCopy[fid]['s1'].lower() == players[id]['name'].lower(
                ):
                    del fights[fid]

            # trigger new room eventOnEnter for the player
            if rooms[players[id]['room']]['eventOnEnter'] is not "":
                addToScheduler(int(rooms[players[id]['room']]['eventOnEnter']),
                               id, eventSchedule, eventDB)

            # go through all the players in the game
            for (pid, pl) in list(players.items()):
                # if player is in the same (new) room and isn't the player
                # sending the command
                if players[pid]['room'] == players[id]['room'] \
                 and pid != id:
                    # send them a message telling them that the player
                    # entered the room
                    # mud.send_message(pid, '{} arrived via exit {}|'.format(players[id]['name'], ex))
                    mud.send_message(
                        pid,
                        '<f32>{}<r> has arrived.'.format(players[id]['name']))

            # send the player a message telling them where they are now
            #mud.send_message(id, 'You arrive at {}'.format(players[id]['room']))
            mud.send_message(
                id, 'You arrive at <f106>{}'.format(
                    rooms[players[id]['room']]['name']))
        else:
            # the specified exit wasn't found in the current room
            # send back an 'unknown exit' message
            mud.send_message(id, "Unknown exit <f226>'{}'".format(ex))
    else:
        mud.send_message(id, 'Somehow, your legs refuse to obey your will.')
Exemplo n.º 3
0
	for l in lines[1:]:
		if len(l) > 0:
			scriptedEventsDB.append([lines[0]] + l.split('|'))
	#print(lines)
	f.close()

log("Scripted Events loaded: " + str(counter), "info")

# Load registered players DB
playersDB = loadPlayersDB()
log("Registered player accounts loaded: " + str(len(playersDB)), "info")

# Execute Reserved Event 1 and 2
# Using -1 for target since no players can be targeted with an event at this time
log("Executing boot time events", "info")
addToScheduler(1, -1, eventSchedule, scriptedEventsDB)
addToScheduler(2, -1, eventSchedule, scriptedEventsDB)
addToScheduler(3, -1, eventSchedule, scriptedEventsDB)

# Declare number of seconds to elapse between State Saves
# A State Save takes values held in memory and updates the database
# at set intervals to achieve player state persistence
stateSaveInterval = int(Config.get('World', 'StateSaveInterval'))
log("State Save interval: " + str(stateSaveInterval) + " seconds", "info")

# Set last state save to 'now' on server boot
lastStateSave = int(time.time())

# Deepcopy npcs fetched from a database into a master template
npcsTemplate = deepcopy(npcs)