/*   $VER: The Shadow's EdGe Die Roller V1.3   By FishBone   9/8/96   */
/*         A dice roller for use with Online RPG's & CNet 3.+         */

options results;signal on SYNTAX;dignal on ERROR;signal on IOERR
tr=transmit;gu=getuser;gc=getchar
gu 1;han=result;gu 12;dt=result;gu 40;act=result;gu 15;acc=result
changewhere 'Rolling Dice!';

dp='gfiles:dice/'   /*   The path where you put the Dice Directory         */
Maint=25            /*   Lowest Access group able to edit the Dice Logs    */


tr"";prompt 3 yesno ">17}cdWould you like to Muffle All ports?c5[cbYc5/c3nc5]cb";muf=upper(result)
  if muf='NO' then signal begin;if muf='YES' then bbscommand 'mu *';
begin:
call panic
tr"[H[J@6[0;1m                        [2;22H[37;44m                                      [3;22H                                      [4;22H                                      [5;22H                                      [6;22H                                      [7;22H                                      [8;22H                                      [9;22H                                      [10;22H                                      [3;24H[37;45m   [0;1;5m[37;45m                              [4;24H                                 [0m [5;24H[37;45m                                 [37;40m [6;24H[37;45m                                 [37;40m [7;24H[37;45m                                 [37;40m [8;24H[37;45m                                 [37;40m [9;25H                                 [37;44m  [2;22H                            [3;24H[0;1m[37;45mÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»[4;56Hº[5;56Hº[6;56Hº[7;56Hº[8;56H¼[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÍ[2DÈ[7;24Hº[6;24Hº[5;24Hº[4;24Hº[5;35H[0;1;5m[37;45m[[33;45mR[37;45m][0;5m[37;45moll Dice[6;32H[0;1;5m[37;45m[[33;45mV[37;45m][0;5m[37;45miew Dice Rolls[7;37H[0;1;5m[37;45m[[33;45mQ[37;45m][0;5m[37;45muit[2;22H[0m[37;44m                                      [3;59H [4;59H [2A[37;40m [3;60H [4;60H [5;60H [6;60H [7;60H [8;60H [9;60H [10;60H [2;26H[37;44m [11;22H                                      [4;32H[0;5m[30;45m Die Roller V1.3[10;35H[0;1;5m[30;44mBy FishBone[11;22H[0m[30;40m                                      [1;9H[30;47m                                                                [2;9H             [38C             [3;9H             [40C           [4;9H             [40C           [5;9H             [40C           [6;9H             [40C           [7;9H             [40C           [8;9H             [40C           [9;9H             [40C           [10;9H             [40C           [11;9H               [38C           [12;9H                                                                [2;31H[0;5m[37;44m The [0;1;5m[30;44mShadow's [0;5m[37;44mEdGe[13;1H[0m                                                                                [1A  [m"
tr"" ; tr"" ; tr"" ; prompt 1 normal  "c9>30}Your Choice?c1[cbRc1/cbVc1/cbQc1]cb "
              st=upper(result)
              if index("R,V,Q",st)=0 & c2d(st)~=27 then do
                signal begin ; end
              if st = R then signal setup
              if st = V then signal view
              if st = Q then signal out

setup:
   tr""
   prompt 3 normal '"caWhat size die Would you like to roll,cd' han'ca?cb(4,6,8,10,12,20,100)ca:c9"'
     d=result
     if d='###PANIC' then call panic
     if index("4,6,8,10,12,20,100,",d)=0 & c2d(d)~=27 then do
       tr "n1}Please Enter 4,6,8,10,12,20,100" ; signal setup; end
  if d=100 then signal times ; if d=20 then signal times ; if d=12 then signal times
  if d=10 then signal times ; if d=8 then signal times ; if d=6 then signal times
  if d=4 then signal times;else signal inv

Times:
    tr"";query "caHow Many times would you like to roll thec9" d "casided die?c9"
      t=result
        if t='###PANIC' then call panic
        if Index("1,2,3,4,5,6,7,8,9,10,t",t)=0 & c2d(t)~=27 then do
          tr "cdPlease enter a Number Between one & Ten" ; signal times ; end      

ok:
    tr"" ; prompt 1 normal  "caYou want to roll ac9" d "caSided diec9" t "catimes?c1[cbYc1/c3nc1/c3qc1]cb "
      ata=Upper(result) 
        if ata='###PANIC' then call panic
          if ata='N' then signal setup; if ata='Y' then signal roll;if ata='Q' then signal Begin

roll:
  do i=1 to t ; di.i=random(1,d,time(s)) ; tr"";end i 
  if t=1 then do
    sin='c9'di.1
      tot=di.1
    end
  if t=2 then do
    sin='c9'di.1 "cf& ac9" di.2
      tot=di.1+di.2
    end
  if t=3 then do
    sin='c9'di.1"cf,c9" di.2 "cf& ac9" di.3
      tot=di.1+di.2+di.3
    end
  if t=4 then do
    sin='c9'di.1"cf,c9" di.2"cf,c9" di.3 "cf& ac9" di.4
      tot=di.1+di.2+di.3+di.4
    end
  if t=5 then do
    sin='c9'di.1"cf,c9" di.2"cf,c9" di.3"cf,c9" di.4 "cf& ac9" di.5
      tot=di.1+di.2+di.3+di.4+di.5
    end
  if t=6 then do
    sin='c9'di.1"cf,c9" di.2"cf,c9" di.3"cf,c9" di.4"cf,c9" di.5 "cf& ac9" di.6
      tot=di.1+di.2+di.3+di.4+di.5+di.6
    end
  if t=7 then do
    sin='c9'di.1"cf,c9" di.2"cf,c9" di.3"cf,c9" di.4"cf,c9" di.5"cf,c9" di.6 "cf& ac9" di.7
      tot=di.1+di.2+di.3+di.4+di.5+di.6+di.7
    end
  if t=8 then do
    sin='c9'di.1"cf,c9" di.2"cf,c9" di.3"cf,c9" di.4"cf,c9" di.5"cf,c9" di.6"cf,c9" di.7 "cf& ac9" di.8
      tot=di.1+di.2+di.3+di.4+di.5+di.6+di.7+di.8
    end
  if t=9 then do
    sin='c9'di.1"cf,c9" di.2"cf,c9" di.3"cf,c9" di.4"cf,c9" di.5"cf,c9" di.6"cf,c9" di.7"cf,c9" di.8 "cf& ac9" di.9
      tot=di.1+di.2+di.3+di.4+di.5+di.6+di.7+di.8+di.9
    end
  if t=10 then do
    sin='c9'di.1"cf,c9" di.2"cf,c9" di.3"cf,c9" di.4"cf,c9" di.5"cf,c9" di.6"cf,c9" di.7"cf,c9" di.8"cf,c9" di.9 "cf& ac9" di.10
      tot=di.1+di.2+di.3+di.4+di.5+di.6+di.7+di.8+di.9+di.10
    end

show:
  call panic
    u=t-1;if tb>1 then z="^"u"}";if t=1 then z=""
    tr z"cfYou rolled a" sin "cffor a total ofc9" tot
    call open('rolls.dat',dp'rolls.dat','A')
      call writeln('rolls.dat','n1cfOncc' dt'm, cd'han 'cfRolled a c5't'c7dcd'd 'cf& got an1>20}c9'sin 'cffor a total ofc9' tot'w1')
    call close('rolls.dat'); tr""
    prompt 3 yesno "caWould you like to roll more dice?c1[cbYc1/c3nc1]c9"
      re=upper(result)  
        if re='###PANIC' then call panic
      if re='YES' then signal setup ; if re='NO' then  signal Begin    

view:
   call panic
      sendstring'f1*0'dp'rolls.dat}'  
        if acc>=maint then signal edit;else tr "cbHit a Keyg1" ; signal begin

edit:
  call panic
    query "n1ccWould you like to cf[cdCcf]cclear, cf[cdEcf]ccdit, or cf[cdQcf]ccuit the Dice Log?cd "
      ed=upper(result)
        if ed='###PANIC' then call panic
      if index("Q,C,E,ed",ed)=0 & c2d(ed)~=27 then signal edit
    if ed='Q' then signal begin;if ed='C' then do
      call open('rolls.dat',dp'rolls.dat','W')
        call writeln('rolls.dat','>25}cfThe c7o1Shadow''so0 cfEdGe c9Die Roller V1.0');call close('rolls.dat')
      call open('rolls.dat',dp'rolls.dat','A')
        call writeln('rolls.dat','>35}cdo1By FishBoneo0')
        call writeln('rolls.dat','>33}c9o1u1 Die Roller Log u0o0n1');call close('rolls.dat')
      signal begin;end
    if ed='E' then do
      loadeditor dp'rolls.dat';calleditor;if result=1 then saveeditor dp'rolls.dat'
      if result=1 then cleareditor;signal begin 
    end

out:
  tr"";tr"";tr center("cfThe c7o1Shadow'so0 cfEdGe c9Die Roller V1.3 cdBy FishBone!",102)
    tr center("cfThanks For Playing!",84) 
      tr center("ccCall cfThe c7o1Shadow'so0 cfEdGe ccBBs!",100)
      tr center("cd(813)578-5197",80)
      tr center("cd(813)577-5266",80)
  tr"" ;cleareditor;if muf='YES' then  bbscommand 'mu *';exit

inv:
  tr""
  tr"c9Please Enter 4,6,8,10,12,20,100"
    signal setup

Panic:
  getcarrier
    if result='TRUE' then return
  bufferflush
  exit
  
error:
    tr center("c9An Error has occured!!!",80)
      tr center("cdNotify SysOp!!!",80)
  exit

syntax:
    tr center("c9A Syntax Error has occured!!!",80)
      tr center("cdNotify SysOp!!!",80)
  exit

ioerr:
    tr center("c9An I/O Error has occured!!!",80)
      tr center("cdNotify SysOp!!!",80)
  exit