;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[@IntegralExchange]
{
#ACT
  Mov     A7  ""
  FormatStr "FLD_CHARACTER='%s'" %USERNAME
  ReadValueSql  "TBL_INTEGRAL"  %A9  "FLD_CHARACTER,FLD_INTEGRAL" [@IntegralExchange1]
[@IntegralExchange1()]
#ACT
   Mov    A0      %ARG(1)
   Mov    D2      %ARG(2)
#SAY
Hi, {FCOLOR/10}<$USERNAME>{FCOLOR/12} I am your local Integral Exchange\\
Integral(1) scrolls are worth 1\
Integral(20) scrolls are worth 20\
Integral(500) scrolls are worth 500\\
You Currently have {FCOLOR/1}<$OUTPUT(D2)>{FCOLOR/12} Integral\\
<[ Continue ]/@ChangeSomeInt>\
<[ Back ]/@IntegralMainMenu>\\\

[@ChangeSomeInt]
#SAY
You Currently have {FCOLOR/1}<$OUTPUT(D2)>{FCOLOR/12} Integral\
<[ Exchange Integral for Integral(1) Scrolls ]/@ExSmallInt(Integral(1),1)>\
<[ Exchange Integral for Integral(20) Scrolls ]/@ExSmallInt(Integral(20),20)>\
<[ Exchange Integral for Integral(500) Scrolls ]/@ExSmallInt(Integral(500),500)>\
<[ Exchange Integral(1) scrolls for Integral ]/@ExForLargeInt(Integral(1),1)>\
<[ Exchange Integral(20) scrolls for Integral ]/@ExForLargeInt(Integral(20),20)>\
<[ Exchange Integral(500) scrolls for Integral ]/@ExForLargeInt(Integral(500),500)>\
<[ Exit  ]/@Exit>\\
;------------------------------------------------------------------------------------
[@ExSmallInt()]
#ACT
Mov  A0  %ARG(1)
Mov  D0  %ARG(2)
#SAY
How many <$OUTPUT(A0)> scrolls would you like to Purchase?\
<[ Enter Qty Of Scrolls ]/@@EnterQtySmall> - Maximum 25\
<[ Exit ]/@Exit>


[@@EnterQtySmall]
#ACT
   Mov  D1   %INPUTSTR
   Mov  D2   25
#IF
   Small   D1  0
#SAY
Do Not try and cheat the system, you Username has been logged!\\
<[ Exit ]/@Exit>\
#ACT
   Mov     A7 %USERNAME
   AddStr  A7 ",,IntegralFraud,"
   AddStr  A7 %D1
   Savelog "QuestDiary\IntegralSystem\IntegralLog.txt" %A7
   Break
#IF
   !Equal  D1  ""
   !Equal  D1  0
   !Large  D1  %D2
#ACT
   Mov  P1   %D0
   Mov  P2   %D1
   Mul  P1   P2
   Mov  D3   %P9
#SAY
This will cost you {FCOLOR/10}<$OUTPUT(D3)>{FCOLOR/12}Integral\
Is this OK?\
<[ Yes ]/@CheckExInt>\
<[ No ]/@Exit>\


[@CheckExInt]
#ACT
   FormatStr "FLD_CHARACTER='%s'" %USERNAME
   ReadValueSql  "TBL_INTEGRAL"  %A9  "FLD_CHARACTER,FLD_INTEGRAL" [@CheckExInt1]


[@CheckExInt1()]
#IF
#ACT
   Mov    D2      %ARG(2)
#IF
   Small D3 %D2
#ACT
   FormatStr "FLD_CHARACTER='%s'" %USERNAME
   Mov   A8     %A9
   Dec   D2     %D3
   Mov   D4     %D2
   FormatStr "FLD_INTEGRAL='%s'" %D4
   UPDATEVALUESQL "TBL_INTEGRAL" %A8 %A9
   Give %A0 %D1
   Mov     A7 %USERNAME
   AddStr  A7 ","
   AddStr  A7 %D3
   AddStr  A7 ","
   AddStr  A7 %A0
   AddStr  A7 ",-"
   AddStr  A7 %D1
   Savelog "QuestDiary\IntegralSystem\IntegralLog.txt" %A7
#SAY
You have spent {FCOLOR/10}<$OUTPUT(D3)>{FCOLOR/12} Integral\
Your current Integral is {FCOLOR/10}<$OUTPUT(D4)>{FCOLOR/12}\
<[ Back ]/@IntegralMainMenu>
#ELSESAY
You do not have enough Integral Points\
Your current Integral is {FCOLOR/10}<$OUTPUT(D1)>{FCOLOR/12}\
<[ Back ]/@IntegralMainMenu>

;------------------------------------------------------------------------------------
[@ExForLargeInt()]
#ACT
Mov  A0  %ARG(1)
Mov  D0  %ARG(2)
#SAY
How many <$OUTPUT(A0)> scrolls would you like to Sell?\
<[ Enter Qty Of Scrolls ]/@@EnterQtyForLarge>\
<[ Exit ]/@Exit>


[@@EnterQtyForLarge]
#ACT
   Mov  D1   %INPUTSTR
#IF
  !Equal   D1  ""
   Large   D1  0
#ACT
   Mov  P1  %D0
   Mov  P2  %D1
   Mul  P1  P2
   Mov  D3  %P9
#SAY
This will Give you {FCOLOR/10}<$OUTPUT(D3)>{FCOLOR/12} Integral\
Is this OK?\
<[ Yes ]/@CheckExForLarge>\
<[ No ]/@Exit>\


[@CheckExForLarge]
#ACT
   FormatStr "FLD_CHARACTER='%s'" %USERNAME
   ReadValueSql  "TBL_INTEGRAL"  %A9  "FLD_CHARACTER,FLD_INTEGRAL" [@CheckExForLarge1]


[@CheckExForLarge1()]
#ACT
   Mov    D2      %ARG(2)
#IF
   CheckItem %A0 %D1
#ACT
   FormatStr "FLD_CHARACTER='%s'" %USERNAME
   Mov   A8     %A9
   Inc   D2     %D3
   Mov   D4     %D2
   FormatStr "FLD_INTEGRAL='%s'" %D4
   UPDATEVALUESQL "TBL_INTEGRAL" %A8 %A9
   Take    %A0 %D1
   Mov     A7  %USERNAME
   AddStr  A7  ",-"
   AddStr  A7  %D3
   AddStr  A7  ","
   AddStr  A7  %A0
   AddStr  A7  ","
   AddStr  A7  %D1
   Savelog "QuestDiary\IntegralSystem\IntegralLog.txt" %A7
#SAY
You have gained {FCOLOR/10}<$OUTPUT(D3)>{FCOLOR/12} Integral\
Your current Integral is {FCOLOR/10}<$OUTPUT(D4)>{FCOLOR/12}\
<[ Back ]/@IntegralMainMenu>\
#ELSESAY
You do not have enough Integral(50) scrolls\
Your current Integral is {FCOLOR/10}<$OUTPUT(D1)>{FCOLOR/12}\
<[ Back ]/@IntegralMainMenu>\

}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;