Search in sources :

Example 1 with UnitLevelManager

use of eidolons.client.cc.logic.UnitLevelManager in project Eidolons by IDemiurge.

the class ArenaPositioner method getCoordinatesForUnitGroup.

public List<ObjAtCoordinate> getCoordinatesForUnitGroup(List<ObjType> presetGroupTypes, Wave wave, int unitLevel) {
    Map<Coordinates, ObjType> map = new LinkedHashMap<>();
    boolean custom = false;
    Coordinates presetCenterCoordinate = wave.getCoordinates();
    if (wave.isPresetCoordinate()) {
        if (presetCenterCoordinate != null) {
            custom = isAutoOptimalFacing();
        }
    }
    if (wave.getBlock() != null) {
    // TODO return
    // getCoordinatesForUnitGroupInMapBlock(presetGroupTypes, wave,
    // wave.getBlock());
    }
    if (forcedSide != null) {
        side = forcedSide;
    // forcedSide = null;
    } else {
        side = new EnumMaster<FACING_DIRECTION>().retrieveEnumConst(FACING_DIRECTION.class, wave.getProperty(PROPS.SPAWNING_SIDE));
        if (side == null) {
            nextSide();
        }
    }
    unitGroups.put(side, map);
    int maxUnitsPerRow = getMaxUnitsPerRow(side);
    List<Coordinates> list = getCoordinatesForUnits(presetGroupTypes, custom, presetCenterCoordinate, maxUnitsPerRow);
    List<ObjAtCoordinate> group = new ArrayList<>();
    int i = 0;
    for (Coordinates c : list) {
        ObjType type = new ObjType(presetGroupTypes.get(i));
        type.getGame().initType(type);
        i++;
        if (unitLevel > 0) {
            type = new UnitLevelManager().getLeveledType(type, unitLevel, false);
        }
        ObjAtCoordinate objAtCoordinate = new ObjAtCoordinate(type, c);
        group.add(objAtCoordinate);
    }
    return group;
}
Also used : ObjAtCoordinate(main.entity.type.ObjAtCoordinate) Coordinates(main.game.bf.Coordinates) FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) UnitLevelManager(eidolons.client.cc.logic.UnitLevelManager) ObjType(main.entity.type.ObjType) EnumMaster(main.system.auxiliary.EnumMaster)

Example 2 with UnitLevelManager

use of eidolons.client.cc.logic.UnitLevelManager in project Eidolons by IDemiurge.

the class WaveAssembler method applyLevel.

public void applyLevel() {
    // TODO foreach unit add level and break if exceeding power
    unitLevel++;
    wave.setUnitLevel(unitLevel);
    for (ObjAtCoordinate type : typeMap) {
        ObjType newType = new UnitLevelManager().getLeveledType(type.getType(), 1, true);
        type.setType(newType);
        if (!checkPowerAdjustmentNeeded()) {
            return;
        }
    }
}
Also used : UnitLevelManager(eidolons.client.cc.logic.UnitLevelManager) ObjAtCoordinate(main.entity.type.ObjAtCoordinate) ObjType(main.entity.type.ObjType)

Example 3 with UnitLevelManager

use of eidolons.client.cc.logic.UnitLevelManager in project Eidolons by IDemiurge.

the class Spawner method spawnUnit.

public Unit spawnUnit(String typeName, String coordinates, DC_Player owner, String facing, String level) {
    if (coordinates == null) {
    // TODO  getPositioner().getcoo
    }
    Coordinates c = new Coordinates(coordinates);
    FACING_DIRECTION facing_direction = facing == null ? getFacingAdjuster().getFacingForEnemy(c) : FacingMaster.getFacing(facing);
    ObjType type = DataManager.getType(typeName, C_OBJ_TYPE.UNITS_CHARS);
    // TODO chars or units?!
    if (level != null) {
        int levelUps = StringMaster.getInteger(level);
        if (levelUps > 0) {
            type = new UnitLevelManager().getLeveledType(type, levelUps);
        }
    }
    Unit unit = (Unit) game.getManager().getObjCreator().createUnit(type, c.x, c.y, owner, new Ref(game));
    unit.setFacing(facing_direction);
    if (!unit.isHero())
        UnitTrainingMaster.train(unit);
    if (unit.isMine())
        TestMasterContent.addTestItems(unit.getType(), false);
    return unit;
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) UnitLevelManager(eidolons.client.cc.logic.UnitLevelManager) Ref(main.entity.Ref) ObjType(main.entity.type.ObjType) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit)

Example 4 with UnitLevelManager

use of eidolons.client.cc.logic.UnitLevelManager in project Eidolons by IDemiurge.

the class DC_ObjInitializer method processUnitDataStringToMap.

