-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Timeline Modification Verification (#11)
* feat(wip): started action input state machine class * style: format files * feat: basic timeline warning system * style: format files * fix: move action arrows * feat: user cannot close invalid timeline --------- Co-authored-by: azaleacolburn <[email protected]>
- Loading branch information
1 parent
668526f
commit 9380b50
Showing
5 changed files
with
80 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { AutoActionData } from '$lib/types'; | ||
|
||
export class ActionInputVerifier { | ||
private held_bunnies: number = 0; | ||
private held_balloons: number = 0; | ||
private held_totes: number = 0; | ||
|
||
public verify_actions(action_data: AutoActionData[]) { | ||
action_data | ||
.reverse() | ||
.forEach((action_data) => (action_data.ok = this.verify_new_action(action_data))); | ||
} | ||
|
||
// Takes an action and returns if it's a legal one | ||
verify_new_action(action_data: AutoActionData): boolean { | ||
const success = action_data.success; | ||
const action = action_data.action; | ||
if (success) { | ||
if (action.includes('IntakeBalloon')) this.held_balloons++; | ||
else if (action.includes('IntakeBunny')) this.held_bunnies++; | ||
else if (action.includes('IntakeTote')) this.held_totes++; | ||
else if (action.includes('EjectBalloon')) this.held_balloons--; | ||
else if (action.includes('EjectBunny')) this.held_bunnies--; | ||
else if (action.includes('EjectTote')) this.held_totes--; | ||
} | ||
if (action.includes('ScoreBalloon')) this.held_balloons--; | ||
else if (action.includes('ScoreBunny')) this.held_bunnies--; | ||
|
||
if (action.includes('Intake')) return true; | ||
return this.held_balloons >= 0 && this.held_bunnies >= 0 && this.held_totes >= 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters