mark items as owned and unowned

This commit is contained in:
BarsTiger
2022-08-09 22:50:19 +03:00
parent f5c0f677cb
commit 8045bbc6b7
8 changed files with 55 additions and 14 deletions

View File

@@ -16,6 +16,10 @@ class Database:
json.dump(default_database, f, indent=4)
return DatabaseModel.from_dict(default_database)
@staticmethod
def get_profile():
return Database.get().profiles[Config.get().profile]
@staticmethod
def write(db: DatabaseModel):
with open(Config.get().database, 'w') as f:
@@ -48,3 +52,18 @@ class Database:
db.profiles.pop(profile_name)
Database.write(db)
@staticmethod
def set_owned(item_name: str):
db = Database.get()
db.profiles[Config.get().profile].owned_items.append(item_name)
Database.write(db)
@staticmethod
def set_unowned(item_name: str):
db = Database.get()
if item_name in db.profiles[Config.get().profile].owned_items:
db.profiles[Config.get().profile].owned_items.remove(item_name)
Database.write(db)