Quick background on myself. This is my first time coding in PHP. I have a computer information systems degree, learned C++, VB, Cobol and Java in college (about 15 years ago), but have not really used it since. Some stuff is coming back to me as I learn this.
I'm attempting to simulate the opening of randomized packs of cards for a trading card game. The end result would be printing out 4 pages. Each page will list 12 card numbers, and all of the information on the card.
Here's what I was planning on doing:
Step One: Generate 180 random numbers from different ranges. Each number represents a card in the game.
- range 1 = 35-74 (116 numbers)
- range 2 = 75-106 (46 numbers)
- range 3 = 107-134 (16 numbers, no duplicates)
- range 4 = 135-142 (2 numbers, no duplicates)
Step Two: Take the 180 numbers and break them down into 90 pairs.
Step Three: From the 90 pairs, break them down to 4 sets of 6 pairs.
Step Four: From the 4 sets of 6 pairs, list the card information for each number and make 4 printable pages, 1 for each set.
I've gotten as far as creating the 180 random numbers. I'm still working on getting the unique numbers. I've tried creating arrays for the numbers I need, but none of them work. Here's the last working code I have, which will generate the 180 numbers I need, however, range 3 and 4 need to be fixed to not allow duplicates.
The way i currently have this coded, it just displays the numbers on the screen. Should I be storing them in an array? Am I just completely tackling the wrong way?
<?php
// generate 116 common cards
echo "Commons: " . '<br />';
for ($commonfeed = 0; $commonfeed < 116; $commonfeed++) {
echo mt_rand(35, 74). '<br />';
}
// generate 46 uncommon cards
echo "Uncommons: " . '<br />';
for ($uncommonfeed = 0; $uncommonfeed < 46; $uncommonfeed++) {
echo mt_rand(75, 106). '<br />';
}
// generate 16 rare cards
echo "Rares: " . '<br />';
for ($rarefeed = 0; $rarefeed < 16; $rarefeed++) {
echo mt_rand(107, 134). '<br />';
}
// generate 2 super rare cards
echo "Super Rares: " . '<br />';
for ($superrarefeed = 0; $superrarefeed < 2; $superrarefeed++) {
echo mt_rand(135, 142). '<br />';
}
?>