nakedmudv3.6/
nakedmudv3.6/lib/
nakedmudv3.6/lib/help/A/
nakedmudv3.6/lib/help/B/
nakedmudv3.6/lib/help/C/
nakedmudv3.6/lib/help/D/
nakedmudv3.6/lib/help/G/
nakedmudv3.6/lib/help/H/
nakedmudv3.6/lib/help/J/
nakedmudv3.6/lib/help/L/
nakedmudv3.6/lib/help/M/
nakedmudv3.6/lib/help/O/
nakedmudv3.6/lib/help/P/
nakedmudv3.6/lib/help/R/
nakedmudv3.6/lib/help/S/
nakedmudv3.6/lib/help/W/
nakedmudv3.6/lib/logs/
nakedmudv3.6/lib/misc/
nakedmudv3.6/lib/players/
nakedmudv3.6/lib/txt/
nakedmudv3.6/lib/world/
nakedmudv3.6/lib/world/examples/
nakedmudv3.6/lib/world/examples/mproto/
nakedmudv3.6/lib/world/examples/oproto/
nakedmudv3.6/lib/world/examples/reset/
nakedmudv3.6/lib/world/examples/rproto/
nakedmudv3.6/lib/world/examples/trigger/
nakedmudv3.6/lib/world/limbo/
nakedmudv3.6/lib/world/limbo/room/
nakedmudv3.6/lib/world/limbo/rproto/
nakedmudv3.6/src/alias/
nakedmudv3.6/src/dyn_vars/
nakedmudv3.6/src/editor/
nakedmudv3.6/src/example_module/
nakedmudv3.6/src/help2/
nakedmudv3.6/src/set_val/
nakedmudv3.6/src/socials/
nakedmudv3.6/src/time/
//*****************************************************************************
//
// pcedit.c
//
// These are the functions for editing player files. Can be used to change
// descriptions and other facets of a character.
//
//*****************************************************************************
#include "../mud.h"
#include "../utils.h"
#include "../socket.h"
#include "../character.h"
#include "../races.h"
#include "../handler.h"
#include "../save.h"

#include "olc.h"



//*****************************************************************************
// mandatory modules
//*****************************************************************************
#include "../editor/editor.h"



//*****************************************************************************
// mobile editing
//*****************************************************************************
#define PCEDIT_NAME          1
#define PCEDIT_MULTI_NAME    2
#define PCEDIT_KEYWORDS      3
#define PCEDIT_RDESC         4
#define PCEDIT_MULTI_RDESC   5
#define PCEDIT_RACE          6
#define PCEDIT_SEX           7



void pcedit_menu(SOCKET_DATA *sock, CHAR_DATA *mob) {
  send_to_socket(sock,
		 "{g1) Name\r\n"
		 "{c%s\r\n"
		 "{g2) Name for multiple occurences\r\n"
		 "{c%s\r\n"
		 "{g3) Keywords\r\n"
		 "{c%s\r\n"
		 "{g4) Room description\r\n"
		 "{c%s\r\n"
		 "{g5) Room description for multiple occurences\r\n"
		 "{c%s\r\n"
		 "{g6) Description\r\n"
		 "{c%s\r\n"
		 "{gR) Change race   {y[{c%8s{y]\r\n"
		 "{gG) Change Gender {y[{c%8s{y]\r\n",
		 charGetName(mob),
		 charGetMultiName(mob),
		 charGetKeywords(mob),
		 charGetRdesc(mob),
		 charGetMultiRdesc(mob),
		 charGetDesc(mob),
		 charGetRace(mob),
		 sexGetName(charGetSex(mob))
		 );
}

int  pcedit_chooser(SOCKET_DATA *sock, CHAR_DATA *mob, const char *option) {
  switch(toupper(*option)) {
  case '1':
    text_to_buffer(sock, "Enter name: ");
    return PCEDIT_NAME;
  case '2':
    text_to_buffer(sock, "Enter name for multiple occurences: ");
    return PCEDIT_MULTI_NAME;
  case '3':
    text_to_buffer(sock, "Enter keywords: ");
    return PCEDIT_KEYWORDS;
  case '4':
    text_to_buffer(sock, "Enter room description: ");
    return PCEDIT_RDESC;
  case '5':
    text_to_buffer(sock, "Enter room description for multiple occurences: ");
    return PCEDIT_MULTI_RDESC;
  case '6':
    text_to_buffer(sock, "Enter description\r\n");
    socketStartEditor(sock, text_editor, charGetDescBuffer(mob));
    return MENU_NOCHOICE;
  case 'R':
    send_to_socket(sock, "%s\r\n\r\n", raceGetList(FALSE));
    text_to_buffer(sock, "Please select a race: ");
    return PCEDIT_RACE;
  case 'G':
    olc_display_table(sock, sexGetName, NUM_SEXES, 1);
    text_to_buffer(sock, "Pick a gender: ");
    return PCEDIT_SEX;
  default: return MENU_CHOICE_INVALID;
  }
}

bool pcedit_parser(SOCKET_DATA *sock, CHAR_DATA *mob, int choice, 
		  const char *arg) {
  switch(choice) {
  case PCEDIT_NAME:
    charSetName(mob, arg);
    return TRUE;
  case PCEDIT_MULTI_NAME:
    charSetMultiName(mob, arg);
    return TRUE;
  case PCEDIT_KEYWORDS:
    charSetKeywords(mob, arg);
    return TRUE;
  case PCEDIT_RDESC:
    charSetRdesc(mob, arg);
    return TRUE;
  case PCEDIT_MULTI_RDESC:
    charSetMultiRdesc(mob, arg);
    return TRUE;
  case PCEDIT_RACE:
    if(!isRace(arg))
      return FALSE;
    charSetRace(mob, arg);
    return TRUE;
  case PCEDIT_SEX: {
    int val = atoi(arg);
    if(!isdigit(*arg) || val < 0 || val >= NUM_SEXES)
      return FALSE;
    charSetSex(mob, val);
    return TRUE;
  }
  default: return FALSE;
  }
}

COMMAND(cmd_pcedit) {
  if(!arg || !*arg)
    send_to_char(ch, "You must supply the player's name, first!\r\n");
  else {
    CHAR_DATA *player = get_player(arg);
    if(player == NULL)
      send_to_char(ch, "Player '%s' does not exist!\r\n", arg);
    else {
      do_olc(charGetSocket(ch), pcedit_menu, pcedit_chooser, pcedit_parser,
	     NULL, NULL, unreference_player, save_player, player);
    }
  }
}