Перейти к содержанию
Авторизация  
XaTTa6bI4

нужна помощь с саб класами

Рекомендуемые сообщения

как  убрать ограничения 

* Kamael могут брать только сабы Kamael
 * Другие классы не могут брать сабы Kamael
         

Спойлер

public class Subclass extends Functions {
    private static final DateFormat TIME_FORMAT = new SimpleDateFormat("dd.MM.yyyy HH:mm");
    public static final String SUB_CLASS = "@sub_class";

    @Bypass("services.Subclass:page")
    public void page(final Player player, final NpcInstance npc, final String[] arg) {
        int sub_count = player.getPlayerClassComponent().getSubClasses().size();
        String page = arg[0];
        HtmlMessage html = new HtmlMessage(5).setFile("scripts/services/Subclass/" + page + ".htm");
        if (page.equals("choice_race")) {
            if (arg.length == 2) {
                html.replace("%type%", arg[1]);
                html.replace("%price%", Util.formatPay(player, Multiproff.SubClassCount(sub_count), Multiproff.SubClassId(sub_count)));
            }
        } else if (page.equals("choice")) {
            html.replace("%price%", Util.formatPay(player, Multiproff.SubClassCount(sub_count), Multiproff.SubClassId(sub_count)));
        } else if (page.equals("choice_cancel")) {
            if (arg.length == 2) {
                html.replace("%id%", arg[1]);
                html.replace("%price%", Util.formatPay(player, Config.BBS_CLASS_MASTER_SUB_CANCEL_PRICE_COUNT[0], (int) Config.BBS_CLASS_MASTER_SUB_CANCEL_PRICE_COUNT[1]));
            }
        } else if (page.equals("choice_cancel_race")) {
            if (arg.length == 3) {
                html.replace("%id%", arg[1]);
                html.replace("%type%", arg[2]);
                html.replace("%price%", Util.formatPay(player, Config.BBS_CLASS_MASTER_SUB_CANCEL_PRICE_COUNT[0], (int) Config.BBS_CLASS_MASTER_SUB_CANCEL_PRICE_COUNT[1]));
            }
        }
        player.sendPacket(html);
        player.sendPacket(ShowBoard.CLOSE);
    }

    @Bypass("services.Subclass:add")
    public void add(final Player player, final NpcInstance npc, final String[] arg) {
        if (arg.length < 2)
            return;

        if (!Config.BBS_CLASS_MASTER_ADD_SUB_CLASS) {
            player.sendMessage(new CustomMessage("scripts.services.off", player));
            return;
        }
        if (!checkCondition(player))
            return;

        HtmlMessage html = new HtmlMessage(5).setFile("scripts/services/Subclass/add.htm");

        final Set<PlayerClass> subsAvailable;
        subsAvailable = getAvailableSubClasses(player);
        String content = "";
        String type = arg[0];
        String race = arg[1];
        String template;
        String block;
        if ((subsAvailable != null) && (!subsAvailable.isEmpty())) {
            template = HtmCache.getInstance().getHtml("scripts/services/Subclass/template_add.htm", player);
            for (final PlayerClass SUB : subsAvailable) {
                if ((check(type, SUB)) &&((!race.equals("human"))
                        || (SUB.isOfRace(PlayerRace.human))) && ((!race.equals("darkelf"))
                        || ((SUB.isOfRace(PlayerRace.darkelf)) && (player.getPlayerTemplateComponent().getPlayerRace() != PlayerRace.elf))) && ((!race.equals("dwarf"))
                        || (SUB.isOfRace(PlayerRace.dwarf))) && ((!race.equals("elf"))
                        || ((SUB.isOfRace(PlayerRace.elf)) && (player.getPlayerTemplateComponent().getPlayerRace() != PlayerRace.darkelf))) && ((!race.equals("kamael"))
                        || ((SUB.isOfRace(PlayerRace.kamael)) && (player.getPlayerTemplateComponent().getPlayerRace() == PlayerRace.kamael))) && ((!race.equals("orc")) || (SUB.isOfRace(PlayerRace.orc)))) {
                    block = template;
                    block = block.replace("{icon}", Util.getRaceIcon(SUB));
                    block = block.replace("{name}", format(SUB));
                    block = block.replace("{link}", "bypass -h htmbypass_services.Subclass:do_add " + SUB.ordinal());
                    block = block.replace("{race}", Util.getRaceName(player, SUB));
                    content = content + block;
                }
            }
        } else {
            player.sendMessage(new CustomMessage("services.SubClass.add.empty", player));
            return;
        }
        if (content.equals("")) {
            html = new HtmlMessage(5).setFile("scripts/services/Subclass/empty.htm");
        } else {
            html.replace("%content%", content);
        }
        player.sendPacket(html);
    }

