Begonnen: Verhalten von Gegnern bei annäherung, Verfolgung etc
This commit is contained in:
@@ -8,8 +8,6 @@ import lombok.Setter;
|
||||
public abstract class GameCharacter {
|
||||
/** Eindeutige ID — entspricht dem Dateinamen ohne Extension. */
|
||||
private String characterId;
|
||||
/** Anzeigename des Charakters — wird zur Laufzeit per TextReference aufgelöst. */
|
||||
private TextReference name;
|
||||
/** Relativer Pfad zum .j3o-Modell (relativ zu blight-assets/src/main/resources). */
|
||||
private String modelPath;
|
||||
/** Relativer Pfad zum .j3o-Animations-Set (in animations/sets/). */
|
||||
|
||||
@@ -26,6 +26,19 @@ public class NPC extends GameCharacter implements Interactable {
|
||||
|
||||
private List<Item> items;
|
||||
|
||||
/** Basis-HP; 0 = Spielwelt-Standardwert (100). */
|
||||
private int maxHp;
|
||||
/** Basis-Mana; 0 = Spielwelt-Standardwert (100). */
|
||||
private int maxMana;
|
||||
/** Basis-Ausdauer; 0 = Spielwelt-Standardwert (100). */
|
||||
private int maxStamina;
|
||||
|
||||
/** Item-ID der primären Nahkampfwaffe (am Rücken getragen). Null = keine Waffe. */
|
||||
private String equippedWeaponId;
|
||||
|
||||
/** Item-ID des Schilds (am Rücken getragen; nur bei Schwertkämpfern sinnvoll). Null = kein Schild. */
|
||||
private String equippedShieldId;
|
||||
|
||||
// ── Flache Dialog-Struktur (serialisiert) ─────────────────────────────────
|
||||
|
||||
/** Alle Dialog-Optionen dieses NPCs, flach nach ID indiziert. */
|
||||
@@ -90,13 +103,12 @@ public class NPC extends GameCharacter implements Interactable {
|
||||
|
||||
@Override
|
||||
public String getDisplayText() {
|
||||
return TextRegistry.resolve(getName(), getCharacterId() != null ? getCharacterId() : "NPC");
|
||||
String key = getLabelKey();
|
||||
return TextRegistry.resolve(new TextReference(key), getCharacterId() != null ? getCharacterId() : "NPC");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabelKey() {
|
||||
TextReference nameRef = getName();
|
||||
if (nameRef != null && nameRef.id() != null && !nameRef.id().isBlank()) return nameRef.id();
|
||||
return getCharacterId() != null ? "npc." + getCharacterId() + ".name" : "";
|
||||
}
|
||||
|
||||
|
||||
@@ -4,17 +4,14 @@ package de.blight.common.model;
|
||||
* Zeitblock innerhalb eines Tagesablaufs.
|
||||
*
|
||||
* {@code startHour} und {@code endHour} sind ganzzahlige Stunden (0–23).
|
||||
* {@code endHour} ist inklusiv: ein Block mit endHour=22 läuft bis 22:59:59.
|
||||
* Ein Block, der über Mitternacht geht (z.B. 22–06), ist erlaubt:
|
||||
* in diesem Fall ist {@code endHour < startHour}.
|
||||
*
|
||||
* Die Dauer berechnet sich als:
|
||||
* endHour >= startHour → endHour - startHour
|
||||
* endHour < startHour → 24 - startHour + endHour
|
||||
*/
|
||||
public class RoutineBlock {
|
||||
|
||||
private int startHour; // 0-23
|
||||
private int endHour; // 0-23 (exklusiv: Block endet um endHour:00)
|
||||
private int endHour; // 0-23 (inklusiv: Block endet um endHour:59:59)
|
||||
private RoutineActivity activity;
|
||||
|
||||
public RoutineBlock() {}
|
||||
@@ -34,23 +31,22 @@ public class RoutineBlock {
|
||||
public RoutineActivity getActivity() { return activity; }
|
||||
public void setActivity(RoutineActivity a) { this.activity = a; }
|
||||
|
||||
/** Anzahl der durch diesen Block abgedeckten Stunden. */
|
||||
/** Anzahl der durch diesen Block abgedeckten Stunden (inkl. endHour). */
|
||||
public int durationHours() {
|
||||
if (endHour > startHour) return endHour - startHour;
|
||||
if (endHour < startHour) return 24 - startHour + endHour;
|
||||
return 0;
|
||||
if (endHour >= startHour) return endHour - startHour + 1;
|
||||
return 24 - startHour + endHour + 1;
|
||||
}
|
||||
|
||||
/** Gibt true wenn die gegebene Stunde (0-23) in diesem Block liegt. */
|
||||
/** Gibt true wenn die gegebene Stunde (0-23) in diesem Block liegt (endHour inklusiv). */
|
||||
public boolean covers(int hour) {
|
||||
if (endHour > startHour) return hour >= startHour && hour < endHour;
|
||||
if (endHour >= startHour) return hour >= startHour && hour <= endHour;
|
||||
// Über-Mitternacht-Block
|
||||
return hour >= startHour || hour < endHour;
|
||||
return hour >= startHour || hour <= endHour;
|
||||
}
|
||||
|
||||
/** Formatiert den Block als "HH:00 – HH:00 | Aktivität". */
|
||||
/** Formatiert den Block als "HH:00 – HH:59 | Aktivität". */
|
||||
public String displayLabel() {
|
||||
String act = activity != null ? activity.summary() : "—";
|
||||
return String.format("%02d:00 – %02d:00 %s", startHour, endHour, act);
|
||||
return String.format("%02d:00 – %02d:59 %s", startHour, endHour, act);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user