From 838d34cc4d547ce235a3297fbcd490a9c88c762a Mon Sep 17 00:00:00 2001 From: Colin Bassett Date: Wed, 26 Feb 2025 13:41:37 -0500 Subject: [PATCH] Implement an update to the UserBase model --- CHANGELOG.md | 9 +++------ api/sql.py | 4 ++++ functions.py | 12 +++++++++++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 368f70c..3e41799 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,6 @@ ## CHANGELOG -## VER: Alpha #7 +## VER: Alpha #8 ## What's new? -- Updated the file structure to hold all the FastAPI files in its own dedicated 'api' folder -- Updated the 'main.py' file to have a working login and register feature -- Updated the 'sql.py' file to have a 'VerifyHero' model for verifying the hero's email & password -- Added a 'functions.py' file to hold all the functions for the main app. (The functions.py file for the API is in the 'api' folder) -- Added CHANGELOG and README files to the project \ No newline at end of file +- Added an update to the UserBase model to add weapons, pickaxes, and upgrades to the users inventory +- Started work on the load_options functions that will allow the user to choose specific options for the game diff --git a/api/sql.py b/api/sql.py index 9fe9f15..e0b47f4 100644 --- a/api/sql.py +++ b/api/sql.py @@ -1,5 +1,6 @@ # Imports from typing import Annotated +from typing import List from fastapi import Depends from sqlmodel import Field, Session, SQLModel, create_engine from pydantic import BaseModel @@ -9,6 +10,9 @@ class HeroBase(SQLModel): name: str gold: int | None = Field(default=0) health: int | None = Field(default=100) + weapons: List[str] | None = Field(default=["basic_sword"]) + pickaxe: List[str] | None = Field(default=["basic_pickaxe"]) + upgrades: List[str] | None = Field(default=[]) # The main hero class. It inherits the name, gold, and health class Hero(HeroBase, table=True): diff --git a/functions.py b/functions.py index fd7425a..2ba613e 100644 --- a/functions.py +++ b/functions.py @@ -30,4 +30,14 @@ def login(email, password): user_response = requests.get(f"{url}/heroes/{response.json()['hero_id']}") return user_response.json() else: - return False \ No newline at end of file + return False + +def load_options() -> int: + print(""" +Here are the available options: +* To select an option just enter its number * +1. Home - View the inventory + """) + + option = int(input("")) + return option \ No newline at end of file