def do_auction(ch, argument): if not argument: if ch.comm.is_set(merc.COMM_NOAUCTION): ch.send("Auction channel is now ON.\n") ch.comm.rem_bit(merc.COMM_NOAUCTION) else: ch.send("Auction channel is now OFF.\n") ch.comm.set_bit(merc.COMM_NOAUCTION) else: # auction message sent, turn auction on if it is off */ if ch.comm.is_set(merc.COMM_QUIET): ch.send("You must turn off quiet mode first.\n") return if ch.comm.is_set(merc.COMM_NOCHANNELS): ch.send("The gods have revoked your channel priviliges.\n") return ch.comm.rem_bit(merc.COMM_NOAUCTION) ch.send("You auction '%s'\n" % argument) for d in merc.descriptor_list: victim = handler_ch.CH(d) if d.is_connected(nanny.con_playing) and d.character != ch \ and not victim.comm.is_set(merc.COMM_NOAUCTION) \ and not victim.comm.is_set(merc.COMM_QUIET): handler_game.act("$n auctions '$t'", ch, argument, d.character, merc.TO_VICT, merc.POS_DEAD)
def do_gossip(ch, argument): if not argument: if ch.comm.is_set(merc.COMM_NOGOSSIP): ch.send("Gossip channel is now ON.\n") ch.comm.rem_bit(merc.COMM_NOGOSSIP) else: ch.send("Gossip channel is now OFF.\n") ch.comm.set_bit(merc.COMM_NOGOSSIP) else: # gossip message sent, turn gossip on if it isn't already if ch.comm.is_set(merc.COMM_QUIET): ch.send("You must turn off quiet mode first.\n") return if ch.comm.is_set(merc.COMM_NOCHANNELS): ch.send("The gods have revoked your channel privileges.\n") return ch.comm.rem_bit(merc.COMM_NOGOSSIP) ch.send("You gossip '%s'\n" % argument) for d in merc.descriptor_list: victim = handler_ch.CH(d) if d.is_connected(nanny.con_playing) \ and d.character != ch \ and not victim.comm.is_set(merc.COMM_NOGOSSIP) \ and not victim.comm.is_set(merc.COMM_QUIET): handler_game.act("$n gossips '$t'", ch, argument, d.character, merc.TO_VICT, merc.POS_SLEEPING)
def do_question(ch, argument): if not argument: if ch.comm.is_set(merc.COMM_NOQUESTION): ch.send("Q/A channel is now ON.\n") ch.comm.rem_bit(merc.COMM_NOQUESTION) else: ch.send("Q/A channel is now OFF.\n") ch.comm.set_bit(merc.COMM_NOQUESTION) else: # question sent, turn Q/A on if it isn't already if ch.comm.is_set(merc.COMM_QUIET): ch.send("You must turn off quiet mode first.\n") return if ch.comm.is_set(merc.COMM_NOCHANNELS): ch.send("The gods have revoked your channel privileges.\n") return ch.comm.rem_bit(merc.COMM_NOQUESTION) ch.send("You question '%s'\n" % argument) for d in merc.descriptor_list: victim = handler_ch.CH(d) if d.is_connected(nanny.con_playing) and d.character != ch \ and not victim.comm.is_set(merc.COMM_NOQUESTION) and not state_checks.IS_SET(victim.comm, merc.COMM_QUIET): handler_game.act("$n questions '$t'", ch, argument, d.character, merc.TO_VICT, merc.POS_SLEEPING)
def do_quit(ch, argument): if ch.is_npc(): return if ch.position == merc.POS_FIGHTING: ch.send("No way! You are fighting.\n") return if ch.position < merc.POS_STUNNED: ch.send("You're not DEAD yet.\n") return ch.send("Alas, all good things must come to an end.\n") handler_game.act("$n has left the game.", ch, None, None, merc.TO_ROOM) logger.info("%s has quit.", ch.name) handler_game.wiznet("$N rejoins the real world.", ch, None, merc.WIZ_LOGINS, 0, ch.trust) # After extract_char the ch is no longer valid! ch.save(logout=True, force=True) #save.legacy_save_char_obj(ch) id = ch.id d = ch.desc ch.extract(True) if d is not None: comm.close_socket(d) # toast evil cheating bastards for d in merc.descriptor_list[:]: tch = handler_ch.CH(d) if tch and tch.id == id: tch.extract(True) comm.close_socket(d) return
def do_shutdown(ch, argument): if ch.invis_level < merc.LEVEL_HERO: ch.do_echo("Shutdown by %s." % ch.name) comm.done = True for d in merc.descriptor_list[:]: vch = handler_ch.CH(d) if vch: vch.save(logout=True, force=True) comm.close_socket(d)
def do_whois(ch, argument): found = False argument, arg = game_utils.read_word(argument) if not arg: ch.send("You must provide a name.\n") return for d in merc.descriptor_list[:]: if not d.is_connected(nanny.con_playing) or not ch.can_see(d.character): continue wch = handler_ch.CH(d) if not ch.can_see(wch): continue if wch.name.lower().startswith(arg): found = True # work out the printing guild = wch.guild.who_name if wch.level == merc.MAX_LEVEL - 0: guild = "IMP" elif wch.level == merc.MAX_LEVEL - 1: guild = "CRE" elif wch.level == merc.MAX_LEVEL - 2: guild = "SUP" elif wch.level == merc.MAX_LEVEL - 3: guild = "DEI" elif wch.level == merc.MAX_LEVEL - 4: guild = "GOD" elif wch.level == merc.MAX_LEVEL - 5: guild = "IMM" elif wch.level == merc.MAX_LEVEL - 6: guild = "DEM" elif wch.level == merc.MAX_LEVEL - 7: guild = "ANG" elif wch.level == merc.MAX_LEVEL - 8: guild = "AVA" # a little formatting */ ch.send("[[%2d %6s %s]] %s%s%s%s%s%s%s%s\n" % ( wch.level, (const.pc_race_table[wch.race.name].who_name if wch.race.name in const.pc_race_table else " "), guild, ("(Incog) " if wch.incog_level >= merc.LEVEL_HERO else ""), ("(Wizi) " if wch.invis_level >= merc.LEVEL_HERO else ""), wch.clan.who_name if wch.clan else "", ("[[AFK]] " if wch.comm.is_set(merc.COMM_AFK) else ""), ("(KILLER) " if wch.act.is_set(merc.PLR_KILLER) else ""), ("(THIEF) " if wch.act.is_set(merc.PLR_THIEF) else ""), wch.name, ("" if wch.is_npc() else wch.title))) if not found: ch.send("No one of that name is playing.\n") return
def do_count(ch, argument): global max_on count = len([ d for d in merc.descriptor_list if d.is_connected(nanny.con_playing) and ch.can_see(handler_ch.CH(d)) ]) max_on = max(count, max_on) if max_on == count: ch.send("There are %d characters on, the most so far today.\n" % count) else: ch.send("There are %d characters on, the most on today was %d.\n" % (count, max_on))
def substitute_alias(d, argument): ch = handler_ch.CH(d) MAX_INPUT_LENGTH = 500 # check for prefix */ if ch.prefix and not "prefix".startswith(argument): if len(ch.prefix) + len(argument) > MAX_INPUT_LENGTH: ch.send("Line to long, prefix not processed.\r\n") else: prefix = "%s %s" % (ch.prefix, argument) if ch.is_npc() or not ch.alias \ or "alias".startswith(argument) or "unalias".startswith(argument) \ or "prefix".startswith(argument): ch.interpret(argument) return remains, sub = game_utils.read_word(argument) if sub not in ch.alias: ch.interpret(argument) return buf = "%s %s" % (ch.alias[sub], remains) ch.interpret(buf)
def do_shout(ch, argument): if not argument: if ch.comm.is_set(merc.COMM_SHOUTSOFF): ch.send("You can hear shouts again.\n") ch.comm.rem_bit(merc.COMM_SHOUTSOFF) else: ch.send("You will no longer hear shouts.\n") ch.comm.set_bit(merc.COMM_SHOUTSOFF) return if ch.comm.is_set(merc.COMM_NOSHOUT): ch.send("You can't shout.\n") return ch.comm.rem_bit(merc.COMM_SHOUTSOFF) state_checks.WAIT_STATE(ch, 12) handler_game.act("You shout '$T'", ch, None, argument, merc.TO_CHAR) for d in merc.descriptor_list: victim = handler_ch.CH(d) if d.is_connected(nanny.con_playing) and d.character != ch \ and not victim.comm.is_set(merc.COMM_SHOUTSOFF) and not state_checks.IS_SET(victim.comm, merc.COMM_QUIET): handler_game.act("$n shouts '$t'", ch, argument, d.character, merc.TO_VICT)
def do_where(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Players near you:\n") found = False for d in merc.descriptor_list: victim = handler_ch.CH(d) if d.is_connected(nanny.con_playing) \ and victim \ and not victim.is_npc() \ and victim.in_room \ and not state_checks.IS_SET(victim.in_room.room_flags, merc.ROOM_NOWHERE) \ and (ch.is_room_owner(victim.in_room) or not victim.in_room.is_private()) \ and victim.in_room.area == ch.in_room.area \ and ch.can_see(victim): found = True ch.send("%-28s %s\n" % (victim.name, victim.in_room.name)) if not found: ch.send("None\n") else: found = False for victim in instance.characters.values(): if victim.in_room \ and victim.in_room.area == ch.in_room.area \ and not victim.is_affected( merc.AFF_HIDE) \ and not victim.is_affected( merc.AFF_SNEAK) \ and ch.can_see(victim) \ and arg in victim.name.lower(): found = True ch.send("%-28s %s\n" % (state_checks.PERS(victim, ch), victim.in_room.name)) break if not found: handler_game.act("You didn't find any $T.", ch, None, arg, merc.TO_CHAR) return
def do_who(ch, argument): fClassRestrict = False fClanRestrict = False fClan = False fRaceRestrict = False fImmortalOnly = False # Set default arguments. iLevelLower = 0 iLevelUpper = merc.MAX_LEVEL rgfClass = {k: False for k, g in const.guild_table.items()} rgfRace = {k: False for k, r in const.pc_race_table.items()} rgfClan = {k: False for k, r in tables.clan_table.items()} # Parse arguments. nNumber = 0 while True: argument, arg = game_utils.read_word(argument) if not arg: break if arg.isdigit(): nNumber += 1 if nNumber == 1: iLevelLower = int(arg) elif nNumber == 2: iLevelUpper = int(arg) else: ch.send("Only two level numbers allowed.\n") return else: # Look for classes to turn on. if "immortals".startswith(arg): fImmortalOnly = True else: if arg not in const.guild_table: if arg not in const.pc_race_table: if "clan".startswith(arg): fClan = True else: if arg in tables.clan_table: fClanRestrict = True rgfClan[arg] = tables.clan_table[arg] else: ch.send( "That's not a valid race, class, or clan.\n" ) return else: fRaceRestrict = True rgfRace[arg] = const.pc_race_table[arg] else: fClassRestrict = True rgfClass[arg] = const.guild_table[arg] # Now show matching chars. nMatch = 0 for d in merc.descriptor_list: # Check for match against restrictions. # Don't use trust as that exposes trusted mortals. if not d.is_connected(nanny.con_playing) or not ch.can_see( d.character): continue wch = handler_ch.CH(d) if not ch.can_see(wch): continue if wch.level < iLevelLower or wch.level > iLevelUpper \ or (fImmortalOnly and wch.level < merc.LEVEL_IMMORTAL) \ or (fClassRestrict and not rgfClass[wch.guild.name]) \ or (fRaceRestrict and not rgfRace[wch.race.name]) \ or (fClan and not wch.is_clan()) or (fClanRestrict and not rgfClan[wch.clan.name]): continue nMatch += 1 # Figure out what to print for class. guild = wch.guild.who_name if wch.level == merc.MAX_LEVEL - 0: guild = "IMP" elif wch.level == merc.MAX_LEVEL - 1: guild = "CRE" elif wch.level == merc.MAX_LEVEL - 2: guild = "SUP" elif wch.level == merc.MAX_LEVEL - 3: guild = "DEI" elif wch.level == merc.MAX_LEVEL - 4: guild = "GOD" elif wch.level == merc.MAX_LEVEL - 5: guild = "IMM" elif wch.level == merc.MAX_LEVEL - 6: guild = "DEM" elif wch.level == merc.MAX_LEVEL - 7: guild = "ANG" elif wch.level == merc.MAX_LEVEL - 8: guild = "AVA" # a little formatting ch.send( "[[%2d %6s %s]] %s%s%s%s%s%s%s%s\n" % (wch.level, const.pc_race_table[wch.race.name].who_name if wch.race.name in const.pc_race_table else " ", guild, "(Incog) " if wch.incog_level >= merc.LEVEL_HERO else "", "(Wizi) " if wch.invis_level >= merc.LEVEL_HERO else "", wch.clan.who_name, "[[AFK]] " if wch.comm.is_set(merc.COMM_AFK) else "", "(KILLER) " if wch.act.is_set(merc.PLR_KILLER) else "", "(THIEF) " if wch.act.is_set(merc.PLR_THIEF) else "", wch.name, "" if wch.is_npc() else wch.title)) ch.send("\nPlayers found: %d\n" % nMatch) return