use of main.content.CONTENT_CONSTS2.SHOP_TYPE in project Eidolons by IDemiurge.
the class TownInitializer method initShops.
public static void initShops(Town town) {
MacroRef ref = MacroGame.getGame().getRef().getCopy();
int i = 0;
int max = town.getLevel();
if (max == 0) {
max = default_shop_limit;
}
int min = town.getLevel() / 2;
if (min == 0) {
min = default_shop_min;
}
for (String shopTypeName : StringMaster.open(town.getProperty(MACRO_PROPS.SHOPS))) {
i++;
if (i > max) {
break;
}
ObjType type = new ObjType(DataManager.getType(shopTypeName, MACRO_OBJ_TYPES.SHOP));
type.initType();
if (type == null) {
type = getGenericShopType(shopTypeName);
}
addShop(town, ref, type);
}
if (i < min) {
// generate by preferred type/level/mod
Map<SHOP_TYPE, Integer> typeMap = new RandomWizard<SHOP_TYPE>().constructWeightMap(town.getProperty(MACRO_PROPS.SHOP_TYPE), SHOP_TYPE.class, MACRO_OBJ_TYPES.SHOP);
Map<SHOP_MODIFIER, Integer> modMap = new RandomWizard<SHOP_MODIFIER>().constructWeightMap(town.getProperty(MACRO_PROPS.SHOP_MODIFIER), SHOP_MODIFIER.class, MACRO_OBJ_TYPES.SHOP);
while (true) {
SHOP_TYPE shopType = new RandomWizard<SHOP_TYPE>().getObjectByWeight(typeMap);
SHOP_MODIFIER shopMode = new RandomWizard<SHOP_MODIFIER>().getObjectByWeight(modMap);
ObjType type = getGenericShopType(shopType.toString());
type.setProperty(MACRO_PROPS.SHOP_MODIFIER, shopMode.toString());
addShop(town, ref, type);
}
}
}
Aggregations