Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int numberOfUnitTypes = 8;
- const int numberOfRolls = 4;
- function PopulateMarketplace()
- {
- <Clear marketplace>
- // Each integer in this array represents the stock of a particular kind of unit
- int unitCounts[numberOfUnitTypes] = {0, 0, 0, 0};
- for(int i = 0; i < numberOfRolls; i++)
- {
- int roll = <random number between 0..numberOfUnitTypes>
- unitCounts[roll]++;
- }
- int marketplaceIndex = 0;
- for(int i = 0; i < numberOfUnitTypes; i++)
- {
- if(unitCounts[i] != 0)
- {
- <Add unit to marketplace at position 'marketplaceIndex' with stock equal to 'unitCounts[i]'>
- marketplaceIndex++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement