Search in sources :

Example 21 with ObjType

use of main.entity.type.ObjType in project Eidolons by IDemiurge.

the class ScenarioPartyManager method initPlayerParty.

@Override
public Party initPlayerParty() {
    if (!getMaster().getMetaGame().isPartyRespawn()) {
        party = Eidolons.getParty();
        return party;
    }
    // preset
    // choice
    // already as Unit?
    ObjType type = getMetaGame().getScenario().getPartyType();
    randomOneHero = OptionsMaster.getGameplayOptions().getBooleanValue(GAMEPLAY_OPTION.RANDOM_HERO);
    chooseOneHero = !randomOneHero;
    if (type == null) {
        String string = getMetaGame().getScenario().getProperty(PROPS.SCENARIO_PARTY);
        type = new ObjType("dummy", DC_TYPE.PARTY);
        type.setProperty(PROPS.MEMBERS, string);
    } else
        type = new ObjType(type);
    if (getGame().getMetaMaster().getPartyManager().isRandomOneHero() || getGame().getMetaMaster().getPartyManager().isChooseOneHero()) {
        List<String> members = StringMaster.openContainer(type.getProperty(PROPS.MEMBERS));
        if (getGame().getMetaMaster().getPartyManager().isRandomOneHero() || members.size() == 1) {
            String hero = new RandomWizard<String>().getRandomListItem(members);
            type.setProperty(PROPS.MEMBERS, hero);
        } else {
            // for restart
            String hero = selectedHero;
            if (hero == null)
                hero = chooseHero(members);
            if (hero == null) {
                // aborted
                return null;
            }
            type.setProperty(PROPS.MEMBERS, hero);
        }
    }
    party = new Party(type);
    // if (party.getNextMission().isEmpty()) {
    // String missions = StringMaster.joinList(getMetaGame().getScenario().getAvailableMissions());
    // party.setProperty(PROPS.PARTY_MISSIONS_NEXT,
    // missions
    // StringMaster.openContainer(getMetaGame().getScenario().
    // getProperty(PROPS.SCENARIO_MISSIONS)).get(0)
    // , true);
    // }
    getGame().getState().addObject(party);
    getGame().getDataKeeper().addUnitData(new UnitData(party));
    party.setProperty(PROPS.PARTY_MISSION, StringMaster.openContainer(getMetaGame().getScenario().getProperty(PROPS.SCENARIO_MISSIONS)).get(0), true);
    return party;
}
Also used : Party(eidolons.client.cc.logic.party.Party) ObjType(main.entity.type.ObjType) UnitData(eidolons.game.battlecraft.logic.dungeon.universal.UnitData)

Example 22 with ObjType

use of main.entity.type.ObjType in project Eidolons by IDemiurge.

the class ScenarioPrecombatMaster method newScenario.

public static void newScenario() {
    final ScenarioChoiceView scv = new ScenarioChoiceView();
    final ChoiceSequence choiceSequence = new ChoiceSequence(scv);
    final ScenarioModeChoiceView smcv = new ScenarioModeChoiceView(choiceSequence, SCENARIO_MODES.class);
    // TODO only if there are choices!
    choiceSequence.addView(smcv);
    choiceSequence.start();
    choiceSequence.setManager(new SequenceManager() {

        @Override
        public void doneSelection() {
            ObjType type = scv.getSelectedItem();
            scenario = new Scenario(type);
            SCENARIO_MODES mode = smcv.getSelectedItem();
            if (mode == SCENARIO_MODES.STORY_MODE) {
                String prop = scenario.getProperty(MACRO_PROPS.MISSION_PARTY);
                List<Unit> heroes;
                if (!DataManager.isTypeName(prop, DC_TYPE.PARTY)) {
                    prop = scenario.getProperty(MACRO_PROPS.MISSION_CUSTOM_PARTY);
                    heroes = new ArrayList<>();
                    String leaderName = prop.split(";")[0];
                    Unit leader = Launcher.getMainManager().initSelectedHero(leaderName);
                    // prop = prop.replace(leaderName, "");
                    // for (String s : StringMaster.open(prop)) {
                    // }
                    heroes.add(leader);
                    PartyHelper.newParty(leader);
                    Launcher.getMainManager().launchHC();
                    return;
                } else {
                    heroes = PartyHelper.loadParty(prop);
                }
                Launcher.getMainManager().launchHC(heroes);
                return;
            }
            Launcher.resetView(VIEWS.MENU);
        }

        @Override
        public void cancelSelection() {
            Launcher.getMainManager().exitToMainMenu();
        }
    });
}
Also used : ObjType(main.entity.type.ObjType) ArrayList(java.util.ArrayList) ChoiceSequence(eidolons.client.cc.gui.neo.choice.ChoiceSequence) ArrayList(java.util.ArrayList) List(java.util.List) Unit(eidolons.entity.obj.unit.Unit) ScenarioChoiceView(eidolons.client.cc.gui.neo.choice.ScenarioChoiceView) ScenarioModeChoiceView(eidolons.client.cc.gui.neo.choice.ScenarioModeChoiceView) SequenceManager(eidolons.client.dc.SequenceManager)

Example 23 with ObjType

use of main.entity.type.ObjType in project Eidolons by IDemiurge.

the class PartyHelper method savePartyAs.

/**
 * @param arcade true for New Branch in arcade mode, false for Export Party
 *               from anywhere
 */
public static void savePartyAs(boolean arcade, boolean auto) {
    String newName = party.getName();
    if (!arcade) {
        newName = DialogMaster.inputText(PARTY_NAME_TIP, party.getName());
    }
    if (newName == null) {
        return;
    }
    if (auto) {
        if (!newName.contains(StringMaster.ARCADE)) {
            newName = newName + " " + StringMaster.ARCADE;
        }
    }
    if (!auto) {
        if (DataManager.isTypeName(newName) && !party.getName().equals(newName)) {
            if (!newName.contains(StringMaster.ARCADE)) {
                newName = newName + " " + StringMaster.ARCADE;
            }
            Loop.startLoop(97);
            int i = 2;
            while (!Loop.loopEnded()) {
                if (DataManager.isTypeName(newName + "-" + i)) {
                    continue;
                }
                newName = newName + "-" + i;
                break;
            }
            if (!checkPartyName(newName)) {
                DialogMaster.error("Invalid name!");
                return;
            }
        }
    }
    // save old party
    saveParty();
    ObjType newType = new ObjType(party.getType());
    Simulation.getGame().initType(newType);
    if (arcade) {
        party.setType(newType);
        party.setProperty(G_PROPS.GROUP, StringMaster.ARCADE, true);
        getParty().setName(newName);
        saveParty();
    } else {
        Party exportedParty = newParty(newType);
        exportedParty.setProperty(G_PROPS.GROUP, StringMaster.PRESET, true);
        exportedParty.setName(newName);
        saveParty(exportedParty, true);
    }
}
Also used : Party(eidolons.client.cc.logic.party.Party) ObjType(main.entity.type.ObjType)

Example 24 with ObjType

use of main.entity.type.ObjType in project Eidolons by IDemiurge.

the class PartyHelper method addCreepParty.

public static void addCreepParty(Wave wave) {
    DC_Game game = wave.getGame();
    Unit leader = wave.getLeader();
    String name = wave.getName();
    List<Unit> units = wave.getUnits();
    ObjType newType = new ObjType(game);
    wave.setParty(addCreepParty(leader, name, units, newType));
}
Also used : ObjType(main.entity.type.ObjType) DC_Game(eidolons.game.core.game.DC_Game) Unit(eidolons.entity.obj.unit.Unit)

Example 25 with ObjType

use of main.entity.type.ObjType in project Eidolons by IDemiurge.

the class PartyHelper method loadParty.

public static List<Unit> loadParty(String typeName, DC_Game game, boolean readTypes) {
    // invoke before obj init, to getOrCreate full obj string
    if (readTypes) {
        File file = getPartyFile(typeName);
        String xml = FileManager.readFile(file);
        if (xml.contains(XML_Converter.openXmlFormatted(typeName))) {
            String partyTypeData = StringMaster.getXmlNode(xml, typeName);
            xml = xml.replace(partyTypeData, "");
            XML_Reader.createCustomTypeList(partyTypeData, DC_TYPE.PARTY, game, true);
        }
        XML_Reader.readCustomTypeFile(file, DC_TYPE.CHARS, game);
    }
    ObjType partyType = DataManager.getType(typeName, DC_TYPE.PARTY);
    setParty(newParty(partyType));
    party.toBase();
    return party.getMembers();
}
Also used : ObjType(main.entity.type.ObjType) File(java.io.File)

Aggregations

ObjType (main.entity.type.ObjType)354 ArrayList (java.util.ArrayList)42 Coordinates (main.game.bf.Coordinates)30 Ref (main.entity.Ref)25 Unit (eidolons.entity.obj.unit.Unit)24 OBJ_TYPE (main.content.OBJ_TYPE)18 PROPERTY (main.content.values.properties.PROPERTY)18 DC_TYPE (main.content.DC_TYPE)16 PARAMETER (main.content.values.parameters.PARAMETER)16 File (java.io.File)15 Entity (main.entity.Entity)12 XLinkedMap (main.data.XLinkedMap)11 EnumMaster (main.system.auxiliary.EnumMaster)11 DC_SpellObj (eidolons.entity.active.DC_SpellObj)9 MATERIAL (main.content.enums.entity.ItemEnums.MATERIAL)9 Obj (main.entity.obj.Obj)9 QUALITY_LEVEL (main.content.enums.entity.ItemEnums.QUALITY_LEVEL)8 MusicList (main.music.entity.MusicList)8 Wave (eidolons.game.battlecraft.logic.battle.arena.Wave)6 C_OBJ_TYPE (main.content.C_OBJ_TYPE)6