I want to make a game for my fun but had some issue to calculate coin:
Problem is the coin in the first class:
I can't calculate coin and save it to this class. Pls fix it for me (I'm a beginer)
class Player_data_infomation:
def init(self,hp,armor, coin,inventory):
self.hp =hp
self.armor =armor
self.coin =coin #<<this is coin
self.invertory =inventory.split()
player_data =Player_data_infomation(100,0,0,"wip") #<<player
text_startgame =["discord limit word issues"]
text_ingame =["same as text_startgame"]
import random as r
shop_item =r.choice(Game_data.item)
shop_weapon =r.choice(Game_data.weapon)
class shop_script(Player_data_infomation):
#calculate coin:
def shop_items():
try:
while player_data.coin < 0:
if "" in shop_item:
player_data.coin -= 60
if "" in shop_item:
player_data.coin -= 15
if "" in shop_items:
player_data.coin -= 30
except:
pass
class main_script(shop_script):
#enter game
for text in text_startgame:
print(text)
while True:
answer =input()
if "start" in answer:
while True:
for text in text_ingame:
print(text)
answer_ingame =input()
#ββthis is the problem
if "1" in answer_ingame:
print(f"({shop_item}) is in stock,({shop_weapon}) is in stock")
print(f"coin:{player_data.coin}")
shop =["same as text_startgame"]
for text in shop:
print(text)
answer_shopchoice =input()
if "1" in answer_shopchoice:
shop_script.shop_items()
if "3" in answer_shopchoice:
shop_item =r.choice(Game_data.item)
shop_weapon =r.choice(Game_data.weapon)
if "2" in answer_ingame:
print("wip")
if "data information" in answer:
#>Just a information blu<
if "quit" in answer:
break