use of main.system.auxiliary.Loop in project Eidolons by IDemiurge.
the class ActionAnimation method drawIconMap.
protected void drawIconMap(Map<Image, String> map, boolean horizontal, int wrap, boolean mouseMap, Font font, int base, int rows, boolean onTarget, boolean inverse, Boolean bonus_mod_other) {
// if (map.isEmpty())
// return;
List<Map<Image, String>> splitMaps = new MapMaster<Image, String>().splitMap(map, wrap);
// font);
for (Map<Image, String> map1 : splitMaps) {
fillTextRowWithDarkBackground(!onTarget, base + MAX_MINI_ICON_SIZE + getIconMapOffsetY(), font);
int i = 0;
for (Image image : map1.keySet()) {
// StringMaster.wrapInParenthesis(s);
if (image == null) {
LogMaster.log(1, "********** null image in " + map1);
continue;
}
Loop loop = new Loop(10);
while (image.getWidth(null) < 1 && loop.continues()) {
WaitMaster.WAIT(50);
}
if (image.getWidth(null) < 1) {
LogMaster.log(1, "********** invalid image for " + map1.get(image));
continue;
}
String s = map1.get(image);
// ImageManager.getImageForDamageFormulaKey(s);
int height = image.getHeight(null);
int width = image.getWidth(null);
// TODO finish
int y = horizontal ? base : 0;
int itemWidth = w / wrap;
int x = itemWidth * i;
if (map1.size() < wrap) {
x = MigMaster.getCenteredPosition(w, itemWidth * map1.size()) + (i) * itemWidth;
}
drawOn(!onTarget, image, x, y);
if (mouseMap) {
PHASE_TYPE arg = null;
if (subPhaseTypeMap != null) {
arg = subPhaseTypeMap.get(image);
}
if (arg == null) {
addMouseItem(false, x, y, width, height, new MouseItemImpl(MOUSE_ITEM.TOOLTIP, getSubPhaseTooltipMap().get(image)));
} else {
addMouseItem(false, x, y, width, height, new MouseItemImpl(MOUSE_ITEM.SUB_PHASE, arg));
}
}
// addToolTip(s+modsMap.getOrCreate(s));
y += // ((inverse) ? -1 : 1) *
(MAX_MINI_ICON_SIZE + getIconMapOffsetY());
Integer mod = StringMaster.getInteger(s);
Color color = getColorForModifier(mod);
String text = s;
if (bonus_mod_other != null) {
text = bonus_mod_other ? StringMaster.getBonusString(mod) : StringMaster.getModifierString(mod);
}
x += (width - FontMaster.getStringWidth(font, text)) / 2;
drawTextOn(!onTarget, text, font, x, y - fontHeight / 2, color);
i++;
}
base = base + ((!inverse) ? 1 : -1) * (MAX_MINI_ICON_SIZE + getIconMapOffsetY() + FontMaster.getFontHeight(font) / 2);
}
}
use of main.system.auxiliary.Loop in project Eidolons by IDemiurge.
the class TipMaster method getTip.
public static String getTip(int combat_hero_misc) {
Class<? extends TIP> tipClass = null;
switch(combat_hero_misc) {
case 0:
tipClass = basicOrAdvanced ? BASIC_COMBAT_TIPS.class : ADVANCED_COMBAT_TIPS.class;
break;
case 1:
tipClass = basicOrAdvanced ? BASIC_HERO_TIPS.class : ADVANCED_HERO_TIPS.class;
break;
case 2:
tipClass = basicOrAdvanced ? BASIC_USABILITY_TIPS.class : BASIC_USABILITY_TIPS.class;
break;
}
String tip = "";
Loop loop = new Loop(200);
while (loop.continues()) {
// int i = RandomWizard.getRandomInt(tipClass.getEnumConstants().length);
List<TIP> list = new EnumMaster<TIP>().getEnumList((Class<TIP>) tipClass);
TIP tipp = new RandomWizard<TIP>().getRandomListItem(list);
if (displayedTips.contains(tipp)) {
continue;
}
tip = tipp.getText();
if (tip.isEmpty())
continue;
displayedTips.add(tipp);
return tip;
}
displayedTips.clear();
return getTip();
}
use of main.system.auxiliary.Loop in project Eidolons by IDemiurge.
the class ContainerMaster method initContents.
public void initContents(BattleFieldObject obj) {
String contents = "";
RandomWizard<CONTAINER_CONTENTS> wizard = new RandomWizard<>();
String prop = obj.getProperty(PROPS.CONTAINER_CONTENTS);
if (test_mode)
prop = "Food(10);";
Map<CONTAINER_CONTENTS, Integer> map = wizard.constructWeightMap(prop, CONTAINER_CONTENTS.class);
prop = obj.getProperty(PROPS.CONTAINER_CONTENT_VALUE);
RandomWizard<CONTAINER_CONTENT_VALUE> wizard_ = new RandomWizard<>();
Map<CONTAINER_CONTENT_VALUE, Integer> typeMap = wizard_.constructWeightMap(prop, CONTAINER_CONTENT_VALUE.class);
List<CONTAINER_CONTENT_VALUE> itemValueList = new ArrayList<>();
Integer maxCost = obj.getIntParam(PARAMS.GOLD_TOTAL);
int totalCost = 0;
// size prop!
int maxGroups = 2;
Loop overLoop = new Loop(maxGroups);
while (overLoop.continues()) {
CONTAINER_CONTENT_VALUE rarity = wizard_.getObjectByWeight(typeMap);
if (rarity == null)
rarity = CONTAINER_CONTENT_VALUE.COMMON;
if (noDuplicates)
typeMap.remove(rarity);
if (totalCost + rarity.getGoldCost() > maxCost)
break;
itemValueList.add(rarity);
totalCost += rarity.getGoldCost();
}
float randomization = (isRandomizationOn()) ? new Random().nextFloat() + 0.5f : 1;
for (CONTAINER_CONTENT_VALUE rarity : itemValueList) {
maxCost = Math.round(randomization * Math.min(totalCost, rarity.getGoldCost()));
CONTAINER_CONTENTS c = wizard.getObjectByWeight(map);
if (noDuplicates)
map.remove(c);
Integer maxItems = c.getMaxItems();
Integer cost = 0;
int items = 0;
Loop loop = new Loop(maxItems * 3);
while (cost < maxCost && items <= maxItems) {
if (!loop.continues())
break;
int max = Math.round((maxCost - cost) * 1.2f);
ObjType item = getItem(c, max);
if (item == null)
if (c == CONTAINER_CONTENTS.FOOD)
continue;
main.system.auxiliary.log.LogMaster.log(1, c + " rarity " + rarity + " = " + item + "; total : " + cost);
if (item == null)
continue;
contents += item.getName() + StringMaster.SEPARATOR;
cost += item.getIntParam(PARAMS.GOLD_COST);
items++;
}
}
if (contents.isEmpty()) {
main.system.auxiliary.log.LogMaster.log(1, ">> " + obj + " has contents: " + contents + itemValueList);
} else
main.system.auxiliary.log.LogMaster.log(1, ">> " + obj + " has contents: " + contents + itemValueList);
obj.setProperty(PROPS.INVENTORY, contents);
}
use of main.system.auxiliary.Loop in project Eidolons by IDemiurge.
the class ContainerMaster method preselectBaseType.
private ObjType preselectBaseType(CONTAINER_CONTENTS contents, ITEM_RARITY rarity) {
DC_TYPE TYPE = getRandomTYPE(contents);
boolean iterate = isIterateAlways() || TYPE == DC_TYPE.ITEMS || TYPE == DC_TYPE.JEWELRY;
if (isFastSelect()) {
String group = getItemGroup(contents, false, TYPE);
String subgroup = getItemGroup(contents, true, TYPE);
ObjType type = null;
List<ObjType> types = DataManager.getTypes(TYPE, iterate);
main.system.auxiliary.log.LogMaster.log(1, " group= " + group + " subgroup= " + subgroup + "; types = " + types);
Iterator<ObjType> iterator = types.iterator();
int n = 0;
// Math.min(50, types.size() / 3));
Loop loop = new Loop(5);
while (true) {
if (iterate) {
if (!iterator.hasNext())
return null;
type = iterator.next();
} else {
n++;
type = new RandomWizard<ObjType>().getRandomListItem(types);
if (n > types.size() / 5) {
if (!loop.continues())
return null;
group = getItemGroup(contents, false, TYPE);
subgroup = getItemGroup(contents, true, TYPE);
n = 0;
}
}
if (type == null)
break;
if (type.isGenerated())
continue;
if (isRemoveBase(contents, type) && TYPE != DC_TYPE.JEWELRY)
if (!type.checkProperty(PROPS.ITEM_RARITY, rarity.name()))
continue;
if (group != null)
if (!type.checkGroupingProperty(group))
continue;
if (subgroup != null)
if (!type.checkSubGroup(subgroup))
continue;
break;
}
return type;
}
List<ObjType> list = new ArrayList<>();
String groups = getItemGroups(contents, TYPE);
if (groups == null)
groups = " ;";
for (String sub : groups.split(";")) {
if (sub.trim().isEmpty())
sub = null;
List<ObjType> group = new ArrayList<>(isGroupsOrSubgroups(contents, TYPE) ? DataManager.getTypesGroup(TYPE, sub) : DataManager.getTypesSubGroup(TYPE, sub));
// TODO set rarity to common by default
FilterMaster.filterByPropJ8(group, PROPS.ITEM_RARITY.getName(), rarity.name());
filter(contents, group, rarity, TYPE);
if (group.isEmpty())
continue;
// group = generateTypes(c, rarity, group);
// group.removeIf(type -> !type.isGenerated()); //remove base types
list.addAll(group);
}
main.system.auxiliary.log.LogMaster.log(1, "type list= " + list);
if (list.isEmpty()) {
return null;
}
return new RandomWizard<ObjType>().getRandomListItem(list);
}
use of main.system.auxiliary.Loop in project Eidolons by IDemiurge.
the class ExploreGameLoop method waitForAnimations.
@Override
protected void waitForAnimations() {
if (AnimMaster.getInstance().isDrawingPlayer()) {
int maxTime = 1000;
Loop loop = new Loop(20);
int waitTime = 0;
while (waitTime < maxTime && loop.continues() && (DungeonScreen.getInstance().getGridPanel().getViewMap().get(activeUnit).getActions().size > 0 || AnimMaster.getInstance().isDrawingPlayer())) {
WaitMaster.WAIT(100);
waitTime += 100;
}
}
}
Aggregations