private static Map<Integer, Class> buildTags() { Map<Integer, Class> tags = new HashMap<>(); tags.put(GameTag.CARDTYPE.getIntValue(), CardType.class); tags.put(GameTag.CLASS.getIntValue(), CardClass.class); tags.put(GameTag.FACTION.getIntValue(), Faction.class); tags.put(GameTag.PLAYSTATE.getIntValue(), PlayState.class); tags.put(GameTag.RARITY.getIntValue(), Rarity.class); tags.put(GameTag.MULLIGAN_STATE.getIntValue(), Mulligan.class); tags.put(GameTag.NEXT_STEP.getIntValue(), Step.class); tags.put(GameTag.STATE.getIntValue(), State.class); tags.put(GameTag.STEP.getIntValue(), Step.class); tags.put(GameTag.ZONE.getIntValue(), Zone.class); return tags; }
private int getTag(List<Tag> tags, GameTag tag) { return tags.stream() .filter(t -> t.getName() == tag.getIntValue()) .findFirst() .map(Tag::getValue) .orElse(-1); }
public static int parseEnum(String tag) { try { int value = Integer.parseInt(tag); return value; } catch (Exception e) { } return GameTag.valueOf(tag).getIntValue(); }
private String getPlayerCardId(HearthstoneReplay replay, PlayerEntity player) { List<GameData> data = replay.getGames().get(0).getData(); int playerEntityId = player.getTags().stream().filter(t -> t.getName() == GameTag.HERO_ENTITY.getIntValue()) .findFirst().get().getValue(); FullEntity playerEntity = data.stream().filter(d -> (d instanceof FullEntity)).map(e -> (FullEntity) e) .filter(e -> e.getId() == playerEntityId).findFirst().get(); return playerEntity.getCardId(); }
private String getPlayerClass(HearthstoneReplay replay, PlayerEntity player) { List<GameData> data = replay.getGames().get(0).getData(); int playerEntityId = player.getTags().stream().filter(t -> t.getName() == GameTag.HERO_ENTITY.getIntValue()) .findFirst().get().getValue(); FullEntity playerEntity = data.stream().filter(d -> (d instanceof FullEntity)).map(e -> (FullEntity) e) .filter(e -> e.getId() == playerEntityId).findFirst().get(); return cardsList.getDbCards().stream() .filter(c -> playerEntity.getCardId().equalsIgnoreCase(c.getId())) .findFirst() .map(DbCard::getPlayerClass) .map(String::toLowerCase) .orElse("unknown"); }
.filter(t -> t.getEntity() == 1 && t.getName() == GameTag.TURN.getIntValue()) .collect(Collectors.toList()); t -> t.getName() == GameTag.PLAYSTATE.getIntValue() && t.getValue() == PlayState.WON.getIntValue()) .findFirst(); t -> t.getName() == GameTag.PLAYSTATE.getIntValue() && t.getValue() == PlayState.TIED.getIntValue()) .findFirst(); if (tied.isPresent()) { .filter(t -> t.getValue() == 1 && t.getName() == GameTag.FIRST_PLAYER.getIntValue()) .findFirst() .orElse(new HasTag(-1, -1, -1));
public void read(TagChange data) { // Start turn if (data.getEntity() == 1 && data.getName() == GameTag.TURN.getIntValue()) { events.turnStart(data.getValue()); } // PREDAMAGE is how much damage should be applied. This includes damage // taken from the armor, while DAMAGE doesn't include armor loss if (data.getName() == GameTag.PREDAMAGE.getIntValue()) { if (data.getValue() > 0 && data.getEntity() != 1) { BaseEntity entity = helper.getEntity(data.getEntity()); events.damageTaken(entity, data.getValue()); } } // Some things still happen after the PLAYSTATE change to WON/LOST/TIED, // so we need to use this // Only raise a single gameEnd event if (data.getName() == GameTag.GOLD_REWARD_STATE.getIntValue() && data.getEntity() == 2) { events.gameEnd(); } } }
Tag tag = Helper.parseTag(tagName, value); if (tag.getName() == GameTag.CURRENT_PLAYER.getIntValue()) { if (state.getFirstPlayerId() == -1) { state.setFirstPlayerId(Integer.parseInt(rawEntity)); if (tag.getName() == GameTag.ENTITY_ID.getIntValue()) { entity = updatePlayerEntity(state, rawEntity, tag, entity); Tag tag = Helper.parseTag(tagName, value); if (tag.getName() == GameTag.CURRENT_PLAYER.getIntValue()) { state.setFirstPlayerId(((PlayerEntity) state.getNode().getObject()).getId());