Browse Source

switch for target type in attack message handler

combat-2
FatBoy-DOTC 1 year ago
parent
commit
5fb3e0fe14
  1. 29
      src/engine/net/client/handlers/AttackCmdMsgHandler.java

29
src/engine/net/client/handlers/AttackCmdMsgHandler.java

@ -49,20 +49,21 @@ public class AttackCmdMsgHandler extends AbstractClientMsgHandler {
targetType = Enum.GameObjectType.values()[msg.getTargetType()]; targetType = Enum.GameObjectType.values()[msg.getTargetType()];
if (msg.getTargetType() == Enum.GameObjectType.Mob.ordinal()) { switch(targetType){
target = Mob.getMob(msg.getTargetID()); case Mob:
} else if (msg.getTargetType() == Enum.GameObjectType.Building.ordinal()) { target = Mob.getMob(msg.getTargetID());
target = BuildingManager.getBuilding(msg.getTargetID()); break;
Building targetBuilding = (Building) target; case PlayerCharacter:
if (!targetBuilding.isVulnerable() || targetBuilding.getRank() < 0) { target = PlayerCharacter.getPlayerCharacter(msg.getTargetID());
playerCharacter.setCombatTarget(null); break;
return true; case Building:
} target = BuildingManager.getBuilding(msg.getTargetID());
} else if(msg.getTargetType() == Enum.GameObjectType.PlayerCharacter.ordinal()){ Building targetBuilding = (Building) target;
target = PlayerCharacter.getPlayerCharacter(msg.getTargetID()); if (!targetBuilding.isVulnerable() || targetBuilding.getRank() < 0)
} else{ return true;// cannot attack destroyed building or protected building
playerCharacter.setCombatTarget(null); break;
return true; //cannot attack other things default:
return true;//cannot attack anything other than the 3 above
} }
if(target == null) { if(target == null) {

Loading…
Cancel
Save