/* * Pixel Dungeon * Copyright (C) 2012-2015 Oleg Dolya * * Shattered Pixel Dungeon * Copyright (C) 2014-2015 Evan Debenham * * 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.actors.hero; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Challenges; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.items.armor.ClothArmor; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows; import com.shatteredpixel.shatteredpixeldungeon.items.food.Food; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMindVision; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfMagicMissile; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Dagger; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.ShortSword; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Dart; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang; import com.watabou.utils.Bundle; public enum HeroClass { WARRIOR( "warrior" ), MAGE( "mage" ), ROGUE( "rogue" ), HUNTRESS( "huntress" ); private String title; HeroClass( String title ) { this.title = title; } //TODO: need to make all these Messages references non-static public static final String[] WAR_PERKS = { Messages.get(HeroClass.class, "warrior_perk1"), Messages.get(HeroClass.class, "warrior_perk2"), Messages.get(HeroClass.class, "warrior_perk3"), Messages.get(HeroClass.class, "warrior_perk4"), Messages.get(HeroClass.class, "warrior_perk5"), }; public static final String[] MAG_PERKS = { Messages.get(HeroClass.class, "mage_perk1"), Messages.get(HeroClass.class, "mage_perk2"), Messages.get(HeroClass.class, "mage_perk3"), Messages.get(HeroClass.class, "mage_perk4"), Messages.get(HeroClass.class, "mage_perk5"), }; public static final String[] ROG_PERKS = { Messages.get(HeroClass.class, "rogue_perk1"), Messages.get(HeroClass.class, "rogue_perk2"), Messages.get(HeroClass.class, "rogue_perk3"), Messages.get(HeroClass.class, "rogue_perk4"), Messages.get(HeroClass.class, "rogue_perk5"), Messages.get(HeroClass.class, "rogue_perk6"), }; public static final String[] HUN_PERKS = { Messages.get(HeroClass.class, "huntress_perk1"), Messages.get(HeroClass.class, "huntress_perk2"), Messages.get(HeroClass.class, "huntress_perk3"), Messages.get(HeroClass.class, "huntress_perk4"), Messages.get(HeroClass.class, "huntress_perk5"), }; public void initHero( Hero hero ) { hero.heroClass = this; initCommon( hero ); switch (this) { case WARRIOR: initWarrior( hero ); break; case MAGE: initMage( hero ); break; case ROGUE: initRogue( hero ); break; case HUNTRESS: initHuntress( hero ); break; } hero.updateAwareness(); } private static void initCommon( Hero hero ) { if (!Dungeon.isChallenged(Challenges.NO_ARMOR)) (hero.belongings.armor = new ClothArmor()).identify(); if (!Dungeon.isChallenged(Challenges.NO_FOOD)) new Food().identify().collect(); } public Badges.Badge masteryBadge() { switch (this) { case WARRIOR: return Badges.Badge.MASTERY_WARRIOR; case MAGE: return Badges.Badge.MASTERY_MAGE; case ROGUE: return Badges.Badge.MASTERY_ROGUE; case HUNTRESS: return Badges.Badge.MASTERY_HUNTRESS; } return null; } private static void initWarrior( Hero hero ) { hero.STR = hero.STR + 1; (hero.belongings.weapon = new ShortSword()).identify(); Dart darts = new Dart( 8 ); darts.identify().collect(); Dungeon.quickslot.setSlot(0, darts); new PotionOfStrength().setKnown(); } private static void initMage( Hero hero ) { MagesStaff staff = new MagesStaff(new WandOfMagicMissile()); (hero.belongings.weapon = staff).identify(); hero.belongings.weapon.activate(hero); Dungeon.quickslot.setSlot(0, staff); new ScrollOfUpgrade().setKnown(); } private static void initRogue( Hero hero ) { (hero.belongings.weapon = new Dagger()).identify(); CloakOfShadows cloak = new CloakOfShadows(); (hero.belongings.misc1 = cloak).identify(); hero.belongings.misc1.activate( hero ); Dart darts = new Dart( 8 ); darts.identify().collect(); Dungeon.quickslot.setSlot(0, cloak); if (ShatteredPixelDungeon.quickSlots() > 1) Dungeon.quickslot.setSlot(1, darts); new ScrollOfMagicMapping().setKnown(); } private static void initHuntress( Hero hero ) { (hero.belongings.weapon = new Dagger()).identify(); Boomerang boomerang = new Boomerang(); boomerang.identify().collect(); Dungeon.quickslot.setSlot(0, boomerang); new PotionOfMindVision().setKnown(); } public String title() { return Messages.get(HeroClass.class, title); } public String spritesheet() { switch (this) { case WARRIOR: return Assets.WARRIOR; case MAGE: return Assets.MAGE; case ROGUE: return Assets.ROGUE; case HUNTRESS: return Assets.HUNTRESS; } return null; } public String[] perks() { switch (this) { case WARRIOR: return WAR_PERKS; case MAGE: return MAG_PERKS; case ROGUE: return ROG_PERKS; case HUNTRESS: return HUN_PERKS; } return null; } private static final String CLASS = "class"; public void storeInBundle( Bundle bundle ) { bundle.put( CLASS, toString() ); } public static HeroClass restoreInBundle( Bundle bundle ) { String value = bundle.getString( CLASS ); return value.length() > 0 ? valueOf( value ) : ROGUE; } }