Search in sources :

Example 56 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class CellPrioritizer method getMeleePriorityCellsForUnit.

public List<Coordinates> getMeleePriorityCellsForUnit(UnitAI ai) {
    // DC_PriorityManager.setUnitAi(ai);
    List<Coordinates> list = new ArrayList<>();
    List<Obj> cells = new ArrayList<>(50);
    int max_priority = Integer.MIN_VALUE;
    DC_Cell priority_cell = null;
    for (Unit enemy : Analyzer.getVisibleEnemies(ai)) {
        for (Coordinates c : enemy.getCoordinates().getAdjacentCoordinates()) {
            if (!cells.contains(c)) {
                DC_Cell cell = enemy.getGame().getCellByCoordinate(c);
                int priority = getMeleePriorityForCell(ai.getUnit(), cell);
                if (// threshold maybe
                priority > max_priority) {
                    max_priority = priority;
                    // list.add(cell.getCoordinates());
                    priority_cell = cell;
                }
            // cells.add(enemy.getGame().getCellByCoordinate(c));
            }
        }
    }
    list.add(priority_cell.getCoordinates());
    // Collections.sort(cells, getPrioritySorter(ai.getUnit()));
    // 
    // for (int i = 0; i < prune_threshold; i++)
    // list.add(cells.getOrCreate(i).getCoordinates());
    LogMaster.log(1, "Prioritized cells: " + list);
    return list;
}
Also used : DC_Cell(eidolons.entity.obj.DC_Cell) DC_Obj(eidolons.entity.obj.DC_Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit)

Example 57 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class Analyzer method getCells.

public static List<DC_Cell> getCells(Unit targetUnit, boolean adjacent, boolean detected, boolean free) {
    List<DC_Cell> list = new ArrayList<>();
    for (Obj obj : targetUnit.getGame().getCells()) {
        DC_Cell cell = (DC_Cell) obj;
        if (adjacent) {
            if (!obj.getCoordinates().isAdjacent(targetUnit.getCoordinates())) {
                continue;
            }
        }
        if (free) {
            if (!StackingRule.checkCanPlace(cell.getCoordinates(), targetUnit, null))
                continue;
        // Unit unit = targetUnit.getGame().getUnitByCoordinate(
        // cell.getCoordinates());
        // if (unit != null) {
        // if (VisionManager.checkVisible(unit)) {
        // continue;
        // }
        // }
        }
        if (// TODO in sight etc
        detected) {
            if (cell.getActivePlayerVisionStatus() != PLAYER_VISION.DETECTED) {
                continue;
            }
        }
        list.add(cell);
    }
    return list;
}
Also used : DC_Cell(eidolons.entity.obj.DC_Cell) DC_SpellObj(eidolons.entity.active.DC_SpellObj) DC_Obj(eidolons.entity.obj.DC_Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) ArrayList(java.util.ArrayList)

Example 58 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class DialogMaster method objChoice.

public static Obj objChoice(String string, Obj[] array) {
    List<Obj> list = new ArrayList<>(Arrays.asList(array));
    ObjType type = (ObjType) entityChoice(DataManager.toTypeList(list));
    for (Obj obj : list) {
        if (obj.getType() == type) {
            return obj;
        }
    }
    return null;
}
Also used : ObjType(main.entity.type.ObjType) Obj(main.entity.obj.Obj) ArrayList(java.util.ArrayList)

Example 59 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class GatewayEffect method getUnitType.

public String getUnitType() {
    if (unitType != null) {
        return unitType;
    }
    Obj obj = ref.getSourceObj().getOwner().getHeroObj();
    typeList = null;
    if (prop == null) {
        typeList = DataManager.toTypeList(((Unit) obj).getDeity().getUnitPool(), DC_TYPE.UNITS);
    } else {
        typeList = new Filter<ObjType>(ref, getCondition()).filter(DataManager.getTypes(C_OBJ_TYPE.UNITS_CHARS));
    }
    if (typeList.isEmpty()) {
        return null;
    }
    random = ref.getObj(KEYS.ACTIVE).checkBool(GenericEnums.STD_BOOLS.RANDOM);
    if (!obj.getOwner().isAi()) {
        random = true;
    }
    if (random) {
        unitType = typeList.get(RandomWizard.getRandomListIndex(typeList)).getName();
    } else {
        if (!getGame().isOffline()) {
            if (!obj.isMine()) {
                // unitType = WaitingThread.waitOrGetInput(code);
                return unitType;
            }
        }
        unitType = ListChooser.chooseType(DataManager.toStringList(typeList), C_OBJ_TYPE.BF_OBJ);
        if (!getGame().isOffline()) {
            if (obj.isMine()) {
            // getGame().getConnection().send(code, unitType);
            }
        }
    }
    return unitType;
}
Also used : Filter(main.elements.Filter) Obj(main.entity.obj.Obj)

Example 60 with Obj

use of main.entity.obj.Obj in project Eidolons by IDemiurge.

the class Loader method createObjects.

private static List<Obj> createObjects(List<String> objectNodes) {
    DC_Game game = DC_Game.game;
    List<Obj> objects = new ArrayList<>();
    // TODO ID ORDER MUST BE PRESERVED! put in parameter?
    for (String typesNode : objectNodes) {
        Document node = XML_Converter.getDoc(typesNode);
        DC_TYPE TYPE = DC_TYPE.getType(node.getNodeName());
        for (Node subNode : XML_Converter.getNodeList(node)) {
            String sub = XML_Converter.getStringFromXML(subNode);
            game.setIdManager(new DC_IdManager(game));
            Map<PROPERTY, String> props = getPropsFromNode(sub);
            Map<PARAMETER, String> params = getParamsFromNode(sub);
            ObjType type = DataManager.getType(subNode.getNodeName(), TYPE);
            // preset ID?! init containers by id... including buffs; but first create them
            Ref ref = new Ref(game);
            Node refNode = XML_Converter.findNode(sub, Saver.OBJ_NODE);
            if (refNode != null)
                for (String substring : StringMaster.open(refNode.getTextContent())) {
                    ref.setValue(KEYS.valueOf(substring.split("=")[0].toUpperCase()), substring.split("=")[1]);
                }
            String ownerName = null;
            DC_Player owner = game.getBattleMaster().getPlayerManager().getPlayer(// property?
            ownerName);
            if (owner == null) {
                owner = DC_Player.NEUTRAL;
            }
            Coordinates c = new Coordinates(params.get(G_PARAMS.POS_X) + "-" + params.get(G_PARAMS.POS_Y));
            Obj object = createObj(type, c.x, c.y, owner, game, ref);
            object.getPropMap().putAll(props);
            object.getParamMap().putAll(params);
            object.setId(StringMaster.getInteger(props.get(G_PROPS.ID)));
            objects.add(object);
            init(object);
        }
    }
    return objects;
}
Also used : DC_TYPE(main.content.DC_TYPE) PROPERTY(main.content.values.properties.PROPERTY) Node(org.w3c.dom.Node) Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) DC_Game(eidolons.game.core.game.DC_Game) Document(org.w3c.dom.Document) DC_Player(eidolons.game.battlecraft.logic.battle.universal.DC_Player) Ref(main.entity.Ref) DC_IdManager(eidolons.entity.DC_IdManager) ObjType(main.entity.type.ObjType) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) DC_QuickItemObj(eidolons.entity.item.DC_QuickItemObj) DC_BuffObj(eidolons.entity.obj.attach.DC_BuffObj) DC_FeatObj(eidolons.entity.obj.attach.DC_FeatObj) DC_JewelryObj(eidolons.entity.item.DC_JewelryObj) DC_SpellObj(eidolons.entity.active.DC_SpellObj) Obj(main.entity.obj.Obj) DC_ArmorObj(eidolons.entity.item.DC_ArmorObj) PARAMETER(main.content.values.parameters.PARAMETER)

Aggregations

Obj (main.entity.obj.Obj)127 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)34 DC_Obj (eidolons.entity.obj.DC_Obj)30 Coordinates (main.game.bf.Coordinates)27 Unit (eidolons.entity.obj.unit.Unit)24 ArrayList (java.util.ArrayList)19 Ref (main.entity.Ref)15 DC_SpellObj (eidolons.entity.active.DC_SpellObj)14 BuffObj (main.entity.obj.BuffObj)13 DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)12 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)11 ActiveObj (main.entity.obj.ActiveObj)10 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)9 PassiveAbilityObj (main.ability.PassiveAbilityObj)9 ObjType (main.entity.type.ObjType)8 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)7 DC_BuffObj (eidolons.entity.obj.attach.DC_BuffObj)7 PARAMETER (main.content.values.parameters.PARAMETER)7 Conditions (main.elements.conditions.Conditions)6 MicroObj (main.entity.obj.MicroObj)6