From 353dc49fa41e087bbd935e97c1cc456a030ea714 Mon Sep 17 00:00:00 2001 From: Evan Debenham <Evan@ShatteredPixel.com> Date: Fri, 19 Dec 2014 16:31:10 -0500 Subject: [PATCH] v0.2.3: refactored logic to distinguish between a Hero's class name, and given name. Note that given name is only going to be set by donation features, which are not in the open source, but the refactor is generally beneficial so I'm putting it in anyway. --- .../shatteredpixeldungeon/actors/hero/Hero.java | 4 ++++ .../shatteredpixeldungeon/actors/mobs/npcs/Imp.java | 6 +++--- .../shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java | 2 +- .../shatteredpixeldungeon/items/artifacts/DriedRose.java | 2 +- .../shatteredpixeldungeon/windows/WndWandmaker.java | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index 6767b2b38..ba18d4e91 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -241,6 +241,10 @@ public class Hero extends Char { public String className() { return subClass == null || subClass == HeroSubClass.NONE ? heroClass.title() : subClass.title(); } + + public String givenName(){ + return name.equals("you") ? className() : name; + } public void live() { Buff.affect( this, Regeneration.class ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Imp.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Imp.java index 6a90a06f7..8d37cca07 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Imp.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Imp.java @@ -78,7 +78,7 @@ public class Imp extends NPC { if (!Quest.given && Dungeon.visible[pos]) { if (!seenBefore) { - yell( Utils.format( TXT_HEY, Dungeon.hero.className() ) ); + yell( Utils.format( TXT_HEY, Dungeon.hero.givenName() ) ); } seenBefore = true; } else { @@ -123,7 +123,7 @@ public class Imp extends NPC { if (tokens != null && (tokens.quantity() >= 8 || (!Quest.alternative && tokens.quantity() >= 6))) { GameScene.show( new WndImp( this, tokens ) ); } else { - tell( Quest.alternative ? TXT_MONKS2 : TXT_GOLEMS2, Dungeon.hero.className() ); + tell( Quest.alternative ? TXT_MONKS2 : TXT_GOLEMS2, Dungeon.hero.givenName() ); } } else { @@ -142,7 +142,7 @@ public class Imp extends NPC { public void flee() { - yell( Utils.format( TXT_CYA, Dungeon.hero.className() ) ); + yell( Utils.format( TXT_CYA, Dungeon.hero.givenName() ) ); destroy(); sprite.die(); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java index 018809f2f..a7c294cf4 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java @@ -129,7 +129,7 @@ public class Wandmaker extends NPC { if (item != null) { GameScene.show( new WndWandmaker( this, item ) ); } else { - tell( Quest.alternative ? TXT_DUST2 : TXT_BERRY2, Dungeon.hero.className() ); + tell( Quest.alternative ? TXT_DUST2 : TXT_BERRY2, Dungeon.hero.givenName() ); } } else { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java index 47439f5a8..63896934c 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java @@ -98,7 +98,7 @@ public class DriedRose extends Artifact { hero.sprite.operate(hero.pos); if (!firstSummon) { - ghost.yell(ghost.VOICE_HELLO + Dungeon.hero.className()); + ghost.yell(ghost.VOICE_HELLO + Dungeon.hero.givenName()); Sample.INSTANCE.play( Assets.SND_GHOST ); firstSummon = true; } else diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndWandmaker.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndWandmaker.java index ea3406ecc..660d0548c 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndWandmaker.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndWandmaker.java @@ -94,7 +94,7 @@ public class WndWandmaker extends Window { Dungeon.level.drop( reward, wandmaker.pos ).sprite.drop(); } - wandmaker.yell( Utils.format( TXT_FARAWELL, Dungeon.hero.className() ) ); + wandmaker.yell( Utils.format( TXT_FARAWELL, Dungeon.hero.givenName() ) ); wandmaker.destroy(); wandmaker.sprite.die();