Logic error with Tesla Tower damage calculations?

Found this bit of code in the round processing section:
game-engine/domain/src/main/java/za/co/entelect/challenge/entities/TowerDefenseGameMap.java:172

if (teslaBuilding.getX() == (GameConfig.getMapWidth() / 2) - 1) {
  missileOwner.takesHitByPlayer(teslaBuilding.getWeaponDamage(), missileOwner);
}

Seems to me that the player taking the damage and the owner of the Tesla Tower are the same player, unless I am understanding the takesHitByPlayer() function incorrectly.

The intention in my opinion was obviously to damage the opponent health if you build a Tesla Tower on the front line and manage to fire it, unlikely as that may be.

@sschocke Thanks for bringing this up, it is a real important part of the tesla tower to not attack yourself :joy:

The fixed release is out, check it out here

Good evening,

I’ve been fiddling with tesla tower. The good news is that it doesn’t shoot its maker anymore, but there are some other bits that don’t quite make sense to me. Would you mind taking a look?

Most of the issues seem to come from the interaction between the missile tower processing and the tesla towers. Basically, this code from TowerDefenceRoundProcessor.java doesn’t filter out tesla towers

private void createMissilesFromGuns() {
    towerDefenseGameMap.getBuildings().stream()
            .filter(Building::isConstructed)
            .forEach(b -> towerDefenseGameMap.addMissileFromBuilding(b));
}

So the cooldown decreases by 2 every turn instead of 1, and the tesla tower resets the cooldown without firing if you don’t have enough energy (it fires a 0 speed missile instead of a lightning attack).

The next issue is this bit in TowerDefenceGameMap.java

if (possibleTargets.size() > 0) {
    opponentPlayer = getPlayer(possibleTargets.get(0).getPlayerType());
} else {
    return;
}

This will stop a tesla tower from hitting an opponent if there aren’t any buildings in the way.

The last weird bit is this line that appears a few times in TowerDefenceGameMap.java

opponentPlayer.takesHitByPlayer(teslaBuilding.getWeaponDamage(), opponentPlayer);

It looks to me like this is awarding the score for the hit to the player being hit?

1 Like

Thanks a lot for the feedback. We have addressed these issues in the new release :smile:

1 Like

This topic was automatically closed after 13 days. New replies are no longer allowed.