    private boolean check(String type, PlayerClass sub) {
        if ((type.equals("Fighter")) && (!sub.isOfType(ClassType.Fighter))) {
            return false;
        }
        if ((type.equals("Mystic")) && (!sub.isOfType(ClassType.Mystic))) {
            return false;
        }
        if ((type.equals("Priest")) && (!sub.isOfType(ClassType.Priest))) {
            return false;
        }
        return true;
    }

    @Bypass("services.Subclass:do_add")
    public void do_add(final Player player, final NpcInstance npc, final String[] arg) {
        final int sub_class = player.getVarInt(SUB_CLASS);
        int sub_count = player.getPlayerClassComponent().getSubClasses().size();
        if (!Config.BBS_CLASS_MASTER_ADD_SUB_CLASS) {
            player.sendMessage(new CustomMessage("scripts.services.off", player));
            return;
        }
        if (!checkCondition(player)) {
            return;
        }
        if (!StringUtils.isBlank(Config.SUB_CLASS_TIME[0])) {
            if (player.getVar("SubClassTime") != null && System.currentTimeMillis() < player.getVarLong("SubClassTime")) {
                player.sendMessage(player.isLangRus() ? "Следующий раз сменить саб класс можно после " + TIME_FORMAT.format(new Date(player.getVarLong("SubClassTime"))) : "The next time you can change the sub class after " + TIME_FORMAT.format(new Date(player.getVarLong("SubClassTime"))));
                return;
            }
        }
        int id = Integer.parseInt(arg[0]);
        Map<Integer, SubClass> list = player.getPlayerClassComponent().getSubClasses();
        if (player.getLevel() < Config.ALT_GAME_LEVEL_TO_GET_SUBCLASS) {
            player.sendMessage(new CustomMessage("org.mmocore.gameserver.model.instances.VillageMasterInstance.NoSubBeforeLevel", player).addNumber(Config.ALT_GAME_LEVEL_TO_GET_SUBCLASS));
            return;
        }
        if (!list.isEmpty()) {
            for (SubClass subClass : list.values()) {
                if (subClass.getLevel() < Config.ALT_GAME_LEVEL_TO_GET_SUBCLASS) {
                    player.sendMessage(new CustomMessage("org.mmocore.gameserver.model.instances.VillageMasterInstance.NoSubBeforeLevel", player).addNumber(Config.ALT_GAME_LEVEL_TO_GET_SUBCLASS));
                    return;
                }
            }
        }
        if (!Config.ALT_GAME_SUBCLASS_WITHOUT_QUESTS && !Config.SERVICES_ALLOW_SUB_CLASS_NO_QUEST && !list.isEmpty() && (list.size() < 2 + Config.ALT_GAME_SUB_ADD)) {
            if (player.isQuestCompleted(234)) {
                if (player.getPlayerTemplateComponent().getPlayerRace() == PlayerRace.kamael) {
                    if (!player.isQuestCompleted(236)) {
                        player.sendMessage(new CustomMessage("org.mmocore.gameserver.model.instances.VillageMasterInstance.QuestSeedsOfChaos", player));
                    }
                } else if (!player.isQuestCompleted(235)) {
                    player.sendMessage(new CustomMessage("org.mmocore.gameserver.model.instances.VillageMasterInstance.QuestMimirsElixir", player));
                }
            } else {
                player.sendMessage(new CustomMessage("org.mmocore.gameserver.model.instances.VillageMasterInstance.QuestFatesWhisper", player));
                return;
            }
        }
        ConfirmDlg dlg = new ConfirmDlg(SystemMsg.S1, 20000).addString("Вы уверены что хотите добавить sub class за " + Multiproff.SubClassCount(sub_count) + " " + DifferentMethods.getItemName(Multiproff.SubClassId(sub_count)) + " ?");

        player.ask(dlg, new OnAnswerListener() {
            @Override
            public void sayYes() {
                if (DifferentMethods.getPay(player, Multiproff.SubClassId(sub_count), Multiproff.SubClassCount(sub_count), true)) {
                    if (!player.getPlayerClassComponent().addSubClass(id, true, 0)) {
                        player.sendMessage(new CustomMessage("services.SubClass.add.haveall", player));
                        player.getInventory().addItem(Multiproff.SubClassId(sub_count), Multiproff.SubClassCount(sub_count));
                    } else {
                        if (!StringUtils.isBlank(Config.SUB_CLASS_TIME[0])) {
                            player.setVar("SubClassTime", System.currentTimeMillis() + (Multiproff.SubClassTime(sub_class) * 3600000), -1);
                            player.setVar(SUB_CLASS, sub_class +1, -1);
                        }
                        player.sendMessage(new CustomMessage("services.SubClass.add.done", player).addString(Util.className(player, id)));
                        CommunityBoardClassMaster.showClassPage(player);
                    }
                }
            }

            @Override
            public void sayNo() {
                //Отказ передачи. Обратно к вводу имени перса
                CommunityBoardClassMaster.showClassPage(player);
            }
        });

    }

