use of main.elements.conditions.PropCondition in project Eidolons by IDemiurge.
the class HqShop method initItems.
private void initItems() {
items = new ArrayList<>();
if (isPreset()) {
items = DataManager.toTypeList(StringMaster.openContainer(getProperty(PROPS.SHOP_ITEMS)), C_OBJ_TYPE.ITEMS);
return;
}
List<ObjType> templates = DataManager.toTypeList(StringMaster.openContainer(getProperty(PROPS.SHOP_ITEM_TEMPLATES)), C_OBJ_TYPE.ITEMS);
items = getItemsFromTemplates(templates);
if (getShopType() == null)
return;
// addStandardItems(); then randomize
PROPERTY prop = getShopType().getFilterProp();
int i = 0;
String[] item_groups = getShopType().getItem_groups();
for (String group : item_groups) {
List<ObjType> pool;
if (prop == null) {
pool = DataManager.toTypeList(DataManager.getTypesSubGroupNames(C_OBJ_TYPE.ITEMS, group), C_OBJ_TYPE.ITEMS);
} else {
pool = ItemGenerator.getBaseTypes(C_OBJ_TYPE.ITEMS);
FilterMaster.filter(pool, new PropCondition(prop, group));
}
pool = constructPool(pool);
pool.addAll(getSpecialItems(group));
i++;
if (!isRandomized()) {
for (ObjType item : pool) {
buyItem(item, 0);
}
// buyAll();
continue;
}
//
goldToSpend = (100 - spareGold - i * 5) / item_groups.length;
// some params from Shop ObjType?
Loop.startLoop(ShopMaster.getMaxItemsPerGroup(this));
while (!Loop.loopEnded() && !pool.isEmpty()) {
int randomListIndex = RandomWizard.getRandomListIndex(pool);
ObjType t = pool.get(randomListIndex);
if (t == null) {
continue;
}
if (!buyItem(t)) {
// second loop based on cheapest items?
break;
}
}
}
}
use of main.elements.conditions.PropCondition in project Eidolons by IDemiurge.
the class AshAnnihilationRule method initConditions.
@Override
public void initConditions() {
conditions = new Conditions(new NumericCondition("{match_blaze_counters}", "0"));
conditions.add(new NotCondition(new ClassificationCondition(CLASSIFICATIONS.ELEMENTAL)));
conditions.add(new NotCondition(new PropCondition(G_PROPS.STANDARD_PASSIVES, STANDARD_PASSIVES.IMMATERIAL.getName())));
}
use of main.elements.conditions.PropCondition in project Eidolons by IDemiurge.
the class Shop method initItems.
private void initItems() {
if (!getProperty(MACRO_PROPS.SHOP_ITEMS).isEmpty()) {
DataManager.toTypeList(StringMaster.openContainer(getProperty(MACRO_PROPS.SHOP_ITEMS)), C_OBJ_TYPE.ITEMS);
}
if (getIntParam(PARAMS.GOLD) == 0) {
setParam(PARAMS.GOLD, ShopMaster.getBaseGold(this));
}
if (getIntParam(PARAMS.GOLD_MOD) == 0) {
setParam(PARAMS.GOLD_MOD, ShopMaster.getBaseGoldCostMod(this), true);
}
if (getIntParam(MACRO_PARAMS.SHOP_INCOME) == 0) {
setParam(MACRO_PARAMS.SHOP_INCOME, ShopMaster.getBaseGoldIncome(this), true);
}
items = new ArrayList<>();
// addStandardItems(); then randomize
PROPERTY prop = getShopType().getFilterProp();
int i = 0;
String[] item_groups = getShopType().getItem_groups();
// Up to 4 item groups!
if (item_groups.length > MAX_ITEM_GROUPS) {
List<String> list = new ArrayList<>(Arrays.asList(item_groups));
item_groups = new String[MAX_ITEM_GROUPS];
int j = 0;
while (j < MAX_ITEM_GROUPS) {
String e = list.get(RandomWizard.getRandomListIndex(list));
list.remove(e);
item_groups[j] = e;
j++;
}
}
for (String group : item_groups) {
List<ObjType> pool;
if (prop == null) {
pool = DataManager.toTypeList(DataManager.getTypesSubGroupNames(C_OBJ_TYPE.ITEMS, group), C_OBJ_TYPE.ITEMS);
} else {
pool = ItemGenerator.getBaseTypes(C_OBJ_TYPE.ITEMS);
FilterMaster.filter(pool, new PropCondition(prop, group));
}
pool = constructPool(pool);
pool.addAll(getSpecialItems(group));
i++;
//
goldToSpend = (100 - spareGold - i * 5) / item_groups.length;
// some params from Shop ObjType?
Loop.startLoop(ShopMaster.getMaxItemsPerGroup(this));
while (!Loop.loopEnded() && !pool.isEmpty()) {
int randomListIndex = RandomWizard.getRandomListIndex(pool);
ObjType t = pool.get(randomListIndex);
if (t == null) {
continue;
}
if (!buyItem(t)) {
// second loop based on cheapest items?
break;
}
}
}
}
use of main.elements.conditions.PropCondition in project Eidolons by IDemiurge.
the class DualAttackMaster method createDual.
private static DC_UnitAction createDual(DC_UnitAction main, DC_UnitAction offhand) {
Costs costs = getDualCosts(main, offhand);
// cooldown!
ActiveAbility activateAttacks = new ActiveAbility(main.getTargeting(), new Effects(new ActivateEffect(main.getName(), true), new ActivateEffect(offhand.getName(), true)));
Ability setCooldown = new ActiveAbility(new AutoTargeting(new PropCondition(G_PROPS.ACTION_TAGS, "Dual", false)), new ModifyValueEffect(PARAMS.C_COOLDOWN, MOD.SET, getCooldown(main.getOwnerObj())));
Abilities abilities = new Abilities();
abilities.add(activateAttacks);
abilities.add(setCooldown);
ObjType newType = new ObjType("Dual: " + main.getName() + " and " + offhand.getName(), DataManager.getType("Dual Attack", DC_TYPE.ACTIONS));
for (Cost cost : costs.getCosts()) {
PARAMETER p = cost.getCostParam();
if (p == null)
continue;
newType.setParam(p, cost.getPayment().getAmountFormula().toString());
}
DC_UnitAction dual = new DC_UnitAction(newType, main.getOwner(), main.getGame(), new Ref(main.getOwnerObj()));
dual.setAbilities(abilities);
dual.setCosts(costs);
dual.setTargeting(main.getTargeting());
dual.getTargeter().setTargetingInitialized(true);
dual.setConstructed(true);
return dual;
}
Aggregations