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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations