foxapi 2.0.0__tar.gz → 2.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {foxapi-2.0.0 → foxapi-2.1.1}/PKG-INFO +6 -2
- {foxapi-2.0.0 → foxapi-2.1.1}/README.md +5 -1
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/__init__.py +1 -4
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/foxapi.py +41 -14
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/objects.py +22 -59
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi.egg-info/PKG-INFO +6 -2
- {foxapi-2.0.0 → foxapi-2.1.1}/LICENSE +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/10.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/11.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/12.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/13.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/14.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/15.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/16.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/17.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/18.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/19.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/20.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/21.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/22.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/23.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/27.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/28.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/29.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/30.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/32.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/33.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/34.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/35.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/36.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/37.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/38.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/39.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/40.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/41.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/45.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/46.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/47.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/5.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/51.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/52.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/53.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/54.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/56.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/57.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/58.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/59.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/6.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/60.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/61.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/62.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/7.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/70.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/71.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/72.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/75.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/8.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/83.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/84.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/88.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/89.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/9.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/90.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/91.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/92.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/DebugIcon.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/MapIconCivicCenter.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/MapIconHomeBaseHallColonial.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/MapIconHomeBaseHallWarden.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/MapIconScorchedTown.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/MapIconTownHall.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapIcons/MapIconVictory.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/FoxholeFestivalMapHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapAcrithiaHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapAllodsBightHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapAshFieldsHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapBasinSionnachHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapCallahansPassageHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapCallumsCapeHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapClahstraHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapClansheadValleyHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapDeadLandsHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapDrownedValeHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapEndlessShoreHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapFarranacCoastHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapFishermansRowHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapGodcroftsHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapGreatMarchHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapGutterHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapHeartlandsHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapHomeRegionC.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapHomeRegionW.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapHowlCountyHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapKalokaiHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapKingsCageHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapKuuraStrandHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapLinnMercyHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapLochMorHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapLykosIsleHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapMarbanHollowHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapMooringCountyHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapMorgensCrossingHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapNevishLineHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapOarbreakerHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapOlavisWakeHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapOnyxHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapOriginHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapPalantineBermHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapPariPeakHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapPipersEnclaveHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapReachingTrailHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapReaversPassHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapRedRiverHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapSableportHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapShackledChasmHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapSpeakingWoodsHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapStemaLandingHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapStlicanShelfHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapStonecradleHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapTempestIslandHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapTerminusHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapTheFingersHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapTyrantFoothillsHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapUmbralWildwoodHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapViperPitHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapWeatheredExpanseHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapWestgateHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/Images/MapsHex/MapWrestaHex.png +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi/utils.py +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi.egg-info/SOURCES.txt +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi.egg-info/dependency_links.txt +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi.egg-info/requires.txt +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/foxapi.egg-info/top_level.txt +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/setup.cfg +0 -0
- {foxapi-2.0.0 → foxapi-2.1.1}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: foxapi
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.1
|
|
4
4
|
Summary: A wrapper for the foxhole API
|
|
5
5
|
Home-page: https://github.com/ThePhoenix78/FoxAPI
|
|
6
6
|
Download-URL: https://github.com/ThePhoenix78/FoxAPI/tarball/master
|
|
@@ -137,11 +137,12 @@ load_hexagon_map(hexagon: str) -> pillow.Image
|
|
|
137
137
|
- Loads the PNG map for the specified hexagon.
|
|
138
138
|
|
|
139
139
|
```py
|
|
140
|
-
make_map_png(hexagon: str, icons: str | list = "all", colored: bool = False, dynamic: SDObject = None, static: SDObject = None, session: aiohttp.ClientSession | None = None) -> pillow.Image
|
|
140
|
+
make_map_png(hexagon: str, icons: str | list = "all", colored: bool = False, dynamic: SDObject = None, static: SDObject = None, force: bool = False, session: aiohttp.ClientSession | None = None) -> pillow.Image
|
|
141
141
|
```
|
|
142
142
|
- Generates a PNG image of the hexagon map with all the icons associated to each faction in their respective colors (included fields and town base). Only public data will be present.
|
|
143
143
|
- colored -> display each region in the team's color
|
|
144
144
|
- icons -> display selected building in their team's color
|
|
145
|
+
- force -> bypass the cache and generate a new map
|
|
145
146
|
|
|
146
147
|
```py
|
|
147
148
|
calculate_death_rate(hexagon: str = None, war_report: WarReportObject = None, session: aiohttp.ClientSession | None = None): -> dict
|
|
@@ -236,6 +237,7 @@ class WarObject:
|
|
|
236
237
|
scheduledConquestEndTime: str
|
|
237
238
|
requiredVictoryTowns: str
|
|
238
239
|
shortRequiredVictoryTowns: str
|
|
240
|
+
response: APIResponse
|
|
239
241
|
|
|
240
242
|
|
|
241
243
|
class WarReportObject:
|
|
@@ -244,6 +246,7 @@ class WarReportObject:
|
|
|
244
246
|
wardenCasualties: int
|
|
245
247
|
dayOfWar: int
|
|
246
248
|
version: int
|
|
249
|
+
response: APIResponse
|
|
247
250
|
|
|
248
251
|
|
|
249
252
|
class MapItemsObject:
|
|
@@ -273,6 +276,7 @@ class SDObject:
|
|
|
273
276
|
|
|
274
277
|
lastUpdated: int
|
|
275
278
|
version: int
|
|
279
|
+
response: APIResponse
|
|
276
280
|
```
|
|
277
281
|
|
|
278
282
|
|
|
@@ -121,11 +121,12 @@ load_hexagon_map(hexagon: str) -> pillow.Image
|
|
|
121
121
|
- Loads the PNG map for the specified hexagon.
|
|
122
122
|
|
|
123
123
|
```py
|
|
124
|
-
make_map_png(hexagon: str, icons: str | list = "all", colored: bool = False, dynamic: SDObject = None, static: SDObject = None, session: aiohttp.ClientSession | None = None) -> pillow.Image
|
|
124
|
+
make_map_png(hexagon: str, icons: str | list = "all", colored: bool = False, dynamic: SDObject = None, static: SDObject = None, force: bool = False, session: aiohttp.ClientSession | None = None) -> pillow.Image
|
|
125
125
|
```
|
|
126
126
|
- Generates a PNG image of the hexagon map with all the icons associated to each faction in their respective colors (included fields and town base). Only public data will be present.
|
|
127
127
|
- colored -> display each region in the team's color
|
|
128
128
|
- icons -> display selected building in their team's color
|
|
129
|
+
- force -> bypass the cache and generate a new map
|
|
129
130
|
|
|
130
131
|
```py
|
|
131
132
|
calculate_death_rate(hexagon: str = None, war_report: WarReportObject = None, session: aiohttp.ClientSession | None = None): -> dict
|
|
@@ -220,6 +221,7 @@ class WarObject:
|
|
|
220
221
|
scheduledConquestEndTime: str
|
|
221
222
|
requiredVictoryTowns: str
|
|
222
223
|
shortRequiredVictoryTowns: str
|
|
224
|
+
response: APIResponse
|
|
223
225
|
|
|
224
226
|
|
|
225
227
|
class WarReportObject:
|
|
@@ -228,6 +230,7 @@ class WarReportObject:
|
|
|
228
230
|
wardenCasualties: int
|
|
229
231
|
dayOfWar: int
|
|
230
232
|
version: int
|
|
233
|
+
response: APIResponse
|
|
231
234
|
|
|
232
235
|
|
|
233
236
|
class MapItemsObject:
|
|
@@ -257,6 +260,7 @@ class SDObject:
|
|
|
257
260
|
|
|
258
261
|
lastUpdated: int
|
|
259
262
|
version: int
|
|
263
|
+
response: APIResponse
|
|
260
264
|
```
|
|
261
265
|
|
|
262
266
|
|
|
@@ -10,7 +10,7 @@ __author__ = 'ThePhoenix78'
|
|
|
10
10
|
__license__ = 'MIT'
|
|
11
11
|
__copyright__ = 'Copyright 2024-2026 ThePhoenix78'
|
|
12
12
|
__url__ = 'https://github.com/ThePhoenix78/FoxAPI'
|
|
13
|
-
__newest__ = __version__ = '2.
|
|
13
|
+
__newest__ = __version__ = '2.1.1'
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
try:
|
|
@@ -26,6 +26,3 @@ if __version__ < __newest__:
|
|
|
26
26
|
print(f"New version of {__title__} available: {__newest__} (Using {__version__})")
|
|
27
27
|
else:
|
|
28
28
|
print(f"version : {__version__}")
|
|
29
|
-
print("NOTE: This version use Objects instead of raw JSON, consider using obj.json to access the raw JSON")
|
|
30
|
-
print("Saving with json.dumps(obj) will not work, use json.dumps(obj.json) instead")
|
|
31
|
-
print("Start using obj.attribute instead of obj['attribute'] as it will be deprecated soon (my magic isn't strong enough to keep it all together)")
|
|
@@ -45,6 +45,7 @@ class FoxAPI():
|
|
|
45
45
|
self._img_dir: str = os.path.join(Path(__file__).parent, "Images")
|
|
46
46
|
|
|
47
47
|
self.cache: dict = {}
|
|
48
|
+
self.cache_img: dict = {}
|
|
48
49
|
self.etag: dict = {}
|
|
49
50
|
|
|
50
51
|
self._death_rate_w : dict = {}
|
|
@@ -312,7 +313,7 @@ class FoxAPI():
|
|
|
312
313
|
new_color: tuple = (current_pixel[0]//2 + color[0], current_pixel[1]//2 + color[1], current_pixel[2]//2 + color[2])
|
|
313
314
|
image.putpixel((x, y), new_color)
|
|
314
315
|
|
|
315
|
-
def add_icons(self, image: Image, icons: str | list, dynamic: SDObject):
|
|
316
|
+
def add_icons(self, image: Image, icons: str | list, dynamic: SDObject, colored: bool = True):
|
|
316
317
|
icon_size: tuple = self._icon_size
|
|
317
318
|
|
|
318
319
|
if isinstance(icons, list):
|
|
@@ -331,7 +332,9 @@ class FoxAPI():
|
|
|
331
332
|
try:
|
|
332
333
|
img_path: str = os.path.join(self._img_dir, "MapIcons", f"{icon}.png")
|
|
333
334
|
img2 = Image.open(img_path).convert("RGBA").resize(icon_size)
|
|
334
|
-
|
|
335
|
+
|
|
336
|
+
if colored:
|
|
337
|
+
self.color_icon(image=img2, team=team)
|
|
335
338
|
|
|
336
339
|
except Exception as e:
|
|
337
340
|
img_path: str = os.path.join(self._img_dir, "MapIcons", f"DebugIcon.png")
|
|
@@ -367,28 +370,28 @@ class FoxAPI():
|
|
|
367
370
|
|
|
368
371
|
async def get_war(self, use_cache: bool = None, session: aiohttp.ClientSession | None = None) -> WarObject:
|
|
369
372
|
data: APIResponse = await self.get_data(endpoint="/war", use_cache=use_cache, session=session)
|
|
370
|
-
return WarObject(**data.json)
|
|
373
|
+
return WarObject(**data.json, response=data)
|
|
371
374
|
|
|
372
375
|
async def get_static(self, hexagon: str, use_cache: bool = True, session: aiohttp.ClientSession | None = None) -> SDObject:
|
|
373
376
|
if self._safe_mode:
|
|
374
377
|
hexagon: str = self._format_hexagon(hexagon)
|
|
375
378
|
|
|
376
379
|
data: APIResponse = await self.get_data(endpoint=f"/maps/{hexagon}/static", use_cache=use_cache, session=session)
|
|
377
|
-
return SDObject(**data.json)
|
|
380
|
+
return SDObject(**data.json, response=data)
|
|
378
381
|
|
|
379
382
|
async def get_dynamic(self, hexagon: str, use_cache: bool = None, session: aiohttp.ClientSession | None = None) -> SDObject:
|
|
380
383
|
if self._safe_mode:
|
|
381
384
|
hexagon: str = self._format_hexagon(hexagon)
|
|
382
385
|
|
|
383
386
|
data: APIResponse = await self.get_data(endpoint=f"/maps/{hexagon}/dynamic/public", use_cache=use_cache, session=session)
|
|
384
|
-
return SDObject(**data.json)
|
|
387
|
+
return SDObject(**data.json, response=data)
|
|
385
388
|
|
|
386
389
|
async def get_war_report(self, hexagon: str, use_cache: bool = None, session: aiohttp.ClientSession | None = None) -> WarReportObject:
|
|
387
390
|
if self._safe_mode:
|
|
388
391
|
hexagon: str = self._format_hexagon(hexagon)
|
|
389
392
|
|
|
390
393
|
data: APIResponse = await self.get_data(endpoint=f"/warReport/{hexagon}", use_cache=use_cache, session=session)
|
|
391
|
-
return WarReportObject(**data.json)
|
|
394
|
+
return WarReportObject(**data.json, response=data)
|
|
392
395
|
|
|
393
396
|
"""
|
|
394
397
|
---------------------------------------- ADDITIONAL ASYNC METHODS ----------------------------------------
|
|
@@ -404,20 +407,30 @@ class FoxAPI():
|
|
|
404
407
|
|
|
405
408
|
return self.associate_towns(dynamic=dynamic, static=static)
|
|
406
409
|
|
|
407
|
-
async def make_map_png(self, hexagon: str, icons: str | list[int | str] = "all", colored: bool = False, dynamic: SDObject = None, static: SDObject = None, session: aiohttp.ClientSession | None = None):
|
|
410
|
+
async def make_map_png(self, hexagon: str, icons: str | list[int | str] = "all", colored: bool = False, dynamic: SDObject = None, static: SDObject = None, force: bool = False, session: aiohttp.ClientSession | None = None):
|
|
408
411
|
if dynamic is None and (icons or colored):
|
|
409
412
|
dynamic: SDObject = await self.get_dynamic(hexagon=hexagon, session=session)
|
|
410
413
|
|
|
411
414
|
if static is None and colored:
|
|
412
415
|
static: SDObject = await self.get_static(hexagon=hexagon, use_cache=True, session=session)
|
|
413
416
|
|
|
417
|
+
if dynamic.response.is_cache and not force:
|
|
418
|
+
img = self.cache_img.get(hexagon)
|
|
419
|
+
|
|
420
|
+
if img:
|
|
421
|
+
return img
|
|
422
|
+
|
|
423
|
+
return await self.make_map_png(hexagon=hexagon, icons=icons, colored=colored, dynamic=dynamic, static=static, force=True)
|
|
424
|
+
|
|
414
425
|
img1: Image = self.load_hexagon_map(hexagon)
|
|
415
426
|
|
|
416
427
|
if colored:
|
|
417
428
|
self.color_regions(image=img1, dynamic=dynamic, static=static)
|
|
418
429
|
|
|
419
430
|
if icons:
|
|
420
|
-
self.add_icons(image=img1, icons=icons, dynamic=dynamic)
|
|
431
|
+
self.add_icons(image=img1, icons=icons, dynamic=dynamic, colored=colored)
|
|
432
|
+
|
|
433
|
+
self.cache_img[hexagon] = img1
|
|
421
434
|
|
|
422
435
|
return img1
|
|
423
436
|
|
|
@@ -454,25 +467,29 @@ class FoxAPI():
|
|
|
454
467
|
return self.get_data_sync(endpoint="/maps", use_cache=use_cache).json
|
|
455
468
|
|
|
456
469
|
def get_war_sync(self, use_cache: bool = None) -> WarObject:
|
|
457
|
-
|
|
470
|
+
data: APIResponse = self.get_data_sync(endpoint="/war", use_cache=use_cache)
|
|
471
|
+
return WarObject(**data.json, response=data)
|
|
458
472
|
|
|
459
473
|
def get_static_sync(self, hexagon: str, use_cache: bool = True) -> SDObject:
|
|
460
474
|
if self._safe_mode:
|
|
461
475
|
hexagon: str = self._format_hexagon(hexagon)
|
|
462
476
|
|
|
463
|
-
|
|
477
|
+
data: APIResponse = self.get_data_sync(endpoint=f"/maps/{hexagon}/static", use_cache=use_cache)
|
|
478
|
+
return SDObject(**data.json, response=data)
|
|
464
479
|
|
|
465
480
|
def get_dynamic_sync(self, hexagon: str, use_cache: bool = None) -> SDObject:
|
|
466
481
|
if self._safe_mode:
|
|
467
482
|
hexagon: str = self._format_hexagon(hexagon)
|
|
468
483
|
|
|
469
|
-
|
|
484
|
+
data: APIResponse = self.get_data_sync(endpoint=f"/maps/{hexagon}/dynamic/public", use_cache=use_cache)
|
|
485
|
+
return SDObject(**data.json, response=data)
|
|
470
486
|
|
|
471
487
|
def get_war_report_sync(self, hexagon: str, use_cache: bool = None) -> WarReportObject:
|
|
472
488
|
if self._safe_mode:
|
|
473
489
|
hexagon: str = self._format_hexagon(hexagon)
|
|
474
490
|
|
|
475
|
-
|
|
491
|
+
data: APIResponse = self.get_data_sync(endpoint=f"/warReport/{hexagon}", use_cache=use_cache)
|
|
492
|
+
return WarReportObject(**data.json, response=data)
|
|
476
493
|
|
|
477
494
|
"""
|
|
478
495
|
---------------------------------------- ADDITIONAL SYNC METHODS ----------------------------------------
|
|
@@ -488,7 +505,7 @@ class FoxAPI():
|
|
|
488
505
|
|
|
489
506
|
return self.associate_towns(dynamic=dynamic, static=static)
|
|
490
507
|
|
|
491
|
-
def make_map_png_sync(self, hexagon: str, icons: str | list[int | str] = "all", colored: bool = False, dynamic: dict = None, static: dict = None):
|
|
508
|
+
def make_map_png_sync(self, hexagon: str, icons: str | list[int | str] = "all", colored: bool = False, dynamic: dict = None, static: dict = None, force: bool = False):
|
|
492
509
|
if dynamic is None and (icons or colored):
|
|
493
510
|
dynamic: dict = self.get_dynamic_sync(hexagon=hexagon)
|
|
494
511
|
|
|
@@ -497,11 +514,21 @@ class FoxAPI():
|
|
|
497
514
|
|
|
498
515
|
img1: Image = self.load_hexagon_map(hexagon)
|
|
499
516
|
|
|
517
|
+
if dynamic.response.is_cache and not force:
|
|
518
|
+
img = self.cache_img.get(hexagon)
|
|
519
|
+
|
|
520
|
+
if img:
|
|
521
|
+
return img
|
|
522
|
+
|
|
523
|
+
return self.make_map_png_sync(hexagon=hexagon, icons=icons, colored=colored, dynamic=dynamic, static=static, force=True)
|
|
524
|
+
|
|
500
525
|
if colored:
|
|
501
526
|
self.color_regions(image=img1, dynamic=dynamic, static=static)
|
|
502
527
|
|
|
503
528
|
if icons:
|
|
504
|
-
self.add_icons(image=img1, icons=icons, dynamic=dynamic)
|
|
529
|
+
self.add_icons(image=img1, icons=icons, dynamic=dynamic, colored=colored)
|
|
530
|
+
|
|
531
|
+
self.cache_img[hexagon] = img1
|
|
505
532
|
|
|
506
533
|
return img1
|
|
507
534
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import inspect
|
|
2
|
-
|
|
3
1
|
class FoxObject:
|
|
4
2
|
pass
|
|
5
3
|
|
|
@@ -9,64 +7,20 @@ class FoxObject(dict):
|
|
|
9
7
|
Universal wrapper for any kind of dict item
|
|
10
8
|
if the data structure change I won't have to do
|
|
11
9
|
massive change in the code
|
|
12
|
-
|
|
13
|
-
def __init__(self, dico: dict):
|
|
14
|
-
for k, v in dico.items():
|
|
15
|
-
if not isinstance(v, dict):
|
|
16
|
-
setattr(self, k, v)
|
|
17
|
-
else:
|
|
18
|
-
setattr(self, k, FoxObject(v))
|
|
19
10
|
"""
|
|
11
|
+
def __init__(self, dico: dict):
|
|
20
12
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def __getitem__(self, x: str | int):
|
|
25
|
-
print("FoxAPI is moving toward objects for API endpoints, please start using object.attribute instead of object['attribute']")
|
|
26
|
-
print("You can also use object.json['attribute'] for JSON manpulations (like saving to JSON)")
|
|
27
|
-
|
|
28
|
-
caller = inspect.stack()[1]
|
|
29
|
-
code = inspect.getsource(caller.frame).split("\n")[caller.lineno-1]
|
|
30
|
-
|
|
31
|
-
print(f"WARNING : (line {caller.lineno}) : {code}")
|
|
32
|
-
|
|
33
|
-
if isinstance(x, str):
|
|
34
|
-
data = getattr(self, x)
|
|
35
|
-
|
|
36
|
-
if isinstance(data, list):
|
|
37
|
-
if data and isinstance(data[0], FoxObject):
|
|
13
|
+
for k, v in dico.items():
|
|
14
|
+
self.__setitem__(k, v)
|
|
38
15
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return data
|
|
16
|
+
def __setattr__(self, k, v):
|
|
17
|
+
super().__setitem__(k, FoxObject(v))
|
|
43
18
|
|
|
19
|
+
def __getattr__(self, k):
|
|
20
|
+
return super().get(k)
|
|
21
|
+
|
|
44
22
|
def __setitem__(self, k, v):
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
def __iter__(self):
|
|
48
|
-
for k, v in self.__dict__.items():
|
|
49
|
-
yield str(k), v
|
|
50
|
-
|
|
51
|
-
def items(self):
|
|
52
|
-
return self.__dict__.items()
|
|
53
|
-
|
|
54
|
-
@property
|
|
55
|
-
def json(self):
|
|
56
|
-
dico: dict = {}
|
|
57
|
-
|
|
58
|
-
for k, v in self.__dict__.items():
|
|
59
|
-
if isinstance(v, list):
|
|
60
|
-
if v and isinstance(v[0], FoxObject):
|
|
61
|
-
dico[k] = [d.json for d in v]
|
|
62
|
-
|
|
63
|
-
else:
|
|
64
|
-
dico[k] = v
|
|
65
|
-
|
|
66
|
-
else:
|
|
67
|
-
dico[k] = v
|
|
68
|
-
|
|
69
|
-
return dico
|
|
23
|
+
super().__setitem__(k, FoxObject(v))
|
|
70
24
|
|
|
71
25
|
|
|
72
26
|
class APIObject(FoxObject):
|
|
@@ -86,6 +40,7 @@ class WarObject(FoxObject):
|
|
|
86
40
|
scheduledConquestEndTime: str,
|
|
87
41
|
requiredVictoryTowns: int,
|
|
88
42
|
shortRequiredVictoryTowns: int,
|
|
43
|
+
response=None,
|
|
89
44
|
**kwargs
|
|
90
45
|
):
|
|
91
46
|
|
|
@@ -99,6 +54,8 @@ class WarObject(FoxObject):
|
|
|
99
54
|
self.requiredVictoryTowns: str = requiredVictoryTowns
|
|
100
55
|
self.shortRequiredVictoryTowns: str = shortRequiredVictoryTowns
|
|
101
56
|
|
|
57
|
+
self.response = response
|
|
58
|
+
|
|
102
59
|
|
|
103
60
|
class WarReportObject(FoxObject):
|
|
104
61
|
def __init__(self,
|
|
@@ -107,6 +64,7 @@ class WarReportObject(FoxObject):
|
|
|
107
64
|
wardenCasualties: int,
|
|
108
65
|
dayOfWar: int,
|
|
109
66
|
version: int,
|
|
67
|
+
response=None,
|
|
110
68
|
**kwargs
|
|
111
69
|
):
|
|
112
70
|
|
|
@@ -118,6 +76,8 @@ class WarReportObject(FoxObject):
|
|
|
118
76
|
self.dayOfWar: int = dayOfWar
|
|
119
77
|
self.version: int = version
|
|
120
78
|
|
|
79
|
+
self.response = response
|
|
80
|
+
|
|
121
81
|
|
|
122
82
|
class MapItemsObject(FoxObject):
|
|
123
83
|
def __init__(self,
|
|
@@ -159,12 +119,13 @@ class SDObject(FoxObject):
|
|
|
159
119
|
def __init__(self,
|
|
160
120
|
regionId: int,
|
|
161
121
|
scorchedVictoryTowns: int,
|
|
162
|
-
mapItems: list,
|
|
163
|
-
mapItemsC: list,
|
|
164
|
-
mapItemsW: list,
|
|
165
|
-
mapTextItems: list,
|
|
122
|
+
mapItems: list[MapItemsObject],
|
|
123
|
+
mapItemsC: list[MapItemsObject],
|
|
124
|
+
mapItemsW: list[MapItemsObject],
|
|
125
|
+
mapTextItems: list[MapTextItemsObject],
|
|
166
126
|
lastUpdated: int,
|
|
167
127
|
version: int,
|
|
128
|
+
response=None,
|
|
168
129
|
**kwargs
|
|
169
130
|
):
|
|
170
131
|
|
|
@@ -179,3 +140,5 @@ class SDObject(FoxObject):
|
|
|
179
140
|
|
|
180
141
|
self.lastUpdated: int = lastUpdated
|
|
181
142
|
self.version: int = version
|
|
143
|
+
|
|
144
|
+
self.response = response
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: foxapi
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.1
|
|
4
4
|
Summary: A wrapper for the foxhole API
|
|
5
5
|
Home-page: https://github.com/ThePhoenix78/FoxAPI
|
|
6
6
|
Download-URL: https://github.com/ThePhoenix78/FoxAPI/tarball/master
|
|
@@ -137,11 +137,12 @@ load_hexagon_map(hexagon: str) -> pillow.Image
|
|
|
137
137
|
- Loads the PNG map for the specified hexagon.
|
|
138
138
|
|
|
139
139
|
```py
|
|
140
|
-
make_map_png(hexagon: str, icons: str | list = "all", colored: bool = False, dynamic: SDObject = None, static: SDObject = None, session: aiohttp.ClientSession | None = None) -> pillow.Image
|
|
140
|
+
make_map_png(hexagon: str, icons: str | list = "all", colored: bool = False, dynamic: SDObject = None, static: SDObject = None, force: bool = False, session: aiohttp.ClientSession | None = None) -> pillow.Image
|
|
141
141
|
```
|
|
142
142
|
- Generates a PNG image of the hexagon map with all the icons associated to each faction in their respective colors (included fields and town base). Only public data will be present.
|
|
143
143
|
- colored -> display each region in the team's color
|
|
144
144
|
- icons -> display selected building in their team's color
|
|
145
|
+
- force -> bypass the cache and generate a new map
|
|
145
146
|
|
|
146
147
|
```py
|
|
147
148
|
calculate_death_rate(hexagon: str = None, war_report: WarReportObject = None, session: aiohttp.ClientSession | None = None): -> dict
|
|
@@ -236,6 +237,7 @@ class WarObject:
|
|
|
236
237
|
scheduledConquestEndTime: str
|
|
237
238
|
requiredVictoryTowns: str
|
|
238
239
|
shortRequiredVictoryTowns: str
|
|
240
|
+
response: APIResponse
|
|
239
241
|
|
|
240
242
|
|
|
241
243
|
class WarReportObject:
|
|
@@ -244,6 +246,7 @@ class WarReportObject:
|
|
|
244
246
|
wardenCasualties: int
|
|
245
247
|
dayOfWar: int
|
|
246
248
|
version: int
|
|
249
|
+
response: APIResponse
|
|
247
250
|
|
|
248
251
|
|
|
249
252
|
class MapItemsObject:
|
|
@@ -273,6 +276,7 @@ class SDObject:
|
|
|
273
276
|
|
|
274
277
|
lastUpdated: int
|
|
275
278
|
version: int
|
|
279
|
+
response: APIResponse
|
|
276
280
|
```
|
|
277
281
|
|
|
278
282
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|