use of main.entity.type.ObjType in project Eidolons by IDemiurge.
the class UnitGroupMaster method createGroupLeader.
public static ObjType createGroupLeader(boolean me, Entity faction, int unitGroupLevel) {
// type =
List<ObjType> list = DataManager.getTypesSubGroup(DC_TYPE.CHARS, StringMaster.PRESET);
String backgrounds = faction.getProperty(PROPS.HERO_BACKGROUNDS);
FilterMaster.filterOut(list, new NotCondition(new StringComparison(backgrounds, StringMaster.getValueRef(KEYS.MATCH, G_PROPS.BACKGROUND), false)));
FilterMaster.filterOut(list, new NotCondition(new NumericCondition("2", "abs(" + StringMaster.getValueRef(KEYS.MATCH, PARAMS.LEVEL) + "-" + unitGroupLevel + ")", false)));
String name = ListChooser.chooseType(DataManager.toStringList(list), DC_TYPE.CHARS);
if (name == null) {
return null;
}
if (me) {
myHero = name;
} else {
enemyHero = name;
}
return DataManager.getType(name, DC_TYPE.CHARS);
}
use of main.entity.type.ObjType in project Eidolons by IDemiurge.
the class UnitGroupMaster method modifyFactions.
public static void modifyFactions() {
for (FACTION f : FACTION.values()) {
DEITY deity = f.getDeity();
ObjType faction = DataManager.getType(f.toString(), MACRO_OBJ_TYPES.FACTIONS);
if (faction == null) {
continue;
}
if (deity != null) {
ObjType deityType = DataManager.getType(deity.name(), DC_TYPE.DEITIES);
for (ObjType unit : DataManager.getTypes(DC_TYPE.UNITS)) {
if (unit.getProperty(G_PROPS.DEITY).equals(deityType.getName())) {
faction.addProperty(PROPS.UNIT_POOL, unit.getName(), true);
}
}
}
// List<String> list =
// StringMaster.openContainer(faction.getProperty(PROPS.UNIT_POOL));
// SortMaster.sortByValue(list, PARAMS.POWER, OBJ_TYPES.FACTIONS,
// false);
}
}
use of main.entity.type.ObjType in project Eidolons by IDemiurge.
the class UnitGroupMaster method chooseGroup.
public static String chooseGroup(boolean me) {
if (factionMode) {
List<ObjType> available = new ArrayList<>(DataManager.getTypes(MACRO_OBJ_TYPES.FACTIONS));
// DC_HeroObj
FilterMaster.filterByProp(available, G_PROPS.WORKSPACE_GROUP.getName(), "" + MetaEnums.WORKSPACE_GROUP.COMPLETE);
ObjType faction = ListChooser.chooseType_(available, MACRO_OBJ_TYPES.FACTIONS);
if (factionLeaderRequired) {
hero = UnitGroupMaster.createGroupLeader(me, faction, powerLevel);
if (hero == null) {
return null;
}
}
return chooseGroup(faction, powerLevel);
}
File groupFile = ListChooser.chooseFile(PathFinder.getUnitGroupPath());
if (groupFile != null) {
return groupFile.getPath();
}
return null;
}
use of main.entity.type.ObjType in project Eidolons by IDemiurge.
the class UnitGroupMaster method chooseUnit.
private static ObjType chooseUnit(ObjType factionType, int power, int max_power) {
Map<ObjType, Integer> pool = initPool(factionType);
List<ObjType> available = new ArrayList<>();
for (ObjType l : pool.keySet()) {
if (getUnitCost(l, factionType) > power) {
continue;
}
if (l.getIntParam(PARAMS.POWER) > max_power) {
continue;
}
available.add(l);
}
if (available.isEmpty()) {
return null;
}
// chooseUnit();
Map<String, String> map = new HashMap<>();
for (ObjType type : pool.keySet()) {
map.put(type.getName(), "Cost: " + pool.get(type) + "; Power: " + type.getIntParam(PARAMS.POWER));
}
ListChooser.setDecorator(new Decorator() {
@Override
public void addComponents(G_Panel panel) {
G_ListPanel<ObjType> list = // new CustomList<>(getUnitList());
new G_ListPanel<ObjType>(getUnitList()) {
@Override
public void setInts() {
wrap = 1;
minItems = max;
rowsVisible = 1;
layoutOrientation = JList.HORIZONTAL_WRAP;
}
@Override
public boolean isVertical() {
return false;
}
};
list.setPanelSize(new Dimension(300, 120));
panel.add(list, "pos tp.x decor_info.y2");
WrappedTextComp textComp = new WrappedTextComp(null) {
@Override
protected Color getColor() {
return Color.black;
}
@Override
public synchronized List<String> getTextLines() {
List<String> list = new ArrayList<>();
list.add(UnitGroupMaster.getRemainingPower() + " points remaining");
list.add("Size contraints: between " + min + " and " + max);
return list;
}
};
textComp.setDefaultSize(new Dimension(300, 120));
panel.add(textComp, "id decor_info, pos tp.x tp.y2");
}
});
ListChooser.setTooltipMapForComponent(map);
ListChooser.setSortingDisabled(true);
return ListChooser.chooseType_(available, DC_TYPE.UNITS);
// gui - a list per ally
}
use of main.entity.type.ObjType in project Eidolons by IDemiurge.
the class UnitGroupMaster method addUnits.
private static void addUnits(ObjType factionType, Map<ObjType, Integer> map, ObjType allyFactionType) {
for (String unit : StringMaster.open(allyFactionType.getProperty(PROPS.UNIT_POOL))) {
ObjType type = DataManager.getType(unit, DC_TYPE.UNITS);
map.put(type, getUnitCost(type, factionType));
}
}
Aggregations