From 92a17f392ee9bb68313be5b56f8cbee347d68924 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 17 Oct 2014 02:16:42 -0400 Subject: [PATCH] Merging Source v1.7.2: top-level class changes --- .../shatteredpixeldungeon/Assets.java | 1 + .../shatteredpixeldungeon/Badges.java | 5 +++ .../shatteredpixeldungeon/Challenges.java | 42 +++++++++++++++++++ .../shatteredpixeldungeon/Chrome.java | 5 +-- .../shatteredpixeldungeon/Dungeon.java | 30 +++++++++---- .../GamesInProgress.java | 4 +- .../shatteredpixeldungeon/Preferences.java | 2 + 7 files changed, 73 insertions(+), 16 deletions(-) create mode 100644 src/com/shatteredpixel/shatteredpixeldungeon/Challenges.java diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Assets.java b/src/com/shatteredpixel/shatteredpixeldungeon/Assets.java index 1bbdc86ed..e9fdff730 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/Assets.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Assets.java @@ -39,6 +39,7 @@ public class Assets { public static final String ROGUE = "rogue.png"; public static final String HUNTRESS = "ranger.png"; public static final String AVATARS = "avatars.png"; + public static final String PET = "pet.png"; public static final String SURFACE = "surface.png"; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Badges.java b/src/com/shatteredpixel/shatteredpixeldungeon/Badges.java index da0b66fa4..474886f1f 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/Badges.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Badges.java @@ -141,6 +141,7 @@ public class Badges { GAMES_PLAYED_3( "500 games played", 62, true ), GAMES_PLAYED_4( "2000 games played", 63, true ), HAPPY_END( "Happy end", 38 ), + CHAMPION( "Challenge won", 39, true ), SUPPORTER( "Thanks for your support!", 31, true ); public boolean meta; @@ -843,6 +844,10 @@ public class Badges { public static void validateHappyEnd() { displayBadge( Badge.HAPPY_END ); } + + public static void validateChampion() { + displayBadge(Badge.CHAMPION); + } private static void displayBadge( Badge badge ) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Challenges.java b/src/com/shatteredpixel/shatteredpixeldungeon/Challenges.java new file mode 100644 index 000000000..c43672f64 --- /dev/null +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Challenges.java @@ -0,0 +1,42 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2014 Oleg Dolya + * + * 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; + +public class Challenges { + + public static final int NO_FOOD = 1; + public static final int NO_ARMOR = 2; + public static final int NO_HEALING = 4; + public static final int NO_HERBALISM = 8; + public static final int SWARM_INTELLIGENCE = 16; + public static final int DARKNESS = 32; + + public static final String[] NAMES = { + "No food", + "No armors", + "No healing potions", + "No dew, no seeds", + "Swarm intelligence", + "Darkness" + }; + + public static final int[] MASKS = { + NO_FOOD, NO_ARMOR, NO_HEALING, NO_HERBALISM, SWARM_INTELLIGENCE, DARKNESS + }; + +} \ No newline at end of file diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Chrome.java b/src/com/shatteredpixel/shatteredpixeldungeon/Chrome.java index 113545bb7..c1c3204be 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/Chrome.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Chrome.java @@ -31,8 +31,7 @@ public class Chrome { SCROLL, TAB_SET, TAB_SELECTED, - TAB_UNSELECTED, - SURFACE + TAB_UNSELECTED }; public static NinePatch get( Type type ) { @@ -57,8 +56,6 @@ public class Chrome { return new NinePatch( Assets.CHROME, 64, 22, 10, 14, 4, 7, 4, 6 ); case TAB_UNSELECTED: return new NinePatch( Assets.CHROME, 74, 22, 10, 14, 4, 7, 4, 6 ); - case SURFACE: - return new NinePatch( Assets.CHROME, 86, 0, 22, 22, 5 ); default: return null; } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java b/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java index 05c441fcf..4bce146fa 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java @@ -124,12 +124,13 @@ public class Dungeon { public static int arcaneStyli; public static boolean dewVial; // true if the dew vial can be spawned public static int transmutation; // depth number for a well of transmutation - + + public static int challenges; public static Hero hero; public static Level level; - // Either� Item or Class + // Either Item or Class public static Object quickslot; public static int depth; @@ -148,6 +149,8 @@ public class Dungeon { public static void init() { + challenges = ShatteredPixelDungeon.challenges(); + Actor.clear(); PathFinder.setMapSize( Level.WIDTH, Level.HEIGHT ); @@ -185,6 +188,10 @@ public class Dungeon { StartScene.curClass.initHero( hero ); } + + public static boolean isChallenged( int mask ) { + return (challenges & mask) != 0; + } public static Level newLevel() { @@ -375,6 +382,7 @@ public class Dungeon { private static final String RN_DEPTH_FILE = "ranger%d.dat"; private static final String VERSION = "version"; + private static final String CHALLENGES = "challenges"; private static final String HERO = "hero"; private static final String GOLD = "gold"; private static final String DEPTH = "depth"; @@ -420,6 +428,7 @@ public class Dungeon { Bundle bundle = new Bundle(); bundle.put( VERSION, Game.versionCode ); + bundle.put( CHALLENGES, challenges ); bundle.put( HERO, hero ); bundle.put( GOLD, gold ); bundle.put( DEPTH, depth ); @@ -488,12 +497,8 @@ public class Dungeon { Actor.fixTime(); saveGame( gameFile( hero.heroClass ) ); saveLevel(); - - GamesInProgress.set( - hero.heroClass, - depth, - hero.lvl, - hero.belongings.armor != null ? hero.belongings.armor.tier : 0 ); + + GamesInProgress.set( hero.heroClass, depth, hero.lvl ); } else if (WndResurrect.instance != null) { @@ -516,6 +521,8 @@ public class Dungeon { Bundle bundle = gameBundle( fileName ); version = bundle.getInt( VERSION ); + + Dungeon.challenges = bundle.getInt( CHALLENGES ); Dungeon.level = null; Dungeon.depth = -1; @@ -625,7 +632,7 @@ public class Dungeon { public static void preview( GamesInProgress.Info info, Bundle bundle ) { info.depth = bundle.getInt( DEPTH ); if (info.depth == -1) { - info.depth = bundle.getInt( "maxDepth" ); // <-- It has to be refactored! + info.depth = bundle.getInt( "maxDepth" ); // FIXME } Hero.preview( info, bundle.getBundle( HERO ) ); } @@ -638,6 +645,11 @@ public class Dungeon { } public static void win( String desc ) { + + if (challenges != 0) { + Badges.validateChampion(); + } + resultDescription = desc; Rankings.INSTANCE.submit( true ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/GamesInProgress.java b/src/com/shatteredpixel/shatteredpixeldungeon/GamesInProgress.java index eabec5fb7..c93f5c63a 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/GamesInProgress.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/GamesInProgress.java @@ -51,11 +51,10 @@ public class GamesInProgress { } } - public static void set( HeroClass cl, int depth, int level, int armor ) { + public static void set( HeroClass cl, int depth, int level ) { Info info = new Info(); info.depth = depth; info.level = level; - info.armor = armor; state.put( cl, info ); } @@ -70,6 +69,5 @@ public class GamesInProgress { public static class Info { public int depth; public int level; - public int armor; } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Preferences.java b/src/com/shatteredpixel/shatteredpixeldungeon/Preferences.java index 8df740886..02c3fac6d 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/Preferences.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Preferences.java @@ -26,11 +26,13 @@ enum Preferences { INSTANCE; public static final String KEY_LANDSCAPE = "landscape"; + public static final String KEY_IMMERSIVE = "immersive"; public static final String KEY_SCALE_UP = "scaleup"; public static final String KEY_MUSIC = "music"; public static final String KEY_SOUND_FX = "soundfx"; public static final String KEY_ZOOM = "zoom"; public static final String KEY_LAST_CLASS = "last_class"; + public static final String KEY_CHALLENGES = "challenges"; public static final String KEY_DONATED = "donated"; public static final String KEY_INTRO = "intro"; public static final String KEY_BRIGHTNESS = "brightness";