diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2026-09-17 17:08:00 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2026-09-17 17:08:00 +0200 |
| commit | 9d55837190bccb9c9a65bcf2642733f2c449a95b (patch) | |
| tree | 0de5dba2d9bfe86d4f94716ecb013edb96ea8864 | |
| parent | bc9cdc0bff49ebf553be19dd959a25d6e97ec23a (diff) | |
| download | bycs-sol-9d55837190bccb9c9a65bcf2642733f2c449a95b.tar.gz bycs-sol-9d55837190bccb9c9a65bcf2642733f2c449a95b.zip | |
graduation: prevent negative points
| -rw-r--r-- | src/graduation-common.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/graduation-common.ts b/src/graduation-common.ts index 3c90e34..6ef0031 100644 --- a/src/graduation-common.ts +++ b/src/graduation-common.ts @@ -119,6 +119,7 @@ class Graduation { green: number = 0; orange: number = 0; red: number = 0; + nettoPoints: number = 0; mandatory: number = 0; level: number = 1; changes: Array<GraduationChange> = []; @@ -147,13 +148,17 @@ class Graduation { switch (change.change) { case "GrĂ¼n": this.green++; + this.nettoPoints++; break; case "Orange": this.orange++; + if (this.nettoPoints > 0) this.nettoPoints--; break; case "Rot": + if (this.nettoPoints > 3) this.nettoPoints -= 2; + else this.nettoPoints = 0; this.red++; break; @@ -163,6 +168,7 @@ class Graduation { this.green = 0; this.orange = 0; this.red = 0; + this.nettoPoints = 0; break; case "CoachZuweisung": @@ -189,6 +195,7 @@ class Graduation { this.green = 0; this.orange = 0; this.red = 0; + this.nettoPoints = 0; this.mandatory = 0; this.level = 1; this.changes = []; @@ -216,9 +223,13 @@ class Graduation { /** * Return the combined value of all points. + * + * Negative values are not possible. Positive points earned after any negativ + * points always count. Two consecutive orange points followed by a single + * green point will result in one netto point. */ getNettoPoints(): number { - return this.green - this.orange - this.red * 2; + return this.nettoPoints; } } |
