v0.6.1: implemented item for document pages

This commit is contained in:
Evan Debenham 2017-07-15 04:24:14 -04:00
parent 17c3f501a8
commit 36f7a7aaa6
7 changed files with 139 additions and 0 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -46,6 +46,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit;
import com.shatteredpixel.shatteredpixeldungeon.items.food.ChargrilledMeat;
import com.shatteredpixel.shatteredpixeldungeon.items.food.FrozenCarpaccio;
import com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat;
import com.shatteredpixel.shatteredpixeldungeon.items.journal.DocumentPage;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfExperience;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
@ -533,8 +534,19 @@ public class Heap implements Bundlable {
pos = bundle.getInt( POS );
seen = bundle.getBoolean( SEEN );
type = Type.valueOf( bundle.getString( TYPE ) );
items = new LinkedList<Item>( (Collection<Item>) ((Collection<?>) bundle.getCollection( ITEMS )) );
items.removeAll(Collections.singleton(null));
//remove any document pages that either don't exist anymore or that the player already has
for (Item item : items.toArray(new Item[0])){
if (item instanceof DocumentPage
&& ( !((DocumentPage) item).document().pages().contains(((DocumentPage) item).page())
|| ((DocumentPage) item).document().hasPage(((DocumentPage) item).page()))){
items.remove(item);
}
}
}
@Override

View File

@ -0,0 +1,73 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2017 Evan Debenham
*
* 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.journal;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundle;
public abstract class DocumentPage extends Item {
{
image = ItemSpriteSheet.MASTERY;
}
public abstract Document document();
private String page;
public void page( String page ){
this.page = page;
}
public String page(){
return page;
}
@Override
public final boolean doPickUp(Hero hero) {
GameScene.pickUpJournal(this);
document().addPage(page);
Sample.INSTANCE.play( Assets.SND_ITEM );
hero.spendAndNext( TIME_TO_PICK_UP );
return true;
}
private static final String PAGE = "page";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put( PAGE, page() );
}
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
page = bundle.getString( PAGE );
}
}

View File

@ -0,0 +1,38 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2017 Evan Debenham
*
* 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.journal;
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class GuidePage extends DocumentPage {
{
image = ItemSpriteSheet.GUIDE_PAGE;
}
@Override
public Document document() {
return Document.ADVENTURERS_GUIDE;
}
}

View File

@ -40,6 +40,14 @@ public enum Document {
return pages.keySet();
}
public boolean addPage( String page ) {
if (pages.containsKey(page) && !pages.get(page)){
pages.put(page, true);
return true;
}
return false;
}
public boolean hasPage( String page ){
return pages.containsKey(page) && pages.get(page);
}

View File

@ -64,12 +64,14 @@ public class ItemSpriteSheet {
public static final int PETAL = UNCOLLECTIBLE+2;
public static final int SANDBAG = UNCOLLECTIBLE+3;
public static final int DBL_BOMB = UNCOLLECTIBLE+4;
public static final int GUIDE_PAGE = UNCOLLECTIBLE+5;
static{
assignItemRect(GOLD, 15, 13);
assignItemRect(DEWDROP, 10, 10);
assignItemRect(PETAL, 8, 8);
assignItemRect(SANDBAG, 10, 10);
assignItemRect(DBL_BOMB, 14, 13);
assignItemRect(GUIDE_PAGE, 10, 11);
}
private static final int CONTAINERS = xy(1, 3); //16 slots

View File

@ -390,6 +390,12 @@ items.food.pasty.cane_desc=A huge sugary sweet candy cane! It's big enough to fi
##journal items
items.journal.documentpage.name=torn page
items.journal.documentpage.desc=A lone page, probably torn from a book of some sort. You'll need to pick it up to read it.
###keys
items.keys.goldenkey.name=golden key
items.keys.goldenkey.desc=The notches on this golden key are tiny and intricate. Maybe it can open some chest lock?