    @Bypass("services.Subclass:change")
    public void change(final Player player, final NpcInstance npc, final String[] arg) {
        if (player == null)
            return;

        if (!Config.BBS_CLASS_MASTER_CHANGE_SUB_CLASS) {
            player.sendMessage(new CustomMessage("scripts.services.off", player));
            return;
        }

        if (!checkCondition(player))
            return;

        String content = "";

        int base = player.getPlayerClassComponent().getBaseClassId();
        Map<Integer, SubClass> list = player.getPlayerClassComponent().getSubClasses();
        HtmlMessage html;
        String template;
        String block;
        if (list.size() < 2) {
            html = new HtmlMessage(5).setFile("scripts/services/Subclass/change_empty.htm");
            html.replace("%price%", Util.formatPay(player, Config.BBS_CLASS_MASTER_SUB_CHANGE_PRICE_COUNT[0], (int) Config.BBS_CLASS_MASTER_SUB_CHANGE_PRICE_COUNT[1]));
        } else {
            html = new HtmlMessage(5).setFile("scripts/services/Subclass/change.htm");
            template = HtmCache.getInstance().getHtml("scripts/services/Subclass/template_change.htm", player);
            if (base == player.getPlayerClassComponent().getActiveClassId()) {
                block = template;
                block = block.replace("{icon}", "icon.etc_royal_membership_i00");
                block = block.replace("{name}", Util.className(player, base));
                block = block.replace("{link}", "");
                block = block.replace("{type}", new CustomMessage("services.SubClass.activebase", player).toString());
                content = content + block;
            } else {
                block = template;
                block = block.replace("{icon}", "icon.etc_quest_subclass_reward_i00");
                block = block.replace("{name}", Util.className(player, player.getPlayerClassComponent().getActiveClassId()));
                block = block.replace("{link}", "");
                block = block.replace("{type}", new CustomMessage("services.SubClass.active", player).toString());
                content = content + block;

                block = template;
                block = block.replace("{icon}", "icon.etc_royal_membership_i00");
                block = block.replace("{name}", Util.className(player, base));
                block = block.replace("{link}", "bypass -h htmbypass_services.Subclass:do_change " + base);
                block = block.replace("{type}", new CustomMessage("services.SubClass.base", player).toString());
                content = content + block;
            }
            for (SubClass subClass : list.values()) {
                int sub = subClass.getClassId();
                if (!subClass.isBase() && sub != player.getPlayerClassComponent().getActiveClassId()) {
                    block = template;
                    block = block.replace("{icon}", "icon.etc_quest_subclass_reward_i00");
                    block = block.replace("{name}", Util.className(player, sub));
                    block = block.replace("{link}", "bypass -h htmbypass_services.Subclass:do_change " + sub);
                    block = block.replace("{type}", new CustomMessage("services.SubClass.normal", player).toString());
                    content = content + block;
                }
            }
        }
        html.replace("%content%", content);
        player.sendPacket(html);
        player.sendPacket(ShowBoard.CLOSE);
    }

