;;#53206.("help_msg") = "Ha!  They won't get rid of me that easily!  Er..."
;;#53206.("feature_verbs") = {"@ninja-radar", "sarc", "gem", "ploc", "des"}
;;#53206.("guest_ok") = 1
"#53206.("key") => E_PERM (Permission denied)
;;#53206.("aliases") = {"Kagan's RPG FO"}
;;#53206.("description") = "LRPG stuff that actually tells useful information and aren't just shortcuts for lazy typists."
;;#53206.("object_size") = {17447, 1141286927}

@verb #53206:"gem" any none none rxd
@program #53206:gem
"Usage: gem <object/player>";
"Gives you a list of all the gems carried in/by <object/player>, their values, and the total.";
if (!valid(dobj))
  target = $string_utils:match_player(dobjstr);
else
  target = dobj;
endif
if (!valid(target))
  return player:tell("I don't see that here.");
endif
player:tell($string_utils:nn(target));
total = 0;
what = target;
lastloc = #-1;
for gem in ($object_utils:all_contents(what))
  $command_utils:suspend_if_needed(5);
  if ($object_utils:isa(gem, #25600))
    if (gem.appraised_value)
      val = gem.appraised_value;
      total = total + val;
    else
      val = "-NA-";
    endif
    if (gem.location != lastloc)
      player:tell("----");
      player:tell("Inside: ", gem.location.name);
      lastloc = gem.location;
    endif
    player:tell_lines($string_utils:columnize({gem.name, val}, 2));
  endif
endfor
player:tell("Total: $", total, " in gold.");
.

@verb #53206:"des" any none none rxd
@program #53206:des
"Usage: des <object>";
"Gives a list of names, object #'s, and locations of the kids of <object>.";
if (!valid(dobj))
  return player:tell("Want to try that again?");
endif
if (dobj == #348)
  return player:tell(">> Try typing 'sarc' instead.");
endif
number = length(kiddies = children(dobj));
x = number;
player:tell_lines($string_utils:columnize({"Name", "Number", "Location", ""}, 4));
player:tell_lines($string_utils:columnize({"----", "------", "--------", ""}, 4));
for what in (kiddies[1..x])
  $command_utils:suspend_if_needed(5);
  if (valid(what.location))
    locname = what.location.name;
    location = what.location;
  else
    locname = "Nowhere";
    location = "";
  endif
  player:tell_lines($string_utils:columnize({what.name, what, locname, location}, 4));
endfor
player:tell("--------------");
player:tell($string_utils:nn(dobj), ": ", x, " total");
.

@verb #53206:"pen*alty penfull penaltyfull" any none none rxd
@program #53206:penalty
"Usage: penalty <skill>";
"Where <skill> is any RPG skill that appears on the slip.  The learn rate helps determine how often a stat will go up.";
skillstr = dobjstr;
if (valid(skill = $local.rpg:match_skill(skillstr)))
  learn = skill.learn;
  player:tell("Skill: ", skill.name, ", Learn rate: ", learn);
  if (verb in {"penfull", "penaltyfull"})
    string = setremove(this:dependant_skills(skill, {}), skill);
    player:tell("Parent skills: ", $string_utils:english_list($list_utils:map_prop(string, "name")));
  endif
else
  player:tell("No such skill.");
endif
.

@verb #53206:"pstat ploc" any any any rxd
@program #53206:pstat
"Usage: ploc/pstat <player>";
"This does the exact same thing that loc does on Kristia's FO (#57580) but this one only works on other players.";
if (valid(dobj = $string_utils:match_player(argstr)))
  player:tell($string_utils:nn(dobj));
  #15870:sc();
  player:tell(dobj.psc, " is currently at ", $string_utils:nn(dobj.location), ".");
else
  player:tell("There is no player by that name.");
endif
.

@verb #53206:"dependant_skills" this none this
@program #53206:dependant_skills
{skill, total} = args;
total = listappend(total, skill);
depends = skill.dependant;
if (depends == {{}, {}})
  return total;
endif
depends = $list_utils:append(depends[1], depends[2]);
for dep in (depends)
  total = this:dependant_skills(dep, total);
endfor
return total;
.

@verb #53206:"sarc" none none none rxd
@program #53206:sarc
"Usage: sarc";
"Yes, the name of the original Spiderknight.  This will hopefully tell you which Spiderknights are alive, who they're hunting, what they're hunting, etc.   Thank Lothian for the rebirth of this verb.";
spiders = children(#348);
total = 0;
for spider in (spiders)
  if (spider.location == #10555)
    spiders = setremove(spiders, spider);
  endif
endfor
total = length(spiders);
if (!total)
  return player:tell("They're all dead.  :(");
endif
player:tell_lines($string_utils:columnize({"Drider", "Hunting", "Wielding", "Location"}, 4));
player:tell_lines($string_utils:columnize({"~~~~~~", "~~~~~~~", "~~~~~~~~", "~~~~~~~~"}, 4));
for drider in (spiders)
  if (valid(drider.hunted))
    hunted = drider.hunted.name;
  else
    hunted = "No one";
  endif
  if (valid(drider.location))
    loc = drider.location.name;
  else
    loc = "Limbo";
  endif
  player:tell_lines($string_utils:columnize({drider.name, hunted, drider.mimic.name, loc}, 4));
endfor
player:tell("~~~~~~");
player:tell("There are ", total, " Spiderknights alive and kicking.");
.

@verb #53206:"@ninja*-radar" any any any rxd
@program #53206:@ninja-radar
"Usage: @ninja-radar <on/off>";
"Turning this on will automatically notify you when the ninja is getting close to rebirth.";
if (!(argstr in {"on", "off"}))
  return player:tell("You can only turn the ninja radar 'on' or 'off'.");
elseif (argstr == "on")
  player:tell("You turn your ninja radar on.");
  player.location:announce_all_but({player}, player.name, " turns ", player.pp, " ninja radar on.");
  this.ninja_watchers = setadd(this.ninja_watchers, player);
else
  player:tell("You turn your ninja radar off.");
  player.location:announce_all_but({player}, player.name, " turns ", player.pp, " ninja radar off.");
  this.ninja_watchers = setremove(this.ninja_watchers, player);
endif
.

"#53206:8 --- Permission denied";
"#53206:9 --- Permission denied";
"#53206:10 --- Permission denied";
"#53206:11 --- Permission denied";
"#53206:12 --- Permission denied";
"#53206:13 --- Permission denied";
"#53206:14 --- Permission denied";
@verb #53206:"survey" any none none rxd
@program #53206:survey
"Usage: survey <whatever>";
"survey          -> survey of the room you're in";
"survey <player> -> survey of the room <player> is in";
"survey <room#>  -> survey of <room>";
"Prints a sorted list of all the connected players in a room, their gender, age (if registered with the birthday machine), age in months, idle time, and their shortest alias.  People who are idle more than 5 minutes are bumped to the bottom of the list.";
if (dobjstr == "")
  loc = player.location;
else
  if ((typeof(dobjstr) == STR) && valid(loc = $string_utils:match_player(dobjstr)))
  else
    loc = dobj;
  endif
endif
if (!valid(loc))
  return player:tell("Hrm, invalid target.");
endif
if (is_player(loc))
  loc = loc.location;
endif
{male, female, other} = {{}, {}, {}};
player:tell($string_utils:nn(loc));
player:tell_lines($string_utils:columnize({"Person", "Gender", "Age", "Months", "Idle", "Alias"}, 6));
player:tell_lines($string_utils:columnize({"------", "------", "---", "-------", "----", "-----"}, 6));
players = $set_utils:intersection(connected_players(), loc.contents);
idlers = {};
for who in (players)
  if (idle_seconds(who) > 300)
    idlers = setadd(idlers, who);
  else
    try
      if (who.ps == "she")
        female = setadd(female, who);
      elseif (who.ps == "he")
        male = setadd(male, who);
      else
        other = setadd(other, who);
      endif
    except (E_PERM)
      other = setadd(other, who);
    endtry
  endif
endfor
c = 0;
for grouping in ({female, male, other, idlers})
  c = c + 1;
  $command_utils:suspend_if_needed();
  if ((c == 4) && (grouping != {}))
    player:tell("-Idle-");
  endif
  for who in (grouping)
    $command_utils:suspend_if_needed();
    alias = $list_utils:shortest(who.aliases);
    idle = #15870:abbr_time(sec = idle_seconds(who));
    age = #36714:age(who);
    vage = #36714:vage(who);
    try
      player:tell_lines($string_utils:columnize({who.name, who.gender, age, vage, idle, alias}, 6));
    except (E_PERM)
      player:tell_lines($string_utils:columnize({who.name, "Hidden", age, vage, idle, alias}, 6));
    endtry
  endfor
endfor
player:tell("~~~~~~~~FIN~~~~~~~~");
.

"#53206:16 --- Permission denied";
@verb #53206:"make_scroll" this none this
@program #53206:make_scroll
":make_scroll(header, body) => Return a scroll with the header centered at the top and the body of text centered beneath it, all inside an ASCII scroll.";
{header, body} = args;
if (typeof(body) == STR)
  body = {body};
elseif (typeof(body) != LIST)
  return E_INVARG;
endif
header_length = length(header);
if ($math_utils:mod(header_length, 2) == 1)
  header = tostr(header, " ");
  header_length = header_length + 1;
endif
margin = 6;
body_length = 58;
extra_h_margin = (body_length - header_length) / 2;
scroll = this.scroll_header;
header_margin = tostr($string_utils:space(margin + extra_h_margin, " "));
scroll = {@scroll, tostr("  |", header_margin, header, header_margin, "|"), this.scroll_blank};
for elem in (body)
  elem = $player:linesplit(elem, body_length);
  for line in (elem)
    line_length = length(line);
    if ($math_utils:mod(line_length, 2) == 1)
      line = tostr(line, " ");
      line_length = line_length + 1;
    endif
    extra_l_margin = (body_length - line_length) / 2;
    line_margin = tostr($string_utils:space(margin + extra_l_margin, " "));
    scroll = {@scroll, tostr("  |", line_margin, line, line_margin, "|")};
  endfor
endfor
scroll = {@scroll, @this.scroll_ending};
return scroll;
.

@verb #53206:"@item" any none none rxd
@program #53206:@item
if (valid(res = $local.rpg.dispenser:match_dispensed(dobjstr)))
  return player:tell($string_utils:nn(res));
else
  return player:tell("No match found.");
endif
.

"***finished***