diff --git a/core/src/main/assets/items.png b/core/src/main/assets/items.png index cee918fce..ab6ebdb11 100644 Binary files a/core/src/main/assets/items.png and b/core/src/main/assets/items.png differ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java index 5c97af703..e52a63855 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java @@ -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( (Collection) ((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 diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/journal/DocumentPage.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/journal/DocumentPage.java new file mode 100644 index 000000000..fd666f003 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/journal/DocumentPage.java @@ -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 + */ + +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 ); + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/journal/GuidePage.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/journal/GuidePage.java new file mode 100644 index 000000000..03934cafa --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/journal/GuidePage.java @@ -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 + */ + +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; + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Document.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Document.java index 53913b58d..173f24e09 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Document.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Document.java @@ -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); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java index afa7dcd5f..0b329152e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java @@ -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 diff --git a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties index 57fba1e5b..e55011c00 100644 --- a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties +++ b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties @@ -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?