Created
July 27, 2019 04:54
-
-
Save An-Nguyen1/3a6b0bc5ebc6d6922a84653118c6f52f to your computer and use it in GitHub Desktop.
This is a starter for most text base card game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
deck = [] | |
hand = [] | |
card = None | |
score = 0 | |
with open('deck.txt', 'r') as d: | |
for line in d: | |
deck.append(line.strip('\n')) | |
random.shuffle(deck) | |
def draw_card(hand): | |
global card | |
card = deck[0] | |
deck.pop(0) | |
hand.append(card) | |
return card | |
def find_score_A(): | |
global score | |
if score <= 10: | |
score += 11 | |
else: | |
score += 1 | |
def find_score(): | |
global score | |
if card[0] == 'K': | |
score += 10 | |
elif card[0] == 'Q': | |
score += 10 | |
elif card[0] == 'J': | |
score += 10 | |
elif card[0] == '1': | |
score += 10 | |
elif card[0] == 'A': | |
find_score_A() | |
else: | |
score += int(card[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A_Spades | |
2_Spades | |
3_Spades | |
4_Spades | |
5_Spades | |
6_Spades | |
7_Spades | |
8_Spades | |
9_Spades | |
10_Spades | |
J_Spades | |
Q_Spades | |
K_Spades | |
A_Heart | |
2_Heart | |
3_Heart | |
4_Heart | |
5_Heart | |
6_Heart | |
7_Heart | |
8_Heart | |
9_Heart | |
10_Heart | |
J_Heart | |
Q_Heart | |
K_Heart | |
A_Diamond | |
2_Diamond | |
3_Diamond | |
4_Diamond | |
5_Diamond | |
6_Diamond | |
7_Diamond | |
8_Diamond | |
9_Diamond | |
10_Diamond | |
J_Diamond | |
Q_Diamond | |
K_Diamond | |
A_Club | |
2_Club | |
3_Club | |
4_Club | |
5_Club | |
6_Club | |
7_Club | |
8_Club | |
9_Club | |
10_Club | |
J_Club | |
Q_Club | |
K_Club |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment