Complete CCS results and rating flow

This commit is contained in:
hz
2026-07-15 11:08:13 -05:00
parent 9f379cda5c
commit 52d435fa2e
14 changed files with 402 additions and 47 deletions
+10 -2
View File
@@ -4,19 +4,22 @@ const Style := preload("res://scripts/ui/ui_style.gd")
var main: Control
var list: VBoxContainer
var prediction: Label
var rating: Label
func _ready() -> void:
set_anchors_preset(Control.PRESET_FULL_RECT); add_theme_constant_override("separation", 12)
var back := Button.new(); back.text = "< Profile"; back.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN; back.pressed.connect(func(): main.show_screen("profile")); add_child(back)
var title := Label.new(); title.text = "CCS Case History"; Style.set_label(title, 32, Style.TEXT); add_child(title)
prediction = Label.new(); prediction.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART; Style.set_label(prediction, 16, Style.CYAN); add_child(prediction)
rating = Label.new(); Style.set_label(rating, 18, Style.TEXT); add_child(rating)
var scroll := ScrollContainer.new(); scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL; add_child(scroll)
list = VBoxContainer.new(); list.size_flags_horizontal = Control.SIZE_EXPAND_FILL; list.add_theme_constant_override("separation", 8); scroll.add_child(list)
CCSService.history_changed.connect(_render)
CCSService.prediction_changed.connect(_render_prediction)
CCSService.rating_changed.connect(_render_rating)
func on_show(_payload: Variant = null) -> void:
CCSService.load_history(); CCSService.load_prediction()
CCSService.load_history(); CCSService.load_prediction(); CCSService.load_rating()
func _render() -> void:
for child in list.get_children(): child.queue_free()
@@ -25,7 +28,9 @@ func _render() -> void:
for item in CCSService.history:
var button := Button.new(); button.alignment = HORIZONTAL_ALIGNMENT_LEFT
var score: Variant = item.get("score", null)
button.text = "%s\n%s | %s%s" % [item.get("caseTitle", "Case"), str(item.get("mode", "")).capitalize(), str(item.get("state", "")).capitalize(), " | %d%%" % int(round(float(score))) if score != null else ""]
var rating_change: Dictionary = item.get("rating", {}) if typeof(item.get("rating", {})) == TYPE_DICTIONARY else {}
var rating_text := " | CCS ELO %+d" % rating_change.get("userEloDelta", 0) if bool(rating_change.get("rated", false)) else ""
button.text = "%s\n%s | %s%s%s" % [item.get("caseTitle", "Case"), str(item.get("mode", "")).capitalize(), str(item.get("state", "")).capitalize(), " | %d%%" % int(round(float(score))) if score != null else "", rating_text]
button.disabled = str(item.get("state", "")) == "abandoned"
button.pressed.connect(_open.bind(str(item.get("id", "")), str(item.get("state", "")))); list.add_child(button)
@@ -39,3 +44,6 @@ func _render_prediction() -> void:
elif data.get("ccsScore", null) != null:
prediction.text = "CCS performance: %.0f%% from %d first timed cases. Complete a Day 1 simulation for a combined prediction." % [data.get("ccsScore", 0), data.get("contributingCases", 0)]
else: prediction.text = "Complete timed CCS cases to begin estimating CCS performance."
func _render_rating() -> void:
rating.text = "CCS ELO %d | %d rated cases" % [CCSService.rating.get("elo", 1000), CCSService.rating.get("ratedCaseCount", 0)]