feat(plants): Plant purchase system in Dave's Shop & pre-battle deck selection screen
This commit is contained in:
1 parent
4e450d758b
commit
84c28addfe
7 files changed
+889
-66
No files matched your search
+24
-3
@@ -88,7 +88,14 @@ def get_default_profile_dict():
|
||||
"maxUnlockedLevel": 1,
|
||||
"highScore": 0,
|
||||
"theme": "classic",
|
||||
"upgrades": {"extraSlot": False, "hasRake": False},
|
||||
"upgrades": {
|
||||
"extraSlot": False,
|
||||
"hasRake": False,
|
||||
"unlockedPlants": ["sunflower", "peashooter", "wallnut"],
|
||||
"selectedDeck": ["sunflower", "peashooter", "wallnut"]
|
||||
},
|
||||
"unlockedPlants": ["sunflower", "peashooter", "wallnut"],
|
||||
"selectedDeck": ["sunflower", "peashooter", "wallnut"],
|
||||
"materials": {"bioHumus": 10, "scrapMetal": 5, "sunEssence": 20, "crystals": 0},
|
||||
"plantLevels": {"peashooter": 1, "sunflower": 1, "wallnut": 1, "potatomine": 1, "repeater": 1, "snowpea": 1, "chomper": 1},
|
||||
"perks": {"magnetism": 0, "startSun": 0, "fastCool": 0, "hardyRoots": 0, "luckyDrop": 0},
|
||||
@@ -199,13 +206,19 @@ def authenticate_user(username, password_hash):
|
||||
if not p:
|
||||
profile_dict = get_default_profile_dict()
|
||||
else:
|
||||
upg_data = json.loads(p["upgrades"] or "{}")
|
||||
unlocked_plants = upg_data.get("unlockedPlants", ["sunflower", "peashooter", "wallnut"])
|
||||
selected_deck = upg_data.get("selectedDeck", ["sunflower", "peashooter", "wallnut"])
|
||||
|
||||
profile_dict = {
|
||||
"coins": p["coins"],
|
||||
"level": p["level"],
|
||||
"maxUnlockedLevel": p["max_unlocked_level"],
|
||||
"highScore": p["high_score"],
|
||||
"theme": p["theme"],
|
||||
"upgrades": json.loads(p["upgrades"] or "{}"),
|
||||
"upgrades": upg_data,
|
||||
"unlockedPlants": unlocked_plants,
|
||||
"selectedDeck": selected_deck,
|
||||
"materials": json.loads(p["materials"] or "{}"),
|
||||
"plantLevels": json.loads(p["plant_levels"] or "{}"),
|
||||
"perks": json.loads(p["perks"] or "{}"),
|
||||
@@ -247,7 +260,15 @@ def save_user_profile(username, data):
|
||||
cur_obj.update(new_val)
|
||||
return json.dumps(cur_obj)
|
||||
|
||||
upgrades_json = merge_json("upgrades", {})
|
||||
upg_obj = json.loads(current["upgrades"] or "{}") if current and current["upgrades"] else {}
|
||||
if "upgrades" in data and isinstance(data["upgrades"], dict):
|
||||
upg_obj.update(data["upgrades"])
|
||||
if "unlockedPlants" in data and isinstance(data["unlockedPlants"], list):
|
||||
upg_obj["unlockedPlants"] = data["unlockedPlants"]
|
||||
if "selectedDeck" in data and isinstance(data["selectedDeck"], list):
|
||||
upg_obj["selectedDeck"] = data["selectedDeck"]
|
||||
upgrades_json = json.dumps(upg_obj)
|
||||
|
||||
materials_json = merge_json("materials", {})
|
||||
plant_levels_json = merge_json("plant_levels", {}) if "plant_levels" in data else (json.dumps(data["plantLevels"]) if "plantLevels" in data else (current["plant_levels"] if current else "{}"))
|
||||
perks_json = merge_json("perks", {})
|
||||
|
||||
Reference in new issue
Block a user