Implement an update to the UserBase model
This commit is contained in:
parent
c4217c5132
commit
838d34cc4d
@ -1,9 +1,6 @@
|
|||||||
## CHANGELOG
|
## CHANGELOG
|
||||||
## VER: Alpha #7
|
## VER: Alpha #8
|
||||||
|
|
||||||
## What's new?
|
## What's new?
|
||||||
- Updated the file structure to hold all the FastAPI files in its own dedicated 'api' folder
|
- Added an update to the UserBase model to add weapons, pickaxes, and upgrades to the users inventory
|
||||||
- Updated the 'main.py' file to have a working login and register feature
|
- Started work on the load_options functions that will allow the user to choose specific options for the game
|
||||||
- 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
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# Imports
|
# Imports
|
||||||
from typing import Annotated
|
from typing import Annotated
|
||||||
|
from typing import List
|
||||||
from fastapi import Depends
|
from fastapi import Depends
|
||||||
from sqlmodel import Field, Session, SQLModel, create_engine
|
from sqlmodel import Field, Session, SQLModel, create_engine
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
@ -9,6 +10,9 @@ class HeroBase(SQLModel):
|
|||||||
name: str
|
name: str
|
||||||
gold: int | None = Field(default=0)
|
gold: int | None = Field(default=0)
|
||||||
health: int | None = Field(default=100)
|
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
|
# The main hero class. It inherits the name, gold, and health
|
||||||
class Hero(HeroBase, table=True):
|
class Hero(HeroBase, table=True):
|
||||||
|
12
functions.py
12
functions.py
@ -30,4 +30,14 @@ def login(email, password):
|
|||||||
user_response = requests.get(f"{url}/heroes/{response.json()['hero_id']}")
|
user_response = requests.get(f"{url}/heroes/{response.json()['hero_id']}")
|
||||||
return user_response.json()
|
return user_response.json()
|
||||||
else:
|
else:
|
||||||
return False
|
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
|
Loading…
Reference in New Issue
Block a user