コード例 #1
0
 /**
  * Heals a Hero's health OR magic OR both. If player is lucky enough they get boost to both stats.
  * Otherwise one or the other.
  */
 public StringBuilder triggerEffectGUI() {
   StringBuilder sb = new StringBuilder();
   Player p = getActivator();
   Hero beingHealed = p.getCharacter();
   randomize();
   Random rand = new Random(System.currentTimeMillis());
   int luck = rand.nextInt(100) + 1 + beingHealed.getLuck();
   if (luck > 75) {
     beingHealed.setCurrentHP(beingHealed.getCurrentHP() + statChange);
     beingHealed.setCurrentMP(beingHealed.getCurrentMP() + statChange2);
     sb.append(
         p.getCustomName()
             + " has gained "
             + statChange
             + " health and "
             + statChange2
             + " mana.\n");
   } else if (rand.nextBoolean()) {
     beingHealed.setCurrentHP(beingHealed.getCurrentHP() + statChange);
     sb.append(p.getCustomName() + " has gained " + statChange + " health.\n");
   } else {
     beingHealed.setCurrentMP(beingHealed.getCurrentMP() + statChange);
     sb.append(p.getCustomName() + " has gained " + statChange + " mana.\n");
   }
   return sb;
 }
コード例 #2
0
 /**
  * Heals a Hero's health OR magic OR both. If player is lucky enough they get boost to both stats.
  * Otherwise one or the other.
  */
 @Override
 public void triggerEffect() {
   Player p = getActivator();
   Hero beingHealed = p.getCharacter();
   randomize();
   Random rand = new Random(System.currentTimeMillis());
   int luck = rand.nextInt(100) + 1 + beingHealed.getLuck();
   if (luck > 75) {
     beingHealed.setCurrentHP(beingHealed.getCurrentHP() + statChange);
     beingHealed.setCurrentMP(beingHealed.getCurrentMP() + statChange2);
   } else if (rand.nextBoolean()) {
     beingHealed.setCurrentHP(beingHealed.getCurrentHP() + statChange);
   } else {
     beingHealed.setCurrentMP(beingHealed.getCurrentMP() + statChange);
   }
 }
コード例 #3
0
 /**
  * Takes in Player class as a parameter. Fully restore current player's HP(MP if Ghost).
  *
  * @param affected
  */
 @Override
 public void triggerEffect(Player affected) {
   Hero hero = affected.getCharacter();
   if (hero.isGhost() == false) {
     hero.setCurrentHP(hero.getMaxHP());
   } else if (hero.isGhost() == true) {
     hero.setCurrentMP(hero.getMaxMP());
   }
   this.setMessage("You were kissed by a magic fairy. Restore HP to max.");
 }