update
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
class_name ElementView
|
||||
extends Control
|
||||
## Die Vier-Elemente-Regel auf einen Blick: offene Wesen je Element auf dem Tisch. Ab vier
|
||||
## bekommt das Element +1/+1 und das Element, das es schlägt, -1/-1.
|
||||
## Elementboni auf einen Blick: offene Wesen je Element auf dem Tisch (ab drei +1/+1) und der
|
||||
## Sondereffekt der eigenen Seite (ab zwei eigenen: Erde Spott, Luft Flink, Wasser Regeneration,
|
||||
## Feuer Doppelschlag), als Symbol in der Elementfarbe.
|
||||
|
||||
var counts := {}
|
||||
var counts := {} # Tisch
|
||||
var own := {} # eigene Seite
|
||||
|
||||
|
||||
func _init(rect: Rect2) -> void:
|
||||
@@ -12,10 +14,13 @@ func _init(rect: Rect2) -> void:
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
for e in Cards.ELEMENTS:
|
||||
counts[e] = 0
|
||||
own[e] = 0
|
||||
|
||||
|
||||
func update_from(g: Game) -> void:
|
||||
func update_from(g: Game, me: Game.Player) -> void:
|
||||
counts = g.element_counts()
|
||||
for e in Cards.ELEMENTS:
|
||||
own[e] = me.element_count(e) if me != null else 0
|
||||
queue_redraw()
|
||||
|
||||
|
||||
@@ -23,9 +28,8 @@ func strong(e: String) -> bool:
|
||||
return int(counts.get(e, 0)) >= Game.ELEMENT_STACK
|
||||
|
||||
|
||||
func weak(e: String) -> bool:
|
||||
var predator := Cards.beaten_by(e)
|
||||
return predator != "" and strong(predator)
|
||||
func paired(e: String) -> bool:
|
||||
return int(own.get(e, 0)) >= Game.ELEMENT_PAIR
|
||||
|
||||
|
||||
## Der Inhalt als Text (Tests, Protokoll).
|
||||
@@ -35,8 +39,8 @@ func text() -> String:
|
||||
var s := "%s %d" % [tr(e), int(counts.get(e, 0))]
|
||||
if strong(e):
|
||||
s += " (+1/+1)"
|
||||
if weak(e):
|
||||
s += " (-1/-1)"
|
||||
if paired(e):
|
||||
s += " (%s)" % tr(Cards.ELEMENT_KEYWORD[e])
|
||||
parts.append(s)
|
||||
return " · ".join(parts)
|
||||
|
||||
@@ -51,9 +55,10 @@ func _draw() -> void:
|
||||
var n := int(counts.get(e, 0))
|
||||
if strong(e):
|
||||
draw_style_box(Style.box(Color(col, 0.35), 6, col, 2), Rect2(x0 + 2, 0, w - 4, size.y))
|
||||
elif weak(e):
|
||||
draw_style_box(Style.box(Color(Style.RED, 0.12), 6, Style.RED, 1), Rect2(x0 + 2, 0, w - 4, size.y))
|
||||
Style.text(self, tr(e), 13, Style.TEXT if strong(e) else Style.MUTED, Vector2(x0 + 12, cy), "midleft", strong(e))
|
||||
elif paired(e):
|
||||
draw_style_box(Style.box(Color(col, 0.18), 6, Color(col, 0.6), 1), Rect2(x0 + 2, 0, w - 4, size.y))
|
||||
var active := strong(e) or paired(e)
|
||||
Style.text(self, tr(e), 13, Style.TEXT if active else Style.MUTED, Vector2(x0 + 12, cy), "midleft", active)
|
||||
var px := x0 + 12 + Style.FONT_BOLD.get_string_size(tr(e), HORIZONTAL_ALIGNMENT_LEFT, -1, Style.fs(13)).x + 12
|
||||
for k in Game.ELEMENT_STACK:
|
||||
var c := Vector2(px + k * 13, cy)
|
||||
@@ -62,12 +67,11 @@ func _draw() -> void:
|
||||
else:
|
||||
draw_circle(c, 4.5, Color(0, 0, 0, 0.35))
|
||||
draw_arc(c, 4.5, 0, TAU, 16, Color(col, 0.6), 1.0)
|
||||
px += Game.ELEMENT_STACK * 13 + 2
|
||||
if n > Game.ELEMENT_STACK:
|
||||
Style.text(self, "+%d" % (n - Game.ELEMENT_STACK), 11, Style.MUTED, Vector2(px + Game.ELEMENT_STACK * 13 + 2, cy), "midleft")
|
||||
var tag := ""
|
||||
Style.text(self, "+%d" % (n - Game.ELEMENT_STACK), 11, Style.MUTED, Vector2(px, cy), "midleft")
|
||||
px += 18
|
||||
if paired(e):
|
||||
Style.keyword_icon(self, Cards.ELEMENT_KEYWORD[e], Vector2(px + 10, cy), 7, Style.lighter(col, 0.45))
|
||||
if strong(e):
|
||||
tag = "+1/+1"
|
||||
elif weak(e):
|
||||
tag = "-1/-1"
|
||||
if tag != "":
|
||||
Style.text(self, tag, 13, Style.GREEN if strong(e) else Style.RED, Vector2(x0 + w - 12, cy), "midright", true)
|
||||
Style.text(self, "+1/+1", 13, Style.GREEN, Vector2(x0 + w - 12, cy), "midright", true)
|
||||
|
||||
Reference in New Issue
Block a user