/* * Pixel Dungeon * Copyright (C) 2012-2015 Oleg Dolya * * Shattered Pixel Dungeon * Copyright (C) 2014-2016 Evan Debenham * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see */ package com.shatteredpixel.shatteredpixeldungeon.items; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.utils.Random; abstract public class KindOfWeapon extends EquipableItem { protected static final float TIME_TO_EQUIP = 1f; @Override public boolean isEquipped( Hero hero ) { return hero.belongings.weapon == this; } @Override public boolean doEquip( Hero hero ) { detachAll( hero.belongings.backpack ); if (hero.belongings.weapon == null || hero.belongings.weapon.doUnequip( hero, true )) { hero.belongings.weapon = this; activate( hero ); updateQuickslot(); cursedKnown = true; if (cursed) { equipCursed( hero ); GLog.n( Messages.get(KindOfWeapon.class, "cursed") ); } hero.spendAndNext( TIME_TO_EQUIP ); return true; } else { collect( hero.belongings.backpack ); return false; } } @Override public boolean doUnequip( Hero hero, boolean collect, boolean single ) { if (super.doUnequip( hero, collect, single )) { hero.belongings.weapon = null; return true; } else { return false; } } public int min(){ return min(level()); } public int max(){ return max(level()); } abstract public int min(int lvl); abstract public int max(int lvl); public int damageRoll( Hero owner ) { return Random.NormalIntRange( min(), max() ); } public float accuracyFactor(Hero hero ) { return 1f; } public float speedFactor( Hero hero ) { return 1f; } public int reachFactor( Hero hero ){ return 1; } public int defenceFactor( Hero hero ) { return 0; } public void proc( Char attacker, Char defender, int damage ) { } }