V0.1.0 Partial Commit

changed package and application names to differentiate from main PD
release
This commit is contained in:
Evan Debenham
2014-08-03 14:46:22 -04:00
parent 65dd9c2dc0
commit aed303672a
474 changed files with 3468 additions and 3458 deletions
@@ -0,0 +1,184 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
import java.util.ArrayList;
import java.util.HashSet;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Blindness;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Bundle;
public abstract class Scroll extends Item {
private static final String TXT_BLINDED = "You can't read a scroll while blinded";
public static final String AC_READ = "READ";
protected static final float TIME_TO_READ = 1f;
private static final Class<?>[] scrolls = {
ScrollOfIdentify.class,
ScrollOfMagicMapping.class,
ScrollOfRecharging.class,
ScrollOfRemoveCurse.class,
ScrollOfTeleportation.class,
ScrollOfUpgrade.class,
ScrollOfRage.class,
ScrollOfTerror.class,
ScrollOfLullaby.class,
ScrollOfWeaponUpgrade.class,
ScrollOfPsionicBlast.class,
ScrollOfMirrorImage.class
};
private static final String[] runes =
{"KAUNAN", "SOWILO", "LAGUZ", "YNGVI", "GYFU", "RAIDO", "ISAZ", "MANNAZ", "NAUDIZ", "BERKANAN", "ODAL", "TIWAZ"};
private static final Integer[] images = {
ItemSpriteSheet.SCROLL_KAUNAN,
ItemSpriteSheet.SCROLL_SOWILO,
ItemSpriteSheet.SCROLL_LAGUZ,
ItemSpriteSheet.SCROLL_YNGVI,
ItemSpriteSheet.SCROLL_GYFU,
ItemSpriteSheet.SCROLL_RAIDO,
ItemSpriteSheet.SCROLL_ISAZ,
ItemSpriteSheet.SCROLL_MANNAZ,
ItemSpriteSheet.SCROLL_NAUDIZ,
ItemSpriteSheet.SCROLL_BERKANAN,
ItemSpriteSheet.SCROLL_ODAL,
ItemSpriteSheet.SCROLL_TIWAZ};
private static ItemStatusHandler<Scroll> handler;
private String rune;
{
stackable = true;
defaultAction = AC_READ;
}
@SuppressWarnings("unchecked")
public static void initLabels() {
handler = new ItemStatusHandler<Scroll>( (Class<? extends Scroll>[])scrolls, runes, images );
}
public static void save( Bundle bundle ) {
handler.save( bundle );
}
@SuppressWarnings("unchecked")
public static void restore( Bundle bundle ) {
handler = new ItemStatusHandler<Scroll>( (Class<? extends Scroll>[])scrolls, runes, images, bundle );
}
public Scroll() {
super();
image = handler.image( this );
rune = handler.label( this );
}
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
actions.add( AC_READ );
return actions;
}
@Override
public void execute( Hero hero, String action ) {
if (action.equals( AC_READ )) {
if (hero.buff( Blindness.class ) != null) {
GLog.w( TXT_BLINDED );
} else {
curUser = hero;
curItem = detach( hero.belongings.backpack );
doRead();
}
} else {
super.execute( hero, action );
}
}
abstract protected void doRead();
public boolean isKnown() {
return handler.isKnown( this );
}
public void setKnown() {
if (!isKnown()) {
handler.know( this );
}
Badges.validateAllScrollsIdentified();
}
@Override
public Item identify() {
setKnown();
return super.identify();
}
@Override
public String name() {
return isKnown() ? name : "scroll \"" + rune + "\"";
}
@Override
public String info() {
return isKnown() ?
desc() :
"This parchment is covered with indecipherable writing, and bears a title " +
"of rune " + rune + ". Who knows what it will do when read aloud?";
}
@Override
public boolean isUpgradable() {
return false;
}
@Override
public boolean isIdentified() {
return isKnown();
}
public static HashSet<Class<? extends Scroll>> getKnown() {
return handler.known();
}
public static HashSet<Class<? extends Scroll>> getUnknown() {
return handler.unknown();
}
public static boolean allKnown() {
return handler.known().size() == scrolls.length;
}
@Override
public int price() {
return 15 * quantity;
}
}