I'm currently making a game were you have to defend a castle. Each level consists out of lanes were enemies come in and attack it. Now, the castle is the same for every level, if it gets damaged in level 1, it will "spawn" in level 2 with the same health points. So what I did was on the start of the game create one castle object and keep this for the rest of the game.
Here's an illustration to clarify my "design":
Now when an enemy arrives at the castle and damages it my codes looks like this:
this.getLane().getLevel().getGame().getCastle().doDamage(1);
Which doesn't really look very good. I've been looking in some design patterns to come up with a cleaner solution but I didn't really find one and was wondering if someone has an idea.
(I know there's this question about chaining getters out there aswell: https://stackoverflow.com/questions/8744668/java-getter-chaining-bad-or-good but it doesn't really come up with a solution)