v0.2.2: overhauled bones system(heroes remains). Fairly tentative, needs to be tested.

This commit is contained in:
Evan Debenham 2014-10-22 17:11:30 -04:00
parent e10cdb3747
commit fa53d78809
24 changed files with 162 additions and 53 deletions

View File

@ -17,17 +17,22 @@
*/
package com.shatteredpixel.shatteredpixeldungeon;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import com.watabou.noosa.Game;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlot;
import com.watabou.noosa.Game;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Iterator;
public class Bones {
private static final String BONES_FILE = "bones.dat";
@ -40,28 +45,8 @@ public class Bones {
public static void leave() {
item = null;
switch (Random.Int( 4 )) {
case 0:
item = Dungeon.hero.belongings.weapon;
break;
case 1:
item = Dungeon.hero.belongings.armor;
break;
case 2:
item = Dungeon.hero.belongings.misc1;
break;
case 3:
item = Dungeon.hero.belongings.misc2;
break;
}
if (item == null) {
if (Dungeon.gold > 0) {
item = new Gold( Random.IntRange( 1, Dungeon.gold ) );
} else {
item = new Gold( 1 );
}
}
item = pickItem(Dungeon.hero);
depth = Dungeon.depth;
@ -77,6 +62,56 @@ public class Bones {
}
}
private static Item pickItem(Hero hero){
Item item = null;
if (Random.Int(2) == 0) {
switch (Random.Int(5)) {
case 0:
item = hero.belongings.weapon;
break;
case 1:
item = hero.belongings.armor;
break;
case 2:
item = hero.belongings.misc1;
break;
case 3:
item = hero.belongings.misc2;
break;
case 4:
item = QuickSlot.getItem();
break;
}
if (item != null && !item.bones)
return pickItem(hero);
} else {
Iterator<Item> iterator = hero.belongings.backpack.iterator();
Item curItem;
ArrayList<Item> items = new ArrayList<Item>();
while (iterator.hasNext()){
curItem = iterator.next();
if (curItem.bones && !(curItem instanceof EquipableItem))
items.add(curItem);
}
if (!items.isEmpty()) {
item = Random.element(items);
if (item.stackable){
item.quantity(Random.NormalIntRange(1, (int)Math.sqrt(item.quantity())));
}
}
}
if (item == null) {
if (Dungeon.gold > 0) {
item = new Gold( Random.NormalIntRange( 1, Dungeon.gold ) );
} else {
item = new Gold( 1 );
}
}
return item;
}
public static Item get() {
if (depth == -1) {
@ -100,7 +135,7 @@ public class Bones {
Game.instance.deleteFile( BONES_FILE );
depth = 0;
if (!item.stackable) {
if (item.isUpgradable()) {
item.cursed = true;
item.cursedKnown = true;
if (item.isUpgradable()) {

View File

@ -46,7 +46,11 @@ public class Ankh extends Item {
{
name = "Ankh";
image = ItemSpriteSheet.ANKH;
}
//You tell the ankh no, don't revive me, and then it comes back to revive you again in another run.
//I'm not sure if that's enthusiasm or passive-aggression.
bones = true;
}
private Boolean blessed = false;

View File

@ -31,6 +31,10 @@ public abstract class EquipableItem extends Item {
public static final String AC_EQUIP = "EQUIP";
public static final String AC_UNEQUIP = "UNEQUIP";
{
bones = true;
}
@Override
public void execute( Hero hero, String action ) {
if (action.equals( AC_EQUIP )) {

View File

@ -17,11 +17,6 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.items;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
@ -40,10 +35,15 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.MissileSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlot;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundlable;
import com.watabou.utils.Bundle;
import com.watabou.utils.Callback;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
public class Item implements Bundlable {
private static final String TXT_PACK_FULL = "Your pack is too full for the %s";
@ -76,6 +76,9 @@ public class Item implements Bundlable {
// Unique items persist through revival
public boolean unique = false;
// whether an item can be included in heroes remains
public boolean bones = false;
private static Comparator<Item> itemComparator = new Comparator<Item>() {
@Override

View File

@ -17,9 +17,6 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.items;
import java.util.ArrayList;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.PurpleParticle;
@ -28,6 +25,9 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.watabou.noosa.audio.Sample;
import java.util.ArrayList;
public class Stylus extends Item {
@ -43,6 +43,8 @@ public class Stylus extends Item {
image = ItemSpriteSheet.STYLUS;
stackable = true;
bones = true;
}
@Override

View File

@ -17,10 +17,6 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.items;
import java.util.ArrayList;
import com.watabou.noosa.BitmapTextMultiline;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
@ -33,6 +29,10 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.shatteredpixel.shatteredpixeldungeon.windows.IconTitle;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.watabou.noosa.BitmapTextMultiline;
import com.watabou.noosa.audio.Sample;
import java.util.ArrayList;
public class Weightstone extends Item {
@ -49,6 +49,8 @@ public class Weightstone extends Item {
image = ItemSpriteSheet.WEIGHT;
stackable = true;
bones = true;
}
@Override

View File

@ -17,12 +17,12 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.items.armor;
import java.util.ArrayList;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Bundle;
import java.util.ArrayList;
abstract public class ClassArmor extends Armor {
private static final String TXT_LOW_HEALTH = "Your health is too low!";
@ -32,6 +32,8 @@ abstract public class ClassArmor extends Armor {
levelKnown = true;
cursedKnown = true;
defaultAction = special();
bones = false;
}
public ClassArmor() {

View File

@ -3,17 +3,37 @@ package com.shatteredpixel.shatteredpixeldungeon.items.food;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Statistics;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.*;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Barkskin;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Weakness;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.*;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfFrost;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfInvisibility;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLiquidFlame;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMindVision;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfParalyticGas;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging;
import com.shatteredpixel.shatteredpixeldungeon.plants.Blindweed;
import com.shatteredpixel.shatteredpixeldungeon.plants.Earthroot;
import com.shatteredpixel.shatteredpixeldungeon.plants.Fadeleaf;
import com.shatteredpixel.shatteredpixeldungeon.plants.Firebloom;
import com.shatteredpixel.shatteredpixeldungeon.plants.Icecap;
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant.Seed;
import com.shatteredpixel.shatteredpixeldungeon.plants.*;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.plants.Sorrowmoss;
import com.shatteredpixel.shatteredpixeldungeon.plants.Sungrass;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
@ -38,6 +58,8 @@ public class Blandfruit extends Food {
image = ItemSpriteSheet.BLANDFRUIT;
energy = (Hunger.STARVING - Hunger.HUNGRY)/2;
hornValue = 6; //only applies when blandfruit is cooked
bones = true;
}
@Override

View File

@ -27,6 +27,8 @@ public class Pasty extends Food {
image = ItemSpriteSheet.PASTY;
energy = Hunger.STARVING;
hornValue = 5;
bones = true;
}
@Override

View File

@ -23,6 +23,8 @@ public class PotionOfExperience extends Potion {
{
name = "Potion of Experience";
bones = true;
}
@Override

View File

@ -31,6 +31,8 @@ public class PotionOfHealing extends Potion {
{
name = "Potion of Healing";
bones = true;
}
@Override

View File

@ -26,6 +26,8 @@ public class PotionOfMight extends PotionOfStrength {
{
name = "Potion of Might";
bones = true;
}
@Override

View File

@ -26,6 +26,8 @@ public class PotionOfStrength extends Potion {
{
name = "Potion of Strength";
bones = true;
}
@Override

View File

@ -29,6 +29,8 @@ public class ScrollOfIdentify extends InventoryScroll {
name = "Scroll of Identify";
inventoryTitle = "Select an item to identify";
mode = WndBag.Mode.UNIDENTIFED;
bones = true;
}
@Override

View File

@ -36,6 +36,8 @@ public class ScrollOfPsionicBlast extends Scroll {
{
name = "Scroll of Psionic Blast";
bones = true;
}
@Override

View File

@ -33,6 +33,8 @@ public class ScrollOfUpgrade extends InventoryScroll {
name = "Scroll of Upgrade";
inventoryTitle = "Select an item to upgrade";
mode = WndBag.Mode.UPGRADEABLE;
bones = true;
}
@Override

View File

@ -33,6 +33,8 @@ public class ScrollOfWeaponUpgrade extends InventoryScroll {
name = "Scroll of Weapon Upgrade";
inventoryTitle = "Select a weapon to upgrade";
mode = WndBag.Mode.WEAPON;
bones = true;
}
@Override

View File

@ -17,9 +17,6 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.items.wands;
import java.util.ArrayList;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
@ -34,8 +31,11 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Random;
import java.util.ArrayList;
public class WandOfMagicMissile extends Wand {
public static final String AC_DISENCHANT = "DISENCHANT";
@ -52,6 +52,8 @@ public class WandOfMagicMissile extends Wand {
{
name = "Wand of Magic Missile";
image = ItemSpriteSheet.WAND_MAGIC_MISSILE;
bones = false;
}
@Override

View File

@ -17,9 +17,6 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
import java.util.ArrayList;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
@ -30,6 +27,9 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.watabou.noosa.audio.Sample;
import java.util.ArrayList;
public class ShortSword extends MeleeWeapon {
@ -49,6 +49,8 @@ public class ShortSword extends MeleeWeapon {
{
name = "short sword";
image = ItemSpriteSheet.SHORT_SWORD;
bones = false;
}
public ShortSword() {

View File

@ -38,6 +38,8 @@ public class Boomerang extends MissileWeapon {
MAX = 4;
stackable = false;
bones = false;
}
@Override

View File

@ -29,6 +29,8 @@ public class Dart extends MissileWeapon {
MIN = 1;
MAX = 4;
bones = false; //Finding them in bones would be semi-frequent and disappointing.
}
public Dart() {

View File

@ -68,6 +68,8 @@ public class Earthroot extends Plant {
plantClass = Earthroot.class;
alchemyClass = PotionOfParalyticGas.class;
bones = true;
}
@Override

View File

@ -65,6 +65,8 @@ public class Sungrass extends Plant {
plantClass = Sungrass.class;
alchemyClass = PotionOfHealing.class;
bones = true;
}
@Override

View File

@ -142,6 +142,11 @@ public class QuickSlot extends Button implements WndBag.Listener {
}
}
public static Item getItem(){
Item item = select();
return (item != null && item.quantity() != 0)? item : null;
}
@Override
public void onSelect( Item item ) {
if (item != null) {