I'm creating a Dominion card-game and I'm stuck on how to turn a player input string into a variable. For example, if player 1 in his action phase wants to use his cellar card, he would type "cellar". But there are numerous types of kingdom cards and I don't think writing an if statement for checking through all the different kingdom card names is correct. Is there a way I can turn the input string "cellar" into a variable that I can just call on directly? In this case, I have it as a function. Thank you!
import random
# Need dictionary of each card: Cost, action, points, curse, etc.
# BASIC CARDS
copper = {"name":"copper", "cardtype":"treasure", "victory":0, "cost":0, "value":1}
silver = {"name":"silver", "cardtype":"treasure", "victory":0, "cost":3, "value":2}
gold = {"name":"gold", "cardtype":"treasure", "victory":0, "cost":6, "value":3}
estate = {"name":"estate", "cardtype":"victory", "victory":1, "cost":2, "value":0}
duchy = {"name":"duchuy", "cardtype":"victory", "victory":3, "cost":5, "value":0}
province = {"name":"province", "cardtype":"victory", "victory":6, "cost":8, "value":0}
curse = {"name":"curse", "cardtype":"victory", "victory":-1, "cost":0, "value":0}
# KINGDOM CARDS
def cellar(x):
pass
# Draw pile, discard pile, hand pile.
drawpile = [0]
discardpile = [0]
hand = [0]
# Each player starts with 8 copper and 2 estates. Shuffle cards and put in draw pile.
number_of_players = input("Ready to start? Input # of players")
if int(number_of_players) < 2:
print("Need at least 2 players")
elif int(number_of_players) > 8:
print("8 is maximum")
else:
for i in range(int(number_of_players)):
print("Player " + str(i))
# Player 1 starts, draw 5 cards from draw pile to hand.
drawpile = [copper["name"], copper["name"], copper["name"], copper["name"], copper["name"], copper["name"], copper["name"], estate["name"], estate["name"]]
random.shuffle(drawpile)
hand = drawpile[:6]
print(hand)
turn1 = input("Action phase, what would you like to do: ")
turn2 = input("Buy phase, what would you like to buy: ")
turn3 = input("Cleanup phase: ")