/** * Returns if this team has proper worms. * * @return Returns if all the worms in this team have a reference to this team. | if (for each * worm in this.getAllWorms(): | worm.getTeam() == this) | then result == true | else result * == false */ protected boolean hasProperWorms() { for (Worm worm : this.getWorms()) { if (!(worm.getTeam() == this)) return false; } return true; }
/** * Checks if a given worm can be removed from this team. * * @param worm The worm that needs to be checked. * @return Returns if the given worm is in this team and if the given worm's team is this team. | * result == this.getWorms().contains(worm) && (worm.getTeam() == this) */ protected boolean canRemoveWorm(Worm worm) { return this.getWorms().contains(worm) && (worm.getTeam() == this); }
/** * Checks if a given worm can join this team. * * @param worm The worm that needs to be checked. * @return Returns if the worm has a reference to this team. | result == (worm.getTeam() == this) */ protected boolean canHaveAsWorm(@Raw Worm worm) { return (worm.getTeam() == this); }