Search in sources :

Example 1 with UnitData

use of eidolons.game.battlecraft.logic.dungeon.universal.UnitData 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 2 with UnitData

use of eidolons.game.battlecraft.logic.dungeon.universal.UnitData in project Eidolons by IDemiurge.

the class CombatScriptExecutor method doSpawn.

private boolean doSpawn(Ref ref, String[] args) {
    int i = 0;
    DC_Player player = getPlayerManager().getPlayer(args[i]);
    if (player == null)
        player = getPlayerManager().getPlayer(false);
    else
        i++;
    List<String> units = new ArrayList<>();
    // if (args[i].contains(ScriptSyntax.SPAWN_ARG_UNITS_WAVE))
    String unitString = args[i];
    int level = StringMaster.getInteger(VariableManager.getVars(unitString));
    unitString = VariableManager.removeVarPart(unitString);
    ObjType wave = DataManager.getType(unitString, DC_TYPE.ENCOUNTERS);
    if (wave != null) {
        for (String sub : StringMaster.open(wave.getProperty(PROPS.PRESET_GROUP))) {
            if (level > 0)
                units.add(UnitLevelManager.getLeveledTypeName(level, sub));
            else
                units.add(sub);
        }
    }
    // TODO adjust wave? difficulty => level
    boolean group = false;
    if (units.isEmpty()) {
        units.addAll(StringMaster.openContainer(UnitGroupMaster.getUnitGroupData(unitString, level)));
    }
    if (units.isEmpty()) {
        // DataManager.gettypes
        units.addAll(StringMaster.openContainer(unitString));
    } else
        group = true;
    if (units.isEmpty())
        return false;
    i++;
    // CoordinatesFactory.createCoordinates(unitString);
    // if (origin==null )
    // origin = ref.getObj(unitString).getCoordinates();
    List<Coordinates> coordinates = null;
    if (group) {
        for (String sub : units) {
            coordinates.add(DC_ObjInitializer.getCoordinatesFromObjString(sub));
        }
    } else
        coordinates = getCoordinatesListForUnits(unitString, player, units, ref);
    String data = "";
    data += DataUnitFactory.getKeyValueString(UnitData.FORMAT, PARTY_VALUE.COORDINATES, StringMaster.joinList(coordinates, DataUnitFactory.getContainerSeparator(UnitData.FORMAT)));
    data += DataUnitFactory.getKeyValueString(UnitData.FORMAT, PARTY_VALUE.MEMBERS, StringMaster.joinStringList(units, DataUnitFactory.getContainerSeparator(UnitData.FORMAT)));
    UnitData unitData = new UnitData(data);
    SPAWN_MODE mode = SPAWN_MODE.SCRIPT;
    List<Unit> unitsList = getSpawner().spawn(unitData, player, mode);
    getSpawner().getFacingAdjuster().adjustFacing(unitsList);
    return true;
}
Also used : Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) Unit(eidolons.entity.obj.unit.Unit) DC_Player(eidolons.game.battlecraft.logic.battle.universal.DC_Player) UnitData(eidolons.game.battlecraft.logic.dungeon.universal.UnitData) SPAWN_MODE(eidolons.game.battlecraft.logic.dungeon.universal.Spawner.SPAWN_MODE) ObjType(main.entity.type.ObjType)

Example 3 with UnitData

use of eidolons.game.battlecraft.logic.dungeon.universal.UnitData in project Eidolons by IDemiurge.

the class TutorialPartyManager method initPlayerParty.

@Override
public Party initPlayerParty() {
    ObjType type = DataManager.getType(TUTORIAL_PARTY, DC_TYPE.PARTY);
    party = new Party(type);
    getGame().getState().addObject(party);
    getGame().getDataKeeper().addUnitData(new UnitData(party));
    return party;
}
Also used : Party(eidolons.client.cc.logic.party.Party) ObjType(main.entity.type.ObjType) UnitData(eidolons.game.battlecraft.logic.dungeon.universal.UnitData)

Aggregations

UnitData (eidolons.game.battlecraft.logic.dungeon.universal.UnitData)3 ObjType (main.entity.type.ObjType)3 Party (eidolons.client.cc.logic.party.Party)2 Unit (eidolons.entity.obj.unit.Unit)1 DC_Player (eidolons.game.battlecraft.logic.battle.universal.DC_Player)1 SPAWN_MODE (eidolons.game.battlecraft.logic.dungeon.universal.Spawner.SPAWN_MODE)1 ArrayList (java.util.ArrayList)1 Coordinates (main.game.bf.Coordinates)1