    @Bypass("services.Subclass:do_change")
    public void do_change(final Player player, final NpcInstance npc, final String[] arg) {
        if (player == null)
            return;

        if (!Config.BBS_CLASS_MASTER_CHANGE_SUB_CLASS) {
            player.sendMessage(new CustomMessage("scripts.services.off", player));
            return;
        }

        if (!checkCondition(player))
            return;

        int id = Integer.parseInt(arg[0]);
        ConfirmDlg dlg = new ConfirmDlg(SystemMsg.S1, 20000).addString("Вы уверены что хотите сменить sub class за " + Config.BBS_CLASS_MASTER_SUB_CHANGE_PRICE_COUNT[0] + " " + DifferentMethods.getItemName((int) Config.BBS_CLASS_MASTER_SUB_CHANGE_PRICE_COUNT[1]) + " ?");

        player.ask(dlg, new OnAnswerListener() {
            @Override
            public void sayYes() {
                if (DifferentMethods.getPay(player, (int) Config.BBS_CLASS_MASTER_SUB_CHANGE_PRICE_COUNT[1], Config.BBS_CLASS_MASTER_SUB_CHANGE_PRICE_COUNT[0], true)) {
                    player.getPlayerClassComponent().setActiveSubClass(id, true);
                    player.sendMessage(new CustomMessage("services.SubClass.change.done", player).addString(Util.className(player, player.getPlayerClassComponent().getActiveClassId())));
                }
            }

            @Override
            public void sayNo() {
                //Отказ передачи. Обратно к вводу имени перса
            }
        });
    }

    @Bypass("services.Subclass:cancel")
    public void cancel(final Player player, final NpcInstance npc, final String[] arg) {
        int sub_count = player.getPlayerClassComponent().getSubClasses().size();
        if (!Config.BBS_CLASS_MASTER_CANCEL_SUB_CLASS) {
            player.sendMessage(new CustomMessage("scripts.services.off", player));
            return;
        }
        if (!checkCondition(player))
            return;

        String content = "";

        Map<Integer, SubClass> list = player.getPlayerClassComponent().getSubClasses();
        HtmlMessage html;
        String template;
        String block;
        if (list.size() < 2) {
            html = new HtmlMessage(5).setFile("scripts/services/Subclass/change_empty.htm");
            html.replace("%price%", Util.formatPay(player, Multiproff.SubClassCount(sub_count), Multiproff.SubClassId(sub_count)));
        } else {
            html = new HtmlMessage(5).setFile("scripts/services/Subclass/cancel.htm");
            template = HtmCache.getInstance().getHtml("scripts/services/Subclass/template_cancel.htm", player);
            for (SubClass sub : list.values()) {
                if (!sub.isBase()) {
                    block = template;
                    block = block.replace("{icon}", "icon.etc_quest_subclass_reward_i00");
                    block = block.replace("{name}", Util.className(player, sub.getClassId()));
                    block = block.replace("{link}", "bypass -h htmbypass_services.Subclass:page choice_cancel " + sub.getClassId());
                    block = block.replace("{type}", new CustomMessage("services.SubClass.normal", player).toString());
                    content = content + block;
                }
            }
        }
        html = html.replace("%content%", content);
        player.sendPacket(html);
        player.sendPacket(ShowBoard.CLOSE);
    }

    @Bypass("services.Subclass:cancel_choice")
    public void cancel_choice(final Player player, final NpcInstance npc, final String[] arg) {
        if (!Config.BBS_CLASS_MASTER_CANCEL_SUB_CLASS) {
            player.sendMessage(new CustomMessage("scripts.services.off", player));
            return;
        }
        if (player.getPlayerClassComponent().getClassId().isOfLevel(ClassLevel.First) || player.getPlayerClassComponent().getClassId().isOfLevel(ClassLevel.Second))
            return;

        if (!checkCondition(player))
            return;

        HtmlMessage html = new HtmlMessage(5).setFile("scripts/services/Subclass/cancel_choice.htm");

        String content = "";

        final Set<PlayerClass> subsAvailable;
        subsAvailable = getAvailableSubClasses(player);
        String template;
        String block;
        String type;
        String race;
        int id;
        if (!subsAvailable.isEmpty()) {
            template = HtmCache.getInstance().getHtml("scripts/services/Subclass/template_cancel_choice.htm", player);

            type = arg[0];
            race = arg[1];
            id = Integer.parseInt(arg[2]);
            for (PlayerClass SUB : subsAvailable) {
                if ((check(type, SUB)) &&
                        ((!race.equals("human")) || (SUB.isOfRace(PlayerRace.human))) &&
                        ((!race.equals("darkelf")) || ((SUB.isOfRace(PlayerRace.darkelf)) && (player.getPlayerTemplateComponent().getPlayerRace() != PlayerRace.elf))) &&
                        ((!race.equals("dwarf")) || (SUB.isOfRace(PlayerRace.dwarf))) &&
                        ((!race.equals("elf")) || ((SUB.isOfRace(PlayerRace.elf)) && (player.getPlayerTemplateComponent().getPlayerRace() != PlayerRace.darkelf))) &&
                        ((!race.equals("kamael")) || ((SUB.isOfRace(PlayerRace.kamael)) && (player.getPlayerTemplateComponent().getPlayerRace() == PlayerRace.kamael))) && (
                        (!race.equals("orc")) || (SUB.isOfRace(PlayerRace.orc)))) {
                    block = template;
                    block = block.replace("{icon}", Util.getRaceIcon(SUB));
                    block = block.replace("{name}", format(SUB));
                    block = block.replace("{link}", "bypass -h htmbypass_services.Subclass:do_cancel " + id + " " + SUB.ordinal());
                    block = block.replace("{race}", Util.getRaceName(player, SUB));
                    content = content + block;
                }
            }
        }
        if (content.isEmpty()) {
            player.sendMessage(new CustomMessage("org.mmocore.gameserver.model.instances.VillageMasterInstance.NoSubAtThisTime", player));
            return;
        }
        html = html.replace("%content%", content);
        player.sendPacket(html);
    }

