Skip to content

Commit

Permalink
Manual Scoring Added *animations need work
Browse files Browse the repository at this point in the history
  • Loading branch information
cpapplefamily committed Nov 30, 2024
1 parent 3e9279b commit f2a26a9
Show file tree
Hide file tree
Showing 5 changed files with 218 additions and 8 deletions.
7 changes: 3 additions & 4 deletions game/amp_speaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ func (ampSpeaker *AmpSpeaker) UpdateState(
currentTime time.Time,
isPlayoffMatch bool,
) {
newAmpNotes := ampNoteCount - ampSpeaker.ampNotesScored()
newSpeakerNotes := speakerNoteCount - ampSpeaker.speakerNotesScored()

newAmpNotes := ampNoteCount - ampSpeaker.ampNotesScored()
newSpeakerNotes := speakerNoteCount - ampSpeaker.speakerNotesScored()
// Handle the autonomous period.
autoValidityCutoff := matchStartTime.Add(GetDurationToAutoEnd() + speakerAutoGracePeriodSec*time.Second)
if currentTime.Before(autoValidityCutoff) {
Expand Down Expand Up @@ -142,4 +141,4 @@ func (ampSpeaker *AmpSpeaker) isAmplified(currentTime time.Time, includeGracePer
meetsTimeCriterion := currentTime.After(ampSpeaker.LastAmplifiedTime) && currentTime.Before(amplifiedValidityCutoff)
meetsNoteCriterion := AmplificationNoteLimit == 0 || ampSpeaker.lastAmplifiedSpeakerNotes < AmplificationNoteLimit
return meetsTimeCriterion && meetsNoteCriterion
}
}
35 changes: 35 additions & 0 deletions static/css/scoring_panel.css
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,38 @@ body {
left: 12.2vw;
width: 9vw;
}

.goal {
width: 10vw;
height: 5vw;
margin: 0.4vw 3vw;
display: flex;
justify-content: space-between;
align-items: center;
}
.number-button {
width: 4vw;
height: 4vw;
display: flex;
justify-content: space-between;
align-items: center;
border: 1px solid #666;
border-radius: 0.5vw;
font-size: 3vw;
}
.plus {
background: #263;
}
.minus {
background: #633;
}
#elements {

justify-content: space-evenly;
align-items: start;
}
.shortcut {
margin: 0 0.2vw;
font-size: 1vw;
align-self: flex-start;
}
26 changes: 26 additions & 0 deletions static/js/scoring_panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,32 @@ const handleRealtimeScore = function(data) {
$(`#stageSide${i}Microphone`).attr("data-value", score.MicrophoneStatuses[i]);
$(`#stageSide${i}Trap`).attr("data-value", score.TrapStatuses[i]);
}

//Some Diagnostis
$("#currentScore").text("Current Score: " + realtimeScore.ScoreSummary.Score);
$("#currentAmpificationCount").text("Banked Amp Notes: " + score.AmpSpeaker.BankedAmpNotes);
$("#ampCount").text("Amp Total Count: " + ( score.AmpSpeaker.TeleopAmpNotes +
score.AmpSpeaker.AutoAmpNotes));
//$("#teleopAmpCount").text(score.TeleopAmpNotes);
//$("#autoAmpCount").text(score.AutoAmpNotes);
$("#speakerCount").text("Speaker Total Count: " + ( score.AmpSpeaker.AutoSpeakerNotes +
score.AmpSpeaker.TeleopUnamplifiedSpeakerNotes +
score.AmpSpeaker.TeleopAmplifiedSpeakerNotes));
//$("#autoSpeakerCount").text(score.AutoSpeakerNotes);
//$("#teleopSpeakerCountNotAmplified").text(score.TeleopSpeakerNotesNotAmplified);
//$("#teleopSpeakerCountAmplified").text(score.TeleopSpeakerNotesAmplified);
//$("#trapCount1").text((score.TrapNotes));
//$("#trapCount").text("Trap Count: " + (score.TrapNotes));


$(`#coopertitionStatus>.value`).text(score.AmpSpeaker.CoopActivated ? "Cooperation Enabled" : "Cooperation");
$("#coopertitionStatus").attr("data-value", score.AmpSpeaker.CoopActivated);
$(`#amplificationActive>.value`).text(realtimeScore.Score.AmplifiedTimeRemainingSec > 0 ? "Amplification Active" : "Amplification");
$("#amplificationActive").attr("data-value", data.Blue.AmplifiedTimeRemainingSec > 0);
//$("#amplificationActive").css("background-color", realtimeScore.AmplifiedTimeRemainingSec > 0 ? "yellow" : "");
//$("#amplificationActive").css("color", !score.AmpAccumulatorDisable && score.AmplificationActive ? "black" : "");
//$("#amplificationActive").css("background-color", !score.AmpAccumulatorDisable && score.AmplificationActive ? "yellow" : "");
//$("#amplificationActive").css("color", !score.AmpAccumulatorDisable && score.AmplificationActive ? "black" : "");
};

// Handles an element click and sends the appropriate websocket message.
Expand Down
75 changes: 75 additions & 0 deletions templates/scoring_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,50 @@
{{define "title"}}Scoring Panel{{end}}
{{define "body"}}
<div id="matchName">&nbsp;</div>
<div id="currentScore"></div>
<div id="alliance">
<td>
1
</td>
<td>
2
</td>
<td>
3
</td>
<div class="scoring-section">

