use of eidolons.entity.obj.BattleFieldObject 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;
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class VisionRule method fullReset.
public void fullReset(Unit... observers) {
BattleFieldObject[][][] array = master.getGame().getMaster().getObjCells();
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array[0].length; j++) {
BattleFieldObject[] objects = master.getGame().getMaster().getObjects(i, j);
DC_Cell cell = master.getGame().getCellByCoordinate(new Coordinates(i, j));
for (Unit observer : observers) {
if (!isResetRequired(observer, cell))
continue;
if (isGammaResetRequired(observer, cell)) {
cell.setGamma(observer, master.getGammaMaster().getGamma(observer, cell));
}
master.getSightMaster().resetUnitVision(observer, cell);
for (BattleFieldObject sub : objects) {
// check ignore?
if (!isObjResetRequired(observer, sub))
continue;
if (isGammaResetRequired(observer, sub))
sub.setGamma(observer, master.getGammaMaster().getGamma(observer, sub));
// master.getSightMaster().resetSightStatuses(observer);
master.getSightMaster().resetUnitVision(observer, sub);
// controller.getUnitVisionMapper()
// sub.setUnitVisionStatus(observer, master.getUnitVisibilityStatus(sub, observer));
controller.getVisibilityLevelMapper().set(observer, sub, visibility(observer, sub));
controller.getOutlineMapper().set(observer, sub, outline(observer, sub));
controller.getPlayerVisionMapper().set(observer.getOwner(), sub, playerVision(observer, sub));
}
}
}
}
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class UnitViewTooltipFactory method supplier.
@Override
protected Supplier<List<ValueContainer>> supplier(BattleFieldObject hero) {
return () -> {
List<ValueContainer> values = new ArrayList<>();
if (hero.checkSelectHighlighted()) {
String actionTargetingTooltip = "";
DC_ActiveObj action = (DC_ActiveObj) hero.getGame().getManager().getActivatingAction();
try {
actionTargetingTooltip = ToolTipMaster.getActionTargetingTooltip(hero, action);
} catch (Exception e) {
if (!action.isBroken()) {
main.system.ExceptionMaster.printStackTrace(e);
} else {
action.setBroken(true);
}
}
if (!StringMaster.isEmpty(actionTargetingTooltip)) {
final ValueContainer activationTooltip = new ValueContainer(actionTargetingTooltip, "");
activationTooltip.setNameAlignment(Align.left);
values.add(activationTooltip);
}
}
if (!hero.isMine())
if (!hero.getGame().isDebugMode())
if (hero.getVisibilityLevelForPlayer() != VISIBILITY_LEVEL.CLEAR_SIGHT) {
final ValueContainer nameContainer = new ValueContainer(hero.getToolTip(), "");
nameContainer.setNameAlignment(Align.left);
values.add(nameContainer);
if (hero.getGame().isStarted())
if (hero.getUnitVisionStatus() != null) {
final ValueContainer valueContainer = new ValueContainer(StringMaster.getWellFormattedString(hero.getUnitVisionStatus().name()), "");
valueContainer.setNameAlignment(Align.left);
values.add(valueContainer);
}
String text = hero.getGame().getVisionMaster().getHintMaster().getHintsString(hero);
TextureRegion texture = TextureCache.getOrCreateR(VISUALS.QUESTION.getImgPath());
final ValueContainer hintsContainer = new ValueContainer(texture, text);
hintsContainer.setNameAlignment(Align.left);
hintsContainer.setValueAlignment(Align.right);
values.add(hintsContainer);
return values;
}
final ValueContainer nameContainer = new ValueContainer(hero.getToolTip(), "");
nameContainer.setNameAlignment(Align.left);
values.add(nameContainer);
INFO_LEVEL info_level = new EnumMaster<INFO_LEVEL>().retrieveEnumConst(INFO_LEVEL.class, OptionsMaster.getGameplayOptions().getValue(GAMEPLAY_OPTION.INFO_DETAIL_LEVEL));
values.add(getValueContainer(hero, PARAMS.C_TOUGHNESS, PARAMS.TOUGHNESS));
values.add(getValueContainer(hero, PARAMS.C_ENDURANCE, PARAMS.ENDURANCE));
if (info_level != null)
switch(info_level) {
case VERBOSE:
values.add(getValueContainer(hero, PARAMS.C_STAMINA, PARAMS.STAMINA));
values.add(getValueContainer(hero, PARAMS.C_FOCUS, PARAMS.FOCUS));
values.add(getValueContainer(hero, PARAMS.C_MORALE, PARAMS.MORALE));
values.add(getValueContainer(hero, PARAMS.C_ESSENCE, PARAMS.ESSENCE));
case NORMAL:
addParamStringToValues(hero, values, PARAMS.ARMOR);
addParamStringToValues(hero, values, PARAMS.RESISTANCE);
case BASIC:
addParamStringToValues(hero, values, PARAMS.DAMAGE);
addParamStringToValues(hero, values, PARAMS.ATTACK);
addParamStringToValues(hero, values, PARAMS.DEFENSE);
}
if (hero.getIntParam(PARAMS.N_OF_ACTIONS) > 0) {
values.add(getValueContainer(hero, PARAMS.C_N_OF_ACTIONS, PARAMS.N_OF_ACTIONS));
}
if (hero.getIntParam(PARAMS.N_OF_COUNTERS) > 0) {
values.add(getValueContainer(hero, PARAMS.C_N_OF_COUNTERS, PARAMS.N_OF_COUNTERS));
}
if (hero.getGame().isDebugMode()) {
ValueContainer valueContainer = new ValueContainer("coord:", hero.getCoordinates().toString());
valueContainer.setNameAlignment(Align.left);
valueContainer.setValueAlignment(Align.right);
values.add(valueContainer);
if (hero.getFacing() != null || hero.getDirection() != null) {
final String name = "direction: " + (hero.getFacing() != null ? hero.getFacing().getDirection() : hero.getDirection());
valueContainer = new ValueContainer(name, hero.getCoordinates().toString());
valueContainer.setNameAlignment(Align.left);
valueContainer.setValueAlignment(Align.right);
values.add(valueContainer);
}
}
if (hero instanceof Unit) {
addPropStringToValues(hero, values, G_PROPS.MODE);
addPropStringToValues(hero, values, G_PROPS.STATUS);
}
if (hero.getCustomParamMap() != null) {
hero.getCustomParamMap().keySet().forEach(counter -> {
final String name = StringMaster.getWellFormattedString(counter);
String img = CounterMaster.getImagePath(counter);
if (img != null) {
TextureRegion texture = TextureCache.getOrCreateR(img);
final ValueContainer valueContainer = (texture == null) ? new ValueContainer(name, hero.getCustomParamMap().get(counter)) : new ValueContainer(texture, name, hero.getCustomParamMap().get(counter));
valueContainer.setNameAlignment(Align.left);
valueContainer.setValueAlignment(Align.right);
values.add(valueContainer);
}
});
}
// if (VisionManager.isVisibilityOn()){
if (RuleMaster.isRuleOn(RULE.VISIBILITY) || Eidolons.game.isDebugMode()) {
addParamStringToValues(hero, values, PARAMS.LIGHT_EMISSION);
addParamStringToValues(hero, values, PARAMS.ILLUMINATION);
addParamStringToValues(hero, values, PARAMS.CONCEALMENT);
// addKeyAndValue("Gamma", ""+hero.getGame().getVisionMaster().
// getGammaMaster().
// getGamma(false, hero.getGame().getManager().getActiveObj(), hero), values);
}
if (hero.getGame().isDebugMode()) {
final ValueContainer outlineContainer = new ValueContainer(StringMaster.getWellFormattedString(hero.getOutlineTypeForPlayer() + ""), "");
outlineContainer.setNameAlignment(Align.left);
values.add(outlineContainer);
final ValueContainer outlineContainer2 = new ValueContainer(StringMaster.getWellFormattedString(hero.getVisibilityLevel() + ""), "");
outlineContainer.setNameAlignment(Align.left);
values.add(outlineContainer);
}
return values;
};
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class Analyzer method getSummonCells.
public static List<DC_Cell> getSummonCells(UnitAI ai, DC_ActiveObj action) {
if (EffectFinder.check(action, RaiseEffect.class)) {
return getCorpseCells(ai.getUnit());
}
List<DC_Cell> cells = getCells(ai, true, true, true);
boolean melee = true;
// } preCheck melee TODO
if (melee) {
for (Unit e : getVisibleEnemies(ai)) {
// e.getCoordinates().getAdjacentCoordinates()
cells.addAll(getCells(e, true, false, true));
}
}
cells.removeIf(cell -> {
boolean result = true;
if (ai.getUnit().getGame().getObjectByCoordinate(cell.getCoordinates()) instanceof BattleFieldObject) {
if (((BattleFieldObject) ai.getUnit().getGame().getObjectByCoordinate(cell.getCoordinates())).isWall())
result = false;
}
return result;
});
return cells;
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class JUnitClearshotTest method checkObj.
protected void checkObj(DC_Obj sub, boolean hero_inside, boolean inside) {
OUTLINE_TYPE outline = sub.getOutlineType();
boolean blocked = hero_inside != inside;
LogMaster.setOff(false);
if (blocked)
if (OUTLINE_TYPE.BLOCKED_OUTLINE != outline) {
boolean result = game.getVisionMaster().getSightMaster().getClearShotCondition().check(getHero(), sub);
if (!result) {
main.system.auxiliary.log.LogMaster.log(1, "Failed ClearShotCondition:" + " " + sub + "; hero_inside= " + hero_inside + "; inside=" + inside);
assertTrue(false);
}
} else if (OUTLINE_TYPE.BLOCKED_OUTLINE == outline) {
main.system.auxiliary.log.LogMaster.log(1, "Failed BLOCKED_OUTLINE:" + " " + sub + "; hero_inside= " + hero_inside + "; inside=" + inside);
assertTrue(false);
}
if (sub instanceof BattleFieldObject)
if (!sub.isMine())
if (sub.getVisibilityLevelForPlayer() != VISIBILITY_LEVEL.UNSEEN) {
main.system.auxiliary.log.LogMaster.log(1, "Failed UNSEEN:" + " " + sub + "; hero_inside= " + hero_inside + "; inside=" + inside);
assertTrue(false);
}
}
Aggregations