@SuppressWarnings("unchecked") public static Enchantment randomCurse( Class<? extends Enchantment> ... toIgnore ){ try { ArrayList<Class<?>> enchants = new ArrayList<>(Arrays.asList(curses)); enchants.removeAll(Arrays.asList(toIgnore)); if (enchants.isEmpty()) { return random(); } else { return (Enchantment) Random.element(enchants).newInstance(); } } catch (Exception e) { ShatteredPixelDungeon.reportException(e); return null; } }
@SuppressWarnings("unchecked") public static Enchantment randomRare( Class<? extends Enchantment> ... toIgnore ) { try { ArrayList<Class<?>> enchants = new ArrayList<>(Arrays.asList(rare)); enchants.removeAll(Arrays.asList(toIgnore)); if (enchants.isEmpty()) { return random(); } else { return (Enchantment) Random.element(enchants).newInstance(); } } catch (Exception e) { ShatteredPixelDungeon.reportException(e); return null; } }
@SuppressWarnings("unchecked") public static Enchantment randomRare( Class<? extends Enchantment> ... toIgnore ) { try { ArrayList<Class<?>> enchants = new ArrayList<>(Arrays.asList(rare)); enchants.removeAll(Arrays.asList(toIgnore)); if (enchants.isEmpty()) { return random(); } else { return (Enchantment) Random.element(enchants).newInstance(); } } catch (Exception e) { ShatteredPixelDungeon.reportException(e); return null; } }
enchants[0] = Weapon.Enchantment.randomCommon( existing ); enchants[1] = Weapon.Enchantment.randomUncommon( existing ); enchants[2] = Weapon.Enchantment.random( existing, enchants[0].getClass(), enchants[1].getClass());
enchants[0] = Weapon.Enchantment.randomCommon( existing ); enchants[1] = Weapon.Enchantment.randomUncommon( existing ); enchants[2] = Weapon.Enchantment.random( existing, enchants[0].getClass(), enchants[1].getClass());
@SuppressWarnings("unchecked") public static Enchantment randomCurse( Class<? extends Enchantment> ... toIgnore ){ try { ArrayList<Class<?>> enchants = new ArrayList<>(Arrays.asList(curses)); enchants.removeAll(Arrays.asList(toIgnore)); if (enchants.isEmpty()) { return random(); } else { return (Enchantment) Random.element(enchants).newInstance(); } } catch (Exception e) { ShatteredPixelDungeon.reportException(e); return null; } }
@SuppressWarnings("unchecked") public static Enchantment randomUncommon( Class<? extends Enchantment> ... toIgnore ) { try { ArrayList<Class<?>> enchants = new ArrayList<>(Arrays.asList(uncommon)); enchants.removeAll(Arrays.asList(toIgnore)); if (enchants.isEmpty()) { return random(); } else { return (Enchantment) Random.element(enchants).newInstance(); } } catch (Exception e) { ShatteredPixelDungeon.reportException(e); return null; } }
@SuppressWarnings("unchecked") public static Enchantment randomCommon( Class<? extends Enchantment> ... toIgnore ) { try { ArrayList<Class<?>> enchants = new ArrayList<>(Arrays.asList(common)); enchants.removeAll(Arrays.asList(toIgnore)); if (enchants.isEmpty()) { return random(); } else { return (Enchantment) Random.element(enchants).newInstance(); } } catch (Exception e) { ShatteredPixelDungeon.reportException(e); return null; } }
@SuppressWarnings("unchecked") public static Enchantment randomUncommon( Class<? extends Enchantment> ... toIgnore ) { try { ArrayList<Class<?>> enchants = new ArrayList<>(Arrays.asList(uncommon)); enchants.removeAll(Arrays.asList(toIgnore)); if (enchants.isEmpty()) { return random(); } else { return (Enchantment) Random.element(enchants).newInstance(); } } catch (Exception e) { ShatteredPixelDungeon.reportException(e); return null; } }
@SuppressWarnings("unchecked") public static Enchantment randomCommon( Class<? extends Enchantment> ... toIgnore ) { try { ArrayList<Class<?>> enchants = new ArrayList<>(Arrays.asList(common)); enchants.removeAll(Arrays.asList(toIgnore)); if (enchants.isEmpty()) { return random(); } else { return (Enchantment) Random.element(enchants).newInstance(); } } catch (Exception e) { ShatteredPixelDungeon.reportException(e); return null; } }
public Statue() { super(); do { weapon = (MeleeWeapon) Generator.random(Generator.Category.WEAPON); } while (weapon.cursed); weapon.enchant( Enchantment.random() ); HP = HT = 15 + Dungeon.depth * 5; defenseSkill = 4 + Dungeon.depth; }
public Item upgrade(boolean enchant ) { if (enchant && (enchantment == null || enchantment.curse())){ enchant( Enchantment.random() ); } else if (!enchant && Random.Float() > Math.pow(0.9, level())){ enchant(null); } cursed = false; return super.upgrade(); }
public Statue() { super(); do { weapon = (MeleeWeapon) Generator.random(Generator.Category.WEAPON); } while (weapon.cursed); weapon.enchant( Enchantment.random() ); HP = HT = 15 + Dungeon.depth * 5; defenseSkill = 4 + Dungeon.depth; }
public Weapon enchant() { Class<? extends Enchantment> oldEnchantment = enchantment != null ? enchantment.getClass() : null; Enchantment ench = Enchantment.random( oldEnchantment ); return enchant( ench ); }
public Weapon enchant() { Class<? extends Enchantment> oldEnchantment = enchantment != null ? enchantment.getClass() : null; Enchantment ench = Enchantment.random( oldEnchantment ); return enchant( ench ); }
public Item upgrade(boolean enchant ) { if (enchant && (enchantment == null || enchantment.curse())){ enchant( Enchantment.random() ); } else if (!enchant && Random.Float() > Math.pow(0.9, level())){ enchant(null); } cursed = false; return super.upgrade(); }