<div id="elements">
<div class="goal-header">Speaker
{{template "goaladd" dict "plus" "S" }}
</div>
<div class="goal-header">AMP
{{template "goaladd" dict "plus" "A" }}
</div>
<div class="goal-header">CoopBTN
{{template "goaladd" dict "plus" "coopButton" }}
</div>
<div class="goal-header">AmpBTN
{{template "goaladd" dict "plus" "amplifyButton" }}
</div>
</div>

<div>
<div id="currentAmpificationCount"></div>
<div id="ampCount"></div>
<div id="speakerCount"></div>
<div id="coopertitionStatus" class="boolean robot-field" onclick="handleClick('coopButton');">
<div class="value"></div>
</div>
<div id="amplificationActive" class="boolean robot-field" onclick="handleClick('amplifyButton');">
<div class="value"></div>
</div>
<div id="ampAccumulatorDisable" class="boolean robot-field" onclick="handleClick('ampAccumulatorDisable');">
<div class="value"></div>
</div>
</div>


<div class="scoring-header">
<div>&nbsp;</div>
<div>Leave</div>
Expand Down Expand Up @@ -74,3 +116,36 @@
<div id="stageSide{{.index}}Trap" class="boolean" onclick="handleClick('trap', 0, {{.index}});">Trap</div>
</div>
{{end}}
{{define "goal"}}
<div class="goal">
<div class="number-button minus" onclick="handleClick('{{.minus}}');">
<div class="shortcut">{{.minus}}</div>
-
<div class="shortcut" style="opacity: 0;">{{.minus}}</div>
</div>
<div id={{.count}}></div>
<div class="number-button plus" onclick="handleClick('{{.plus}}');">
<div class="shortcut">{{.plus}}</div>
+
<div class="shortcut" style="opacity: 0;">{{.plus}}</div>
</div>
</div>
{{end}}
{{define "goaladd"}}
<div class="goal">
<div class="number-button plus" onclick="handleClick('{{.plus}}');">
<div class="shortcut">{{.plus}}</div>
+
<div class="shortcut" style="opacity: 0;">{{.plus}}</div>
</div>
</div>
{{end}}
{{define "goalsub"}}
<div class="goal">
<div class="number-button minus" onclick="handleClick('{{.minus}}');">
<div class="shortcut">{{.minus}}</div>
-
<div class="shortcut" style="opacity: 0;">{{.minus}}</div>
</div>
</div>
{{end}}
83 changes: 79 additions & 4 deletions web/scoring_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"io"
"log"
"net/http"
"time"

)

// Renders the scoring interface which enables input of scores in real-time.
Expand Down Expand Up @@ -139,6 +141,7 @@ func (web *Web) scoringPanelWebsocketHandler(w http.ResponseWriter, r *http.Requ
scoreChanged = true
}
case "microphone":
log.Printf("Microphone Pressed")
if args.StageIndex >= 0 && args.StageIndex <= 2 {
score.MicrophoneStatuses[args.StageIndex] = !score.MicrophoneStatuses[args.StageIndex]
scoreChanged = true
Expand All @@ -148,10 +151,82 @@ func (web *Web) scoringPanelWebsocketHandler(w http.ResponseWriter, r *http.Requ
score.TrapStatuses[args.StageIndex] = !score.TrapStatuses[args.StageIndex]
scoreChanged = true
}
case "speeker":

case "amp":

case "S":
var _matchStartTime = web.arena.MatchStartTime
var _currentTime = time.Now()
score.AmpSpeaker.UpdateState( score.AmpSpeaker.AutoAmpNotes +
score.AmpSpeaker.TeleopAmpNotes,

score.AmpSpeaker.AutoSpeakerNotes +
score.AmpSpeaker.TeleopUnamplifiedSpeakerNotes +
score.AmpSpeaker.TeleopAmplifiedSpeakerNotes + 1,

false,

false,

_matchStartTime,

_currentTime)
log.Printf("Speaker Pressed")
scoreChanged = true
case "A":
var _matchStartTime = web.arena.MatchStartTime
var _currentTime = time.Now()
score.AmpSpeaker.UpdateState( score.AmpSpeaker.AutoAmpNotes +
score.AmpSpeaker.TeleopAmpNotes + 1,

score.AmpSpeaker.AutoSpeakerNotes +
score.AmpSpeaker.TeleopUnamplifiedSpeakerNotes +
score.AmpSpeaker.TeleopAmplifiedSpeakerNotes,

false,

false,

_matchStartTime,

_currentTime)
log.Printf("Amp Pressed")
scoreChanged = true
case "amplifyButton":
var _matchStartTime = web.arena.MatchStartTime
var _currentTime = time.Now()
score.AmpSpeaker.UpdateState( score.AmpSpeaker.AutoAmpNotes +
score.AmpSpeaker.TeleopAmpNotes,

score.AmpSpeaker.AutoSpeakerNotes +
score.AmpSpeaker.TeleopUnamplifiedSpeakerNotes +
score.AmpSpeaker.TeleopAmplifiedSpeakerNotes,

true,

false,

_matchStartTime,

_currentTime)
log.Printf("amplifyButton Pressed")
scoreChanged = true
case "coopButton":
var _matchStartTime = web.arena.MatchStartTime
var _currentTime = time.Now()
score.AmpSpeaker.UpdateState( score.AmpSpeaker.AutoAmpNotes +
score.AmpSpeaker.TeleopAmpNotes,

score.AmpSpeaker.AutoSpeakerNotes +
score.AmpSpeaker.TeleopUnamplifiedSpeakerNotes +
score.AmpSpeaker.TeleopAmplifiedSpeakerNotes,

false,

true,

_matchStartTime,

_currentTime)
log.Printf("coopButton Pressed")
scoreChanged = true
}

if scoreChanged {
Expand Down

0 comments on commit f2a26a9

Please sign in to comment.