Skip to content

Improve ServerBuilding teaching logic, add safety checks and introduce two new validation tests - #150

Open
JaskRendix wants to merge 2 commits into
FreeCol:sf-auto-mergefrom
JaskRendix:server-building
Open

Improve ServerBuilding teaching logic, add safety checks and introduce two new validation tests#150
JaskRendix wants to merge 2 commits into
FreeCol:sf-auto-mergefrom
JaskRendix:server-building

Conversation

@JaskRendix

Copy link
Copy Markdown

Changes:

  • added a bidirectional consistency check between teacher and student to prevent stale or mismatched references, when a mismatch is detected, both sides of the relationship are cleaned up safely
  • improved student assignment logic so that a teacher only clears its work type when necessary, avoiding redundant colony production recalculations
  • clarified and documented the teaching flow, including how training turns are incremented and when they are reset
  • strengthened csTrainStudent by ensuring both teacher and student have their moves and training counters reset in a consistent and predictable way
  • improved logging and comments to make the teaching lifecycle easier to understand and debug
  • modernized the unit‑repair logic using a clearer stream‑based implementation
  • simplified csCheckMissingInput with early returns and clearer branching between “no input at all” and “insufficient input” cases
  • ensured csNewTurn logs the building state before performing teaching and repair operations
  • added two new tests to validate teaching behavior: a test ensuring that a student who already has the same skill as the teacher is not assigned for training + a test ensuring that no student is assigned when the colony contains no eligible units

Things I considered:

  • I checked how teaching interacts with food, production, and work assignments. None of these affect training; as long as there’s a valid student, teaching just continues.
  • I looked into whether buildings can be disabled or damaged in a way that would stop teaching or repairs. The ruleset doesn’t support that idea, so buildings always function if they exist.
  • I reviewed whether modifiers or colony bonuses could change training speed or eligibility. Training times are fixed by unit type and school level, with no dynamic adjustments.
  • I examined how student selection works when several candidates are available. The engine handles this internally, and there’s no way to force a specific choice in tests.
  • I confirmed that units working in production buildings can still be reassigned as students. The system is designed to pull them out immediately if needed.
  • I focused on the core teaching rules and added two tests that match them: one to ensure a unit already at the teacher’s skill level isn’t selected, and one to ensure no student is assigned when none are eligible

@JaskRendix JaskRendix closed this Feb 1, 2026
@JaskRendix JaskRendix reopened this Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant