package dungeonmania.entities.collectables;
import dungeonmania.Game;
import dungeonmania.battles.BattleStatistics;
Copyright By PowCoder代写 加微信 powcoder
import dungeonmania.entities.BattleItem;
import dungeonmania.entities.Entity;
import dungeonmania.entities.Player;
import dungeonmania.entities.inventory.InventoryItem;
import dungeonmania.map.GameMap;
import dungeonmania.util.Position;
public class Sword extends Entity implements InventoryItem, BattleItem {
public static final double DEFAULT_ATTACK = 1;
public static final double DEFAULT_ATTACK_SCALE_FACTOR = 1;
public static final int DEFAULT_DURABILITY = 5;
public static final double DEFAULT_DEFENCE = 0;
public static final double DEFAULT_DEFENCE_SCALE_FACTOR = 1;
private int durability;
private double attack;
public Sword(Position position, double attack, int durability) {
super(position);
this.attack = attack;
this.durability = durability;
public boolean canMoveOnto(GameMap map, Entity entity) {
return true;
public void onOverlap(GameMap map, Entity entity) {
if (entity instanceof Player) {
if (!((Player) entity).pickUp(this)) return;
map.destroyEntity(this);
public void onMovedAway(GameMap map, Entity entity) {
public void onDestroy(GameMap gameMap) {
public void use(Game game) {
durability–;
if (durability <= 0) {
game.getPlayer().remove(this);
public BattleStatistics applyBuff(BattleStatistics origin) {
return BattleStatistics.applyBuff(origin, new BattleStatistics(
public int getDurability() {
return durability;
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com