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,324 @@
/*
* 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.rings;
import java.util.ArrayList;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
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;
import com.watabou.utils.Random;
public class Ring extends EquipableItem {
private static final float TIME_TO_EQUIP = 1f;
private static final String TXT_IDENTIFY =
"you are now familiar enough with your %s to identify it. It is %s.";
protected Buff buff;
private static final Class<?>[] rings = {
RingOfMending.class,
RingOfDetection.class,
RingOfShadows.class,
RingOfPower.class,
RingOfHerbalism.class,
RingOfAccuracy.class,
RingOfEvasion.class,
RingOfSatiety.class,
RingOfHaste.class,
RingOfHaggler.class,
RingOfElements.class,
RingOfThorns.class
};
private static final String[] gems =
{"diamond", "opal", "garnet", "ruby", "amethyst", "topaz", "onyx", "tourmaline", "emerald", "sapphire", "quartz", "agate"};
private static final Integer[] images = {
ItemSpriteSheet.RING_DIAMOND,
ItemSpriteSheet.RING_OPAL,
ItemSpriteSheet.RING_GARNET,
ItemSpriteSheet.RING_RUBY,
ItemSpriteSheet.RING_AMETHYST,
ItemSpriteSheet.RING_TOPAZ,
ItemSpriteSheet.RING_ONYX,
ItemSpriteSheet.RING_TOURMALINE,
ItemSpriteSheet.RING_EMERALD,
ItemSpriteSheet.RING_SAPPHIRE,
ItemSpriteSheet.RING_QUARTZ,
ItemSpriteSheet.RING_AGATE};
private static ItemStatusHandler<Ring> handler;
private String gem;
private int ticksToKnow = 200;
@SuppressWarnings("unchecked")
public static void initGems() {
handler = new ItemStatusHandler<Ring>( (Class<? extends Ring>[])rings, gems, images );
}
public static void save( Bundle bundle ) {
handler.save( bundle );
}
@SuppressWarnings("unchecked")
public static void restore( Bundle bundle ) {
handler = new ItemStatusHandler<Ring>( (Class<? extends Ring>[])rings, gems, images, bundle );
}
public Ring() {
super();
syncGem();
}
public void syncGem() {
image = handler.image( this );
gem = handler.label( this );
}
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
actions.add( isEquipped( hero ) ? AC_UNEQUIP : AC_EQUIP );
return actions;
}
@Override
public boolean doEquip( Hero hero ) {
if (hero.belongings.ring1 != null && hero.belongings.ring2 != null) {
GLog.w( "you can only wear 2 rings at a time" );
return false;
} else {
if (hero.belongings.ring1 == null) {
hero.belongings.ring1 = this;
} else {
hero.belongings.ring2 = this;
}
detach( hero.belongings.backpack );
activate( hero );
cursedKnown = true;
if (cursed) {
equipCursed( hero );
GLog.n( "your " + this + " tightens around your finger painfully" );
}
hero.spendAndNext( TIME_TO_EQUIP );
return true;
}
}
public void activate( Char ch ) {
buff = buff();
buff.attachTo( ch );
}
@Override
public boolean doUnequip( Hero hero, boolean collect ) {
if (cursed) {
GLog.w( "You can't remove cursed " + name() + "!" );
return false;
}
if (hero.belongings.ring1 == this) {
hero.belongings.ring1 = null;
} else {
hero.belongings.ring2 = null;
}
hero.remove( buff );
buff = null;
hero.spendAndNext( TIME_TO_EQUIP );
if (collect && !collect( hero.belongings.backpack )) {
Dungeon.level.drop( this, hero.pos );
}
return true;
}
@Override
public boolean isEquipped( Hero hero ) {
return hero.belongings.ring1 == this || hero.belongings.ring2 == this;
}
@Override
public Item upgrade() {
super.upgrade();
if (buff != null) {
Char owner = buff.target;
buff.detach();
if ((buff = buff()) != null) {
buff.attachTo( owner );
}
}
return this;
}
public boolean isKnown() {
return handler.isKnown( this );
}
protected void setKnown() {
if (!isKnown()) {
handler.know( this );
}
Badges.validateAllRingsIdentified();
}
@Override
public String name() {
return isKnown() ? name : gem + " ring";
}
@Override
public String desc() {
return
"This metal band is adorned with a large " + gem + " gem " +
"that glitters in the darkness. Who knows what effect it has when worn?";
}
@Override
public String info() {
if (isEquipped( Dungeon.hero )) {
return desc() + "\n\n" + "The " + name() + " is on your finger" +
(cursed ? ", and because it is cursed, you are powerless to remove it." : "." );
} else if (cursed && cursedKnown) {
return desc() + "\n\nYou can feel a malevolent magic lurking within the " + name() + ".";
} else {
return desc();
}
}
@Override
public boolean isIdentified() {
return super.isIdentified() && isKnown();
}
@Override
public Item identify() {
setKnown();
return super.identify();
}
@Override
public Item random() {
level = Random.Int( 1, 3 );
if (Random.Float() < 0.3f) {
level = -level;
cursed = true;
}
return this;
}
public static boolean allKnown() {
return handler.known().size() == rings.length - 2;
}
@Override
public int price() {
int price = 80;
if (cursed && cursedKnown) {
price /= 2;
}
if (levelKnown) {
if (level > 0) {
price *= (level + 1);
} else if (level < 0) {
price /= (1 - level);
}
}
if (price < 1) {
price = 1;
}
return price;
}
protected RingBuff buff() {
return null;
}
public class RingBuff extends Buff {
private static final String TXT_KNOWN = "This is a %s";
public int level;
public RingBuff() {
level = Ring.this.level;
}
@Override
public boolean attachTo( Char target ) {
if (target instanceof Hero && ((Hero)target).heroClass == HeroClass.ROGUE && !isKnown()) {
setKnown();
GLog.i( TXT_KNOWN, name() );
Badges.validateItemLevelAquired( Ring.this );
}
return super.attachTo(target);
}
@Override
public boolean act() {
if (!isIdentified() && --ticksToKnow <= 0) {
String gemName = name();
identify();
GLog.w( TXT_IDENTIFY, gemName, Ring.this.toString() );
Badges.validateItemLevelAquired( Ring.this );
}
spend( TICK );
return true;
}
}
}
@@ -0,0 +1,40 @@
/*
* 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.rings;
public class RingOfAccuracy extends Ring {
{
name = "Ring of Accuracy";
}
@Override
protected RingBuff buff( ) {
return new Accuracy();
}
@Override
public String desc() {
return isKnown() ?
"This ring increases your chance to hit the enemy." :
super.desc();
}
public class Accuracy extends RingBuff {
}
}
@@ -0,0 +1,55 @@
/*
* 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.rings;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
public class RingOfDetection extends Ring {
{
name = "Ring of Detection";
}
@Override
public boolean doEquip( Hero hero ) {
if (super.doEquip( hero )) {
Dungeon.hero.search( false );
return true;
} else {
return false;
}
}
@Override
protected RingBuff buff( ) {
return new Detection();
}
@Override
public String desc() {
return isKnown() ?
"Wearing this ring will allow the wearer to notice hidden secrets - " +
"traps and secret doors - without taking time to search. Degraded rings of detection " +
"will dull your senses, making it harder to notice secrets even when actively searching for them." :
super.desc();
}
public class Detection extends RingBuff {
}
}
@@ -0,0 +1,77 @@
/*
* 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.rings;
import java.util.HashSet;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Eye;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Warlock;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Yog;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.LightningTrap;
import com.watabou.utils.Random;
public class RingOfElements extends Ring {
{
name = "Ring of Elements";
}
@Override
protected RingBuff buff( ) {
return new Resistance();
}
@Override
public String desc() {
return isKnown() ?
"This ring provides resistance to different elements, such as fire, " +
"electricity, gases etc. Also it decreases duration of negative effects." :
super.desc();
}
private static final HashSet<Class<?>> EMPTY = new HashSet<Class<?>>();
private static final HashSet<Class<?>> FULL;
static {
FULL = new HashSet<Class<?>>();
FULL.add( Burning.class );
FULL.add( ToxicGas.class );
FULL.add( Poison.class );
FULL.add( LightningTrap.Electricity.class );
FULL.add( Warlock.class );
FULL.add( Eye.class );
FULL.add( Yog.BurningFist.class );
}
public class Resistance extends RingBuff {
public HashSet<Class<?>> resistances() {
if (Random.Int( level + 3 ) >= 3) {
return FULL;
} else {
return EMPTY;
}
}
public float durationFactor() {
return level < 0 ? 1 : (2 + 0.5f * level) / (2 + level);
}
}
}
@@ -0,0 +1,40 @@
/*
* 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.rings;
public class RingOfEvasion extends Ring {
{
name = "Ring of Evasion";
}
@Override
protected RingBuff buff( ) {
return new Evasion();
}
@Override
public String desc() {
return isKnown() ?
"This ring increases your chance to dodge enemy attack." :
super.desc();
}
public class Evasion extends RingBuff {
}
}
@@ -0,0 +1,68 @@
/*
* 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.rings;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
public class RingOfHaggler extends Ring {
{
name = "Ring of Haggler";
}
@Override
protected RingBuff buff( ) {
return new Haggling();
}
@Override
public Item random() {
level = +1;
return this;
}
@Override
public boolean doPickUp( Hero hero ) {
identify();
Badges.validateRingOfHaggler();
Badges.validateItemLevelAquired( this );
return super.doPickUp(hero);
}
@Override
public boolean isUpgradable() {
return false;
}
@Override
public String desc() {
return isKnown() ?
"In fact this ring doesn't provide any magic effect, but it demonstrates " +
"to shopkeepers and vendors, that the owner of the ring is a member of " +
"The Thieves' Guild. Usually they are glad to give a discount in exchange " +
"for temporary immunity guarantee. Upgrading this ring won't give any additional " +
"bonuses." :
super.desc();
}
public class Haggling extends RingBuff {
}
}
@@ -0,0 +1,40 @@
/*
* 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.rings;
public class RingOfHaste extends Ring {
{
name = "Ring of Haste";
}
@Override
protected RingBuff buff( ) {
return new Haste();
}
@Override
public String desc() {
return isKnown() ?
"This ring accelerates the wearer's flow of time, allowing one to perform all actions a little faster." :
super.desc();
}
public class Haste extends RingBuff {
}
}
@@ -0,0 +1,40 @@
/*
* 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.rings;
public class RingOfHerbalism extends Ring {
{
name = "Ring of Herbalism";
}
@Override
protected RingBuff buff( ) {
return new Herbalism();
}
@Override
public String desc() {
return isKnown() ?
"This ring increases your chance to gather dew and seeds from trampled grass." :
super.desc();
}
public class Herbalism extends RingBuff {
}
}
@@ -0,0 +1,42 @@
/*
* 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.rings;
public class RingOfMending extends Ring {
{
name = "Ring of Mending";
}
@Override
protected RingBuff buff( ) {
return new Rejuvenation();
}
@Override
public String desc() {
return isKnown() ?
"This ring increases the body's regenerative properties, allowing " +
"one to recover lost health at an accelerated rate. Degraded rings will " +
"decrease or even halt one's natural regeneration." :
super.desc();
}
public class Rejuvenation extends RingBuff {
}
}
@@ -0,0 +1,41 @@
/*
* 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.rings;
public class RingOfPower extends Ring {
{
name = "Ring of Power";
}
@Override
protected RingBuff buff( ) {
return new Power();
}
@Override
public String desc() {
return isKnown() ?
"Your wands will become more powerful in the energy field " +
"that radiates from this ring. Degraded rings of power will instead weaken your wands." :
super.desc();
}
public class Power extends RingBuff {
}
}
@@ -0,0 +1,40 @@
/*
* 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.rings;
public class RingOfSatiety extends Ring {
{
name = "Ring of Satiety";
}
@Override
protected RingBuff buff( ) {
return new Satiety();
}
@Override
public String desc() {
return isKnown() ?
"Wearing this ring you can go without food longer. Degraded rings of satiety will cause the opposite effect." :
super.desc();
}
public class Satiety extends RingBuff {
}
}
@@ -0,0 +1,41 @@
/*
* 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.rings;
public class RingOfShadows extends Ring {
{
name = "Ring of Shadows";
}
@Override
protected RingBuff buff( ) {
return new Shadows();
}
@Override
public String desc() {
return isKnown() ?
"Enemies will be less likely to notice you if you wear this ring. Degraded rings " +
"of shadows will alert enemies who might otherwise not have noticed your presence." :
super.desc();
}
public class Shadows extends RingBuff {
}
}
@@ -0,0 +1,66 @@
/*
* 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.rings;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
public class RingOfThorns extends Ring {
{
name = "Ring of Thorns";
}
@Override
protected RingBuff buff( ) {
return new Thorns();
}
@Override
public Item random() {
level = +1;
return this;
}
@Override
public boolean doPickUp( Hero hero ) {
identify();
Badges.validateRingOfThorns();
Badges.validateItemLevelAquired( this );
return super.doPickUp(hero);
}
@Override
public boolean isUpgradable() {
return false;
}
@Override
public String desc() {
return isKnown() ?
"Though this ring doesn't provide real thorns, an enemy that attacks you " +
"will itself be wounded by a fraction of the damage that it inflicts. " +
"Upgrading this ring won't give any additional bonuses." :
super.desc();
}
public class Thorns extends RingBuff {
}
}