public static Map<Coordinates, MicroObj> processUnitDataStringToMap(Player owner, String objData, DC_Game game, boolean alt) {
    if (objData == null || objData.equals("")) {
        return null;
    }
    String[] items = objData.split(getObjSeparator(alt));
    Map<Coordinates, MicroObj> map = new HashMap<>();
    int i = 0;
    boolean first = true;
    boolean creeps = false;
    List<Coordinates> excludedCoordinates = new ArrayList<>();
    Boolean last = null;
    for (int indx = 0; indx < items.length; indx++) {
        String item = items[indx];
        boolean excludeCoordinate = false;
        if (mapBlockMode) {
            if (item.contains("%")) {
                Integer chance = StringMaster.getInteger(VariableManager.getVarPart(item).replace("%", " "));
                if (chance < 0) {
                    chance = -chance;
                    excludeCoordinate = true;
                }
                if (RandomWizard.chance(chance)) {
                    continue;
                }
            }
        }
        Coordinates c = null;
        if (item.contains("(") || item.contains("-")) {
            if (!item.contains("null=")) {
                c = getCoordinatesFromObjString(item, alt);
            }
        }
        String typeName = getNameFromObjString(item, alt);
        i++;
        if (i == items.length) {
            last = true;
        }
        int level = 0;
        if (typeName.contains(UnitGroupMaster.TYPE_LEVEL_SEPARATOR)) {
            level = StringMaster.getInteger(StringMaster.getLastPart(typeName, UnitGroupMaster.TYPE_LEVEL_SEPARATOR));
        }
        ObjType type = DataManager.getType(typeName, C_OBJ_TYPE.BF_OBJ);
        if (type == null) {
            type = DataManager.getType(typeName, C_OBJ_TYPE.ITEMS);
            if (type != null)
                createItem(type, c);
            continue;
        }
        if (type.getOBJ_TYPE_ENUM() == DC_TYPE.BF_OBJ)
            owner = DC_Player.NEUTRAL;
        else if (level == 0) {
            if (!owner.isMe())
                if (owner.isAi()) {
                    level = game.getDungeonMaster().getSpawner().getMinLevel(typeName);
                }
        }
        if (type == null) {
            type = DataManager.getType(typeName, DC_TYPE.ENCOUNTERS);
        }
        if (type == null) {
            main.system.auxiliary.log.LogMaster.log(1, "ERROR: Type not found - " + typeName);
            continue;
        }
        if (level != 0) {
            type = new UnitLevelManager().getLeveledType(type, level);
        }
        // UnitGroupMaster.getCurrentGroupHeight();
        int height = UnitGroupMaster.getGroupSizeY(owner);
        int width = UnitGroupMaster.getGroupSizeX(owner);
        if (UnitGroupMaster.getFlip() == FLIP.CW90) {
            int buffer = c.x;
            c.setX(c.y);
            c.setY(buffer);
        } else if (UnitGroupMaster.getFlip() == FLIP.CCW90) {
            int buffer = width - c.x;
            c.setX(height - c.y);
            c.setY(buffer);
        }
        if (UnitGroupMaster.isMirror()) {
            if (UnitGroupMaster.getFlip() == FLIP.CW90 || UnitGroupMaster.getFlip() == FLIP.CCW90) {
                c.setX(width - c.x);
            } else {
                c.setY(height - c.y);
            }
        // TODO c.setX(width - c.x);
        }
        if (offset != null) {
            c.setX(c.x + offset.x);
            c.setY(c.y + offset.y);
            if (!DC_Game.game.getRules().getStackingRule().canBeMovedOnto(type, c)) {
                // TODO tactics?
                // direction
                c = Positioner.adjustCoordinate(type, c, FacingMaster.getRandomFacing());
            // preference?
            }
        }
        if (mapBlockMode) {
            if (excludedCoordinates.contains(c)) {
                continue;
            }
            if (type.getOBJ_TYPE_ENUM() == DC_TYPE.ENCOUNTERS) {
                if (!game.isSimulation()) {
                    game.getBattleMaster().getSpawner().addDungeonEncounter(c_dungeon, block, c, type);
                }
                continue;
            }
            if (!CoreEngine.isLevelEditor() && C_OBJ_TYPE.UNITS_CHARS.equals(type.getOBJ_TYPE_ENUM())) {
                owner = game.getPlayer(false);
            } else {
                owner = DC_Player.NEUTRAL;
            }
            if (C_OBJ_TYPE.ITEMS.equals(type.getOBJ_TYPE_ENUM())) {
            // TODO 'treasure'?
            }
        }
        if (excludeCoordinate) {
            excludedCoordinates.add(c);
        }
        if (type == null) {
            continue;
        }
        if (data != null) {
        // data.addType(type, owner.isMe());
        }
        if (game.isDebugMode()) {
            if (owner.isMe()) {
                try {
                    TestMasterContent.addTestItems(type, last);
                } catch (Exception e) {
                    main.system.ExceptionMaster.printStackTrace(e);
                }
            }
        }
        last = false;
        // todo optimize create unit func it too slow
        BattleFieldObject unit = (BattleFieldObject) game.createUnit(type, c, owner);
        if (unit == null) {
            continue;
        }
        if (FAST_DC.isRunning()) {
            if (!owner.isMe()) {
                creeps = true;
            } else {
                try {
                    Unit hero = (Unit) unit;
                    if (first) {
                        PartyHelper.newParty(hero);
                    } else {
                        PartyHelper.addMember(hero);
                    }
                } catch (Exception e) {
                    main.system.ExceptionMaster.printStackTrace(e);
                }
            }
        }
        first = false;
        if (map.containsKey(c)) {
            ZCoordinates coordinates = new ZCoordinates(c.x, c.y, new Random().nextInt());
            map.put(coordinates, unit);
        } else {
            map.put(c, unit);
        }
        if (!CoreEngine.isLevelEditor()) {
            if (unit.getOBJ_TYPE_ENUM() == DC_TYPE.UNITS) {
                // if (!owner.isMe() || game.isDebugMode()) TODO why
                // not?
                // todo optimize train func it too slow
                UnitTrainingMaster.train((Unit) unit);
            }
        }
    }
    // PartyManager.addCreepParty(DataManager.convertToTypeList(list));
    return map;
}
Also used : MicroObj(main.entity.obj.MicroObj) ZCoordinates(main.game.bf.ZCoordinates) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit) ZCoordinates(main.game.bf.ZCoordinates) UnitLevelManager(eidolons.client.cc.logic.UnitLevelManager) ObjType(main.entity.type.ObjType) BattleFieldObject(eidolons.entity.obj.BattleFieldObject)

