From 9f93a5dfc751e2995ecb39c5d6d93cacdc5b3e38 Mon Sep 17 00:00:00 2001 From: Allan Galarza Date: Sat, 17 Aug 2019 08:49:24 -0700 Subject: [PATCH] Fixed kill statistics race stats being inverted --- CHANGELOG.rst | 7 +++++++ tests/tests_kill_statistics.py | 7 +++++++ tibiapy/kill_statistics.py | 6 ++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5fde48d1..9a7c7645 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,13 @@ Changelog Due to this library relying on external content, older versions are not guaranteed to work. Try to always use the latest version. +.. _v2.2.2: + +2.2.2 (2019-08-17) +================== + +- Fixed killed by players and palyers kill stats being inverted for ``KillStatistics`` + .. _v2.2.1: 2.2.1 (2019-08-10) diff --git a/tests/tests_kill_statistics.py b/tests/tests_kill_statistics.py index 33eb4d8a..195609e0 100644 --- a/tests/tests_kill_statistics.py +++ b/tests/tests_kill_statistics.py @@ -26,6 +26,13 @@ def test_kill_statistics_from_content(self): self.assertEqual(kill_statistics.players.last_week_killed, 7) self.assertEqual(kill_statistics.players.last_week_killed, kill_statistics.players.last_week_players_killed) + # demons + demons_entry = kill_statistics.entries["demons"] + self.assertEqual(2071, demons_entry.last_day_killed) + self.assertEqual(1, demons_entry.last_day_players_killed) + self.assertEqual(18484, demons_entry.last_week_killed) + self.assertEqual(8, demons_entry.last_week_players_killed) + def test_kill_statistics_from_content_empty(self): """Testing parsing empty kill statistics""" content = self._load_resource(FILE_KILL_STATISTICS_EMPTY) diff --git a/tibiapy/kill_statistics.py b/tibiapy/kill_statistics.py index cf243e6a..c476b06e 100644 --- a/tibiapy/kill_statistics.py +++ b/tibiapy/kill_statistics.py @@ -92,8 +92,10 @@ def from_content(cls, content): for i, row in enumerate(rows): columns_raw = row.find_all('td') columns = [c.text.replace('\xa0', ' ').strip() for c in columns_raw] - entry = RaceEntry(last_day_killed=int(columns[1]), last_day_players_killed=int(columns[2]), - last_week_killed=int(columns[3]), last_week_players_killed=int(columns[4])) + entry = RaceEntry(last_day_players_killed=int(columns[1]), + last_day_killed=int(columns[2]), + last_week_players_killed=int(columns[3]), + last_week_killed=int(columns[4]), ) if i == len(rows) - 1: total = entry else: