Skip to content

Commit d16740a

Browse files
committed
Implement Freedom's Flame
Minor Fixes
1 parent a26db84 commit d16740a

File tree

8 files changed

+27
-14
lines changed

8 files changed

+27
-14
lines changed

.dockerignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.idea/
2-
32
.github/
43
.venv/
54
!env/.env.example

src/cfg/settings.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"User-Agent": "Diveharder API - api.diverharder.com",
2323
"Authorization": os.environ["SESSION_TOKEN"],
2424
},
25-
"time_delay": 20,
25+
"time_delay": int(20),
2626
}
2727

2828

@@ -51,6 +51,7 @@
5151
"season_pass_ce": base_url + os.environ["SEASON_PASS_CE"],
5252
"season_pass_dd": base_url + os.environ["SEASON_PASS_DD"],
5353
"season_pass_pp": base_url + os.environ["SEASON_PASS_PP"],
54+
"season_pass_ff": base_url + os.environ["SEASON_PASS_FF"],
5455
"score_calc": base_url + os.environ["MISSION_SCORE_CALC_PARAMS"],
5556
"election_candidates": base_url + os.environ["ELECTION_CANDIDATES"],
5657
"election_terms": base_url + os.environ["ELECTION_TERMS"],

src/data/api/api.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(self):
2020
self.urls = cfg.urls
2121

2222
self.update_time = 0
23-
self.time_delay = cfg.ahgs_api.get("time_delay")
23+
self.time_delay: int = cfg.ahgs_api.get("time_delay", 20)
2424

2525
self.raw_data = {
2626
"status": {"data": [], "update_time": 0, "auth": True},
@@ -41,6 +41,7 @@ def __init__(self):
4141
"season_pass_ce": {"data": [], "update_time": 0, "auth": True},
4242
"season_pass_dd": {"data": [], "update_time": 0, "auth": True},
4343
"season_pass_pp": {"data": [], "update_time": 0, "auth": True},
44+
"season_pass_ff": {"data": [], "update_time": 0, "auth": True},
4445
"score_calc": {"data": [], "update_time": 0, "auth": True},
4546
"election_candidates": {"data": [], "update_time": 0, "auth": True},
4647
"election_terms": {"data": [], "update_time": 0, "auth": True},
@@ -99,7 +100,7 @@ async def fetch_data(self, info_name: str = ""):
99100
)
100101
)
101102
if update_needed:
102-
authed = self.raw_data.get(info_name)["auth"]
103+
authed = self.raw_data.get(info_name, {})["auth"]
103104
url = self.urls[info_name]
104105
self.raw_data[info_name]["update_time"] = int(time())
105106
self.raw_data[info_name]["data"] = await self.get_url(url, authed)

src/data/json_handler.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ def sort_json_dicts():
7171
"cutting_edge": raw_json_data["warbonds_cutting_edge"],
7272
"democratic_detonation": raw_json_data["warbonds_democratic_detonation"],
7373
"polar_patriots": raw_json_data["warbonds_polar_patriots"],
74+
"viper_commandos": raw_json_data["warbonds_viper_commandos"],
75+
"freedoms_flame": raw_json_data["warbonds_freedoms_flame"],
7476
},
7577
"factions": raw_json_data["factions"],
7678
}
@@ -161,7 +163,7 @@ def expand_json():
161163
page["assets"][item_id].update(
162164
json_data["items"]["weapons"]["grenades"][item_id]
163165
)
164-
page["assets"][item_id].update({"medal_cost": item["medal_cost"]})
166+
page["assets"][item_id].update({"medal_cost": item.get("medal_cost", 0)})
165167
page["items"] = page["assets"]
166168
page.pop("assets")
167169

src/routes/raw.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ async def get_raw_major_order(request: Request):
108108

109109

110110
@router.get("/personal_order", status_code=200)
111-
async def get_raw_major_order(request: Request):
111+
async def get_raw_personal_order(request: Request):
112112
"""Get the raw data for personal_order"""
113113
log.info(request, status.HTTP_200_OK)
114114
await api.fetch_data(info_name="personal_order")

src/routes/response_models/status.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ class GlobalEvent(BaseModel):
5656
planetIndices: List[int] | None
5757

5858

59+
class PlanetActiveEffects(BaseModel):
60+
index: int
61+
galacticEffectId: int
62+
63+
5964
class StatusResponse(BaseModel):
6065
warId: int
6166
time: int
@@ -67,7 +72,7 @@ class StatusResponse(BaseModel):
6772
communityTargets: List[int] | None
6873
jointOperations: List[JointOperation]
6974
planetEvents: List[PlanetEvent]
70-
planetActiveEffects: List[int] | None
75+
planetActiveEffects: List[PlanetActiveEffects] | None
7176
activeElectionPolicyEffects: List[int] | None
7277
globalEvents: list[GlobalEvent]
7378
superEarthWarResults: List[int] | None

src/routes/response_models/war_info.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44

55
class PlanetCoords(BaseModel):
6-
x: int
7-
y: int
6+
x: float
7+
y: float
88

99

1010
class PlanetInfo(BaseModel):

src/routes/v1.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -403,14 +403,12 @@ async def update_store_data(data):
403403
for item in data.get("salesPage", {}).get("sections", [{}])[0].get("items", {})
404404
]
405405
store_items = []
406-
407406
for k, v in helper_data["item_list"].items():
408-
if (v["mix_id"] not in raw_store_items and k not in raw_store_items) or (
409-
v["mix_id"] in store_items or k in store_items
410-
):
407+
if (
408+
v["mix_id"] not in raw_store_items and k not in raw_store_items
409+
): # or (v["mix_id"] in store_items or k in store_items):
411410
continue
412411
elif v["mix_id"] in raw_store_items or k in raw_store_items:
413-
print("Item ID", k, "Mix ID", v["mix_id"])
414412
if k in json_data["items"]["armor"]:
415413
store_items.append(k)
416414

@@ -424,4 +422,11 @@ async def update_store_data(data):
424422
items.append(item_data)
425423
else:
426424
items.append({"name": "Unmapped"})
425+
if not items:
426+
items: List[dict[str, str]] = [
427+
{"name": "Unmapped"},
428+
{"name": "Unmapped"},
429+
{"name": "Unmapped"},
430+
{"name": "Unmapped"},
431+
]
427432
return {"expire_time": expire_time, "items": items}

0 commit comments

Comments
 (0)