Skip to content

Commit

Permalink
Merge pull request #893 from GKnirps/king_python_pollution_reason
Browse files Browse the repository at this point in the history
Fix pick of pollution reason in python King
  • Loading branch information
coding-horror authored Aug 28, 2023
2 parents c0ce909 + fa4f688 commit def6d26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
14 changes: 8 additions & 6 deletions 01_Acey_Ducey/python/acey_ducey.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import random


cards = {
2: "2",
3: "3",
Expand All @@ -22,18 +23,19 @@
14: "Ace",
}


def play_game() -> None:
cash = 100
while cash > 0:
print(f"You now have {cash} dollars\n")
print("Here are you next two cards")
round_cards = list(cards.keys()) # gather cards from dictionary
card_a = random.choice(round_cards) # choose a card
card_b = card_a # clone the first card, so we avoid the same number for the second card
while (card_a == card_b): # if the cards are the same, choose another card
round_cards = list(cards.keys()) # gather cards from dictionary
card_a = random.choice(round_cards) # choose a card
card_b = card_a # clone the first card, so we avoid the same number for the second card
while (card_a == card_b): # if the cards are the same, choose another card
card_b = random.choice(round_cards)
card_c = random.choice(round_cards) # choose last card
if card_a > card_b: # swap cards if card_a is greater than card_b
card_c = random.choice(round_cards) # choose last card
if card_a > card_b: # swap cards if card_a is greater than card_b
card_a, card_b = card_b, card_a
print(f" {cards[card_a]}")
print(f" {cards[card_b]}\n")
Expand Down
10 changes: 5 additions & 5 deletions 53_King/python/king.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,17 @@ def handle_tourist_trade(self) -> None:
tourist_trade_earnings = V1 - V2
print(f" YOU MADE {tourist_trade_earnings} RALLODS FROM TOURIST TRADE.")
if V2 != 0 and not (V1 - V2 >= self.tourism_earnings):
print(" DECREASE BECAUSE ")
print(" DECREASE BECAUSE ", end="")
reason = randint(0, 10)
if reason <= 2:
print("FISH POPULATION HAS DWINDLED DUE TO WATER POLLUTION.")
if reason <= 4:
elif reason <= 4:
print("AIR POLLUTION IS KILLING GAME BIRD POPULATION.")
if reason <= 6:
elif reason <= 6:
print("MINERAL BATHS ARE BEING RUINED BY WATER POLLUTION.")
if reason <= 8:
elif reason <= 8:
print("UNPLEASANT SMOG IS DISCOURAGING SUN BATHERS.")
if reason <= 10:
else:
print("HOTELS ARE LOOKING SHABBY DUE TO SMOG GRIT.")

# NOTE: The following two lines had a bug in the original game:
Expand Down

0 comments on commit def6d26

Please sign in to comment.