Every once in awhile, someone sends us some code from a game. Now, I’ve never delved deep into game development, aside from making a 3D asteroids game as a final project for a class twenty years ago, but I’ve also read an article about how fast inverse square root works, and know that you shouldn’t blow in a Nintendo cartridge, so I’m basically an expert, and I understand that under the constraints of games, some of the rules about clarity and maintainability go out the window.

But Adam S found some code that’d be just plain bad in any context:

DamageResult progress(UUID uuid, double progress, boolean auto) {
  return this.isLooted() ? DamageResult.ALREADY_LOOTED : this.thief == null ? this.makeProgress(uuid, progress) : 
    this.challenger == null ? this.thief.equals(uuid) ? auto ? 
    this.ticksSinceLastThiefHit >= this.getConfig().getLootTickRate() ? this.makeProgress(uuid, progress) : 
    DamageResult.AUTO_NOT_YET : this.ticksSinceLastThiefHit >= this.getConfig().getClickRateCap() ? 
    this.makeProgress(uuid, progress) : DamageResult.TOO_QUICK : this.makeChallengeProgress(uuid, progress, true) : 
    this.thief.equals(uuid) || this.challenger.equals(uuid) ? auto ? DamageResult.NO_AUTO_CHALLENGE : 
    (this.thief.equals(uuid) ? this.ticksSinceLastThiefHit : 
      this.ticksSinceLastChallengerHit) >= this.getConfig().getChallengeClickRateCap() ? 
    this.makeChallengeProgress(uuid, progress, false) : DamageResult.TOO_QUICK : DamageResult.CHALLENGE_IN_PROGRESS;
}

Line breaks were added, less to make this any more readable, and more because it needs to fit on the screen somehow. The original is all in one line. The part where they nest a ternary into the conditional side of a ternary leaves me going “null ? what ? auto ?”.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!