// class name, not given name public Member makeAvailable(String className, FactionManager fManager) { Member toMakeAvailable = removeFromAvailable(className); if (toMakeAvailable == null) return null; if (team != null) toMakeAvailable.setColor(team.getColor()); sortedAdd(toMakeAvailable); if (members.size() == 2) { Faction randFac = fManager.getFaction(Constants.A_RANDOM); ArrayList<RoleTemplate> list = new ArrayList<>(); randomMember = new RandomMember(getName() + " Random", getColor()); for (RoleTemplate m : members) { if (!m.isRandom()) { randomMember.addMember((Member) m); } } list.add(randomMember); randFac.add(list); } else if (members.size() > 2) { randomMember.addMember(toMakeAvailable); } return toMakeAvailable; }
public void add(ArrayList<RoleTemplate> list) { for (RoleTemplate m : list) { if (m.isRandom()) sortedAdd(m); else { Member memb = (Member) m; if (team != null) memb.setColor(getColor()); makeAvailable(memb); } } }
public Member makeUnavailable(String roleName, FactionManager fManager) { Member newUnavailable = null; for (RoleTemplate rt : members) { if (rt.isRandom()) continue; Member m = (Member) rt; if (m.getName().equals(roleName)) { newUnavailable = m; break; } } if (newUnavailable == null) return null; unavailableRoles.add(newUnavailable); members.remove(newUnavailable); Collections.sort(unavailableRoles); if (members.size() == 1) { fManager.removeFromRandoms(this); randomMember = null; } return newUnavailable; }
public RoleTemplate getRole(String name) { for (RoleTemplate rt : members) { if (rt.getName().equals(name)) return rt; } return null; }