Package vee.items.weapons

Source Code of vee.items.weapons.Weapon

package vee.items.weapons;

import vee.AttackAction;
import vee.types.DamageType;
import vee.Weaponise;
import vee.items.Equipment;
import vee.types.EquipmentSlot;
import vee.utilities.Utility;


public abstract class Weapon extends Equipment implements Weaponise {

  protected Double minDamage;

  protected Double maxDamage;

  protected DamageType damageType;


  @Override
  public AttackAction attack() {
    AttackAction attackAction = new AttackAction();

    attackAction.setDamage(this.calculateDamage());
    attackAction.setDamageType(this.getDamageType());

    return attackAction;
  }

  public DamageType getDamageType() {
    return this.damageType;
  }

  public void setDamageType(DamageType damageType) {
    this.damageType = damageType;
  }

  public Double getMaxDamage() {
    return this.maxDamage;
  }

  public void setMinDamage(Double minDamage) {
    this.minDamage = minDamage;
  }

  public void setMaxDamage(Double maxDamage) {
    this.maxDamage = maxDamage;
  }

  public Double getMinDamage() {
    return this.minDamage;
  }


  public Double calculateDamage() {
    //TODO: I really don't like this ceil crap. Surely there's something better to do?
    return Math.ceil(Utility.generateRandom(this.getMinDamage(), this.getMaxDamage()));
  }


  @Override
  protected void setDefaults() {
    this.weapon = true;
    this.armor = false;
    this.setSlot(EquipmentSlot.MainHand);
  }

}
TOP

Related Classes of vee.items.weapons.Weapon

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.