Skip to content

Commit 43d6c92

Browse files
Implement file handling
1 parent abcaee5 commit 43d6c92

File tree

1 file changed

+11
-87
lines changed

1 file changed

+11
-87
lines changed

Tarot Reader/tarot_card_reader.py

Lines changed: 11 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,12 @@
11
import random
22

33

4-
# tarot deck of 78 cards and 'predictions'
5-
tarot_deck = [
6-
"The Fool: \n\tExperience is your best teacher",
7-
"The Magician: \n\tLife is Magic... do you control yours?",
8-
"The High Priestess: \n\tStay away from worldly affairs",
9-
"The Empress: \n\tThe world bows before you, you bow to none",
10-
"The Emperor: \n\tThe world bows before you, you bow to none",
11-
"The Hierophant: \n\tFollow the 4rc@n3 principles",
12-
"The Lovers: \n\tI've never writ, nor no man never loved",
13-
"The Chariot: \n\tYou'll get to see your dream ride soon",
14-
"Strength: \n\tYou are stong enough",
15-
"The Hermit: \n\tThe World hurtles forward, yet you remain uncaught in its riptide",
16-
"Wheel of Fortune: \n\tYour luck today depends on whether the first living thing you see is a plant or an animal",
17-
"Justice: \n\tThe Mills of God grind slow but fine",
18-
"The Hanged Man: \n\tThat's rough buddy",
19-
"Death: \n\tLife's younger sibling brushed your shoulder just now, but you're fine- it was just lint",
20-
"Temperance: \n\tThe World needs more of it, and of you",
21-
"The Devil: \n\tGet over here so I can prove that you exist",
22-
"The Tower: \n\tExchange places with the king",
23-
"The Star: \n\tLike diamonds in the sky~",
24-
"The Moon: \n\tYou might find that your enthusiasm waxes and wanes, but that's alright",
25-
"The Sun: \n\tYou're the light of someone's life",
26-
"Judgement: \n\t*judges you in spanish*",
27-
"The World: \n\tThese hands could hold you but it'll never be enough~",
28-
"Ace of Wands: \n\tYou're a wizard, Harry",
29-
"Two of Wands: \n\tYour sibling is pretty cool",
30-
"Three of Wands: \n\tTry to avoid tournaments for the time being",
31-
"Four of Wands: \n\tFind trouble and make it double",
32-
"Five of Wands: \n\tExpecto Patronum",
33-
"Six of Wands: \n\tDraw your wand",
34-
"Seven of Wands: \n\tIf you see a noseless man with the complexion of crushed eggshells, RUN",
35-
"Eight of Wands: \n\tI'm surprised you got this tbh... I'll let you in on a secret - Seven didn't actually eat Nine",
36-
"Nine of Wands: \n\tOh, the card you're looking for is 3 quarters to the right",
37-
"Ten of Wands: \n\tOh, the card you're looking for is a quarter to the left",
38-
"Page of Wands: \n\tYou're going to be called to the Head's Office - you shouldn't have messed with alchemy unsupervised",
39-
"Knight of Wands: \n\tYou just had to buy that giant chess set, didn't you?",
40-
"Queen of Wands: \n\tWith great power...",
41-
"King of Wands: \n\tWith great power...",
42-
"Ace of Cups: \n\tIf you ever see a trophy in the middle of a hedge maze...",
43-
"Two of Cups: \n\tBottoms up, friend!",
44-
"Three of Cups: \n\tTwo's company, three's better company!",
45-
"Four of Cups: \n\tThe more the merrier!",
46-
"Five of Cups: \n\tYeah, social distancing is important",
47-
"Six of Cups: \n\tNow that's one too many",
48-
"Seven of Cups: \n\tTwo's company enough",
49-
"Eight of Cups: \n\tTake a break",
50-
"Nine of Cups: \n\tIf three's a crowd...",
51-
"Ten of Cups: \n\tStop it now",
52-
"Page of Cups: \n\tI don't think you should drive until you clear your head",
53-
"Knight of Cups: \n\tPut that sword down right this instant",
54-
"Queen of Cups: \n\tDon't offend anyone influential",
55-
"King of Cups: \n\tDon't get on your gaurdians' bad side",
56-
"Ace of Swords: \n\tDraw your sword",
57-
"Two of Swords: \n\tEn garde",
58-
"Three of Swords: \n\tAllez!",
59-
"Four of Swords: \n\tParry!",
60-
"Five of Swords: \n\tLearn enough to be dangerous",
61-
"Six of Swords: \n\tGet yourself a teacher",
62-
"Seven of Swords: \n\tParlay!",
63-
"Eight of Swords: \n\tDo something nice for a stranger",
64-
"Nine of Swords: \n\tBe chivalrous",
65-
"Ten of Swords: \n\tI'm not asking for much, just be nice",
66-
"Page of Swords: \n\tThe pen is mightier",
67-
"Knight of Swords: \n\tLive by the code you're honour-bound to follow",
68-
"Queen of Swords: \n\tPledge alliance",
69-
"King of Swords: \n\tPledge alliance",
70-
"Ace of Coins: \n\tYou now have an iron nail",
71-
"Two of Coins: \n\tFlip a coin",
72-
"Three of Coins: \n\tFor want of a nail...",
73-
"Four of Coins: \n\tYou now have a paperclip",
74-
"Five of Coins: \n\tSleep well, it is a blessing",
75-
"Six of Coins: \n\tRoll a die",
76-
"Seven of Coins: \n\tYou're a lucky one",
77-
"Eight of Coins: \n\tYou're like a pineapple tree - i.e. you're a factual error",
78-
"Nine of Coins: \n\tAccessory fruit(affectionate)",
79-
"Ten of Coins: \n\t<insert cool fruit fact here>",
80-
"Page of Coins: \n\tYou're due for a promotion soon",
81-
"Knight of Coins: \n\tTreat your subordinates",
82-
"Queen of Coins: \n\tYou're worth your weight in gold",
83-
"King of Coins: \n\tYou're worth your weight in gold"
84-
]
85-
4+
# get tarot deck of 78 cards and 'predictions' from tarot.txt
5+
file_handle = open("tarot.txt", "r")
6+
cards = file_handle.readlines()
7+
tarot_deck = []
8+
for card in cards:
9+
tarot_deck.append(card)
8610

