home *** CD-ROM | disk | FTP | other *** search
/ UnrealScript Game Programming All in One / UnrealScriptGameProgrammingAllInOne.iso / UGPAIOListings / UGPAIOListingsCh14 / CH14LIST / Classes / CH14_06LIST.uc < prev   
Encoding:
Text File  |  2006-02-07  |  1.9 KB  |  75 lines

  1. // %PARAMETERS = "CH14LIST C:\UT2004"
  2. //Identifies the package
  3. //CH14_06LIST.uc
  4.  
  5. class CH14_06LIST extends Commandlet;
  6. function int Main(string Args){
  7. //do while loops
  8. //#1
  9. local Array<string> rgQuartzValues;
  10. local string szQuartzValues, szHead;
  11. local int iLIMIT, iCtr, iScore, iPoint, iHW;
  12.  
  13. szHead = "";
  14. iPoint = 0; iHW = 55; iCtr = 0; iScore = 0;
  15.  
  16. //Set up a list of items, colon delimited
  17. //to allow for white spaces
  18. szQuartzValues  =  "Amethyst:Modest:Citrine: High"$
  19.                    ":Rose  :High :Colorless: Low"$
  20.                    ":Cat's-eye:Low:Chal'dony: High"$
  21.                    ":Adventurine:Modest";
  22.  
  23. iLIMIT =  Split(szQuartzValues, ":" , rgQuartzValues);
  24.  
  25. //#1
  26. //Make a line
  27.    do{
  28.    //Concatenate characters into a line
  29.       szHead $= Chr(178);
  30.       iCtr++;
  31.    }until(iCtr > iHW);
  32.  
  33. Log(" " $ Chr(10) @ "CH14_05LIST" @ Chr(10));
  34. //#2
  35. //Introduce the loop
  36. Log(" " $szHead);
  37. Log("             Quartz Luck");
  38. Log(" " $szHead $ Chr(10));
  39.  
  40.    iCtr = 0;
  41. //Start the infinite loop
  42.    while(true){
  43.       iCtr++;
  44.       //#3
  45.       //First test - exit the loop
  46.       if(iCtr > 7){
  47.           Log("  You lose. ...... ");
  48.           break;
  49.       }
  50.      //#4
  51.      //Generate random values for scores
  52.      //and to retrieve items
  53.       iPoint = Rand((iLIMIT-2));
  54.       if(iScore >= 17){
  55.            Log( iScore $ "!!!... You Win !!! ");
  56.            break;
  57.            //continue;
  58.       }
  59.  
  60.       //#5
  61.       //Display the quartzes with each iteration
  62.       //retrieve values, and add up the score
  63.       if(iPoint % 2 == 0){
  64.          Log("  Points--" $ iPoint $ "--"
  65.                     $ rgQuartzValues[iPoint] $ Chr(9) $ Chr(9)
  66.                     $ rgQuartzValues[iPoint + 1 ]);
  67.           //Add up the score
  68.           iScore += iPoint;
  69.       }
  70.       Log( Chr(10) $ " Score now: "  $ iScore $ "...");
  71.       //Increment by to so skip alternates
  72.    }
  73.   return 0;
  74. }
  75.