Example 5 with UnitLevelManager

use of eidolons.client.cc.logic.UnitLevelManager in project Eidolons by IDemiurge.

the class UnitTrainingMaster method train.

public static void train(Unit unit) {
    if (FAST_DC.isRunning())
        return;
    if (CoreEngine.isFastMode())
        return;
    // if (!FAST_DC.getLauncher().getFAST_MODE()) {
    // if (CoreEngine.isGraphicTestMode()) {
    // return;
    // }
    // }
    int perc = DEFAULT_XP_MOD;
    if (unit.checkClassification(UnitEnums.CLASSIFICATIONS.HUMANOID)) {
        perc += HUMANOID_XP_MOD;
    }
    unit.modifyParamByPercent(PARAMS.XP, perc);
    Integer spell_xp = unit.getIntParam(PARAMS.SPELL_XP_MOD);
    if (spell_xp == 0 && UnitAnalyzer.checkIsCaster(unit)) {
        spell_xp = getSpellXpPercentage(unit);
        spell_xp = MathMaster.applyMod(DEFAULT_CASTER_XP_MOD, spell_xp);
    }
    // DEFAULT_CASTER_XP_MOD;
    int spellXp = unit.getIntParam(PARAMS.XP) * (spell_xp) / 100;
    int skillXp = unit.getIntParam(PARAMS.XP) - spellXp;
    unit.setParam(PARAMS.XP, skillXp);
    if (isSkillsOn()) {
        try {
            // // TODO: 17.11.2016 improve train func execution speed
            UnitTrainer.train(unit);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    if (isShopOn()) {
        try {
            UnitShop.buyItemsForUnit(unit);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    unit.modifyParameter(PARAMS.XP, spellXp);
    if (isSpellsOn()) {
        try {
            UnitLibrary.learnSpellsForUnit(unit);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    try {
        // adjust XP/Gold as per mods and default types...
        // monsters should probably getOrCreate more...
        // and then there is the Unit Level...
        new UnitLevelManager().buyPoints(true, unit.getType());
        new UnitLevelManager().buyPoints(false, unit.getType());
        new UnitLevelManager().spendPoints(unit.getType(), true);
        // will xp/gold be "spent"? WriteToType, nota bene...
        unit.toBase();
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
}
Also used : UnitLevelManager(eidolons.client.cc.logic.UnitLevelManager)

Aggregations

UnitLevelManager (eidolons.client.cc.logic.UnitLevelManager)5 ObjType (main.entity.type.ObjType)4 Coordinates (main.game.bf.Coordinates)3 Unit (eidolons.entity.obj.unit.Unit)2 ObjAtCoordinate (main.entity.type.ObjAtCoordinate)2 FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)2 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 Ref (main.entity.Ref)1 MicroObj (main.entity.obj.MicroObj)1 ZCoordinates (main.game.bf.ZCoordinates)1 EnumMaster (main.system.auxiliary.EnumMaster)1