Compare commits

..

2 commits

Author SHA1 Message Date
Emma Nora Theuer
0f6d7eac0f Add a bunch of new weapons, fix unexpected behavior 2024-09-08 15:46:13 +02:00
Emma Nora Theuer
ad2c9fd150 Add some extra info text. 2024-09-08 15:45:48 +02:00
2 changed files with 158 additions and 11 deletions

View file

@ -26,9 +26,9 @@ interface Weapon {
abstract class Sword implements Weapon { abstract class Sword implements Weapon {
Map<String, Integer> requirements; Map<String, Integer> requirements;
String infoDamageDice;
String infoDamageBonus; String infoDamageBonus;
int playerStrength; int playerStrength;
int playerDex;
String type = "Melee"; String type = "Melee";
String name; String name;
String rarity; String rarity;
@ -61,6 +61,7 @@ abstract class Sword implements Weapon {
abstract class Bow implements Weapon { abstract class Bow implements Weapon {
Map<String, Integer> requirements; Map<String, Integer> requirements;
String infoDamageDice;
String infoDamageBonus; String infoDamageBonus;
int playerStrength; int playerStrength;
int playerDex; int playerDex;

View file

@ -7,6 +7,7 @@ class Longbow extends Bow {
requirements.put("Str", 8); requirements.put("Str", 8);
playerStrength = strength; playerStrength = strength;
playerDex = dex; playerDex = dex;
infoDamageDice = "1d8";
infoDamageBonus = "0-2"; infoDamageBonus = "0-2";
name = "Longbow"; name = "Longbow";
rarity = "Common"; rarity = "Common";
@ -17,10 +18,9 @@ class Longbow extends Bow {
@Override @Override
public int getDamageBonus(int distance) { 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; return -20;
} }
if (distance > 20 && distance <= 165) { if (distance > 20 && distance <= 165) {
return 2; return 2;
} }
@ -32,14 +32,9 @@ class Longbow extends Bow {
} }
} }
@Override
public int rollToHit(int bonus) {
return dice.rollD20();
}
@Override @Override
public int rollDamage(int bonus) { public int rollDamage(int bonus) {
int dieResult = dice.rollD10(); int dieResult = dice.rollD8();
if (dieResult + bonus < 0) { if (dieResult + bonus < 0) {
return 0; return 0;
} else { } else {
@ -53,6 +48,7 @@ class Shortbow extends Bow {
requirements = new HashMap<>(); requirements = new HashMap<>();
requirements.put("Dex", 8); requirements.put("Dex", 8);
requirements.put("Str", 6); requirements.put("Str", 6);
infoDamageDice = "1d6";
infoDamageBonus = "0"; infoDamageBonus = "0";
playerStrength = strength; playerStrength = strength;
playerDex = dex; playerDex = dex;
@ -63,8 +59,8 @@ class Shortbow extends Bow {
damageBonus = getDamageBonus(); damageBonus = getDamageBonus();
} }
@Override @Override
public int getDamageBonus() { 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; return -20;
} else { } else {
return 0; return 0;
@ -72,6 +68,7 @@ class Shortbow extends Bow {
} }
@Override
public int rollDamage(int bonus){ public int rollDamage(int bonus){
int dieResult = dice.rollD6(); int dieResult = dice.rollD6();
if (dieResult + bonus < 0) { 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;
}
}
}