v0.6.1: reworked the HP mechanics on right of might

This commit is contained in:
Evan Debenham 2017-06-21 17:11:48 -04:00
parent 42a37ec1ac
commit 8fe920ff17
4 changed files with 39 additions and 20 deletions

View File

@ -161,6 +161,8 @@ public class Hero extends Char {
public int lvl = 1;
public int exp = 0;
public int HTBoost = 0;
private ArrayList<Mob> visibleEnemies;
//This list is maintained so that some logic checks can be skipped
@ -179,6 +181,19 @@ public class Hero extends Char {
visibleEnemies = new ArrayList<Mob>();
}
public void updateHT( boolean boostHP ){
int curHT = HT;
HT = 20 + 5*(lvl-1) + HTBoost;
float multiplier = RingOfMight.HTMultiplier(this);
HT = Math.round(multiplier * HT);
if (boostHP){
HP += Math.max(HT - curHT, 0);
}
HP = Math.min(HP, HT);
}
public int STR() {
int STR = this.STR;
@ -193,6 +208,7 @@ public class Hero extends Char {
private static final String STRENGTH = "STR";
private static final String LEVEL = "lvl";
private static final String EXPERIENCE = "exp";
private static final String HTBOOST = "htboost";
@Override
public void storeInBundle( Bundle bundle ) {
@ -209,6 +225,8 @@ public class Hero extends Char {
bundle.put( LEVEL, lvl );
bundle.put( EXPERIENCE, exp );
bundle.put( HTBOOST, HTBoost );
belongings.storeInBundle( bundle );
}
@ -229,6 +247,8 @@ public class Hero extends Char {
lvl = bundle.getInt( LEVEL );
exp = bundle.getInt( EXPERIENCE );
HTBoost = bundle.getInt(HTBOOST);
belongings.restoreFromBundle( bundle );
}
@ -1191,8 +1211,7 @@ public class Hero extends Char {
lvl++;
levelUp = true;
HT += 5;
HP += 5;
updateHT( true );
attackSkill++;
defenseSkill++;

View File

@ -40,8 +40,8 @@ public class PotionOfMight extends Potion {
setKnown();
hero.STR++;
hero.HT += 5;
hero.HP += 5;
hero.HTBoost += 5;
hero.updateHT( true );
hero.sprite.showStatus( CharSprite.POSITIVE, Messages.get(this, "msg_1") );
GLog.p( Messages.get(this, "msg_2") );

View File

@ -31,8 +31,7 @@ public class RingOfMight extends Ring {
@Override
public boolean doEquip(Hero hero) {
if (super.doEquip(hero)){
hero.HT += level()*5;
hero.HP = Math.min(hero.HP, hero.HT);
hero.updateHT( false );
return true;
} else {
return false;
@ -41,34 +40,30 @@ public class RingOfMight extends Ring {
@Override
public boolean doUnequip(Hero hero, boolean collect, boolean single) {
if (super.doUnequip(hero, collect, single)){
hero.HT -= level()*5;
hero.HP = Math.min(hero.HP, hero.HT);
hero.updateHT( false );
return true;
} else {
return false;
}
}
@Override
public Item upgrade() {
if (buff != null && buff.target != null){
buff.target.HT += 5;
}
return super.upgrade();
super.upgrade();
updateTargetHT();
return this;
}
@Override
public void level(int value) {
if (buff != null && buff.target != null){
buff.target.HT -= level()*5;
}
super.level(value);
if (buff != null && buff.target != null){
buff.target.HT += level()*5;
buff.target.HP = Math.min(buff.target.HP, buff.target.HT);
updateTargetHT();
}
private void updateTargetHT(){
if (buff != null && buff.target instanceof Hero){
((Hero) buff.target).updateHT( false );
}
}
@ -80,6 +75,10 @@ public class RingOfMight extends Ring {
public static int strengthBonus( Char target ){
return getBonus( target, Might.class );
}
public static float HTMultiplier( Char target ){
return (float)Math.pow(1.035, getBonus(target, Might.class));
}
public class Might extends RingBuff {
}

View File

@ -91,6 +91,7 @@ public class ScrollOfRemoveCurse extends InventoryScroll {
if (procced) {
hero.sprite.emitter().start( ShadowParticle.UP, 0.05f, 10 );
hero.updateHT( false ); //for ring of might
}
return procced;