From c41ac72f28144f46a26f33c50fdf56e5d49f2ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Prieto?= Date: Sun, 15 Jun 2025 16:16:19 +0200 Subject: [PATCH] Initial commit --- .gitignore | 13 +++++ pom.xml | 26 ++++++++++ .../FourtyKCalculatorApp.java | 47 +++++++++++++++++++ .../games/fourtykcalculator/Main.java | 7 +++ .../games/fourtykcalculator/Weapon.java | 22 +++++++++ src/main/resources/weapons.yaml | 1 + 6 files changed, 116 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 src/main/java/ninja/thefirearchmage/games/fourtykcalculator/FourtyKCalculatorApp.java create mode 100644 src/main/java/ninja/thefirearchmage/games/fourtykcalculator/Main.java create mode 100644 src/main/java/ninja/thefirearchmage/games/fourtykcalculator/Weapon.java create mode 100644 src/main/resources/weapons.yaml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9825d5b --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +## Mac OS ### +.DS_Store \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..1bf4742 --- /dev/null +++ b/pom.xml @@ -0,0 +1,26 @@ + + + 4.0.0 + + org.example + 40kDamageCalculator + 0.0.1 + + + 24 + 24 + UTF-8 + + + + + + org.openjfx + javafx-controls + 24-ea+5 + + + + \ No newline at end of file diff --git a/src/main/java/ninja/thefirearchmage/games/fourtykcalculator/FourtyKCalculatorApp.java b/src/main/java/ninja/thefirearchmage/games/fourtykcalculator/FourtyKCalculatorApp.java new file mode 100644 index 0000000..3c86779 --- /dev/null +++ b/src/main/java/ninja/thefirearchmage/games/fourtykcalculator/FourtyKCalculatorApp.java @@ -0,0 +1,47 @@ +package ninja.thefirearchmage.games.fourtykcalculator; + +import javafx.application.Application; +import javafx.geometry.Insets; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.TextArea; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; + +import java.util.Arrays; + +public class FourtyKCalculatorApp extends Application { + @Override + public void start(Stage stage) throws Exception { + stage.setTitle("Eradicator Damage Calculator"); + + TextArea output = new TextArea(); + output.setEditable(false); + + Button calculateBtn = new Button("Calculate"); + calculateBtn.setOnAction(e -> { + List targets = Arrays.asList( + new Target("Rhino", 9, 3, null, 10), + new Target("Lehman Russ", 11, 2, null, 13), + new Target("Redemptor Dread", 10, 3, 5, 12), + new Target("Knight Paladin", 13, 2, 5, 22), + new Target("Plagueburst Crawler", 12, 3, 4, 12) + ); + + StringBuilder sb = new StringBuilder(); + for (Target target : targets) { + sb.append(calculate(target, 3, true, true, true, "melta")); + sb.append("\n"); + } + output.setText(sb.toString()); + }); + + VBox layout = new VBox(10); + layout.setPadding(new Insets(10)); + layout.getChildren().addAll(calculateBtn, output); + + Scene scene = new Scene(layout, 500, 400); + stage.setScene(scene); + stage.show(); + } +} diff --git a/src/main/java/ninja/thefirearchmage/games/fourtykcalculator/Main.java b/src/main/java/ninja/thefirearchmage/games/fourtykcalculator/Main.java new file mode 100644 index 0000000..051d7ae --- /dev/null +++ b/src/main/java/ninja/thefirearchmage/games/fourtykcalculator/Main.java @@ -0,0 +1,7 @@ +package ninja.thefirearchmage.games.fourtykcalculator; + +public class Main { + public static void main(String[] args) { + System.out.printf("Hello and welcome!"); + } +} \ No newline at end of file diff --git a/src/main/java/ninja/thefirearchmage/games/fourtykcalculator/Weapon.java b/src/main/java/ninja/thefirearchmage/games/fourtykcalculator/Weapon.java new file mode 100644 index 0000000..1b9170d --- /dev/null +++ b/src/main/java/ninja/thefirearchmage/games/fourtykcalculator/Weapon.java @@ -0,0 +1,22 @@ +package ninja.thefirearchmage.games.fourtykcalculator; + +import java.util.Optional; + +public class Weapon { + private int strength; + private int ap; + private double averageDamage; + private int hitValue; + private boolean hasLethalHits; + private Optional sustainedHits; + private boolean hasMortalWounds; + private boolean hasHazardous; + private Optional antiInfantery; + private Optional antiVehicle; + private Optional antiMonster; + private Optional antiPsychic; + private boolean hasHeavy; + private boolean hasBlast; + private boolean hasLance; + private Optional melta; +} diff --git a/src/main/resources/weapons.yaml b/src/main/resources/weapons.yaml new file mode 100644 index 0000000..8d1e74f --- /dev/null +++ b/src/main/resources/weapons.yaml @@ -0,0 +1 @@ +melta: