private int updatePlayerEntity(ParserState state, String rawEntity, Tag tag, int entity) { if (!Utils.isInteger(rawEntity) && !rawEntity.startsWith("[") && !rawEntity.equals("GameEntity")) { if (entity != tag.getValue()) { entity = tag.getValue(); String tmpName = ((PlayerEntity) state.getCurrentGame().getData().get(1)).getName(); ((PlayerEntity) state.getCurrentGame().getData().get(1)) .setName(((PlayerEntity) state.getCurrentGame().getData().get(2)).getName()); ((PlayerEntity) state.getCurrentGame().getData().get(2)).setName(tmpName); for (Object obj : ((Game) state.getNode().getObject()).getData()) { TagChange tChange = obj instanceof TagChange ? (TagChange) obj : null; if (tChange != null) { tChange.setEntity(tChange.getEntity() == 2 ? 3 : 2); } } } } return entity; }
TagChange tagChange = new TagChange(entity, tag.getName(), tag.getValue()); state.updateCurrentNode(Game.class, Action.class); log.debug("\thandling tag change " + tagChange + " on current node " + state.getNode().getType());
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(); } } }
t -> t.getName() == GameTag.PLAYSTATE.getIntValue() && t.getValue() == PlayState.WON.getIntValue()) .findFirst(); if (ourEntityId == winner.get().getEntity()) { winStatus = "won"; t -> t.getName() == GameTag.PLAYSTATE.getIntValue() && t.getValue() == PlayState.TIED.getIntValue()) .findFirst(); if (tied.isPresent()) {