game: Kampf — 18×9-Raster, Initiative, Bewegung, Angriff, Sieg
This commit is contained in:
parent
aed14b9b22
commit
45df888d4b
18 changed files with 1205 additions and 6 deletions
61
game/scripts/systems/kampf_regeln.gd
Normal file
61
game/scripts/systems/kampf_regeln.gd
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
class_name KampfRegeln
|
||||
extends RefCounted
|
||||
## Kampfmathematik aus docs/systeme.md §6 — testbar, ohne Szene.
|
||||
##
|
||||
## Angriff: d20 + Bonus gegen RK. Natürliche 20 trifft immer und verdoppelt
|
||||
## die Schadenswürfel; natürliche 1 verfehlt immer. Schaden mindestens 1.
|
||||
|
||||
static func initiative(dex_mod: int) -> int:
|
||||
return Dice.roll("d20") + dex_mod
|
||||
|
||||
|
||||
static func angriff(bonus: int, rk: int) -> Dictionary:
|
||||
var wurf: int = Dice.roll("d20")
|
||||
var total := wurf + bonus
|
||||
var treffer := wurf == 20 or (wurf != 1 and total >= rk)
|
||||
return {"wurf": wurf, "total": total, "treffer": treffer, "krit": wurf == 20}
|
||||
|
||||
|
||||
static func schaden(ausdruck: String, kritisch: bool) -> int:
|
||||
var wert: int = Dice.roll(ausdruck)
|
||||
if kritisch:
|
||||
wert += Dice.roll(ausdruck)
|
||||
return maxi(1, wert)
|
||||
|
||||
|
||||
## Nahkampfbonus einer Partei-Figur: Klassenleiter + STÄ-Modifikator.
|
||||
static func nahkampf_bonus(figur: Dictionary) -> int:
|
||||
var sta := Dice.modifier(int(figur.get("attributes", {}).get("str", 10)))
|
||||
return Game.angriffsbonus(figur) + sta
|
||||
|
||||
|
||||
static func waffe(figur: Dictionary) -> String:
|
||||
var id := str(figur.get("equipment", {}).get("weapon", ""))
|
||||
if id.is_empty():
|
||||
return "1d2"
|
||||
var item: Dictionary = Content.entry("items", id)
|
||||
return str(item.get("damage", "1d2"))
|
||||
|
||||
|
||||
static func rk(figur: Dictionary) -> int:
|
||||
var bonus := 2 if bool(figur.get("verteidigen", false)) else 0
|
||||
return Game.rk(figur) + bonus
|
||||
|
||||
|
||||
## Chebyshev-Abstand zwischen zwei Footprints (1 = angrenzend, auch diagonal).
|
||||
static func abstand(a: Dictionary, b: Dictionary) -> int:
|
||||
var beste := 99
|
||||
for ka in _felder(a):
|
||||
for kb in _felder(b):
|
||||
beste = mini(beste, maxi(absi(ka.x - kb.x), absi(ka.y - kb.y)))
|
||||
return beste
|
||||
|
||||
|
||||
static func _felder(einheit: Dictionary) -> Array[Vector2i]:
|
||||
var out: Array[Vector2i] = []
|
||||
var kachel: Vector2i = einheit["tile"]
|
||||
var size: Vector2i = einheit["size"]
|
||||
for x in size.x:
|
||||
for y in size.y:
|
||||
out.append(kachel + Vector2i(x, y))
|
||||
return out
|
||||
1
game/scripts/systems/kampf_regeln.gd.uid
Normal file
1
game/scripts/systems/kampf_regeln.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dudlj0a674fom
|
||||
Loading…
Add table
Add a link
Reference in a new issue