@Override public final boolean isSecret(final IClassification branch) { for (final IAlleleSpecies species : branch.getMemberSpecies()) { if (!this.isSecret(species)) { return false; } } return true; }
@Override public final Collection<IClassification> getDiscoveredBranches(final IBreedingTracker tracker) { final List<IClassification> branches = new ArrayList<>(); for (final IClassification branch : this.getAllBranches()) { boolean discovered = false; for (final IAlleleSpecies species : branch.getMemberSpecies()) { if (this.isSpeciesDiscovered(species, tracker)) { discovered = true; } } if (discovered) { branches.add(branch); } } return branches; }
@Override public final Collection<IClassification> getDiscoveredBranches(final World world, final GameProfile player) { final List<IClassification> branches = new ArrayList<>(); for (final IClassification branch : this.getAllBranches()) { boolean discovered = false; for (final IAlleleSpecies species : branch.getMemberSpecies()) { if (this.isSpeciesDiscovered(species, world, player)) { discovered = true; } } if (discovered) { branches.add(branch); } } return branches; }
@Override public void calculateBranches(ISpeciesRoot speciesRoot) { Collection<IClassification> allRegBranches = AlleleManager.alleleRegistry.getRegisteredClassifications().values(); this.allBranches = new ArrayList<>(); for (IClassification branch : allRegBranches) { IAlleleSpecies[] species = branch.getMemberSpecies(); if (species.length <= 0) { continue; } IAlleleSpecies firstSpecies = species[0]; IAllele[] template = speciesRoot.getTemplate(firstSpecies.getUID()); if (template != null) { boolean possible = false; for (IAlleleSpecies species2 : branch.getMemberSpecies()) { if (allActiveSpecies.contains(species2)) { possible = true; } } if (!possible) { continue; } this.allBranches.add(branch); } } }
@Override public void onValueChanged(final IClassification branch) { this.branchName.setValue(TextFormatting.UNDERLINE + I18N.localise(DatabaseConstants.BRANCH_KEY + ".name", branch.getName())); this.branchScientific.setValue(TextFormatting.ITALIC + I18N.localise(DatabaseConstants.BRANCH_KEY + ".apidae", branch.getScientific())); this.branchAuthority.setValue(I18N.localise(DatabaseConstants.BRANCH_KEY + ".discoveredBy", TextFormatting.BOLD + branch.getMemberSpecies()[0].getAuthority())); for (final IWidget widget : this.branchDescription) { this.deleteChild(widget); } this.branchDescription.clear(); String desc = branch.getDescription(); if (desc == null || Objects.equals(desc, "") || desc.contains("for.")) { desc = I18N.localise(DatabaseConstants.BRANCH_KEY + ".noDesc"); } StringBuilder line = new StringBuilder(); final List<String> descLines = new ArrayList<>(); for (final String str : desc.split(" ")) { if (RenderUtil.getTextWidth(line + " " + str) > 134) { descLines.add(TextFormatting.ITALIC + line.toString() + TextFormatting.RESET); line = new StringBuilder(); } line.append(' ').append(str); } descLines.add(line.toString()); int i = 0; for (final String dLine : descLines) { this.branchDescription.add(new ControlTextCentered(this, 84 + 12 * i++, dLine)); } } }
public void setBranch(final IClassification branch) { if (branch != this.branch) { this.branch = branch; final List<IAlleleSpecies> speciesList2 = new ArrayList<>(); this.movePercentage(-100.0f); this.setOptions(speciesList2); //final EntityPlayer player = Window.get(this).getPlayer(); final GameProfile playerName = Window.get(this).getUsername(); final WindowAbstractDatabase db = Window.get(this); IBreedingSystem breedingSystem = db.getBreedingSystem(); final Collection<IAlleleSpecies> speciesList3 = db.isMaster() ? breedingSystem.getAllSpecies() : breedingSystem.getDiscoveredSpecies(db.getWorld(), playerName); if (branch != null) { for (final IAlleleSpecies species : branch.getMemberSpecies()) { if (speciesList3.contains(species)) { speciesList2.add(species); } } } this.setOptions(speciesList2); } } }