use of com.nyrds.android.util.TrackedRuntimeException in project pixel-dungeon-remix by NYRDS.
the class PredesignedLevel method createItems.
@Override
protected void createItems() {
try {
if (mLevelDesc.has("items")) {
JSONArray itemsDesc = mLevelDesc.getJSONArray("items");
for (int i = 0; i < itemsDesc.length(); ++i) {
JSONObject itemDesc = itemsDesc.optJSONObject(i);
int x = itemDesc.getInt("x");
int y = itemDesc.getInt("y");
if (cellValid(x, y)) {
Item item = ItemFactory.createItemFromDesc(itemDesc);
drop(item, cell(x, y));
}
}
}
} catch (JSONException e) {
throw new TrackedRuntimeException("bad items description", e);
} catch (Exception e) {
throw new TrackedRuntimeException(e);
}
}
use of com.nyrds.android.util.TrackedRuntimeException in project pixel-dungeon-remix by NYRDS.
the class SpellFactory method getSpellByName.
@Nullable
public static Spell getSpellByName(String name) {
try {
Class<? extends Spell> spellClass = mSpellsList.get(name);
if (spellClass == null) {
EventCollector.logEvent("bug", Utils.format("Unknown spell: [%s], getting Magic Torch instead", name));
spellClass = mSpellsList.get("MagicTorch");
}
return spellClass.newInstance();
} catch (InstantiationException e) {
throw new TrackedRuntimeException(e);
} catch (IllegalAccessException e) {
throw new TrackedRuntimeException(e);
}
}
use of com.nyrds.android.util.TrackedRuntimeException in project pixel-dungeon-remix by NYRDS.
the class Item method detach.
public final Item detach(Bag container) {
if (quantity() <= 0) {
return null;
} else {
if (quantity() == 1) {
return detachAll(container);
} else {
quantity(quantity() - 1);
updateQuickslot();
try {
Item detached = getClass().newInstance();
detached.level(level());
detached.onDetach();
return detached;
} catch (Exception e) {
throw new TrackedRuntimeException(e);
}
}
}
}
use of com.nyrds.android.util.TrackedRuntimeException in project pixel-dungeon-remix by NYRDS.
the class Item method virtual.
public static Item virtual(Class<? extends Item> cl) {
try {
Item item = cl.newInstance();
item.quantity(0);
return item;
} catch (Exception e) {
throw new TrackedRuntimeException("Item.virtual");
}
}
use of com.nyrds.android.util.TrackedRuntimeException in project pixel-dungeon-remix by NYRDS.
the class Item method morphTo.
protected Item morphTo(Class<? extends Item> itemClass) {
try {
Item result = itemClass.newInstance();
result.quantity(quantity());
return result;
} catch (Exception e) {
throw new TrackedRuntimeException(e);
}
}
Aggregations