Search in sources :

Example 21 with TrackedRuntimeException

use of com.nyrds.android.util.TrackedRuntimeException in project pixel-dungeon-remix by NYRDS.

the class Mob method split.

public Mob split(int cell, int damage) {
    Mob clone;
    try {
        clone = getClass().newInstance();
    } catch (Exception e) {
        throw new TrackedRuntimeException("split issue");
    }
    clone.hp(Math.max((hp() - damage) / 2, 1));
    clone.setPos(cell);
    clone.setState(clone.HUNTING);
    if (Dungeon.level.map[clone.getPos()] == Terrain.DOOR) {
        Door.enter(clone.getPos());
    }
    Dungeon.level.spawnMob(clone, SPLIT_DELAY);
    Actor.addDelayed(new Pushing(clone, getPos(), clone.getPos()), -1);
    if (hasBuff(Burning.class)) {
        Buff.affect(clone, Burning.class).reignite(clone);
    }
    if (hasBuff(Poison.class)) {
        Buff.affect(clone, Poison.class).set(2);
    }
    if (isPet()) {
        Mob.makePet(clone, Dungeon.hero);
    }
    return clone;
}
Also used : TrackedRuntimeException(com.nyrds.android.util.TrackedRuntimeException) Pushing(com.watabou.pixeldungeon.effects.Pushing) Poison(com.watabou.pixeldungeon.actors.buffs.Poison) JSONException(org.json.JSONException) TrackedRuntimeException(com.nyrds.android.util.TrackedRuntimeException) Burning(com.watabou.pixeldungeon.actors.buffs.Burning)

Example 22 with TrackedRuntimeException

use of com.nyrds.android.util.TrackedRuntimeException in project pixel-dungeon-remix by NYRDS.

the class Bundle method put.

public void put(String key, int[] array) {
    try {
        JSONArray jsonArray = new JSONArray();
        for (int i = 0; i < array.length; i++) {
            jsonArray.put(i, array[i]);
        }
        data.put(key, jsonArray);
    } catch (JSONException e) {
        throw new TrackedRuntimeException("key:" + key, e);
    }
}
Also used : TrackedRuntimeException(com.nyrds.android.util.TrackedRuntimeException) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException)

Example 23 with TrackedRuntimeException

use of com.nyrds.android.util.TrackedRuntimeException in project pixel-dungeon-remix by NYRDS.

the class Bundle method put.

public void put(String key, boolean[] array) {
    try {
        JSONArray jsonArray = new JSONArray();
        for (int i = 0; i < array.length; i++) {
            jsonArray.put(i, array[i]);
        }
        data.put(key, jsonArray);
    } catch (JSONException e) {
        throw new TrackedRuntimeException("key:" + key, e);
    }
}
Also used : TrackedRuntimeException(com.nyrds.android.util.TrackedRuntimeException) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException)

Example 24 with TrackedRuntimeException

use of com.nyrds.android.util.TrackedRuntimeException in project pixel-dungeon-remix by NYRDS.

the class Bundle method write.

public static void write(Bundle bundle, OutputStream stream) {
    try {
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stream));
        writer.write(bundle.data.toString());
        writer.close();
    } catch (IOException e) {
        throw new TrackedRuntimeException("bundle write failed: %s\n", e);
    }
}
Also used : TrackedRuntimeException(com.nyrds.android.util.TrackedRuntimeException) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter)

Example 25 with TrackedRuntimeException

use of com.nyrds.android.util.TrackedRuntimeException in project pixel-dungeon-remix by NYRDS.

the class Bundle method put.

public void put(String key, Collection<? extends Bundlable> collection) {
    JSONArray array = new JSONArray();
    for (Bundlable object : collection) {
        if (!object.dontPack()) {
            Bundle bundle = new Bundle();
            bundle.put(CLASS_NAME, object.getClass().getName());
            object.storeInBundle(bundle);
            BundleHelper.Pack(object, bundle);
            array.put(bundle.data);
        }
    }
    try {
        data.put(key, array);
    } catch (JSONException e) {
        throw new TrackedRuntimeException("key:" + key, e);
    }
}
Also used : TrackedRuntimeException(com.nyrds.android.util.TrackedRuntimeException) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException)

Aggregations

TrackedRuntimeException (com.nyrds.android.util.TrackedRuntimeException)41 JSONException (org.json.JSONException)24 JSONArray (org.json.JSONArray)15 JSONObject (org.json.JSONObject)10 IOException (java.io.IOException)5 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)4 Item (com.watabou.pixeldungeon.items.Item)3 SuppressLint (android.annotation.SuppressLint)2 Pushing (com.watabou.pixeldungeon.effects.Pushing)2 Bitmap (android.graphics.Bitmap)1 Nullable (android.support.annotation.Nullable)1 FakeLastLevel (com.nyrds.pixeldungeon.levels.FakeLastLevel)1 GutsLevel (com.nyrds.pixeldungeon.levels.GutsLevel)1 IceCavesBossLevel (com.nyrds.pixeldungeon.levels.IceCavesBossLevel)1 IceCavesLevel (com.nyrds.pixeldungeon.levels.IceCavesLevel)1 NecroBossLevel (com.nyrds.pixeldungeon.levels.NecroBossLevel)1 NecroLevel (com.nyrds.pixeldungeon.levels.NecroLevel)1 PredesignedLevel (com.nyrds.pixeldungeon.levels.PredesignedLevel)1 RandomLevel (com.nyrds.pixeldungeon.levels.RandomLevel)1 ShadowLordLevel (com.nyrds.pixeldungeon.levels.ShadowLordLevel)1