    @Bypass("services.Subclass:do_cancel")
    public void do_cancel(final Player player, final NpcInstance npc, final String[] arg) {
        if (!Config.BBS_CLASS_MASTER_CANCEL_SUB_CLASS) {
            player.sendMessage(new CustomMessage("scripts.services.off", player));
            return;
        }
        if (!checkCondition(player))
            return;

        int oldid = Integer.parseInt(arg[0]);
        int newid = Integer.parseInt(arg[1]);
        ConfirmDlg dlg = new ConfirmDlg(SystemMsg.S1, 20000).addString("Вы уверены что хотите отменить sub class за " + Config.BBS_CLASS_MASTER_SUB_CANCEL_PRICE_COUNT[0] + " " + DifferentMethods.getItemName((int) Config.BBS_CLASS_MASTER_SUB_CANCEL_PRICE_COUNT[1]) + " ?");

        player.ask(dlg, new OnAnswerListener() {
            @Override
            public void sayYes() {
                if (DifferentMethods.getPay(player, (int) Config.BBS_CLASS_MASTER_SUB_CANCEL_PRICE_COUNT[1], Config.BBS_CLASS_MASTER_SUB_CANCEL_PRICE_COUNT[0], true)) {
                    if (player.getPlayerClassComponent().modifySubClass(oldid, newid)) {
                        if (newid > -1) {
                            player.sendMessage(new CustomMessage("services.SubClass.cancel.done", player).addString(Util.className(player, oldid)).addString(Util.className(player, newid)));
                        } else {
                            player.sendMessage(new CustomMessage("services.SubClass.cancel.delete", player).addString(Util.className(player, oldid)));
                        }
                        CommunityBoardClassMaster.showClassPage(player);
                        return;
                    }
                    player.sendMessage(new CustomMessage("org.mmocore.gameserver.model.instances.VillageMasterInstance.SubclassCouldNotBeAdded", player));
                    player.getInventory().addItem((int) Config.BBS_CLASS_MASTER_SUB_CANCEL_PRICE_COUNT[1], Config.BBS_CLASS_MASTER_SUB_CANCEL_PRICE_COUNT[0]);
                }
            }

            @Override
            public void sayNo() {
                //Отказ передачи. Обратно к вводу имени перса
                CommunityBoardClassMaster.showClassPage(player);
            }
        });
    }

    private String format(PlayerClass className) {
        String classNameStr = className.toString();
        char[] charArray = classNameStr.toCharArray();
        for (int i = 1; i < charArray.length; i++) {
            if (Character.isUpperCase(charArray[i])) {
                classNameStr = classNameStr.substring(0, i) + " " + classNameStr.substring(i);
            }
        }
        return classNameStr;
    }

