In my game loop I am trying to draw numbers to represent the cost of a card. From my hand, I am pulling the name of the card, which is part of a class where .cost will call a number but when I throw it into the function below it says that str has no attribute cost:
class Text:
def __init__(self, text, font, surface, x, y):
self.text = text
self.font = font
self.surface = surface
self.x = x
self.y = y
def draw_text(self):
text_obj = textPromptFont.render(self.text, 1, (0,0,0))
text_rect = text_obj.get_rect()
text_rect.topleft = (self.x, self.y)
self.surface.blit(text_obj, text_rect)
x= hand[currentHandImageIndex][:-4] #wont show code but printing results something like: Card_Name
text_card_stats_cost = Text(x.cost, textCardStatsFont, DISPLAYSURF, 1050, 200)
Text(x.cost, textCardStatsFont, DISPLAYSURF, 1050, 200).draw_text()
Here is the code for my card class if relevant:
class Card_Details_Players:
def __init__(self, trait, pos, cost, attack, defense, ability, act_type, act_act, sig_type, sig_act, extra1, extra2):
self.trait = trait
self.pos = pos
self.cost = cost
self.attack = attack
self.defense = defense
self.ability = ability
self.act_type = act_type
self.act_act = act_act
self.sig_type = sig_type
self.sig_act = sig_act
self.extra1 = extra1
self.extra2 = extra2