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,299 @@
/*
* 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.actors.hero;
import java.util.Iterator;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
import com.shatteredpixel.shatteredpixeldungeon.items.keys.Key;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRemoveCurse;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
public class Belongings implements Iterable<Item> {
public static final int BACKPACK_SIZE = 19;
private Hero owner;
public Bag backpack;
public KindOfWeapon weapon = null;
public Armor armor = null;
public Ring ring1 = null;
public Ring ring2 = null;
public Belongings( Hero owner ) {
this.owner = owner;
backpack = new Bag() {{
name = "backpack";
size = BACKPACK_SIZE;
}};
backpack.owner = owner;
}
private static final String WEAPON = "weapon";
private static final String ARMOR = "armor";
private static final String RING1 = "ring1";
private static final String RING2 = "ring2";
public void storeInBundle( Bundle bundle ) {
backpack.storeInBundle( bundle );
bundle.put( WEAPON, weapon );
bundle.put( ARMOR, armor );
bundle.put( RING1, ring1 );
bundle.put( RING2, ring2 );
}
public void restoreFromBundle( Bundle bundle ) {
backpack.clear();
backpack.restoreFromBundle( bundle );
weapon = (KindOfWeapon)bundle.get( WEAPON );
if (weapon != null) {
weapon.activate( owner );
}
armor = (Armor)bundle.get( ARMOR );
ring1 = (Ring)bundle.get( RING1 );
if (ring1 != null) {
ring1.activate( owner );
}
ring2 = (Ring)bundle.get( RING2 );
if (ring2 != null) {
ring2.activate( owner );
}
}
@SuppressWarnings("unchecked")
public<T extends Item> T getItem( Class<T> itemClass ) {
for (Item item : this) {
if (itemClass.isInstance( item )) {
return (T)item;
}
}
return null;
}
@SuppressWarnings("unchecked")
public <T extends Key> T getKey( Class<T> kind, int depth ) {
for (Item item : backpack) {
if (item.getClass() == kind && ((Key)item).depth == depth) {
return (T)item;
}
}
return null;
}
public void countIronKeys() {
IronKey.curDepthQunatity = 0;
for (Item item : backpack) {
if (item instanceof IronKey && ((IronKey)item).depth == Dungeon.depth) {
IronKey.curDepthQunatity = item.quantity();
return;
}
}
}
public void identify() {
for (Item item : this) {
item.identify();
}
}
public void observe() {
if (weapon != null) {
weapon.identify();
Badges.validateItemLevelAquired( weapon );
}
if (armor != null) {
armor.identify();
Badges.validateItemLevelAquired( armor );
}
if (ring1 != null) {
ring1.identify();
Badges.validateItemLevelAquired( ring1 );
}
if (ring2 != null) {
ring2.identify();
Badges.validateItemLevelAquired( ring2 );
}
for (Item item : backpack) {
item.cursedKnown = true;
}
}
public void uncurseEquipped() {
ScrollOfRemoveCurse.uncurse( owner, armor, weapon, ring1, ring2 );
}
public Item randomUnequipped() {
return Random.element( backpack.items );
}
public void resurrect( int depth ) {
for (Item item : backpack.items.toArray( new Item[0])) {
if (item instanceof Key) {
if (((Key)item).depth == depth) {
item.detachAll( backpack );
}
} else if (item.unique) {
} else if (!item.isEquipped( owner )) {
item.detachAll( backpack );
}
}
if (weapon != null) {
weapon.cursed = false;
weapon.activate( owner );
}
if (armor != null) {
armor.cursed = false;
}
if (ring1 != null) {
ring1.cursed = false;
ring1.activate( owner );
}
if (ring2 != null) {
ring2.cursed = false;
ring2.activate( owner );
}
}
public int charge( boolean full) {
int count = 0;
for (Item item : this) {
if (item instanceof Wand) {
Wand wand = (Wand)item;
if (wand.curCharges < wand.maxCharges) {
wand.curCharges = full ? wand.maxCharges : wand.curCharges + 1;
count++;
wand.updateQuickslot();
}
}
}
return count;
}
public int discharge() {
int count = 0;
for (Item item : this) {
if (item instanceof Wand) {
Wand wand = (Wand)item;
if (wand.curCharges > 0) {
wand.curCharges--;
count++;
wand.updateQuickslot();
}
}
}
return count;
}
@Override
public Iterator<Item> iterator() {
return new ItemIterator();
}
private class ItemIterator implements Iterator<Item> {
private int index = 0;
private Iterator<Item> backpackIterator = backpack.iterator();
private Item[] equipped = {weapon, armor, ring1, ring2};
private int backpackIndex = equipped.length;
@Override
public boolean hasNext() {
for (int i=index; i < backpackIndex; i++) {
if (equipped[i] != null) {
return true;
}
}
return backpackIterator.hasNext();
}
@Override
public Item next() {
while (index < backpackIndex) {
Item item = equipped[index++];
if (item != null) {
return item;
}
}
return backpackIterator.next();
}
@Override
public void remove() {
switch (index) {
case 0:
equipped[0] = weapon = null;
break;
case 1:
equipped[1] = armor = null;
break;
case 2:
equipped[2] = ring1 = null;
break;
case 3:
equipped[3] = ring2 = null;
break;
default:
backpackIterator.remove();
}
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,89 @@
/*
* 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.actors.hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
public class HeroAction {
public int dst;
public static class Move extends HeroAction {
public Move( int dst ) {
this.dst = dst;
}
}
public static class PickUp extends HeroAction {
public PickUp( int dst ) {
this.dst = dst;
}
}
public static class OpenChest extends HeroAction {
public OpenChest( int dst ) {
this.dst = dst;
}
}
public static class Buy extends HeroAction {
public Buy( int dst ) {
this.dst = dst;
}
}
public static class Interact extends HeroAction {
public Mob.NPC npc;
public Interact( Mob.NPC npc ) {
this.npc = npc;
}
}
public static class Unlock extends HeroAction {
public Unlock( int door ) {
this.dst = door;
}
}
public static class Descend extends HeroAction {
public Descend( int stairs ) {
this.dst = stairs;
}
}
public static class Ascend extends HeroAction {
public Ascend( int stairs ) {
this.dst = stairs;
}
}
public static class Cook extends HeroAction {
public Cook( int pot ) {
this.dst = pot;
}
}
public static class Attack extends HeroAction {
public Char target;
public Attack( Char target ) {
this.target = target;
}
}
}
@@ -0,0 +1,221 @@
/*
* 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.actors.hero;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.TomeOfMastery;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.ClothArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.food.Food;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfShadows;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfMagicMissile;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Dagger;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Knuckles;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.ShortSword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Dart;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang;
import com.watabou.utils.Bundle;
public enum HeroClass {
WARRIOR( "warrior" ), MAGE( "mage" ), ROGUE( "rogue" ), HUNTRESS( "huntress" );
private String title;
private HeroClass( String title ) {
this.title = title;
}
public static final String[] WAR_PERKS = {
"Warriors start with 11 points of Strength.",
"Warriors start with a unique short sword. This sword can be later \"reforged\" to upgrade another melee weapon.",
"Warriors are less proficient with missile weapons.",
"Any piece of food restores some health when eaten.",
"Potions of Strength are identified from the beginning.",
};
public static final String[] MAG_PERKS = {
"Mages start with a unique Wand of Magic Missile. This wand can be later \"disenchanted\" to upgrade another wand.",
"Mages recharge their wands faster.",
"When eaten, any piece of food restores 1 charge for all wands in the inventory.",
"Mages can use wands as a melee weapon.",
"Scrolls of Identify are identified from the beginning."
};
public static final String[] ROG_PERKS = {
"Rogues start with a Ring of Shadows+1.",
"Rogues identify a type of a ring on equipping it.",
"Rogues are proficient with light armor, dodging better while wearing one.",
"Rogues are proficient in detecting hidden doors and traps.",
"Rogues can go without food longer.",
"Scrolls of Magic Mapping are identified from the beginning."
};
public static final String[] HUN_PERKS = {
"Huntresses start with 15 points of Health.",
"Huntresses start with a unique upgradeable boomerang.",
"Huntresses are proficient with missile weapons and get damage bonus for excessive strength when using them.",
"Huntresses gain more health from dewdrops.",
"Huntresses sense neighbouring monsters even if they are hidden behind obstacles."
};
public void initHero( Hero hero ) {
hero.heroClass = this;
switch (this) {
case WARRIOR:
initWarrior( hero );
break;
case MAGE:
initMage( hero );
break;
case ROGUE:
initRogue( hero );
break;
case HUNTRESS:
initHuntress( hero );
break;
}
hero.updateAwareness();
}
private static void initWarrior( Hero hero ) {
hero.STR = hero.STR + 1;
(hero.belongings.weapon = new ShortSword()).identify();
(hero.belongings.armor = new ClothArmor()).identify();
new Dart( 8 ).identify().collect();
new Food().identify().collect();
if (Badges.isUnlocked( Badges.Badge.MASTERY_WARRIOR )) {
new TomeOfMastery().collect();
}
Dungeon.quickslot = Dart.class;
new PotionOfStrength().setKnown();
}
private static void initMage( Hero hero ) {
(hero.belongings.weapon = new Knuckles()).identify();
(hero.belongings.armor = new ClothArmor()).identify();
new Food().identify().collect();
WandOfMagicMissile wand = new WandOfMagicMissile();
wand.identify().collect();
if (Badges.isUnlocked( Badges.Badge.MASTERY_MAGE )) {
new TomeOfMastery().collect();
}
Dungeon.quickslot = wand;
new ScrollOfIdentify().setKnown();
}
private static void initRogue( Hero hero ) {
(hero.belongings.weapon = new Dagger()).identify();
(hero.belongings.armor = new ClothArmor()).identify();
(hero.belongings.ring1 = new RingOfShadows()).upgrade().identify();
new Dart( 8 ).identify().collect();
new Food().identify().collect();
hero.belongings.ring1.activate( hero );
if (Badges.isUnlocked( Badges.Badge.MASTERY_ROGUE )) {
new TomeOfMastery().collect();
}
Dungeon.quickslot = Dart.class;
new ScrollOfMagicMapping().setKnown();
}
private static void initHuntress( Hero hero ) {
hero.HP = (hero.HT -= 5);
(hero.belongings.weapon = new Dagger()).identify();
(hero.belongings.armor = new ClothArmor()).identify();
Boomerang boomerang = new Boomerang();
boomerang.identify().collect();
new Food().identify().collect();
if (Badges.isUnlocked( Badges.Badge.MASTERY_HUNTRESS )) {
new TomeOfMastery().collect();
}
Dungeon.quickslot = boomerang;
}
public String title() {
return title;
}
public String spritesheet() {
switch (this) {
case WARRIOR:
return Assets.WARRIOR;
case MAGE:
return Assets.MAGE;
case ROGUE:
return Assets.ROGUE;
case HUNTRESS:
return Assets.HUNTRESS;
}
return null;
}
public String[] perks() {
switch (this) {
case WARRIOR:
return WAR_PERKS;
case MAGE:
return MAG_PERKS;
case ROGUE:
return ROG_PERKS;
case HUNTRESS:
return HUN_PERKS;
}
return null;
}
private static final String CLASS = "class";
public void storeInBundle( Bundle bundle ) {
bundle.put( CLASS, toString() );
}
public static HeroClass restoreInBundle( Bundle bundle ) {
String value = bundle.getString( CLASS );
return value.length() > 0 ? valueOf( value ) : ROGUE;
}
}
@@ -0,0 +1,88 @@
/*
* 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.actors.hero;
import com.watabou.utils.Bundle;
public enum HeroSubClass {
NONE( null, null ),
GLADIATOR( "gladiator",
"A successful attack with a melee weapon allows the _Gladiator_ to start a combo, " +
"in which every next successful hit inflicts more damage." ),
BERSERKER( "berserker",
"When severely wounded, the _Berserker_ enters a state of wild fury " +
"significantly increasing his damage output." ),
WARLOCK( "warlock",
"After killing an enemy the _Warlock_ consumes its soul. " +
"It heals his wounds and satisfies his hunger." ),
BATTLEMAGE( "battlemage",
"When fighting with a wand in his hands, the _Battlemage_ inflicts additional damage depending " +
"on the current number of charges. Every successful hit restores 1 charge to this wand." ),
ASSASSIN( "assassin",
"When performing a surprise attack, the _Assassin_ inflicts additional damage to his target." ),
FREERUNNER( "freerunner",
"The _Freerunner_ can move almost twice faster, than most of the monsters. When he " +
"is running, the Freerunner is much harder to hit. For that he must be unencumbered and not starving." ),
SNIPER( "sniper",
"_Snipers_ are able to detect weak points in an enemy's armor, " +
"effectively ignoring it when using a missile weapon." ),
WARDEN( "warden",
"Having a strong connection with forces of nature gives _Wardens_ an ability to gather dewdrops and " +
"seeds from plants. Also trampling a high grass grants them a temporary armor buff." );
private String title;
private String desc;
private HeroSubClass( String title, String desc ) {
this.title = title;
this.desc = desc;
}
public String title() {
return title;
}
public String desc() {
return desc;
}
private static final String SUBCLASS = "subClass";
public void storeInBundle( Bundle bundle ) {
bundle.put( SUBCLASS, toString() );
}
public static HeroSubClass restoreInBundle( Bundle bundle ) {
String value = bundle.getString( SUBCLASS );
try {
return valueOf( value );
} catch (Exception e) {
return NONE;
}
}
}