v0.6.1: lots of guidebook implementation

This commit is contained in:
Evan Debenham
2017-07-19 18:01:14 -04:00
committed by Evan Debenham
parent ce47af7d8f
commit fb5e8bc3bd
12 changed files with 116 additions and 58 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

@@ -22,6 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.items.journal; package com.shatteredpixel.shatteredpixeldungeon.items.journal;
import com.shatteredpixel.shatteredpixeldungeon.journal.Document; import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class GuidePage extends DocumentPage { public class GuidePage extends DocumentPage {
@@ -35,4 +36,8 @@ public class GuidePage extends DocumentPage {
return Document.ADVENTURERS_GUIDE; return Document.ADVENTURERS_GUIDE;
} }
@Override
public String desc() {
return Messages.get(this, "desc", document().pageTitle(page()));
}
} }
@@ -43,6 +43,7 @@ public enum Document {
public boolean addPage( String page ) { public boolean addPage( String page ) {
if (pages.containsKey(page) && !pages.get(page)){ if (pages.containsKey(page) && !pages.get(page)){
pages.put(page, true); pages.put(page, true);
Journal.saveNeeded = true;
return true; return true;
} }
return false; return false;
@@ -64,18 +65,18 @@ public enum Document {
return Messages.get( this, name() + "." + page + ".body"); return Messages.get( this, name() + "." + page + ".body");
} }
static { public static final String GUIDE_INTRO_PAGE = "Intro";
ADVENTURERS_GUIDE.pages.put("0", false); public static final String GUIDE_SEARCH_PAGE = "Examining_and_Searching";
ADVENTURERS_GUIDE.pages.put("1", false);
ADVENTURERS_GUIDE.pages.put("2", false);
ADVENTURERS_GUIDE.pages.put("3", false);
ADVENTURERS_GUIDE.pages.put("4", false);
ADVENTURERS_GUIDE.pages.put("5", false);
ADVENTURERS_GUIDE.pages.put("6", false);
ADVENTURERS_GUIDE.pages.put("7", false);
ADVENTURERS_GUIDE.pages.put("8", false);
ADVENTURERS_GUIDE.pages.put("9", false);
static {
ADVENTURERS_GUIDE.pages.put(GUIDE_INTRO_PAGE, false);
ADVENTURERS_GUIDE.pages.put("Identifying", false);
ADVENTURERS_GUIDE.pages.put(GUIDE_SEARCH_PAGE, false);
ADVENTURERS_GUIDE.pages.put("Upgrades", false);
ADVENTURERS_GUIDE.pages.put("Food", false);
ADVENTURERS_GUIDE.pages.put("Levelling", false);
ADVENTURERS_GUIDE.pages.put("Surprise_Attacks", false);
ADVENTURERS_GUIDE.pages.put("Dieing", false);
} }
private static final String DOCUMENTS = "documents"; private static final String DOCUMENTS = "documents";
@@ -31,8 +31,10 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.journal.GuidePage;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder; import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder;
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.LoopBuilder; import com.shatteredpixel.shatteredpixeldungeon.levels.builders.LoopBuilder;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
@@ -51,8 +53,10 @@ import com.watabou.utils.Bundle;
import com.watabou.utils.Random; import com.watabou.utils.Random;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
public abstract class RegularLevel extends Level { public abstract class RegularLevel extends Level {
@@ -81,12 +85,7 @@ public abstract class RegularLevel extends Level {
rooms = builder.build((ArrayList<Room>)initRooms.clone()); rooms = builder.build((ArrayList<Room>)initRooms.clone());
} while (rooms == null); } while (rooms == null);
if (painter().paint(this, rooms)){ return painter().paint(this, rooms);
placeSign();
return true;
} else {
return false;
}
} }
@@ -133,25 +132,6 @@ public abstract class RegularLevel extends Level {
protected abstract Painter painter(); protected abstract Painter painter();
protected void placeSign(){
while (true) {
int pos = pointToCell(roomEntrance.random());
if (pos != entrance && traps.get(pos) == null && findMob(pos) == null) {
map[pos] = Terrain.SIGN;
break;
}
}
//teaches new players about secret doors
if (Dungeon.depth == 2 && !Badges.isUnlocked(Badges.Badge.BOSS_SLAIN_1)) {
for (Room r : roomEntrance.connected.keySet()) {
Room.Door d = roomEntrance.connected.get(r);
if (d.type == Room.Door.Type.REGULAR)
map[d.x + d.y * width()] = Terrain.SECRET_DOOR;
}
}
}
protected float waterFill(){ protected float waterFill(){
return 0; return 0;
} }
@@ -375,6 +355,33 @@ public abstract class RegularLevel extends Level {
} }
drop( item, cell ).type = Heap.Type.REMAINS; drop( item, cell ).type = Heap.Type.REMAINS;
} }
//guide pages
Collection<String> allPages = Document.ADVENTURERS_GUIDE.pages();
ArrayList<String> missingPages = new ArrayList<>();
for ( String page : allPages){
if (!Document.ADVENTURERS_GUIDE.hasPage(page)){
missingPages.add(page);
}
}
//these are dropped specially
missingPages.remove(Document.GUIDE_INTRO_PAGE);
missingPages.remove(Document.GUIDE_SEARCH_PAGE);
//chance to find a page scales with pages missing and depth
if (missingPages.size() > 0 &&
Random.Int(allPages.size()) < missingPages.size() + Dungeon.depth/2){
GuidePage p = new GuidePage();
p.page(missingPages.get(0));
int cell = randomDropCell();
if (map[cell] == Terrain.HIGH_GRASS) {
map[cell] = Terrain.GRASS;
losBlocking[cell] = false;
}
drop( p, cell ).type = Heap.Type.REMAINS;
}
} }
protected Room randomRoom( Class<?extends Room> type ) { protected Room randomRoom( Class<?extends Room> type ) {
@@ -74,19 +74,6 @@ public class SewerBossLevel extends SewerLevel {
.setTunnelLength(new float[]{0, 3, 1}, new float[]{1}); .setTunnelLength(new float[]{0, 3, 1}, new float[]{1});
} }
@Override
protected void placeSign() {
while (true) {
int pos = pointToCell(roomEntrance.random(2));
if (map[pos] != Terrain.LOCKED_EXIT
&& map[pos] != Terrain.WALL_DECO
&& map[pos] != Terrain.ENTRANCE) {
map[pos] = Terrain.SIGN;
break;
}
}
}
@Override @Override
protected float waterFill(){ protected float waterFill(){
return 0.50f; return 0.50f;
@@ -21,10 +21,16 @@
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard; package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.journal.GuidePage;
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.watabou.utils.Point;
import com.watabou.utils.Random;
public class EntranceRoom extends StandardRoom { public class EntranceRoom extends StandardRoom {
@@ -51,6 +57,40 @@ public class EntranceRoom extends StandardRoom {
level.entrance = level.pointToCell(random(2)); level.entrance = level.pointToCell(random(2));
} while (level.findMob(level.entrance) != null); } while (level.findMob(level.entrance) != null);
Painter.set( level, level.entrance, Terrain.ENTRANCE ); Painter.set( level, level.entrance, Terrain.ENTRANCE );
if (Dungeon.depth == 1 && !Document.ADVENTURERS_GUIDE.hasPage(Document.GUIDE_INTRO_PAGE)){
int pos;
do {
//can't be on bottom row of tiles
pos = level.pointToCell(new Point( Random.IntRange( left + 1, right - 1 ),
Random.IntRange( top + 1, bottom - 2 )));
} while (pos == level.entrance || level.findMob(level.entrance) != null);
GuidePage p = new GuidePage();
p.page(Document.GUIDE_INTRO_PAGE);
level.drop( p, pos );
}
if (Dungeon.depth == 2){
if (!Badges.isUnlocked(Badges.Badge.BOSS_SLAIN_4)){
for (Room.Door door : connected.values()) {
door.set( Door.Type.HIDDEN );
}
}
if (!Document.ADVENTURERS_GUIDE.hasPage(Document.GUIDE_SEARCH_PAGE)){
int pos;
do {
//can't be on bottom row of tiles
pos = level.pointToCell(new Point( Random.IntRange( left + 1, right - 1 ),
Random.IntRange( top + 1, bottom - 2 )));
} while (pos == level.entrance || level.findMob(level.entrance) != null);
GuidePage p = new GuidePage();
p.page(Document.GUIDE_SEARCH_PAGE);
level.drop( p, pos );
}
}
} }
} }
@@ -251,14 +251,15 @@ public class WndJournal extends WndTabbed {
private String page; private String page;
public GuideItem( String page ){ public GuideItem( String page ){
super( Icons.get(Icons.MASTERY), Messages.titleCase(Document.ADVENTURERS_GUIDE.pageTitle(page)), -1); super( new ItemSprite( ItemSpriteSheet.GUIDE_PAGE, null),
Messages.titleCase(Document.ADVENTURERS_GUIDE.pageTitle(page)), -1);
this.page = page; this.page = page;
found = Document.ADVENTURERS_GUIDE.hasPage(page); found = Document.ADVENTURERS_GUIDE.hasPage(page);
if (!found) { if (!found) {
icon.hardlight( 0.5f, 0.5f, 0.5f); icon.hardlight( 0.5f, 0.5f, 0.5f);
label.text("???"); label.text( Messages.titleCase(Messages.get( this, "missing" )));
label.hardlight( 0x999999 ); label.hardlight( 0x999999 );
} }
@@ -35,9 +35,9 @@ import com.watabou.utils.SparseArray;
public class WndStory extends Window { public class WndStory extends Window {
private static final int WIDTH_P = 120; private static final int WIDTH_P = 125;
private static final int WIDTH_L = 144; private static final int WIDTH_L = 160;
private static final int MARGIN = 6; private static final int MARGIN = 2;
private static final float bgR = 0.77f; private static final float bgR = 0.77f;
private static final float bgG = 0.73f; private static final float bgG = 0.73f;
@@ -394,6 +394,8 @@ items.food.pasty.cane_desc=A huge sugary sweet candy cane! It's big enough to fi
items.journal.documentpage.name=torn page 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. 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.
items.journal.guidepage.name=torn guidebook page
items.journal.guidepage.desc=A torn page from an adventuring guidebook.\n\nMost of the text is too small to read at a distance, but you can make out the title of the page:\n\n_"%s"_
###keys ###keys
@@ -1,6 +1,20 @@
journal.document.adventurers_guide.title=Adventurer's Guide journal.document.adventurers_guide.title=Adventurer's Guide
journal.document.adventurers_guide.0.title=Coming soon... journal.document.adventurers_guide.intro.title=Introduction
journal.document.adventurers_guide.0.body=Welcome to the Adventurer's Guide to Dungeoneering!\n\nThe most important thing to remember: DON'T PANIC! journal.document.adventurers_guide.intro.body=Greetings Adventurer!\n\nYou have just purchased (or looted) the amazing Adventurer's Guide to Dungeoneering! This guidebook is full of tips, tricks, and advice to help budding adventurers survive and excel!\n\nWhile you can read this guide all at once, it is best used as a reference. Make sure to check it whenever you're struggling.\n\nKeep your wits about you, and remember:\nDON'T PANIC!
journal.document.adventurers_guide.identifying.title=Identifying Items
journal.document.adventurers_guide.identifying.body=Identifying items can be just as important as finding them!\n\nThe colors on potions and glyphs on scrolls are different in each dungeon, so you won't know what effect you'll get if they're unidentified.\n\nUnidentified equipment can be upgraded if you're lucky, or it might be cursed! Accidentally equipping a cursed item is bad, but usually isn't instant doom.\n\nScrolls of identify, upgrade, or remove curse are very useful if you want to reduce the risk of unidentified items.\n\n(You can find a list of all the items you've identified in the items tab of your journal)
journal.document.adventurers_guide.examining_and_searching.title=Examining and Searching
journal.document.adventurers_guide.examining_and_searching.body=Charging forward recklessly is a great way to get killed.\n\nThere's always time to slow down and examine things around you, which can help you figure out the best way to approach a situation. Rushing into enemies is almost never the best way to deal with them.\n\nDungeons are full of secret passages and traps which appear invisible at first glance. It's good to be willing to thoroughly search an area if you suspect something is hidden.\n\n(The magnifying glass button is used for examining and searching. Tap it once and then tap on something to examine, tap it twice to search the area around you.)
journal.document.adventurers_guide.upgrades.title=Upgrades and Strength
journal.document.adventurers_guide.upgrades.body=TODO
journal.document.adventurers_guide.food.title=Effective Rationing
journal.document.adventurers_guide.food.body=TODO
journal.document.adventurers_guide.levelling.title=Gaining Experience
journal.document.adventurers_guide.levelling.body=TODO
journal.document.adventurers_guide.surprise_attacks.title=Surprise Attacks
journal.document.adventurers_guide.surprise_attacks.body=TODO
journal.document.adventurers_guide.dieing.title=Handling Defeat
journal.document.adventurers_guide.dieing.body=TODO
journal.notes$landmark.well_of_health=well of health journal.notes$landmark.well_of_health=well of health
journal.notes$landmark.well_of_awareness=well of awareness journal.notes$landmark.well_of_awareness=well of awareness
@@ -1,3 +1,3 @@
ui.quickslotbutton.select_item=Quickslot an item ui.quickslotbutton.select_item=Quickslot an item
ui.toolbar.examine_prompt=Press again to search\nPress a tile for info ui.toolbar.examine_prompt=Press again to search\nPress a tile to examine
@@ -36,6 +36,7 @@ windows.wndinfotrap.inactive=This trap is inactive, and can no longer be trigger
windows.wndjournal.guide=Guide windows.wndjournal.guide=Guide
windows.wndjournal.notes=Notes windows.wndjournal.notes=Notes
windows.wndjournal.items=Items windows.wndjournal.items=Items
windows.wndjournal$guidetab$guideitem.missing=page missing
windows.wndjournal$notestab.keys=Keys windows.wndjournal$notestab.keys=Keys
windows.wndjournal$notestab.landmarks=Landmarks windows.wndjournal$notestab.landmarks=Landmarks