Skip to content

Commit e6c47d6

Browse files
committed
Try to deal with inconsistencies between older and newer war log entries with sccwl and regular wars
1 parent e8246bd commit e6c47d6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

coc/client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ async def get_warlog(self, clan_tag, cache=False, fetch=True, json=False):
348348
if cache:
349349
data = self._war_logs.get(clan_tag, None)
350350
if data:
351-
return check_json(WarLog, data, json)
351+
return check_json((WarLog, LeagueWarLogEntry), data, json)
352352

353353
if fetch is False:
354354
return None
@@ -357,10 +357,16 @@ async def get_warlog(self, clan_tag, cache=False, fetch=True, json=False):
357357

358358
wars = []
359359
for n in r.get('items', []):
360+
# lately war log entries for sccwl can be distinguished by a `null` result
360361
if n.get('result') is None:
361362
wars.append(LeagueWarLogEntry(data=n))
362363
continue
363364

365+
# for earlier logs this is distinguished by no opponent tag (result called `tie`)
366+
if n.get('opponent', {}).get('tag', None) is None:
367+
wars.append(LeagueWarLogEntry(data=n))
368+
continue
369+
364370
wars.append(WarLog(data=n))
365371
self._add_war_log(wars)
366372

0 commit comments

Comments
 (0)