v0.9.4: improved Document method names

This commit is contained in:
Evan Debenham 2021-08-08 17:20:35 -04:00
parent d26e6b41dd
commit 65a45d19dc
12 changed files with 22 additions and 29 deletions

View File

@ -97,7 +97,7 @@ public class Hunger extends Buff implements Hero.Doom {
GLog.w( Messages.get(this, "onhungry") ); GLog.w( Messages.get(this, "onhungry") );
if (!Document.ADVENTURERS_GUIDE.pageRead(Document.GUIDE_FOOD)){ if (!Document.ADVENTURERS_GUIDE.isPageRead(Document.GUIDE_FOOD)){
GLog.p(Messages.get(Guidebook.class, "hint")); GLog.p(Messages.get(Guidebook.class, "hint"));
GameScene.flashForDocument(Document.GUIDE_FOOD); GameScene.flashForDocument(Document.GUIDE_FOOD);
} }

View File

@ -43,7 +43,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Combo; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Combo;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Drowsy; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Drowsy;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Foresight; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Foresight;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Fury;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.HoldFast; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.HoldFast;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
@ -60,10 +59,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.abilities.warrior.En
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Monk; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Monk;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Snake; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Snake;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.CheckedCell; import com.shatteredpixel.shatteredpixeldungeon.effects.CheckedCell;
import com.shatteredpixel.shatteredpixeldungeon.effects.Flare;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite; import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite;
import com.shatteredpixel.shatteredpixeldungeon.items.Amulet; import com.shatteredpixel.shatteredpixeldungeon.items.Amulet;
import com.shatteredpixel.shatteredpixeldungeon.items.Ankh; import com.shatteredpixel.shatteredpixeldungeon.items.Ankh;
@ -1256,7 +1252,7 @@ public class Hero extends Char {
target = m; target = m;
} }
if (m instanceof Snake if (m instanceof Snake
&& !Document.ADVENTURERS_GUIDE.pageRead(Document.GUIDE_EXAMINING)){ && !Document.ADVENTURERS_GUIDE.isPageRead(Document.GUIDE_EXAMINING)){
GLog.p(Messages.get(Guidebook.class, "hint")); GLog.p(Messages.get(Guidebook.class, "hint"));
GameScene.flashForDocument(Document.GUIDE_EXAMINING); GameScene.flashForDocument(Document.GUIDE_EXAMINING);
//we set to read here to prevent this message popping up a bunch //we set to read here to prevent this message popping up a bunch

View File

@ -21,7 +21,6 @@
package com.shatteredpixel.shatteredpixeldungeon.actors.mobs; package com.shatteredpixel.shatteredpixeldungeon.actors.mobs;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.journal.Guidebook; import com.shatteredpixel.shatteredpixeldungeon.items.journal.Guidebook;
@ -62,7 +61,7 @@ public class Snake extends Mob {
@Override @Override
public String defenseVerb() { public String defenseVerb() {
dodges++; dodges++;
if (dodges >= 2 && !Document.ADVENTURERS_GUIDE.pageRead(Document.GUIDE_SURPRISE_ATKS)){ if (dodges >= 2 && !Document.ADVENTURERS_GUIDE.isPageRead(Document.GUIDE_SURPRISE_ATKS)){
GLog.p(Messages.get(Guidebook.class, "hint")); GLog.p(Messages.get(Guidebook.class, "hint"));
GameScene.flashForDocument(Document.GUIDE_SURPRISE_ATKS); GameScene.flashForDocument(Document.GUIDE_SURPRISE_ATKS);
dodges = 0; dodges = 0;

View File

@ -36,8 +36,6 @@ import com.watabou.noosa.audio.Sample;
import java.util.ArrayList; import java.util.ArrayList;
import javax.print.Doc;
public abstract class EquipableItem extends Item { public abstract class EquipableItem extends Item {
public static final String AC_EQUIP = "EQUIP"; public static final String AC_EQUIP = "EQUIP";
@ -57,7 +55,7 @@ public abstract class EquipableItem extends Item {
@Override @Override
public boolean doPickUp(Hero hero) { public boolean doPickUp(Hero hero) {
if (super.doPickUp(hero)){ if (super.doPickUp(hero)){
if (!isIdentified() && !Document.ADVENTURERS_GUIDE.pageRead(Document.GUIDE_IDING)){ if (!isIdentified() && !Document.ADVENTURERS_GUIDE.isPageRead(Document.GUIDE_IDING)){
GLog.p(Messages.get(Guidebook.class, "hint")); GLog.p(Messages.get(Guidebook.class, "hint"));
GameScene.flashForDocument(Document.GUIDE_IDING); GameScene.flashForDocument(Document.GUIDE_IDING);
} }

View File

@ -417,10 +417,10 @@ public class Heap implements Bundlable {
for (Item item : items.toArray(new Item[0])){ for (Item item : items.toArray(new Item[0])){
if (item instanceof DocumentPage if (item instanceof DocumentPage
&& ( !((DocumentPage) item).document().pageNames().contains(((DocumentPage) item).page()) && ( !((DocumentPage) item).document().pageNames().contains(((DocumentPage) item).page())
|| ((DocumentPage) item).document().pageFound(((DocumentPage) item).page()))){ || ((DocumentPage) item).document().isPageFound(((DocumentPage) item).page()))){
items.remove(item); items.remove(item);
} }
if (item instanceof Guidebook && Document.ADVENTURERS_GUIDE.pageRead(0)){ if (item instanceof Guidebook && Document.ADVENTURERS_GUIDE.isPageRead(0)){
items.remove(item); items.remove(item);
} }
} }

View File

@ -56,12 +56,12 @@ public enum Document {
return findPage( pagesStates.keySet().toArray(new String[0])[pageIdx] ); return findPage( pagesStates.keySet().toArray(new String[0])[pageIdx] );
} }
public boolean pageFound( String page ){ public boolean isPageFound( String page ){
return pagesStates.containsKey(page) && pagesStates.get(page) > NOT_FOUND; return pagesStates.containsKey(page) && pagesStates.get(page) > NOT_FOUND;
} }
public boolean pageFound( int pageIdx ){ public boolean isPageFound( int pageIdx ){
return pageFound( pagesStates.keySet().toArray(new String[0])[pageIdx] ); return isPageFound( pagesStates.keySet().toArray(new String[0])[pageIdx] );
} }
public boolean readPage( String page ) { public boolean readPage( String page ) {
@ -77,12 +77,12 @@ public enum Document {
return readPage( pagesStates.keySet().toArray(new String[0])[pageIdx] ); return readPage( pagesStates.keySet().toArray(new String[0])[pageIdx] );
} }
public boolean pageRead( String page ){ public boolean isPageRead( String page ){
return pagesStates.containsKey(page) && pagesStates.get(page) == READ; return pagesStates.containsKey(page) && pagesStates.get(page) == READ;
} }
public boolean pageRead( int pageIdx ){ public boolean isPageRead( int pageIdx ){
return pageRead( pagesStates.keySet().toArray(new String[0])[pageIdx] ); return isPageRead( pagesStates.keySet().toArray(new String[0])[pageIdx] );
} }
public Collection<String> pageNames(){ public Collection<String> pageNames(){

View File

@ -439,7 +439,7 @@ public abstract class RegularLevel extends Level {
Collection<String> allPages = Document.ADVENTURERS_GUIDE.pageNames(); Collection<String> allPages = Document.ADVENTURERS_GUIDE.pageNames();
ArrayList<String> missingPages = new ArrayList<>(); ArrayList<String> missingPages = new ArrayList<>();
for ( String page : allPages){ for ( String page : allPages){
if (!Document.ADVENTURERS_GUIDE.pageFound(page)){ if (!Document.ADVENTURERS_GUIDE.isPageFound(page)){
missingPages.add(page); missingPages.add(page);
} }
} }

View File

@ -216,7 +216,7 @@ public abstract class RegularPainter extends Painter {
//entrance doors on floor 2 are hidden if the player hasn't picked up 2nd guidebook page //entrance doors on floor 2 are hidden if the player hasn't picked up 2nd guidebook page
if (Dungeon.depth == 2 if (Dungeon.depth == 2
&& !Document.ADVENTURERS_GUIDE.pageFound(Document.GUIDE_SEARCHING) && !Document.ADVENTURERS_GUIDE.isPageFound(Document.GUIDE_SEARCHING)
&& r instanceof EntranceRoom){ && r instanceof EntranceRoom){
d.type = Room.Door.Type.HIDDEN; d.type = Room.Door.Type.HIDDEN;
} }

View File

@ -79,7 +79,7 @@ public class LaboratoryRoom extends SpecialRoom {
Collection<String> allPages = Document.ALCHEMY_GUIDE.pageNames(); Collection<String> allPages = Document.ALCHEMY_GUIDE.pageNames();
ArrayList<String> missingPages = new ArrayList<>(); ArrayList<String> missingPages = new ArrayList<>();
for ( String page : allPages){ for ( String page : allPages){
if (!Document.ALCHEMY_GUIDE.pageFound(page)){ if (!Document.ALCHEMY_GUIDE.isPageFound(page)){
missingPages.add(page); missingPages.add(page);
} }
} }

View File

@ -67,7 +67,7 @@ public class EntranceRoom extends StandardRoom {
Random.pushGenerator(); Random.pushGenerator();
//places the first guidebook page on floor 1 //places the first guidebook page on floor 1
if (Dungeon.depth == 1 && !Document.ADVENTURERS_GUIDE.pageRead(Document.GUIDE_INTRO)){ if (Dungeon.depth == 1 && !Document.ADVENTURERS_GUIDE.isPageRead(Document.GUIDE_INTRO)){
int pos; int pos;
do { do {
//can't be on bottom row of tiles //can't be on bottom row of tiles
@ -78,7 +78,7 @@ public class EntranceRoom extends StandardRoom {
} }
//places the third guidebook page on floor 2 //places the third guidebook page on floor 2
if (Dungeon.depth == 2 && !Document.ADVENTURERS_GUIDE.pageFound(Document.GUIDE_SEARCHING)){ if (Dungeon.depth == 2 && !Document.ADVENTURERS_GUIDE.isPageFound(Document.GUIDE_SEARCHING)){
int pos; int pos;
do { do {
//can't be on bottom row of tiles //can't be on bottom row of tiles

View File

@ -538,7 +538,7 @@ public class GameScene extends PixelScene {
} }
if (Rankings.INSTANCE.totalNumber > 0 && !Document.ADVENTURERS_GUIDE.pageRead(Document.GUIDE_DIEING)){ if (Rankings.INSTANCE.totalNumber > 0 && !Document.ADVENTURERS_GUIDE.isPageRead(Document.GUIDE_DIEING)){
GLog.p(Messages.get(Guidebook.class, "hint")); GLog.p(Messages.get(Guidebook.class, "hint"));
GameScene.flashForDocument(Document.GUIDE_DIEING); GameScene.flashForDocument(Document.GUIDE_DIEING);
} }
@ -1178,7 +1178,7 @@ public class GameScene extends PixelScene {
GameScene.show( new WndHero() ); GameScene.show( new WndHero() );
} else if ( o instanceof Mob ){ } else if ( o instanceof Mob ){
GameScene.show(new WndInfoMob((Mob) o)); GameScene.show(new WndInfoMob((Mob) o));
if (o instanceof Snake && !Document.ADVENTURERS_GUIDE.pageRead(Document.GUIDE_SURPRISE_ATKS)){ if (o instanceof Snake && !Document.ADVENTURERS_GUIDE.isPageRead(Document.GUIDE_SURPRISE_ATKS)){
GLog.p(Messages.get(Guidebook.class, "hint")); GLog.p(Messages.get(Guidebook.class, "hint"));
GameScene.flashForDocument(Document.GUIDE_SURPRISE_ATKS); GameScene.flashForDocument(Document.GUIDE_SURPRISE_ATKS);
} }

View File

@ -269,7 +269,7 @@ public class WndJournal extends WndTabbed {
super( iconForPage(page), Messages.titleCase(Document.ADVENTURERS_GUIDE.pageTitle(page))); super( iconForPage(page), Messages.titleCase(Document.ADVENTURERS_GUIDE.pageTitle(page)));
this.page = page; this.page = page;
found = Document.ADVENTURERS_GUIDE.pageFound(page); found = Document.ADVENTURERS_GUIDE.isPageFound(page);
if (!found) { if (!found) {
icon.hardlight( 0.5f, 0.5f, 0.5f); icon.hardlight( 0.5f, 0.5f, 0.5f);
@ -295,7 +295,7 @@ public class WndJournal extends WndTabbed {
//TODO might just want this to be part of the Document class //TODO might just want this to be part of the Document class
public static Image iconForPage( String page ){ public static Image iconForPage( String page ){
if (!Document.ADVENTURERS_GUIDE.pageFound(page)){ if (!Document.ADVENTURERS_GUIDE.isPageFound(page)){
return new ItemSprite( ItemSpriteSheet.GUIDE_PAGE ); return new ItemSprite( ItemSpriteSheet.GUIDE_PAGE );
} }
switch (page){ switch (page){
@ -357,7 +357,7 @@ public class WndJournal extends WndTabbed {
updateList(); updateList();
} }
}; };
if (Document.ALCHEMY_GUIDE.pageFound(i)) { if (Document.ALCHEMY_GUIDE.isPageFound(i)) {
pageButtons[i].icon(new ItemSprite(ItemSpriteSheet.SOMETHING + spriteIndexes[i], null)); pageButtons[i].icon(new ItemSprite(ItemSpriteSheet.SOMETHING + spriteIndexes[i], null));
} else { } else {
pageButtons[i].icon(new ItemSprite(ItemSpriteSheet.SOMETHING, null)); pageButtons[i].icon(new ItemSprite(ItemSpriteSheet.SOMETHING, null));