I am trying to make a card game using Python. I have this text file below that is the Card ID, Card Name, Card Description, and Card Hit Point.
1, Medusa, Feel The Wraith, 98
2, Gigle , See Him See Him, 54
3, Brozi , Pinch an inch, 91
I have this class that is just a card. What I want to do is have a Deck (list) of these Cards (Class Objects). Here is some code that I am trying to do that will read the text file and place them into objects and then into the list.
import sys
import os
class Card:
def__init__(self, card_id, name, desc, hp):
self.card_id = card_id
self.name = name
self.desc = desc
self.hp = hp
self.cards = []
deck = []
fh = open('dets.txt').readlines()
for line in fh:
row = line.split(',')
card_id, name, desc, hp = [i.strip() for i in row]
card = deck.get(card_id, Card(card_id, name, desc, hp))
deck[card_id] = card
Am I on the track?
lstart at 0 up tolen(l) - 1?defand__init__@goodknight