    private boolean checkCondition(Player player) {
        if (player.getPlayerClassComponent().getClassId().isOfLevel(ClassLevel.First) || player.getPlayerClassComponent().getClassId().isOfLevel(ClassLevel.Second)){
            return false;
        }

        if (player.isDead() || player.isAlikeDead()) {
            player.sendMessage(new CustomMessage("services.SubClass.condition.Dead", player));
            return false;
        }
        if (player.isCastingNow() || player.isInCombat() || player.isAttackingNow() || player.isMoving) {
            return false;
        }
        if (player.getServitor() != null) {
            player.sendPacket(SystemMsg.A_SUBCLASS_MAY_NOT_BE_CREATED_OR_CHANGED_WHILE_A_SERVITOR_OR_PET_IS_SUMMONED);
            return false;
        }
        if (player.isActionsDisabled() || player.isTransformed()) {
            player.sendPacket(SystemMsg.SUBCLASSES_MAY_NOT_BE_CREATED_OR_CHANGED_WHILE_A_SKILL_IS_IN_USE);
            return false;
        }
        if (player.getWeightPenalty() >= 3) {
            player.sendPacket(SystemMsg.A_SUBCLASS_CANNOT_BE_CREATED_OR_CHANGED_WHILE_YOU_ARE_OVER_YOUR_WEIGHT_LIMIT);
            return false;
        }

        if (player.getInventoryLimit() * 0.8 < player.getInventory().getSize()) {
            player.sendPacket(SystemMsg.A_SUBCLASS_CANNOT_BE_CREATED_OR_CHANGED_BECAUSE_YOU_HAVE_EXCEEDED_YOUR_INVENTORY_LIMIT);
            return false;
        }
        if ((player.isInZone(Zone.ZoneType.battle_zone)) || (player.isInZone(Zone.ZoneType.no_escape)) || (player.isInZone(Zone.ZoneType.epic)) || (player.isInZone(Zone.ZoneType.SIEGE)) || (player.isInZone(Zone.ZoneType.RESIDENCE)) || (player.getVar("jailed") != null)) {
            player.sendMessage(new CustomMessage("services.SubClass.condition.battle_zone", player));
            return false;
        }
        if (player.getActiveWeaponFlagAttachment() != null) {
            player.sendMessage(new CustomMessage("services.SubClass.condition.FlagAttachment", player));
            return false;
        }
        if (((Config.ENABLE_OLYMPIAD) && (Olympiad.isRegisteredInComp(player))) || (player.isInOlympiadMode())) {
            player.sendMessage(new CustomMessage("scripts.services.olympiad.enable", player));
            return false;
        }
        if (player.getReflection() != ReflectionManager.DEFAULT) {
            player.sendMessage(new CustomMessage("services.SubClass.condition.Reflection", player));
            return false;
        }
        if ((player.isInDuel()) || (player.getTeam() != TeamType.NONE)) {
            player.sendMessage(new CustomMessage("services.SubClass.condition.InDuel", player));
            return false;
        }
        if ((player.isInCombat()) || (player.getPvpFlag() != 0)) {
            player.sendMessage(new CustomMessage("services.SubClass.condition.InCombat", player));
            return false;
        }
        if ((player.isOnSiegeField()) || (player.isInZoneBattle())) {
            player.sendMessage(new CustomMessage("services.SubClass.condition.OnSiegeField", player));
            return false;
        }
        if (player.isFlying()) {
            player.sendMessage(new CustomMessage("services.SubClass.condition.Flying", player));
            return false;
        }
        if (player.isInWater() || player.isInBoat()) {
            player.sendMessage(new CustomMessage("services.SubClass.condition.InWater", player));
            return false;
        }
        return true;
    }

