Skip to content

Commit

Permalink
Minimal initial changes to support Mercenaries power logs
Browse files Browse the repository at this point in the history
  • Loading branch information
joolean committed Oct 6, 2021
1 parent 8dfa766 commit 547754d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
3 changes: 2 additions & 1 deletion hslog/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from .exceptions import MissingPlayerData
from .tokens import UNKNOWN_HUMAN_PLAYER
from .utils import is_mercenaries_game_type


class PlayerReference:
Expand Down Expand Up @@ -227,7 +228,7 @@ def create_or_update_player(
if player_id:
if player.player_id is None:
player.player_id = player_id
elif player.player_id != player_id:
elif player.player_id != player_id and not is_mercenaries_game_type(self._game_type):
raise InconsistentPlayerIdError(player, player_id)

if player.player_id in self._players_by_player_id:
Expand Down
12 changes: 11 additions & 1 deletion hslog/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from hearthstone.enums import TAG_TYPES, GameTag
from hearthstone.enums import TAG_TYPES, GameTag, GameType


def parse_enum(enum, value):
Expand All @@ -20,3 +20,13 @@ def parse_tag(tag, value):
else:
raise NotImplementedError("Invalid string value %r = %r" % (tag, value))
return tag, value


def is_mercenaries_game_type(game_type: GameType):
return game_type in (
GameType.GT_MERCENARIES_AI_VS_AI,
GameType.GT_MERCENARIES_FRIENDLY,
GameType.GT_MERCENARIES_PVE_COOP,
GameType.GT_MERCENARIES_PVE,
GameType.GT_MERCENARIES_PVP,
)
22 changes: 22 additions & 0 deletions tests/test_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,25 @@ def test_name_aliasing(parser: LogParser):
exporter = EntityTreeExporter(packet_tree, player_manager=parser.player_manager)
exporter.export()
assert True


@pytest.mark.regression_suite
def test_mercenaries_solo_bounty(parser: LogParser):
with open(logfile("93227_mercenaries_solo_bounty.power.log")) as f:
parser.read(f)

packet_tree = parser.games[0]
exporter = EntityTreeExporter(packet_tree, player_manager=parser.player_manager)
exporter.export()
assert True


@pytest.mark.regression_suite
def test_mercenaries_solo_pvp(parser: LogParser):
with open(logfile("93227_mercenaries_solo_pvp.power.log")) as f:
parser.read(f)

packet_tree = parser.games[0]
exporter = EntityTreeExporter(packet_tree, player_manager=parser.player_manager)
exporter.export()
assert True

0 comments on commit 547754d

Please sign in to comment.