Hello,
I have been working on a very simple Python Game so far (Not using pygame atm) and I ran into a problem that is very simple but I just do not know what to use to get it to work.
Basically what I have right now is that the player will deal a set of cards. Each card will be randomized with a simple code:
card1 = random.randrange(1,10)
card2 = random.randrange(1,10)
card3 = random.randrange(1,10)
card4 = random.randrange(1,10)
card5 = random.randrange(1,10)
The problem I am having is that after randomizing the cards, I do not know how to make it so that if the card is equal to 1, it will execute a different function then if it was 5.
For example, a simple tower-tower block battle. Each castle starts with 50 blocks. Using this randomizer with cards, if the random numbers are odd, X number of blocks will be deducted from the 2nd player's tower. If the random numbers are even, X number of blocks will be added to your tower.
I was wondering if this was possible (It probably is), but I still feel I haven't explained this right.
Let me put it this way.
"randomnumber1" will do the following:
Add 5 Blocks to your tower.
Print a message.
Discard the card.
"randomnumber2" will do the following:
Delete 5 Blocks to other tower.
Print a message.
Discard the card.
I "Deal" the cards. My first card is a random number of 2. If I decide to use my first card, it will execute "randomnumber2".
So basically I am wondering if I could:
- Set up executable lines of code such as "randomnumber1" and 2.
- Link the randomized number to the executable lines of code depending on the number.
- "Use" the card to execute the commands of the code.
Please tell me if you need more clarification in what I am trying to say! I would love to get some help on this. I have been googling for a few hours now :@
Thanks!