I am creating a shop/inventory system for a python rpg and return several variables from a function in my shop. I create 3-5 items every time the shop is visited so right now if you print one of my returned variables it will print the info from the last item created. I need to be able to store each unique items values in an array so that each item can be called on not just the last one.
if plus == 0: #if item made has a plus equal to nothing
if has_add == 'yes': #if it has an add
if item_type == 'weapon': #if it is a weapon (no plus, has add, is weapon)
created_item = print(str(count) + ". " + quality + " " + wep_adj + " " + "" + weapon_type + " of " + wep_add + "..........Attack: " + str(weapon_attack) + " Price: " + str(wep_price)) #print this
if item_type == 'armor': #if it is an armor (no plus, has add, is armor)
created_item = print(str(count) + ". " + quality + " " + arm_adj + " " + " " + armor_piece + " of " + arm_add + "..........Armor: " + str(armor_defense) + " HP: " + str(armor_hp) + " Price: " + str(arm_price)) #print this
else: # if item doesnt have add
if item_type == 'weapon': #if it is a weapon (no plus, no add, is weapon)
created_item = print(str(count) + ". " + quality + " " + wep_adj + " " + "" + weapon_type + "..........Attack: " + str(weapon_attack) + " Price: " + str(wep_price)) #print this
if item_type == 'armor': # if it is an armor (no plus, no add, is armor)
created_item = print(str(count) + ". " + quality + " " + arm_adj + " " + " " + armor_piece + "..........Armor: " + str(armor_defense) + " HP: " + str(armor_hp) + " Price: " + str(arm_price)) #print this
else: #if item made has a plus
if has_add == 'yes': # if it has an add
if item_type == 'weapon': # if it is a weapon (has plus, has add, is weapon)
created_item = print(str(count) + ". " + quality + " " + wep_adj + " " + "" + weapon_type + " of " + wep_add + " +" + str(plus) + "..........Attack: " + str(weapon_attack) + " Price: " + str(wep_price)) #print this
if item_type == 'armor': #if it is an armor (has plus, has add, is armor)
created_item = print(str(count) + ". " + quality + " " + arm_adj + " " + " " + armor_piece + " of " + arm_add + " +" + str(plus) + "..........Armor: " + str(armor_defense) + " HP: " + str(armor_hp) + " Price: " + str(arm_price)) #print this
else: # if it doesnt have an add
if item_type == 'weapon': #if it is a weapon (has plus, no add, is weapon)
created_item = print(str(count) + ". " + quality + " " + wep_adj + " " + "" + weapon_type + " +" + str(plus) + "..........Attack: " + str(weapon_attack) + " Price: " + str(wep_price)) #print this
if item_type == 'armor': #if it is an armor (has plus, no add, is armor)
created_item = print(str(count) + ". " + quality + " " + arm_adj + " " + " " + armor_piece + " +" + str(plus) + "..........Armor: " + str(armor_defense) + " HP: " + str(armor_hp) + " Price: " + str(arm_price)) #print this
if item_type == 'weapon': #allows us to get info out of function
return (created_item, count, quality, wep_adj, weapon_type, wep_add, plus, weapon_attack, wep_price, randvar)
else:
return (created_item, count, quality, arm_adj, armor_piece, arm_add, plus, armor_defense, arm_price, armor_hp)
while items_amount > items_made: #if we've made 3-5 items, stop making them
new_item, count, quality, adj, piece, add, plus, stat, price, other_stat = make_item()
items_made += 1 #increase items made every time one is made
count += 1
return (new_item, count, quality, adj, piece, add, plus, stat, price, other_stat)
new_item, count, quality, adj, piece, add, plus, stat, price, other_stat = generate_items() #call function to make all items when shop is visited
print(new_item, count, quality, adj, piece, add, plus, stat, price, other_stat)
Since my code is so immense I don't want to link the entirety of relevant code. The most relevant is this:
while items_amount > items_made: #if we've made 3-5 items, stop making them
new_item, count, quality, adj, piece, add, plus, stat, price, other_stat = make_item()
items_made += 1 #increase items made every time one is made
count += 1
return (new_item, count, quality, adj, piece, add, plus, stat, price, other_stat)
I need to be able to return them as arrays instead of variables