Unit Monsters;



interface

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

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

Uses

  DMAid_G;



Procedure MonsterAdd(MonFile: string);

Procedure MonsterGet(MonFile: string; var MonRec: MonsterRec);

Function  MonsterInput(InChar: char): boolean;

Procedure MonsterMenu;

Procedure MonsterShow(MonRec: MonsterRec);



implementation

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

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

Uses

  Globals,

  SubProgs;



Procedure MonsterAdd(MonFile: string);

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

var

  MonRec: MonsterRec;

  MF: MonsterFile;

begin

  WinIn(WinMon);

  with MonRec do

    begin

      MonName := AskStr('Monster Name');

      with Num do

        begin

          Mul := AskIntDef('Number Multiplier', 1, MaxInt, 1);

          Die := AskIntDef('Hit Die', 1, MaxInt, 8);

          Bas := AskIntDef('Bonus', 0, MaxInt, 0);

        end;

      Thac0 := AskIntDef('THAC0', -MaxInt, MaxInt, 20);

      with HD do

        begin

          Mul := AskIntDef('Number Multiplier', 1, MaxInt, 1);

          Die := AskIntDef('Hit Die', 1, MaxInt, 8);

          Bas := AskIntDef('Bonus', 0, MaxInt, 0);

        end;

      Damage := AskStr('Damage');

      XP := AskIntDef('Experience Points', 0, MaxLongInt, 0);

    end;

  WinOut(WinMon);

  DumBool := FileExistsMake(MonFile);

  Assign(MF, MonFile);

  Reset(MF);

  Seek(MF, FileSize(MF));

  write(MF, MonRec);

  Close(MF);

end;



Procedure MonsterGet(MonFile: string; var MonRec: MonsterRec);

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

var

  MF: MonsterFile;

begin

  Assign(MF, MonFile);

  Reset(MF);

  Seek(MF, DiceRoll(1, FileSize(MF), 0) - 1);

  Read(MF, MonRec);

  Close(MF);

end;



Function  MonsterInput(InChar: char): boolean;

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

var

  Temp: boolean;

  MonFile: string;

  MonRec: MonsterRec;

begin

  MonFile := 'Level1.DMA';

  Temp := true;

  case InChar of

    '1':

      begin

        MonsterGet(MonFile, MonRec);

        MonsterShow(MonRec);

      end;

    '2': MonsterAdd(MonFile);

    else

      Temp := false;

  end; {case}

  MonsterInput := Temp;

end;



Procedure MonsterMenu;

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

begin

  WinIn(WinMenu);

  Clr;

  write('MONSTERS:  1) Get Monster 2) Make Monster');

  WinOut(WinMenu);

end;



Procedure MonsterShow(MonRec: MonsterRec);

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

var

  Number: integer;

  alpha: integer;

begin

  WinIn(WinMon);

  with MonRec do

    begin

      Writeln('Monster: ', MonName, '  ');

      with Num do

        Number := DiceRoll(Mul, Die, Bas);

      Write('Number Appearing: ', Number,'   ');

      write('THAC0: ',Thac0,'   ');

      Write('XP: ',XP,'   ');

      with HD do

        begin

          writeln('Hit Die: ',Mul,'D',Die,'+',Bas,'   ');

          Writeln('Damage: ',Damage,'   ');

          write('Hit Points: ');

          for alpha := 1 to Number do

            write(DiceRoll(Mul, Die, Bas), ' ');

        end;

    end; {with}

  WinOut(WinMon);

end;





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

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

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

begin

end.