8711
def fin():
8812
print("Whichever your choice was...")
@@ -111,12 +35,12 @@ def youve_chosen_yes():
11135
print()
11236
print("Your second card is...")
11337
pick_card2 = random.randint(0, 78)
114-
print(tarot_deck[pick_card2] if pick_card2 != pick_card1 else tarot_deck[random.randint(0, 78)])
38+
print(tarot_deck[pick_card2] if pick_card2 != pick_card1 else tarot_deck[random.randint(0, 78)])
11539
input(">> press enter")
11640
print()
11741
print("And your third and final card is...")
11842
pick_card3 = random.randint(0, 78)
119-
print(tarot_deck[pick_card3] if pick_card3 != pick_card1 and pick_card3 != pick_card2 else tarot_deck[random.randint(0, 78)])
43+
print(tarot_deck[pick_card3] if pick_card3 != pick_card1 and pick_card3 != pick_card2 else tarot_deck[random.randint(0, 78)])
12044
input(">> press enter")
12145
print()
12246
fin()
@@ -147,7 +71,7 @@ def youve_chosen_neither():
14771
fin()
14872

14973

150-
# Introductory text
74+
# Introductory lines
15175
print("In this black box, you read white words")
15276
input(">> press enter")
15377
print("Words that might warn you of danger...")
@@ -158,12 +82,12 @@ def youve_chosen_neither():
15882
input(">> press enter")
15983
print()
16084

161-
162-
# Choice made here
85+
# Choice to be made here
16386
print("Do you dare draw a card?")
16487
ch = input(">> enter Y/N: ")
16588
print("\nInteresting...")
16689

90+
# Driver code
16791
if ch.lower() == 'y':
16892
youve_chosen_yes()
16993

0 commit comments

Comments
 (0)