    private Set<PlayerClass> getAvailableSubClasses(final Player player)
    {
        final int charClassId = player.getPlayerClassComponent().getBaseClassId();

        final PlayerClass currClass = PlayerClass.values()[charClassId];// .valueOf(charClassName);

        /**
         * If the race of your main class is Elf or Dark Elf, you may not select
         * each class as a subclass to the other class, and you may not select
         * Overlord and Warsmith class as a subclass.
         *
         * You may not select a similar class as the subclass. The occupations
         * classified as similar classes are as follows:
         *
         * Treasure Hunter, Plainswalker and Abyss Walker Hawkeye, Silver Ranger
         * and Phantom Ranger Paladin, Dark Avenger, Temple Knight and Shillien
         * Knight Warlocks, Elemental Summoner and Phantom Summoner Elder and
         * Shillien Elder Swordsinger and Bladedancer Sorcerer, Spellsinger and
         * Spellhowler
         *
         * Kamael могут брать только сабы Kamael
         * Другие классы не могут брать сабы Kamael
         *
         */
        final Set<PlayerClass> availSubs = currClass.getAvailableSubclasses();
        if(availSubs == null)
            return null;

        // из списка сабов удаляем мейн класс игрока
        availSubs.remove(currClass);

        for(final PlayerClass availSub : availSubs)
        {
            // Удаляем из списка возможных сабов, уже взятые сабы и их предков
            for(final SubClass subClass : player.getPlayerClassComponent().getSubClasses().values())
            {
                if(availSub.ordinal() == subClass.getClassId())
                {
                    availSubs.remove(availSub);
                    continue;
                }

                // Удаляем из возможных сабов их родителей, если таковые есть у чара
                final ClassId parent = ClassId.VALUES[availSub.ordinal()].getParent(player.getSex());
                if(parent != null && parent.getId() == subClass.getClassId())
                {
                    availSubs.remove(availSub);
                    continue;
                }

                // Удаляем из возможных сабов родителей текущих сабклассов, иначе если взять саб berserker
                // и довести до 3ей профы - doombringer, игроку будет предложен berserker вновь (дежавю)
                final ClassId subParent = ClassId.VALUES[subClass.getClassId()].getParent(player.getSex());
                if(subParent != null && subParent.getId() == availSub.ordinal())
                    availSubs.remove(availSub);
            }

            // Особенности саб классов камаэль
            if(availSub.isOfRace(PlayerRace.kamael))
            {
                // Для Soulbreaker-а и SoulHound не предлагаем Soulbreaker-а другого пола
                if((currClass == PlayerClass.MaleSoulHound || currClass == PlayerClass.FemaleSoulHound || currClass == PlayerClass.FemaleSoulbreaker || currClass == PlayerClass.MaleSoulbreaker) && (availSub == PlayerClass.FemaleSoulbreaker || availSub == PlayerClass.MaleSoulbreaker))
                    availSubs.remove(availSub);

                // Для Berserker(doombringer) и Arbalester(trickster) предлагаем Soulbreaker-а только своего пола
                if(currClass == PlayerClass.Berserker || currClass == PlayerClass.Doombringer || currClass == PlayerClass.Arbalester || currClass == PlayerClass.Trickster)
                    if(player.getSex() == 1 && availSub == PlayerClass.MaleSoulbreaker || player.getSex() == 0 && availSub == PlayerClass.FemaleSoulbreaker)
                        availSubs.remove(availSub);

                // Inspector доступен, только когда вкачаны 2 возможных первых саба камаэль(+ мейн класс):
                // doombringer(berserker), soulhound(maleSoulbreaker, femaleSoulbreaker), trickster(arbalester)
                if(availSub == PlayerClass.Inspector)
                    if(!(player.getPlayerClassComponent().getSubClasses().containsKey(131) || player.getPlayerClassComponent().getSubClasses().containsKey(127)))
                        availSubs.remove(availSub);
                    else if(!(player.getPlayerClassComponent().getSubClasses().containsKey(132) || player.getPlayerClassComponent().getSubClasses().containsKey(133) || player.getPlayerClassComponent().getSubClasses().containsKey(128) || player.getPlayerClassComponent().getSubClasses().containsKey(129)))
                        availSubs.remove(availSub);
                    else if(!(player.getPlayerClassComponent().getSubClasses().containsKey(134) || player.getPlayerClassComponent().getSubClasses().containsKey(130)))
                        availSubs.remove(availSub);
            }
        }
        return availSubs;
    }
}

 

 

Изменено пользователем XaTTa6bI4
Закинул под спойлер

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты
21 час назад, serfan1 сказал:

Спрячь код в спойлер...

как?

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

сборка моя, путь указал где править надо, подумать немного не хочет человек

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты
В 11.04.2020 в 08:41, AlexZr сказал:

сборка моя, путь указал где править надо, подумать немного не хочет человек

уже 3 пытались  помогти не вышло 

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Для публикации сообщений создайте учётную запись или авторизуйтесь

Вы должны быть пользователем, чтобы оставить комментарий

Создать учетную запись

Зарегистрируйте новую учётную запись в нашем сообществе. Это очень просто!

Регистрация нового пользователя

Войти

Уже есть аккаунт? Войти в систему.

Войти
Авторизация  

  • Последние посетители   0 пользователей онлайн

    Ни одного зарегистрированного пользователя не просматривает данную страницу

×
×
  • Создать...