Add weekly consistency goals

This commit is contained in:
hz
2026-08-01 04:14:39 -05:00
parent ecd5da9162
commit 300b230c03
16 changed files with 589 additions and 2 deletions
+74
View File
@@ -24,6 +24,7 @@ var review_list: VBoxContainer
var recent_list: VBoxContainer
var weekly_summary: VBoxContainer
var mission_content: VBoxContainer
var weekly_goal_content: VBoxContainer
var metric_values: Dictionary = {}
var metric_details: Dictionary = {}
var metric_trends: Dictionary = {}
@@ -45,6 +46,8 @@ func _ready() -> void:
DashboardService.dashboard_failed.connect(_show_error)
DailyMissionService.missions_changed.connect(_render_missions)
DailyMissionService.missions_failed.connect(_show_mission_error)
WeeklyGoalService.goal_changed.connect(_render_weekly_goal)
WeeklyGoalService.goal_failed.connect(_show_weekly_goal_error)
review_queue_service.question_loaded.connect(_on_review_question_loaded)
review_queue_service.question_failed.connect(_on_review_question_failed)
review_queue_service.pass_completed.connect(_on_review_pass_completed)
@@ -60,6 +63,7 @@ func on_show(_payload: Variant = null) -> void:
_render()
DashboardService.refresh()
DailyMissionService.refresh()
WeeklyGoalService.refresh()
func _build() -> void:
@@ -187,6 +191,10 @@ func _build() -> void:
weekly_summary.custom_minimum_size.x = 180
weekly_summary.add_theme_constant_override("separation", 10)
weekly_row.add_child(weekly_summary)
weekly.add_child(HSeparator.new())
weekly_goal_content = VBoxContainer.new()
weekly_goal_content.add_theme_constant_override("separation", 8)
weekly.add_child(weekly_goal_content)
lower_grid.add_child(_card(weekly, 16))
recent_list = VBoxContainer.new()
recent_list.add_theme_constant_override("separation", 6)
@@ -221,6 +229,7 @@ func _render() -> void:
_render_weekly(data, weekly)
_render_recent(data.get("recentActivity", []))
_render_missions()
_render_weekly_goal()
func _render_missions() -> void:
@@ -304,6 +313,71 @@ func _show_mission_error(message: String) -> void:
mission_content.add_child(_label(message, 13, Brand.MAGENTA))
func _render_weekly_goal() -> void:
if weekly_goal_content == null:
return
_clear(weekly_goal_content)
var header := HBoxContainer.new()
header.add_child(_section_title("Balanced weekly goal"))
var spacer := Control.new()
spacer.size_flags_horizontal = Control.SIZE_EXPAND_FILL
header.add_child(spacer)
header.add_child(_label("Monday-Sunday UTC", 11, Brand.muted_color(UIThemeService.is_dark_mode())))
weekly_goal_content.add_child(header)
var components: Array = WeeklyGoalService.state.get("components", [])
if components.is_empty():
weekly_goal_content.add_child(_label("Loading weekly progress...", 13, Brand.muted_color(UIThemeService.is_dark_mode())))
return
for component_value in components:
var component: Dictionary = component_value
var row := HBoxContainer.new()
row.add_theme_constant_override("separation", 8)
var completed := bool(component.get("completed", false))
var label := _label(str(component.get("label", "Weekly progress")), 12,
Brand.SUCCESS if completed else Brand.text_color(UIThemeService.is_dark_mode()))
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
row.add_child(label)
row.add_child(_label("%d / %d" % [int(component.get("progress", 0)), int(component.get("target", 1))],
12, Brand.SUCCESS if completed else Brand.ROYAL_BLUE, true))
if not completed:
var action := Button.new()
action.text = "Start"
action.flat = true
action.pressed.connect(_launch_weekly_component.bind(component))
row.add_child(action)
weekly_goal_content.add_child(row)
if bool(WeeklyGoalService.state.get("completed", false)):
weekly_goal_content.add_child(_label("Weekly goal complete - %d RZ Coins earned" % int(WeeklyGoalService.state.get("rewardAmount", 0)),
13, Brand.SUCCESS, true))
else:
weekly_goal_content.add_child(_label("Complete all three for up to 10 RZ Coins.", 11,
Brand.muted_color(UIThemeService.is_dark_mode())))
func _launch_weekly_component(component: Dictionary) -> void:
var type := str(component.get("type", ""))
if type == "reviews":
_start_review_queue()
return
var system := str(WeeklyGoalService.state.get("suggestedSystem", ""))
main.show_screen("setup", {
"mastery_target": not system.is_empty(),
"step3_system": system if not system.is_empty() else "All Systems",
"question_count": 10,
"difficulty_min": 4 if type == "hard_correct" else 0,
"difficulty_max": 5 if type == "hard_correct" else 0
})
func _show_weekly_goal_error(message: String) -> void:
if weekly_goal_content == null:
return
_clear(weekly_goal_content)
weekly_goal_content.add_child(_section_title("Balanced weekly goal"))
weekly_goal_content.add_child(_label(message, 12, Brand.MAGENTA))
func _trend_series(trend: Array, field: String) -> Array:
var series: Array = []
for point in trend: