use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class ParryRule method canParry.
// precalculateRawDamageForDisplay
private boolean canParry(Attack attack) {
// if (!RuleMaster.isParryOn())return false;
Unit attackedUnit = (Unit) attack.getAttackedUnit();
if (attackedUnit == null)
return false;
if (attackedUnit.getIntParam(PARAMS.PARRY_CHANCE) <= 0) {
return false;
}
if (attack.isSneak()) {
return false;
}
if (attack.isCritical()) {
return false;
}
if (attack.isRanged()) {
return false;
}
if (attack.getWeapon().getWeaponType() == ItemEnums.WEAPON_TYPE.NATURAL) {
return false;
}
if (attack.getWeapon().getWeaponType() == ItemEnums.WEAPON_TYPE.BLUNT) {
return false;
}
// if (attack.getWeapon().getWeaponSize() == WEAPON_SIZE.TINY)
// {
// TODO
DC_WeaponObj parryWeapon = attackedUnit.getActiveWeapon(false);
if (Math.abs(DC_ContentManager.compareSize(parryWeapon.getWeaponSize(), attack.getWeapon().getWeaponSize())) > 2) {
if (attackedUnit.checkDualWielding()) {
} else {
return false;
}
}
// }
return true;
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class StackingRule method canBeMovedOnto.
private boolean canBeMovedOnto(Integer maxSpaceTakenPercentage, Entity unit, Coordinates c, Integer z, List<? extends Entity> otherUnits) {
HashMap<Coordinates, Boolean> bools = cache.get(unit);
boolean result = false;
if (maxSpaceTakenPercentage == 100) {
if (bools != null) {
if (bools.containsKey(c)) {
return bools.get(c);
}
} else {
bools = new HashMap<>();
cache.put(unit, bools);
}
}
// get all units on the cell
DequeImpl<? extends Entity> units = new DequeImpl<>(otherUnits);
for (BattleFieldObject u : game.getObjectsOnCoordinate(z, c, false, false, false)) {
if (!units.contains(u)) {
if (!u.isAnnihilated())
// continue; TODO why was Type necessary?
units.addCast(!u.isDead() ? u.getType() : u);
if (u.isWall())
if (!u.isDead())
return false;
}
}
// check if '1 unit per cell' is on
if (maxSpaceTakenPercentage <= 0) {
if (!units.isEmpty()) {
return false;
}
}
if (unit == null) {
unit = DataManager.getType(HeroCreator.BASE_HERO, DC_TYPE.CHARS);
}
Obj cell;
if (!game.isSimulation()) {
cell = game.getCellByCoordinate(c);
} else {
cell = new DC_Cell(c, game);
}
if (cell == null) {
return false;
}
if (z == null) {
if (unit instanceof Unit) {
Unit heroObj = (Unit) unit;
z = heroObj.getZ();
}
}
// TODO ???
if (game.isSimulation()) {
if (units.size() > 1) {
return false;
}
}
// no passable/overlaying!
int space = StringMaster.getInteger(PARAMS.SPACE.getDefaultValue());
if (c != null) {
if (!game.isSimulation()) {
space = cell.getIntParam(PARAMS.SPACE);
}
}
int girth = 0;
for (Entity u : units) {
if (u == unit) {
continue;
}
// }
if (UnitAnalyzer.isWall(u)) {
// if (!UnitAnalyzer.isFlying(unit)) {
return false;
// }
}
if (u.isDead())
girth += u.getIntParam(PARAMS.GIRTH) / 3;
else
girth += u.getIntParam(PARAMS.GIRTH);
// TODO if (DoorMaster.isDoor((BattleFieldObject) u)) {
//
// }
// main.system.auxiliary.LogMaster.log(1, "****************** " +
// u.getName()
// + "'s Girth " + u.getIntParam(PARAMS.GIRTH));
}
// [QUICK FIX]
if (unit.getIntParam(PARAMS.GIRTH) == 0) {
girth += StringMaster.getInteger(PARAMS.GIRTH.getDefaultValue());
} else {
girth += unit.getIntParam(PARAMS.GIRTH);
}
// main.system.auxiliary.LogMaster.log(1, "****************** " + space
// + " Space vs " + girth
// + " Girth on " + c + " for " + unit);
space = space * maxSpaceTakenPercentage / 100;
if (space >= girth) {
result = true;
} else {
if (unit.getIntParam(PARAMS.GIRTH) > space) {
if (units.isEmpty()) {
result = true;
}
}
}
if (// only cache for default cases!
maxSpaceTakenPercentage == 100) {
bools.put(c, result);
}
return result;
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class ScenarioPartyManager method gameStarted.
@Override
public void gameStarted() {
Unit hero = getGame().getMaster().getUnitByName(PartyManager.selectedHero, true, null, null, getGame().getPlayer(true), null);
// will find 1st if name==null
mainHeroSelected(party, hero);
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class ScenarioPrecombatMaster method newScenario.
public static void newScenario() {
final ScenarioChoiceView scv = new ScenarioChoiceView();
final ChoiceSequence choiceSequence = new ChoiceSequence(scv);
final ScenarioModeChoiceView smcv = new ScenarioModeChoiceView(choiceSequence, SCENARIO_MODES.class);
// TODO only if there are choices!
choiceSequence.addView(smcv);
choiceSequence.start();
choiceSequence.setManager(new SequenceManager() {
@Override
public void doneSelection() {
ObjType type = scv.getSelectedItem();
scenario = new Scenario(type);
SCENARIO_MODES mode = smcv.getSelectedItem();
if (mode == SCENARIO_MODES.STORY_MODE) {
String prop = scenario.getProperty(MACRO_PROPS.MISSION_PARTY);
List<Unit> heroes;
if (!DataManager.isTypeName(prop, DC_TYPE.PARTY)) {
prop = scenario.getProperty(MACRO_PROPS.MISSION_CUSTOM_PARTY);
heroes = new ArrayList<>();
String leaderName = prop.split(";")[0];
Unit leader = Launcher.getMainManager().initSelectedHero(leaderName);
// prop = prop.replace(leaderName, "");
// for (String s : StringMaster.open(prop)) {
// }
heroes.add(leader);
PartyHelper.newParty(leader);
Launcher.getMainManager().launchHC();
return;
} else {
heroes = PartyHelper.loadParty(prop);
}
Launcher.getMainManager().launchHC(heroes);
return;
}
Launcher.resetView(VIEWS.MENU);
}
@Override
public void cancelSelection() {
Launcher.getMainManager().exitToMainMenu();
}
});
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class PartyHelper method addCreepParty.
public static Party addCreepParty(Unit leader, String name, List<Unit> units, ObjType newType) {
newType.setName(name);
Party p = createParty(newType, leader);
for (Unit unit : units) {
p.addMember(unit);
}
parties.add(p);
return p;
}
Aggregations