v0.9.0: baseline talent logic implementation
This commit is contained in:
parent
2a7b94d51d
commit
bd480e25cd
|
@ -296,6 +296,39 @@ actors.buffs.wellfed.desc=You feel quite satisfied and full.\n\nWhile well fed,
|
|||
|
||||
|
||||
###hero
|
||||
actors.hero.talent.test_warrior_1.title=hearty meal
|
||||
actors.hero.talent.test_warrior_1.desc=_+1:_ Eating at below 50% health heals the Warrior for _4 HP_.\n\n_+2:_ Eating at below 50% health heals the Warrior for _6 HP_.
|
||||
actors.hero.talent.test_warrior_2.title=armsmaster's intuition
|
||||
actors.hero.talent.test_warrior_2.desc=_+1:_ The warrior identifies Weapons and Armor _3x faster_.\n\n_+2:_ The warrior identifies Weapons and Armor _when he equips them_.
|
||||
actors.hero.talent.test_warrior_3.title=test talent
|
||||
actors.hero.talent.test_warrior_3.desc=_+1:_ Whenever he identifies a potion, the warrior heals for _3 HP_.\n\n_+2:_ Whenever he identifies a potion, the warrior heals for _5 HP_.
|
||||
actors.hero.talent.test_warrior_4.title=iron will
|
||||
actors.hero.talent.test_warrior_4.desc=_+1:_ The max shield provided by the warrior's seal is _increased by 1_.\n\n_+2:_ The max shield provided by the warrior's seal is _increased by 2_.
|
||||
actors.hero.talent.test_mage_1.title=test talent
|
||||
actors.hero.talent.test_mage_1.desc=TODO
|
||||
actors.hero.talent.test_mage_2.title=test talent
|
||||
actors.hero.talent.test_mage_2.desc=TODO
|
||||
actors.hero.talent.test_mage_3.title=test talent
|
||||
actors.hero.talent.test_mage_3.desc=TODO
|
||||
actors.hero.talent.test_mage_4.title=test talent
|
||||
actors.hero.talent.test_mage_4.desc=TODO
|
||||
actors.hero.talent.test_rogue_1.title=test talent
|
||||
actors.hero.talent.test_rogue_1.desc=TODO
|
||||
actors.hero.talent.test_rogue_2.title=test talent
|
||||
actors.hero.talent.test_rogue_2.desc=TODO
|
||||
actors.hero.talent.test_rogue_3.title=test talent
|
||||
actors.hero.talent.test_rogue_3.desc=TODO
|
||||
actors.hero.talent.test_rogue_4.title=test talent
|
||||
actors.hero.talent.test_rogue_4.desc=TODO
|
||||
actors.hero.talent.test_huntress_1.title=test talent
|
||||
actors.hero.talent.test_huntress_1.desc=TODO
|
||||
actors.hero.talent.test_huntress_2.title=test talent
|
||||
actors.hero.talent.test_huntress_2.desc=TODO
|
||||
actors.hero.talent.test_huntress_3.title=test talent
|
||||
actors.hero.talent.test_huntress_3.desc=TODO
|
||||
actors.hero.talent.test_huntress_4.title=test talent
|
||||
actors.hero.talent.test_huntress_4.desc=TODO
|
||||
|
||||
actors.hero.hero.name=you
|
||||
actors.hero.hero.leave=You can't leave yet!
|
||||
actors.hero.hero.level_up=Level up!
|
||||
|
|
|
@ -131,6 +131,7 @@ import com.watabou.utils.Random;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class Hero extends Char {
|
||||
|
||||
|
@ -150,6 +151,7 @@ public class Hero extends Char {
|
|||
|
||||
public HeroClass heroClass = HeroClass.ROGUE;
|
||||
public HeroSubClass subClass = HeroSubClass.NONE;
|
||||
public ArrayList<LinkedHashMap<Talent, Integer>> talents = new ArrayList<>();
|
||||
|
||||
private int attackSkill = 10;
|
||||
private int defenseSkill = 5;
|
||||
|
@ -235,6 +237,7 @@ public class Hero extends Char {
|
|||
|
||||
heroClass.storeInBundle( bundle );
|
||||
subClass.storeInBundle( bundle );
|
||||
Talent.storeTalentsInBundle( bundle, this );
|
||||
|
||||
bundle.put( ATTACK, attackSkill );
|
||||
bundle.put( DEFENSE, defenseSkill );
|
||||
|
@ -255,6 +258,7 @@ public class Hero extends Char {
|
|||
|
||||
heroClass = HeroClass.restoreInBundle( bundle );
|
||||
subClass = HeroSubClass.restoreInBundle( bundle );
|
||||
Talent.restoreTalentsFromBundle( bundle, this );
|
||||
|
||||
attackSkill = bundle.getInt( ATTACK );
|
||||
defenseSkill = bundle.getInt( DEFENSE );
|
||||
|
@ -280,6 +284,42 @@ public class Hero extends Char {
|
|||
info.subClass = HeroSubClass.restoreInBundle( bundle );
|
||||
Belongings.preview( info, bundle );
|
||||
}
|
||||
|
||||
public boolean hasTalent( Talent talent ){
|
||||
return pointsInTalent(talent) > 0;
|
||||
}
|
||||
|
||||
public int pointsInTalent( Talent talent ){
|
||||
for (LinkedHashMap<Talent, Integer> tier : talents){
|
||||
for (Talent f : tier.keySet()){
|
||||
if (f == talent) return tier.get(f);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void upgradeTalent( Talent talent ){
|
||||
for (LinkedHashMap<Talent, Integer> tier : talents){
|
||||
for (Talent f : tier.keySet()){
|
||||
if (f == talent) tier.put(talent, tier.get(talent)+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int talentPointsSpent(){
|
||||
int total = 0;
|
||||
for (LinkedHashMap<Talent, Integer> tier : talents){
|
||||
for (int i : tier.values()){
|
||||
total += i;
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public int talentPointsAvailable(){
|
||||
//hero currently only gains points up to level 6
|
||||
return Math.min(lvl, 6) - 1 - talentPointsSpent();
|
||||
}
|
||||
|
||||
public String className() {
|
||||
return subClass == null || subClass == HeroSubClass.NONE ? heroClass.title() : subClass.title();
|
||||
|
|
|
@ -72,6 +72,7 @@ public enum HeroClass {
|
|||
public void initHero( Hero hero ) {
|
||||
|
||||
hero.heroClass = this;
|
||||
Talent.initClassTalents(hero);
|
||||
|
||||
initCommon( hero );
|
||||
|
||||
|
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2020 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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.actors.hero;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.watabou.utils.Bundle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public enum Talent {
|
||||
|
||||
TEST_WARRIOR_1(0),
|
||||
TEST_WARRIOR_2(1),
|
||||
TEST_WARRIOR_3(2),
|
||||
TEST_WARRIOR_4(3),
|
||||
|
||||
TEST_MAGE_1(16),
|
||||
TEST_MAGE_2(17),
|
||||
TEST_MAGE_3(18),
|
||||
TEST_MAGE_4(19),
|
||||
|
||||
TEST_ROGUE_1(32),
|
||||
TEST_ROGUE_2(33),
|
||||
TEST_ROGUE_3(34),
|
||||
TEST_ROGUE_4(35),
|
||||
|
||||
TEST_HUNTRESS_1(48),
|
||||
TEST_HUNTRESS_2(49),
|
||||
TEST_HUNTRESS_3(50),
|
||||
TEST_HUNTRESS_4(51);
|
||||
|
||||
int icon;
|
||||
|
||||
Talent(int icon ){
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public int icon(){
|
||||
return icon;
|
||||
}
|
||||
|
||||
public int maxPoints(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
public String title(){
|
||||
return Messages.get(this, name() + ".title");
|
||||
}
|
||||
|
||||
public String desc(){
|
||||
return Messages.get(this, name() + ".desc");
|
||||
}
|
||||
|
||||
private static final int TALENT_TIERS = 1;
|
||||
|
||||
public static void initClassTalents( Hero hero ){
|
||||
while (hero.talents.size() < TALENT_TIERS){
|
||||
hero.talents.add(new LinkedHashMap<>());
|
||||
}
|
||||
|
||||
ArrayList<Talent> tierTalents = new ArrayList<>();
|
||||
|
||||
//tier 1
|
||||
switch (hero.heroClass){
|
||||
case WARRIOR: default:
|
||||
Collections.addAll(tierTalents, TEST_WARRIOR_1, TEST_WARRIOR_2, TEST_WARRIOR_3, TEST_WARRIOR_4);
|
||||
break;
|
||||
case MAGE:
|
||||
Collections.addAll(tierTalents, TEST_MAGE_1, TEST_MAGE_2, TEST_MAGE_3, TEST_MAGE_4);
|
||||
break;
|
||||
case ROGUE:
|
||||
Collections.addAll(tierTalents, TEST_ROGUE_1, TEST_ROGUE_2, TEST_ROGUE_3, TEST_ROGUE_4);
|
||||
break;
|
||||
case HUNTRESS:
|
||||
Collections.addAll(tierTalents, TEST_HUNTRESS_1, TEST_HUNTRESS_2, TEST_HUNTRESS_3, TEST_HUNTRESS_4);
|
||||
break;
|
||||
}
|
||||
for (Talent talent : tierTalents){
|
||||
hero.talents.get(0).put(talent, 0);
|
||||
}
|
||||
tierTalents.clear();
|
||||
|
||||
//tier 2+
|
||||
//TBD
|
||||
}
|
||||
|
||||
public static void initSubclassTalents( Hero hero ){
|
||||
//Nothing here yet. Hm.....
|
||||
}
|
||||
|
||||
private static final String TALENTS = "talents";
|
||||
|
||||
public static void storeTalentsInBundle( Bundle bundle, Hero hero ){
|
||||
Bundle talentBundle = new Bundle();
|
||||
|
||||
for (Talent talent : values()){
|
||||
if (hero.hasTalent(talent)){
|
||||
talentBundle.put(talent.name(), hero.pointsInTalent(talent));
|
||||
}
|
||||
}
|
||||
|
||||
bundle.put(TALENTS, talentBundle);
|
||||
}
|
||||
|
||||
public static void restoreTalentsFromBundle( Bundle bundle, Hero hero ){
|
||||
if (hero.heroClass != null) initClassTalents(hero);
|
||||
if (hero.subClass != null) initSubclassTalents(hero);
|
||||
|
||||
if (!bundle.contains(TALENTS)) return;
|
||||
Bundle talentBundle = bundle.getBundle(TALENTS);
|
||||
|
||||
for (Talent talent : values()){
|
||||
if (talentBundle.contains(talent.name())){
|
||||
for (LinkedHashMap<Talent, Integer> tier : hero.talents){
|
||||
if (tier.containsKey(talent)){
|
||||
tier.put(talent, talentBundle.getInt(talent.name()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
|
@ -114,6 +115,7 @@ public class TomeOfMastery extends Item {
|
|||
curUser.busy();
|
||||
|
||||
curUser.subClass = way;
|
||||
Talent.initSubclassTalents(curUser);
|
||||
|
||||
curUser.sprite.operate( curUser.pos );
|
||||
Sample.INSTANCE.play( Assets.Sounds.MASTERY );
|
||||
|
|
Loading…
Reference in New Issue
Block a user