Skip to content

Commit

Permalink
fixing var names in region manager
Browse files Browse the repository at this point in the history
- fixed var names and help for region stuff
- fixed bug with add that made it seem like input was put in incorrectly
  • Loading branch information
Samalmeida1028 committed Dec 11, 2022
1 parent 456c696 commit c4e47f8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
16 changes: 10 additions & 6 deletions Objects/TypeAndRegionManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,20 @@ def __init__(self, shop: ShopManager, item: ItemManager,filename: str = "regions
if key not in self.region_list:
self.region_list.update({key: []}) # updates all the keys with the regions in the save file

def addItemRegion(self, key, value): # adds an item region to a given shop region
def addItemRegion(self, region, item): # adds an item region to a given shop region
temp = []
if self.region_list[key]:
temp += self.region_list[key]
if temp.count(value) == 0:
temp += [value]
if self.region_list[region]:
temp += self.region_list[region]
if temp.count(item) == 0:
temp += [item]
if len(temp) != 0:
self.region_list.update({key: temp})
self.region_list.update({region: temp})
self.saveRegions()

def addNewShopRegion(self, key):
if key not in self.region_list:
self.region_list.update({key: []})
self.saveRegions()

def removeItemRegion(self, key, value): # removes an item region from a given shop region
temp = []
Expand All @@ -108,11 +110,13 @@ def removeItemRegion(self, key, value): # removes an item region from a given s
temp.pop(value)
if len(temp) != 0:
self.region_list.update({key: temp})
self.saveRegions()

def addNewShopItemRegion(self, key, value): # adds a new shop region and a new item region to the shop region
if key not in self.region_list:
self.region_list.update({key: []})
self.addItemRegion(key, value)
self.saveRegions()

def saveRegions(self): # saves the regions for each shop to the save text file
file = open("../Resources/save_data/" + self.filename, "r+")
Expand Down
Binary file modified Objects/__pycache__/TypeAndRegionManager.cpython-310.pyc
Binary file not shown.
5 changes: 4 additions & 1 deletion Resources/save_data/regions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@
"Mines",
"Plains"
],
"Pitt": []
"Pitt": [],
"Bozoland": [
"Bozos"
]
}
8 changes: 5 additions & 3 deletions shop-generator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# DONE (ISH): Make shop regions and biome easier to interpret, as well as shop types and item types
# TODO: Refactor code for ease of use and remove dependencies on hard coded values to support tweaking of parameters
# TODO: Load those parameters into another json editable file so users can tweak program values without tweaking code
# TODO: Add help commands into each manager and shorten commands for users, make commands less ambiguous

# ---GLOBALS---
REGION_ITEM_VALUE = 1.2 # used to determine how an item's value fluctuates based on region
Expand Down Expand Up @@ -110,8 +111,9 @@ def runCommands(argv: list): # simple interface with if statements to run comma
elif argv[0] in clearScreen:
os.system('cls' if os.name == 'nt' else 'clear') # clears screen
elif argv[0] in addCommand:
if (len(argv[0]) != 2):
if (len(argv) != 2):
print("Invalid structure for 'add'")
return
if argv[1] == "shop":
print(
"Enter shop fields separated by a comma ([name],[shop_type],[city],[region],[wealth],[items],"
Expand Down Expand Up @@ -531,9 +533,9 @@ def printHelp():
"----------------------------------------------------------------------------------------------------------\n"
"edit regions: opens the edit region\n"
"----------------------------------------------------------------------------------------------------------\n"
"(in region manager) add shop region: adds a new region\n"
"(in region manager) add shop region,[Region]: adds a new shop region\n"
"----------------------------------------------------------------------------------------------------------\n"
"(in region manager) add item to region: adds a new item to a region\n"
"(in region manager) add item to shop region,[Region],[Item Region]: adds a new item region to a region\n"
"----------------------------------------------------------------------------------------------------------\n"
"(in region manager) print regions: prints all regions\n"
"----------------------------------------------------------------------------------------------------------\n"
Expand Down

0 comments on commit c4e47f8

Please sign in to comment.