From b731569f85e58709271a7642c3d96882cfac94ed Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 22 Apr 2016 01:23:11 -0400 Subject: [PATCH] v0.3.5: refactors to names and info for heaps --- .../shatteredpixeldungeon/items/Heap.java | 49 +++++++++++++++++++ .../messages/items/items.properties | 16 ++++++ .../messages/windows/windows.properties | 15 ------ .../scenes/GameScene.java | 2 +- .../windows/WndInfoItem.java | 40 ++------------- 5 files changed, 69 insertions(+), 53 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java index 4749a0c10..c5504794b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java @@ -37,6 +37,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.AlchemistsToolkit; +import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact; import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit; import com.shatteredpixel.shatteredpixeldungeon.items.food.ChargrilledMeat; import com.shatteredpixel.shatteredpixeldungeon.items.food.FrozenCarpaccio; @@ -45,6 +46,8 @@ import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfExperience; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; +import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.plants.Plant.Seed; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; @@ -456,6 +459,52 @@ public class Heap implements Bundlable { items = null; } + @Override + public String toString(){ + switch(type){ + case CHEST: + case MIMIC: + return Messages.get(this, "chest"); + case LOCKED_CHEST: + return Messages.get(this, "locked_chest"); + case CRYSTAL_CHEST: + return Messages.get(this, "crystal_chest"); + case TOMB: + return Messages.get(this, "tomb"); + case SKELETON: + return Messages.get(this, "skeleton"); + case REMAINS: + return Messages.get(this, "remains"); + default: + return peek().toString(); + } + } + + public String info(){ + switch(type){ + case CHEST: + case MIMIC: + return Messages.get(this, "chest_desc"); + case LOCKED_CHEST: + return Messages.get(this, "locked_chest_desc"); + case CRYSTAL_CHEST: + if (peek() instanceof Artifact) + return Messages.get(this, "crystal_chest_desc", Messages.get(this, "artifact") ); + else if (peek() instanceof Wand) + return Messages.get(this, "crystal_chest_desc", Messages.get(this, "wand") ); + else + return Messages.get(this, "crystal_chest_desc", Messages.get(this, "ring") ); + case TOMB: + return Messages.get(this, "tomb_desc"); + case SKELETON: + return Messages.get(this, "skeleton_desc"); + case REMAINS: + return Messages.get(this, "remains_desc"); + default: + return peek().info(); + } + } + private static final String POS = "pos"; private static final String SEEN = "seen"; private static final String TYPE = "type"; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties b/src/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties index 0ee817da6..550761acd 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties +++ b/src/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties @@ -833,6 +833,22 @@ items.equipableitem.ac_unequip=UNEQUIP items.gold.name=gold items.gold.desc=A pile of gold coins. Collect gold coins to spend them later in a shop. +items.heap.chest=Chest +items.heap.chest_desc=You won't know what's inside until you open it! +items.heap.locked_chest=Locked chest +items.heap.locked_chest_desc=You won't know what's inside until you open it! But to open it you need a golden key. +items.heap.crystal_chest=Crystal chest +items.heap.crystal_chest_desc=You can see %s inside, but to open the chest you need a golden key. +items.heap.artifact=an artifact +items.heap.wand=a wand +items.heap.ring=a ring +items.heap.tomb=Tomb +items.heap.tomb_desc=This ancient tomb may contain something useful, but its owner will most certainly object to checking. +items.heap.skeleton=Skeletal remains +items.heap.skeleton_desc=This is all that's left of some unfortunate adventurer. Maybe it's worth checking for any valuables. +items.heap.remains=Heroes remains +items.heap.remains_desc=This is all that's left from one of your predecessors. Maybe it's worth checking for any valuables. + items.honeypot.name=honeypot items.honeypot.ac_shatter=SHATTER items.honeypot.desc=This large honeypot is only really lined with honey, instead it houses a giant bee! These sorts of massive bees usually stay in their hives, perhaps the pot is some sort of specialized trapper's cage? The bee seems pretty content inside the pot with its honey, and buzzes at you warily when you look at it. diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/messages/windows/windows.properties b/src/com/shatteredpixel/shatteredpixeldungeon/messages/windows/windows.properties index a9c0f1161..9ef44724a 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/messages/windows/windows.properties +++ b/src/com/shatteredpixel/shatteredpixeldungeon/messages/windows/windows.properties @@ -37,21 +37,6 @@ windows.wndhero$statstab.depth=Maximum Depth windows.wndimp.message=Oh yes! You are my hero!\nRegarding your reward, I don't have cash with me right now, but I have something better for you. This is my family heirloom ring: my granddad took it off a dead paladin's finger. windows.wndimp.reward=Take the ring -windows.wndinfoitem.chest=Chest -windows.wndinfoitem.locked_chest=Locked chest -windows.wndinfoitem.crystal_chest=Crystal chest -windows.wndinfoitem.tomb=Tomb -windows.wndinfoitem.skeleton=Skeletal remains -windows.wndinfoitem.remains=Heroes remains -windows.wndinfoitem.wont_know=You won't know what's inside until you open it! -windows.wndinfoitem.need_key=You won't know what's inside until you open it! But to open it you need a golden key. -windows.wndinfoitem.inside=You can see %s inside, but to open the chest you need a golden key. -windows.wndinfoitem.owner=This ancient tomb may contain something useful, but its owner will most certainly object to checking. -windows.wndinfoitem.skeleton_desc=This is all that's left of some unfortunate adventurer. Maybe it's worth checking for any valuables. -windows.wndinfoitem.remains_desc=This is all that's left from one of your predecessors. Maybe it's worth checking for any valuables. -windows.wndinfoitem.artifact=an artifact -windows.wndinfoitem.wand=a wand -windows.wndinfoitem.ring=a ring windows.wndinfotrap.inactive=This trap is inactive, and can no longer be triggered. windows.wndjournal.title=Journal diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java index e02d63f36..e6b8c56d9 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -803,7 +803,7 @@ public class GameScene extends PixelScene { Heap heap = Dungeon.level.heaps.get(cell); if (heap != null) { objects.add(heap); - names.add(Messages.titleCase( heap.peek().toString() )); + names.add(Messages.titleCase( heap.toString() )); } Plant plant = Dungeon.level.plants.get( cell ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java index 6e6fcdffa..ebe165a1e 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java @@ -22,11 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.items.Heap; -import com.shatteredpixel.shatteredpixeldungeon.items.Heap.Type; import com.shatteredpixel.shatteredpixeldungeon.items.Item; -import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact; -import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring; -import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; @@ -58,39 +54,9 @@ public class WndInfoItem extends Window { fillFields( item.image(), item.glowing(), color, item.toString(), item.info() ); } else { - - String title; - String info; - - if (heap.type == Type.CHEST || heap.type == Type.MIMIC) { - title = Messages.get(this, "chest"); - info = Messages.get(this, "wont_know"); - } else if (heap.type == Type.TOMB) { - title = Messages.get(this, "tomb"); - info = Messages.get(this, "owner"); - } else if (heap.type == Type.SKELETON) { - title = Messages.get(this, "skeleton"); - info = Messages.get(this, "skeleton_desc"); - } else if (heap.type == Type.REMAINS) { - title = Messages.get(this, "remains"); - info = Messages.get(this, "remains_desc"); - } else if (heap.type == Type.CRYSTAL_CHEST) { - title = Messages.get(this, "crystal_chest"); - if (heap.peek() instanceof Artifact) - info = Messages.get(this, "inside", Messages.get(this, "artifact") ); - else if (heap.peek() instanceof Wand) - info = Messages.get(this, "inside", Messages.get(this, "wand") ); - else if (heap.peek() instanceof Ring) - info = Messages.get(this, "inside", Messages.get(this, "ring") ); - else - info = ""; //This shouldn't happen - } else { - title = Messages.get(this, "locked_chest"); - info = Messages.get(this, "need_key"); - } - - fillFields( heap.image(), heap.glowing(), TITLE_COLOR, title, info ); - + + fillFields( heap.image(), heap.glowing(), TITLE_COLOR, heap.toString(), heap.info() ); + } }