Skip to content

Commit

Permalink
added chest for future plans
Browse files Browse the repository at this point in the history
  • Loading branch information
Samalmeida1028 committed Dec 8, 2022
1 parent 05fce21 commit acaa59f
Show file tree
Hide file tree
Showing 9 changed files with 652 additions and 17 deletions.
20 changes: 10 additions & 10 deletions Objects/Item.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@

class Item:

def __init__(self, name, baseRegion, itemType="misc", baseValue="1", rarity="1", arg=[]):
def __init__(self, name, baseRegion, item_type="misc", baseValue="1", rarity="1", arg=[]):
if len(arg) == 0:
self.name = name
self.itemType = itemType
self.item_type = item_type
self.baseValue = baseValue
self.rarity = rarity
self.baseRegion = baseRegion
else:
self.name = arg[0]
self.itemType = arg[1]
self.item_type = arg[1]
self.baseValue = arg[2]
self.rarity = arg[3]
self.baseRegion = arg[4]

def __str__(self):
return '{"Name":"' + self.name + '","Type":"' + self.itemType + '","Value":"' + self.baseValue + '","Rarity":"'\
return '{"Name":"' + self.name + '","Type":"' + self.item_type + '","Value":"' + self.baseValue + '","Rarity":"'\
+ self.rarity + '","Base Region":"' + self.baseRegion + '"}'

def str(self):
Expand All @@ -29,7 +29,7 @@ class ItemManager:

def __init__(self): # inits by trying to load an items.txt json for the save data, else it creates a new one
temp = ""
self.itemTypes = []
self.item_types = []
self.itemRegions = []
self.itemList = {}
try:
Expand All @@ -43,8 +43,8 @@ def __init__(self): # inits by trying to load an items.txt json for the save da
except json.decoder.JSONDecodeError:
self.itemList = {}

def addItem(self, name, itemType, baseValue, rarity, baseRegion): # add item by property
temp = Item(name, itemType, baseValue, rarity, baseRegion)
def addItem(self, name, item_type, baseValue, rarity, baseRegion): # add item by property
temp = Item(name, item_type, baseValue, rarity, baseRegion)
self.itemList[name] = json.loads(temp.str())

def addItem(self, item_list): # add new item by list
Expand All @@ -59,9 +59,9 @@ def getItemRegions(self) -> list: # returns a list of all the regions in the it

def getItemTypes(self) -> list: # gets all the item types in the item list
for key in self.itemList:
if self.itemList[key]["Type"] not in self.itemTypes:
self.itemTypes.append(self.itemList[key]["Type"])
return self.itemTypes
if self.itemList[key]["Type"] not in self.item_types:
self.item_types.append(self.itemList[key]["Type"])
return self.item_types

def getItemIndex(self, index) -> Item: # gets the index of an item in the item list
item_name = list(self.itemList)[int(index)]
Expand Down
8 changes: 4 additions & 4 deletions Objects/Shop.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ def __init__(self, name="", owner="", notes="", shop_type="", city="", region=""
sell_mult=""):
self.name = name
self.owner = owner
self.shopType = shop_type
self.shop_type = shop_type
self.notes = notes
self.city = city
self.region = region
self.wealth = wealth
self.items = {}
if type(items) != str:
self.addItems(items)
self.goldAmount = gold_amount
self.gold_amount = gold_amount
self.sell_mult = sell_mult

def __str__(self): # this puts the shop items in JSON format for saving
temp = json.dumps(self.items, indent=4)
return '{"Name":"' + self.name + '","Owner":"' + self.owner + '","Notes":"' + self.notes + '","Type":"' \
+ self.shopType + '","City":"' + self.city + '","Region":"' + self.region + '","Wealth":"' + self.wealth \
+ '","Items":' + temp + ',"GoldAmount":"' + self.goldAmount + '","SellMult":"' + self.sellMult + '"}'
+ self.shop_type + '","City":"' + self.city + '","Region":"' + self.region + '","Wealth":"' + self.wealth \
+ '","Items":' + temp + ',"GoldAmount":"' + self.gold_amount + '","SellMult":"' + self.sell_mult + '"}'

def str(self):
return self.__str__()
Expand Down
Binary file modified Objects/__pycache__/Item.cpython-39.pyc
Binary file not shown.
Binary file modified Objects/__pycache__/Shop.cpython-39.pyc
Binary file not shown.
Binary file modified Objects/__pycache__/TypeAndRegionManager.cpython-39.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion Resources/save_data/regions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"Polar": "[]",
"Oksandarr": "['Mines','Magic Lands']",
"Crestus": "['Mines','Plains']",
"Pitt": "[]"
"Pitt": "[]",
"1": "[]"
}
Loading

0 comments on commit acaa59f

Please sign in to comment.