ldmud-3.2.9/doc/
ldmud-3.2.9/doc/efun/
ldmud-3.2.9/mud/
ldmud-3.2.9/mud/heaven7/
ldmud-3.2.9/mud/heaven7/lib/
ldmud-3.2.9/mud/lp-245/
ldmud-3.2.9/mud/lp-245/banish/
ldmud-3.2.9/mud/lp-245/doc/
ldmud-3.2.9/mud/lp-245/doc/examples/
ldmud-3.2.9/mud/lp-245/doc/sefun/
ldmud-3.2.9/mud/lp-245/log/
ldmud-3.2.9/mud/lp-245/obj/Go/
ldmud-3.2.9/mud/lp-245/players/lars/
ldmud-3.2.9/mud/lp-245/room/death/
ldmud-3.2.9/mud/lp-245/room/maze1/
ldmud-3.2.9/mud/lp-245/room/sub/
ldmud-3.2.9/mud/lp-245/secure/
ldmud-3.2.9/mud/morgengrauen/
ldmud-3.2.9/mud/morgengrauen/lib/
ldmud-3.2.9/mud/sticklib/
ldmud-3.2.9/mud/sticklib/src/
ldmud-3.2.9/mudlib/uni-crasher/
ldmud-3.2.9/pkg/
ldmud-3.2.9/pkg/debugger/
ldmud-3.2.9/pkg/diff/
ldmud-3.2.9/pkg/misc/
ldmud-3.2.9/src/autoconf/
ldmud-3.2.9/src/bugs/
ldmud-3.2.9/src/bugs/MudCompress/
ldmud-3.2.9/src/bugs/b-020916-files/
ldmud-3.2.9/src/bugs/doomdark/
ldmud-3.2.9/src/bugs/ferrycode/ferry/
ldmud-3.2.9/src/bugs/ferrycode/obj/
ldmud-3.2.9/src/bugs/psql/
ldmud-3.2.9/src/done/
ldmud-3.2.9/src/done/order_alist/
ldmud-3.2.9/src/done/order_alist/obj/
ldmud-3.2.9/src/done/order_alist/room/
ldmud-3.2.9/src/gcc/
ldmud-3.2.9/src/gcc/2.7.0/
ldmud-3.2.9/src/gcc/2.7.1/
ldmud-3.2.9/src/hosts/
ldmud-3.2.9/src/hosts/GnuWin32/
ldmud-3.2.9/src/hosts/amiga/NetIncl/
ldmud-3.2.9/src/hosts/amiga/NetIncl/netinet/
ldmud-3.2.9/src/hosts/amiga/NetIncl/sys/
ldmud-3.2.9/src/hosts/i386/
ldmud-3.2.9/src/hosts/msdos/byacc/
ldmud-3.2.9/src/hosts/msdos/doc/
ldmud-3.2.9/src/hosts/os2/
ldmud-3.2.9/src/hosts/win32/
ldmud-3.2.9/src/util/
ldmud-3.2.9/src/util/erq/
ldmud-3.2.9/src/util/indent/hosts/next/
ldmud-3.2.9/src/util/xerq/
ldmud-3.2.9/src/util/xerq/lpc/
ldmud-3.2.9/src/util/xerq/lpc/www/
#include <mudlib.h>
#include <material.h>
#include <daemons.h>

#define CAP(xxx) capitalize(xxx)

inherit OBJECT;

object moPlayer;
string msPlayer;
string msShipName;
string msShipClass;

void reset(int iArg) {
  if(!is_clone(this_object())) return;
  ::reset();
  if(iArg) return;
  set_name("ship application");
  set_alias("app");
  add_alias("application");
  set_short("application for ship ownership");
  set_long("\
This is the application you need to fill out before you\n\
can purchase a ship. Please be careful when you do.\n");
  set_value(0);
}

void init() {
  ::init();
  add_action("read_func","read");
  add_action("fillin_func","fillin");
  add_action("junk_it","junk");
}

void setup(object oArg) {
  moPlayer = oArg;
  msPlayer = moPlayer->query_real_name();
}

status is_valid_name(string sText) {
  string junk1;
  string junk2;

  if(sscanf(sText, "%s %s", junk1, junk2) != 2) {
    if(file_size("/banish/" + sText + ".o") >= 0){
      write("You may not use the name of a former player.\n");
      return 0;
    }
    if(find_object(PLAYER_INFO_D))
      destruct(find_object(PLAYER_INFO_D));
    if (PLAYER_INFO_D->restore_player(lower_case(sText)) > 0) {
      write("You may not use the name of a current player.\n");
      return 0;
    }
  }
  junk1 = PROFANITY_D->ProfanityScan(sText,this_player());
  if(junk1 != sText) {
    write("Ship and fleet names may not contain profanity.\n");
    return 0;
  }
  return 1;
}

status read_func(string sArg) {
  if(!id(sArg)) {
    notify_fail("Read what?\n");
    return 0;
  }
  write("\
----------------------------------------------------------------------\n");
  write("\
          Ship Application for " + CAP(msPlayer) + "\n\n");
  write("1) Ship Name: " +
    (msShipName ? CAP(msShipName) : "____________") + "\n");
  write("2) Ship Class: " +
    (msShipClass ? CAP(msShipClass) : "____________") + "\n");
  write("Ship costs per class are as follows:\n");
  write("    Cog -------------- 120000 coins\n");
  write("    Lateen Galley ---- 180000 coins\n");
  write("    Carrack ---------- 400000 coins\n\n");
  write("Please \"fillin [number] [text]\" to complete this application.\n");
  write("When you are finished, \"turnin\" the application at a ship shop.\n\n");
  write("\
----------------------------------------------------------------------\n\n");
  return 1;
}

status fillin_func(string sArg) {
  int iItem;
  string sText;
  string junk1;
  string junk2;

  if(!sArg) {
    notify_fail("Fillin what?\n");
    return 0;
  }
  if(sscanf(sArg,"%d %s",iItem,sText) != 2) {
    notify_fail("\
Please use the proper format. Read your application for details.\n");
    return 0;
  }
  sText = lower_case(sText);
  if(iItem > 2 || iItem < 1) {
    write("There are only 2 items on the application!\n");
    return 1;
  }
  if(iItem == 1) {
    if(SHIP_D->is_ship_name(sText)) {
      write(CAP(sText) + " is already the name of a ship. Choose another name.\n");
      return 1;
    }
    if(sscanf(sText,"%s %s",junk1, junk2) == 2) {
      write("Ship names may not contain spaces.\n");
      return 1;
    }
    if(!is_valid_name(sText)) return 1;
    write("You fill in the name of the ship: \"" + CAP(sText) + "\"\n");
    write("You can always fillin again if you made an error.\n");
    msShipName = sText;
    return 1;
  }
  if(iItem == 2) {
    if(sText != "carrack" && sText != "galley" && sText != "cog") {
      write("\
That is not a valid class of ship! Read your application for valid\n\
choices and their prices.\n");
      return 1;
    }
    write("You fill in the class of the ship: \"" + CAP(sText) + "\"\n");
    write("You can always fillin again if you made an error.\n");
    msShipClass = sText;
    return 1;
  }
}

status junk_it(string sArg) {
  if(!id(sArg))  return 0;
  write("You change your mind and junk the application.\n");
  destruct(this_object());
  return 1;
}

string query_player() {return msPlayer; }
string query_ship_name() {return msShipName; }
string query_ship_class() { return msShipClass; }
status query_finished() {
  if(msShipName &&  msShipClass)
    return 1;
  return 0;
}

int drop(int iSilently) { return 1; }