Skip to content

Commit

Permalink
#344 y #322 hechizo inmovilizar no funciona. Aviso de que no tiene ma…
Browse files Browse the repository at this point in the history
…ná (#346)

* BUG #344 Se arregla el hechizo inmovilizar, y con el los hechizos aumentar fuerza y aumentar agilidad.  Se añade un mensaje que faltaba para avisar de que no tienes maná #322. Enlazado con #344 inmovilizar ya consume, maná.

* BUG  #322. Enlazado con #344 inmovilizar ya consume, maná.
  • Loading branch information
vicosdev committed May 10, 2020
1 parent cccc5ce commit 17bc8ce
Showing 1 changed file with 38 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ private void castSpell(int playerId, int target, Spell spell) {
return;
}


if(playerId == target) {
if(spell.getSumHP() == 2 || spell.isImmobilize() || spell.isParalyze()) {
notifyMagic( playerId, Messages.CANT_ATTACK_YOURSELF );
Expand All @@ -124,6 +123,7 @@ private void castSpell(int playerId, int target, Spell spell) {
int fxGrh = spell.getFxGrh();
E targetEntity = E( target );
int damage;

if(spell.getSumHP() > 0) {
Health health = targetEntity.getHealth();
damage = calculateMagicDamage( playerId, target, spell );
Expand All @@ -144,34 +144,6 @@ private void castSpell(int playerId, int target, Spell spell) {
soundEntitySystem.add( playerId, 126 );

}
if(spell.isImmobilize()) {
targetEntity.immobile();
victimUpdateToAllBuilder.withComponents( targetEntity.getImmobile() );
} else if(spell.isRemoveParalysis()) {
if(targetEntity.isImmobile()) {
targetEntity.immobile( false );
victimUpdateToAllBuilder.remove( Immobile.class );
} else {
notifyInfo( playerId, Messages.NOT_PARALYSIS );
return;
}
}

if(spell.isSumStrength()) {
int random = new Random().nextInt( spell.getMaxStrength() - spell.getMinStrength() + 1 ) + spell.getMinStrength();
targetEntity.strengthCurrentValue( targetEntity.strengthCurrentValue() + random );
targetEntity.buff().buffAddAttribute( targetEntity.getStrength(), spell.getStrengthDuration() );
sendAttributeUpdate( target, targetEntity.getStrength(), targetEntity.getBuff() );
}

if(spell.isSumAgility()) {
int random = new Random().nextInt( spell.getMaxAgility() - spell.getMinAgility() + 1 ) + spell.getMinAgility();
targetEntity.agilityCurrentValue( targetEntity.agilityCurrentValue() + random );
targetEntity.buff().buffAddAttribute( targetEntity.getAgility(), spell.getAgilityDuration() );
sendAttributeUpdate( target, targetEntity.getAgility(), targetEntity.getBuff() );
}


if(fxGrh > 0) {
effectEntitySystem.addFX( target, fxGrh, Math.max( 1, spell.getLoops() ) );
}
Expand All @@ -182,7 +154,6 @@ private void castSpell(int playerId, int target, Spell spell) {
updateMana( playerId, requiredMana, mana );
Dialog magicWords = new Dialog( spell.getMagicWords(), Dialog.Kind.MAGIC_WORDS );


Log.info( "Magic attack " + spell.getMagicWords() );
int spellSound = spell.getWav();
soundEntitySystem.add( playerId, spellSound );
Expand All @@ -192,10 +163,44 @@ private void castSpell(int playerId, int target, Spell spell) {

EntityUpdate playerUpdate = playerUpdateBuilder.withComponents( magicWords ).build();
entityUpdateSystem.add( playerUpdate, UpdateTo.ALL );
} else {
notifyInfo( playerId, Messages.DEAD_CANT_ATTACK );

} else if(spell.isImmobilize()) {/*Inmovilizar*/
targetEntity.immobile();
victimUpdateToAllBuilder.withComponents( targetEntity.getImmobile() );
updateMana( playerId, requiredMana, mana );
} else if(spell.isRemoveParalysis()) {
if(targetEntity.isImmobile()) {
targetEntity.immobile( false );
victimUpdateToAllBuilder.remove( Immobile.class );
updateMana( playerId, requiredMana, mana );
} else {
notifyInfo( playerId, Messages.NOT_PARALYSIS );
return;
}
}else if(spell.isSumStrength()) {/*Sumar fuerza*/

int random = new Random().nextInt( spell.getMaxStrength() - spell.getMinStrength() + 1 ) + spell.getMinStrength();
targetEntity.strengthCurrentValue( targetEntity.strengthCurrentValue() + random );
targetEntity.buff().buffAddAttribute( targetEntity.getStrength(), spell.getStrengthDuration() );
sendAttributeUpdate( target, targetEntity.getStrength(), targetEntity.getBuff() );
updateMana( playerId, requiredMana, mana );

}else if(spell.isSumAgility()) {/*Sumar agilidad*/

int random = new Random().nextInt( spell.getMaxAgility() - spell.getMinAgility() + 1 ) + spell.getMinAgility();
targetEntity.agilityCurrentValue( targetEntity.agilityCurrentValue() + random );
targetEntity.buff().buffAddAttribute( targetEntity.getAgility(), spell.getAgilityDuration() );
sendAttributeUpdate( target, targetEntity.getAgility(), targetEntity.getBuff() );
updateMana( playerId, requiredMana, mana );

}

}else{
notifyInfo(playerId,Messages.NOT_ENOUGHT_MANA);

}
}else {
notifyInfo( playerId, Messages.DEAD_CANT_ATTACK );
}
}

Expand Down Expand Up @@ -266,4 +271,4 @@ private String getName(int userId) {
return E(userId).getName().text;
}

}
}

0 comments on commit 17bc8ce

Please sign in to comment.