141 lines
3.5 KiB
Java
141 lines
3.5 KiB
Java
/*
|
|
* 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 <http://www.gnu.org/licenses/>
|
|
*/
|
|
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
|
import com.watabou.utils.Random;
|
|
|
|
public class MeleeWeapon extends Weapon {
|
|
|
|
public int tier;
|
|
|
|
@Override
|
|
public int min(int lvl) {
|
|
return tier + //base
|
|
lvl; //level scaling
|
|
}
|
|
|
|
@Override
|
|
public int max(int lvl) {
|
|
return 5*(tier+1) + //base
|
|
lvl*(tier+1); //level scaling
|
|
}
|
|
|
|
@Override
|
|
public Item upgrade() {
|
|
return upgrade( false );
|
|
}
|
|
|
|
public Item safeUpgrade() {
|
|
return upgrade( enchantment != null );
|
|
}
|
|
|
|
public int STRReq(int lvl){
|
|
lvl = Math.max(0, lvl);
|
|
//strength req decreases at +1,+3,+6,+10,etc.
|
|
return (8 + tier * 2) - (int)(Math.sqrt(8 * lvl + 1) - 1)/2;
|
|
}
|
|
|
|
@Override
|
|
public String info() {
|
|
String name = name();
|
|
|
|
String info = desc();
|
|
|
|
info += "\n\n" + Messages.get(MeleeWeapon.class, "tier", tier);
|
|
|
|
if (levelKnown) {
|
|
int min = min();
|
|
int max = max();
|
|
float dmgfactor = (imbue == Imbue.LIGHT ? 0.7f : imbue == Imbue.HEAVY ? 1.5f : 1);
|
|
info += " " + Messages.get(Weapon.class, "avg_dmg", Math.round((min + (max - min) / 2)*dmgfactor));
|
|
} else {
|
|
int min = min(0);
|
|
int max = max(0);
|
|
info += " " + Messages.get(MeleeWeapon.class, "unknown", (min + (max - min) / 2), STRReq(0));
|
|
if (STRReq(0) > Dungeon.hero.STR()) {
|
|
info += " " + Messages.get(MeleeWeapon.class, "probably_too_heavy");
|
|
}
|
|
}
|
|
|
|
switch (imbue) {
|
|
case LIGHT:
|
|
info += " " + Messages.get(Weapon.class, "lighter");
|
|
break;
|
|
case HEAVY:
|
|
info += " " + Messages.get(Weapon.class, "heavier");
|
|
break;
|
|
case NONE:
|
|
}
|
|
|
|
String stats_desc = Messages.get(this, "stats_desc");
|
|
if (!stats_desc.equals("")) info+= "\n\n" + stats_desc;
|
|
|
|
if (levelKnown && STRReq() > Dungeon.hero.STR()) {
|
|
info += "\n\n" + Messages.get(Weapon.class, "too_heavy");
|
|
}
|
|
|
|
if (cursed && isEquipped( Dungeon.hero )) {
|
|
info += "\n\n" + Messages.get(MeleeWeapon.class, "cursed_worn");
|
|
} else if (cursedKnown && cursed) {
|
|
info += "\n\n" + Messages.get(MeleeWeapon.class, "cursed");
|
|
}
|
|
|
|
return info;
|
|
}
|
|
|
|
@Override
|
|
public int price() {
|
|
int price = 20 * (1 << (tier - 1));
|
|
if (enchantment != null) {
|
|
price *= 1.5;
|
|
}
|
|
if (cursed && cursedKnown) {
|
|
price /= 2;
|
|
}
|
|
if (levelKnown) {
|
|
if (level() > 0) {
|
|
price *= (level() + 1);
|
|
} else if (level() < 0) {
|
|
price /= (1 - level());
|
|
}
|
|
}
|
|
if (price < 1) {
|
|
price = 1;
|
|
}
|
|
return price;
|
|
}
|
|
|
|
@Override
|
|
public Item random() {
|
|
super.random();
|
|
|
|
if (Random.Int( 10 + level() ) == 0) {
|
|
enchant();
|
|
}
|
|
|
|
return this;
|
|
}
|
|
}
|