home *** CD-ROM | disk | FTP | other *** search
- // %PARAMETERS = "CH14LIST C:\UT2004"
- //Identifies the package
- //CH14_06LIST.uc
-
- class CH14_06LIST extends Commandlet;
- function int Main(string Args){
- //do while loops
- //#1
- local Array<string> rgQuartzValues;
- local string szQuartzValues, szHead;
- local int iLIMIT, iCtr, iScore, iPoint, iHW;
-
- szHead = "";
- iPoint = 0; iHW = 55; iCtr = 0; iScore = 0;
-
- //Set up a list of items, colon delimited
- //to allow for white spaces
- szQuartzValues = "Amethyst:Modest:Citrine: High"$
- ":Rose :High :Colorless: Low"$
- ":Cat's-eye:Low:Chal'dony: High"$
- ":Adventurine:Modest";
-
- iLIMIT = Split(szQuartzValues, ":" , rgQuartzValues);
-
- //#1
- //Make a line
- do{
- //Concatenate characters into a line
- szHead $= Chr(178);
- iCtr++;
- }until(iCtr > iHW);
-
- Log(" " $ Chr(10) @ "CH14_05LIST" @ Chr(10));
- //#2
- //Introduce the loop
- Log(" " $szHead);
- Log(" Quartz Luck");
- Log(" " $szHead $ Chr(10));
-
- iCtr = 0;
- //Start the infinite loop
- while(true){
- iCtr++;
- //#3
- //First test - exit the loop
- if(iCtr > 7){
- Log(" You lose. ...... ");
- break;
- }
- //#4
- //Generate random values for scores
- //and to retrieve items
- iPoint = Rand((iLIMIT-2));
- if(iScore >= 17){
- Log( iScore $ "!!!... You Win !!! ");
- break;
- //continue;
- }
-
- //#5
- //Display the quartzes with each iteration
- //retrieve values, and add up the score
- if(iPoint % 2 == 0){
- Log(" Points--" $ iPoint $ "--"
- $ rgQuartzValues[iPoint] $ Chr(9) $ Chr(9)
- $ rgQuartzValues[iPoint + 1 ]);
- //Add up the score
- iScore += iPoint;
- }
- Log( Chr(10) $ " Score now: " $ iScore $ "...");
- //Increment by to so skip alternates
- }
- return 0;
- }
-