Unit DMHelpXP;



Interface

Uses

  Crt;

const

  NumItems: integer = 0;

  MaxNumItems: integer = 30;

var

  XPValue: array[1..30] of longint;

  Description: array[1..30] of string;



Procedure XPTracker;



Implementation



Var

  Option: integer;

  Code: integer;

  UserInput: string;

Const

  StartDisp: integer = 1;



{*************************************************************************}

Procedure Wait;

var

  pause: char;

begin

  writeln;

  write('Hit Enter to continue...');

  readln(pause);

end;



{*************************************************************************}

Procedure DisplayMT;

var

  TotalXP: longint;

  DispMT: integer;

  StopDisp: integer;

  XPAdd: integer;

begin

  clrscr;

  if StartDisp > NumItems then StartDisp := 1;

  StopDisp := StartDisp + 9;

  if StopDisp > NumItems then StopDisp := NumItems;

  for DispMT := StartDisp to StopDisp do

    writeln(DispMT,') ',Description[DispMT],':  ',XPValue[DispMT]);

  writeln;

  TotalXP := 0;

  for XPAdd := 1 to NumItems do

    TotalXP := TotalXP + XPValue[XPAdd];

  writeln('Total XP for ',NumItems,' items:  ',TotalXP);

  writeln;

end;

{*************************************************************************}

Procedure WriteGetOptions;

type

   OptionsArray = array[1..4] of string;

const

  Options: OptionsArray = (

    '1)  Enter Monster and/or Treasure',

    '2)  Delete Monster and/or Treasure',

    '3)  Display Next 10 Monster/Treasure Descriptions',

    '4)  Quit to Main Menu'

    );

  NumOptions: integer = 4;

var

  OptionNum: integer;

  OptionChar: char;

begin

  for OptionNum := 1 to NumOptions do

    writeln(Options[optionNum]);

  repeat

    writeln;

    write('Option:  ');

    OptionChar := readkey;

    writeln(OptionChar);

    val(OptionChar, Option, code)

  until Option in [1..NumOptions];

end;



{***************************************************************************}

Procedure AddMT;

begin

  writeln;

  If NumItems + 1 > MaxNumItems then

    begin

      writeln('Maximum number of items already loaded.');

      wait;

      exit;

    end;

  NumItems := NumItems + 1;

  write('Description:  ');

  readln(Description[NumItems]);

  write('Experience Point Value:  ');

  readln(UserInput);

  val(UserInput,XPValue[NumItems],code);

end;



{***************************************************************************}

Procedure DelMT;

var

  Deleted: integer;

  CleanUp: integer;

begin

  writeln;

  write('Delete which Monster/Treasure [0 to exit]:  ');

  readln(UserInput);

  val(UserInput,Deleted,code);

  if (Deleted <= 0) or (Deleted > NumItems) then exit;

  NumItems := NumItems - 1;

  for Cleanup := Deleted to NumItems do

    begin

      Description[Cleanup] := Description[Cleanup + 1];

      XPValue[CleanUp] := XPValue[CleanUp + 1];

    end;

end;

{***************************************************************************}

{***************************************************************************}

{***************************************************************************}

Procedure XPTracker;

var

  Quit: boolean;

begin

  repeat

    Quit := false;

    DisplayMT;

    WriteGetOptions;

    Case Option of

      1:  AddMT;

      2:  DelMT;

      3:  StartDisp := StartDisp + 10;

      4:  Quit := true;

    end;

  until Quit;

end;

end.