SHARE
TWEET

Untitled

a guest Jan 18th, 2020 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const int numberOfUnitTypes = 8;
  2. const int numberOfRolls = 4;
  3.  
  4. function PopulateMarketplace()
  5. {
  6.     <Clear marketplace>
  7.     // Each integer in this array represents the stock of a particular kind of unit
  8.     int unitCounts[numberOfUnitTypes] = {0, 0, 0, 0};
  9.  
  10.     for(int i = 0; i < numberOfRolls; i++)
  11.     {
  12.         int roll = <random number between 0..numberOfUnitTypes>
  13.         unitCounts[roll]++;
  14.     }
  15.  
  16.     int marketplaceIndex = 0;
  17.     for(int i = 0; i < numberOfUnitTypes; i++)
  18.     {
  19.         if(unitCounts[i] != 0)
  20.         {
  21.             <Add unit to marketplace at position 'marketplaceIndex' with stock equal to 'unitCounts[i]'>
  22.             marketplaceIndex++;
  23.         }
  24.     }
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top