Skip to content

Commit

Permalink
in process of standardizing key names
Browse files Browse the repository at this point in the history
  • Loading branch information
Samalmeida1028 committed Dec 9, 2022
1 parent 192ea41 commit 005af63
Show file tree
Hide file tree
Showing 6 changed files with 3,365 additions and 472 deletions.
16 changes: 8 additions & 8 deletions Objects/Item.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,25 @@ def addItem(self, item_list): # add new item by list

def getItemRegions(self) -> list: # returns a list of all the regions in the item list
for key in self.item_list:
if self.item_list[key]["Base Region"] not in self.itemRegions:
self.itemRegions.append(self.item_list[key]["Base Region"])
if self.item_list[key]["base_region"] not in self.itemRegions:
self.itemRegions.append(self.item_list[key]["base_region"])
return self.itemRegions

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

def getItemIndex(self, index: int | str) -> Item: # gets the index of an item in the item list
item_name = list(self.item_list)[int(index)]
item = Item(item_name, self.item_list[item_name]["Base Region"], self.item_list[item_name]["Type"],
self.item_list[item_name]["Value"], self.item_list[item_name]["Rarity"])
item = Item(item_name, self.item_list[item_name]["base_region"], self.item_list[item_name]["item_type"],
self.item_list[item_name]["base_value"], self.item_list[item_name]["rarity"])
return item

def getItemName(self, name: str) -> Item: # gets an item if given a name
item = Item(name, self.item_list[name]["Base Region"], self.item_list[name]["Type"], self.item_list[name]["Value"],
self.item_list[name]["Rarity"])
item = Item(name, self.item_list[name]["base_region"], self.item_list[name]["item_type"], self.item_list[name]["base_value"],
self.item_list[name]["rarity"])
return item

def saveItems(self): # saves the items to the txt file
Expand Down
24 changes: 12 additions & 12 deletions Objects/Shop.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@ def Serialize(self):

def addItems(self, items: dict): # adds a list of items, given an item list, to the shop
for key in items:
self.items[key] = {"Cost": "", "Amount": "0"}
if items[key]["Base Region"] == self.region:
self.items[key]["Cost"] = str((float(items[key]["Value"]) * 1 / float(items[key]["Rarity"])) // 2)
self.items[key] = {"cost": "", "amount": "0"}
if items[key]["base_region"] == self.region:
self.items[key]["cost"] = str((float(items[key]["base_value"]) * 1 / float(items[key]["Rarity"])) // 2)
else:
self.items[key]["Cost"] = str((float(items[key]["Value"]) * 1 / float(items[key]["Rarity"])))
self.items[key]["cost"] = str((float(items[key]["base_value"]) * 1 / float(items[key]["Rarity"])))

def addNewItem(self, item: Item, amount: str, cost: float): # adds a new item to the shop
self.items[item.name] = {"Cost": float(cost), "Amount": amount}
self.items[item.name] = {"cost": float(cost), "amount": amount}

def addItem(self, name: str, amount: float): # adds a previous item to the shop, increasing the amount
try:
temp = int(self.items[name]["Amount"])
temp = int(self.items[name]["amount"])
except KeyError:
print("Item is not in shop, please use 'addNewItem'")
return
temp += amount
self.items[name]["Amount"] = temp
self.items[name]["amount"] = temp

def updateItemPrice(self, item_name: str, cost: float): # updates the cost of an item
self.items[item_name]["Cost"] = cost
self.items[item_name]["cost"] = cost


#
Expand Down Expand Up @@ -81,15 +81,15 @@ def getShopRegions(self) -> list: # returns all the regions that shops have
regions = []
for key in self.shop_list:
if self.shop_list[key]["region"] not in regions:
regions.append(self.shop_list[key]["Region"])
regions.append(self.shop_list[key]["region"])
return regions

def getShopTypes(self) -> dict: # returns all the different types of shops
types = {}
temp = []
for key in self.shop_list:
if self.shop_list[key]["type"] not in temp:
temp.append(self.shop_list[key]["type"])
if self.shop_list[key]["shop_type"] not in temp:
temp.append(self.shop_list[key]["shop_type"])
types.update({'Shop Types': temp})
return types

Expand Down Expand Up @@ -132,7 +132,7 @@ def removeItem(self, shop_name: str, item: str):

def addNewItem(self, shop_name: str, item_name: str):
shop = self.shop_list[shop_name]
new_item = self.items.itemList[item_name]
new_item = self.items.item_list[item_name]
cost = float(new_item["base_value"])
cost /= (float(new_item["rarity"]) * random.uniform(.5, .9))
if new_item["base_region"] == shop["region"]:
Expand Down
Binary file modified Objects/__pycache__/Item.cpython-310.pyc
Binary file not shown.
Binary file modified Objects/__pycache__/Shop.cpython-310.pyc
Binary file not shown.
Loading

0 comments on commit 005af63

Please sign in to comment.