Skip to content

Commit

Permalink
Merge stock editor to main save-editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Aholicknight committed Dec 19, 2023
1 parent b626130 commit 8438079
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 8 deletions.
51 changes: 48 additions & 3 deletions save-editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ def main():
print("6) Load/Backup Current Save File")
print("7) " + Fore.GREEN + "Unlock" + Style.RESET_ALL + " all implants")
print("8) " + Fore.RED + "Lock" + Style.RESET_ALL + " all implants")
print("9) Exit")
print("9) Edit Stocks")
print("10) Exit")

choice = input("Enter your choice: ")

Expand Down Expand Up @@ -283,8 +284,52 @@ def main():
time.sleep(2)
clear_console()
print_status(save_data)

elif choice == "9": # exit

elif choice == "9": # edit stocks
stocks_data = load_stocks_file()
print(Fore.GREEN + f"File {stocks_file_path} loaded." + Style.RESET_ALL)
print(f"Last modified: {datetime.datetime.fromtimestamp(os.path.getmtime(stocks_file_path)).strftime('%Y-%m-%d %H:%M:%S')}")
print(f"Last accessed: {datetime.datetime.fromtimestamp(os.path.getatime(stocks_file_path)).strftime('%Y-%m-%d %H:%M:%S')}")
# print(f"Data: {stocks_data}")
# Print the stock tickers
tickers = [ticker for ticker in stocks_data.keys() if ticker not in ['fish_found', 'org_found']]
tickers_str = ", ".join(tickers)
print(f"Tickers: {tickers_str}")
stocks_data = load_stocks_file()
if stocks_data is None:
return
while True:
print("What do you want to do?")
print("1. Edit stock")
print("2. Remove stocks")
print("3. Go back to main menu")
choice = input("Enter your choice: ")
if choice == "1":
stock_name = input("Enter the stock name (Ticker): ")
if stock_name in stocks_data:
owned_stocks = input("Enter the number of owned stocks: ")
stocks_data[stock_name]['owned'] = int(owned_stocks)
save_stocks_file(stocks_data)
print(Fore.GREEN + f"Stock {stock_name} updated." + Style.RESET_ALL)
else:
print(Fore.RED + f"Stock {stock_name} not found." + Style.RESET_ALL)
elif choice == "2":
stock_name = input("Enter the stock name (Ticker): ")
if stock_name in stocks_data:
stocks_data[stock_name]['owned'] = 0
save_stocks_file(stocks_data)
print(Fore.GREEN + f"Stock {stock_name} removed." + Style.RESET_ALL)
else:
print(Fore.RED + f"Stock {stock_name} not found." + Style.RESET_ALL)
elif choice == "3":
clear_console()
print_status(save_data)
break # go back to main menu
else:
print(Fore.RED + "Invalid choice." + Style.RESET_ALL)
time.sleep(1)

elif choice == "10": # exit
break

else: # if a number is invalid exit the save editor
Expand Down
11 changes: 6 additions & 5 deletions stocks-save-editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ def print_status():
print(f"Last accessed: {datetime.datetime.fromtimestamp(os.path.getatime(stocks_file_path)).strftime('%Y-%m-%d %H:%M:%S')}")
# print(f"Data: {stocks_data}")
# Print the stock tickers
tickers = ", ".join(stocks_data.keys())
print(f"Tickers: {tickers}")
tickers = [ticker for ticker in stocks_data.keys() if ticker not in ['fish_found', 'org_found']]
tickers_str = ", ".join(tickers)
print(f"Tickers: {tickers_str}")

def main():
print_status()
Expand All @@ -53,7 +54,7 @@ def main():
while True:
print("What do you want to do?")
print("1. Edit stock")
print("2. Remove stock")
print("2. Remove stocks")
print("3. Exit")
choice = input("Enter your choice: ")
if choice == "1":
Expand All @@ -66,9 +67,9 @@ def main():
else:
print(Fore.RED + f"Stock {stock_name} not found." + Style.RESET_ALL)
elif choice == "2":
stock_name = input("Enter the stock name: ")
stock_name = input("Enter the stock name (Ticker): ")
if stock_name in stocks_data:
del stocks_data[stock_name]
stocks_data[stock_name]['owned'] = 0
save_stocks_file(stocks_data)
print(Fore.GREEN + f"Stock {stock_name} removed." + Style.RESET_ALL)
else:
Expand Down

0 comments on commit 8438079

Please sign in to comment.