/// The current disciplinary state. Derived from debt, drives what the app /// permits: Good -> Warned -> Grounded -> Lockdown. enum Standing { Good, Warned, Grounded, Lockdown } String standingLabel(Standing value) { switch (value) { case Standing.Good: return "Good standing"; case Standing.Warned: return "Warned"; case Standing.Grounded: return "Grounded"; case Standing.Lockdown: return "Lockdown"; } } /// Whether the user is allowed to create new commitments in this standing. bool canAddCommitments(Standing value) { return value == Standing.Good || value == Standing.Warned; } /// Whether elective commitments are permitted in this standing. bool canAddElectives(Standing value) { return value == Standing.Good; } Standing getStanding(String? name) { for (Standing value in Standing.values) { if (value.name == name) { return value; } } return Standing.Good; }