Add a bunch of new weapons, fix unexpected behavior

This commit is contained in:
Emma Nora Theuer 2024-09-08 15:46:13 +02:00
parent ad2c9fd150
commit 0f6d7eac0f

View file

@ -7,6 +7,7 @@ class Longbow extends Bow {
requirements.put("Str", 8);
playerStrength = strength;
playerDex = dex;
infoDamageDice = "1d8";
infoDamageBonus = "0-2";
name = "Longbow";
rarity = "Common";
@ -17,10 +18,9 @@ class Longbow extends Bow {
@Override
public int getDamageBonus(int distance) {
if (playerDex < requirements.get("Dex") || playerStrength < requirements.get("Str")) {
if (playerDex < requirements.get("Dex") || playerStrength < requirements.get("Str") || distance > range) {
return -20;
}
if (distance > 20 && distance <= 165) {
return 2;
}
@ -32,14 +32,9 @@ class Longbow extends Bow {
}
}
@Override
public int rollToHit(int bonus) {
return dice.rollD20();
}
@Override
public int rollDamage(int bonus) {
int dieResult = dice.rollD10();
int dieResult = dice.rollD8();
if (dieResult + bonus < 0) {
return 0;
} else {
@ -53,6 +48,7 @@ class Shortbow extends Bow {
requirements = new HashMap<>();
requirements.put("Dex", 8);
requirements.put("Str", 6);
infoDamageDice = "1d6";
infoDamageBonus = "0";
playerStrength = strength;
playerDex = dex;
@ -63,8 +59,8 @@ class Shortbow extends Bow {
damageBonus = getDamageBonus();
}
@Override
public int getDamageBonus() {
if (playerDex < requirements.get("Dex") || playerStrength < requirements.get("Str")) {
public int getDamageBonus(int distance) {
if (playerDex < requirements.get("Dex") || playerStrength < requirements.get("Str") || distance > range) {
return -20;
} else {
return 0;
@ -72,6 +68,7 @@ class Shortbow extends Bow {
}
@Override
public int rollDamage(int bonus){
int dieResult = dice.rollD6();
if (dieResult + bonus < 0) {
@ -81,3 +78,152 @@ class Shortbow extends Bow {
}
}
}
class BowOfTheEnchantedOak extends Bow {
public BowOfTheEnchantedOak(int distance, int strength, int dex) {
requirements = new HashMap<>();
requirements.put("Dex", 25);
requirements.put("Str", 12);
playerStrength = strength;
playerDex = dex;
infoDamageDice = "2d8";
infoDamageBonus = "0-4";
name = "Bow of the Enchanted Oak";
rarity = "Rare";
range = getRange(650);
hitBonus = getHitBonus();
damageBonus = getDamageBonus(distance);
}
@Override
public int getDamageBonus(int distance) {
if (playerDex < requirements.get("Dex") || playerStrength < requirements.get("Str") || distance > range) {
return -20;
}
if (distance > 20 && distance <= 200) {
return 4;
}
else if (distance > 200 && distance <= 400) {
return 2;
}
else if (distance > 400 && distance <= 500){
return 1;
}
else {
return 0;
}
}
@Override
public int rollDamage(int bonus) {
int dieResult = dice.rollD8() + dice.rollD8();
if (dieResult + bonus < 0) {
return 0;
} else {
return dieResult + bonus;
}
}
}
class StraightSword extends Sword {
public StraightSword(int strength) {
requirements = new HashMap<>();
requirements.put("Str", 12);
playerStrength = strength;
infoDamageDice = "1d10";
infoDamageBonus = "1-4";
name = "Straight Sword";
rarity = "Common";
range = getRange();
hitBonus = getHitBonus();
damageBonus = getHitBonus();
}
@Override
public int getDamageBonus() {
if (requirements.get("Str") > playerStrength) {
return -20;
} else {
return dice.rollD4();
}
}
@Override
public int rollDamage(int bonus) {
int dieResult = dice.rollD10();
if (dieResult + bonus < 0) {
return 0;
} else {
return dieResult + bonus;
}
}
}
class ShortSword extends Sword {
public ShortSword(int strength) {
requirements = new HashMap<>();
requirements.put("Str", 8);
infoDamageDice = "1d8";
infoDamageBonus = "-1 - 2";
playerStrength = strength;
name = "Short Sword";
rarity = "Common";
range = getRange();
hitBonus = getHitBonus();
damageBonus = getHitBonus();
}
@Override
public int getDamageBonus() {
if (requirements.get("Str") > playerStrength) {
return -20;
} else {
return dice.rollD4() -2;
}
}
@Override
public int rollDamage(int bonus) {
int dieResult = dice.rollD8();
if (dieResult + bonus < 0) {
return 0;
} else {
return dieResult + bonus;
}
}
}
class PrideOfTheGiantForges extends Sword {
public PrideOfTheGiantForges(int strength) {
requirements = new HashMap<>();
requirements.put("Str", 25);
playerStrength = strength;
infoDamageDice = "2d10";
infoDamageBonus = "3-6";
name = "Pride of the Giant's forges";
rarity = "Rare";
range = getRange();
hitBonus = getHitBonus();
damageBonus = getHitBonus();
}
@Override
public int getDamageBonus() {
if (requirements.get("Str") > playerStrength) {
return -25;
} else {
return dice.rollD4() + 2;
}
}
@Override
public int rollDamage(int bonus) {
int dieResult = dice.rollD10() + dice.rollD10();
if (dieResult + bonus < 0) {
return 0;
} else {
return dieResult + bonus;
}
}
}