mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 13:46:44 -04:00
Update match review for 2020.
This commit is contained in:
@@ -32,21 +32,26 @@ var renderResults = function(alliance) {
|
||||
$("#" + alliance + "Score").html(scoreContent);
|
||||
|
||||
// Set the values of the form fields from the JSON results data.
|
||||
for (var i = 0; i < 3; i++) {
|
||||
for (var i = 0; i < 4; i++) {
|
||||
var i1 = i + 1;
|
||||
getInputElement(alliance, "RobotStartLevel" + i1, result.score.RobotStartLevels[i]).prop("checked", true);
|
||||
getInputElement(alliance, "SandstormBonus" + i1).prop("checked", result.score.SandstormBonuses[i]);
|
||||
getInputElement(alliance, "RobotEndLevel" + i1, result.score.RobotEndLevels[i]).prop("checked", true);
|
||||
getSelectElement(alliance, "RocketNearLeftBay" + i1).val(result.score.RocketNearLeftBays[i]);
|
||||
getSelectElement(alliance, "RocketNearRightBay" + i1).val(result.score.RocketNearRightBays[i]);
|
||||
getSelectElement(alliance, "RocketFarLeftBay" + i1).val(result.score.RocketFarLeftBays[i]);
|
||||
getSelectElement(alliance, "RocketFarRightBay" + i1).val(result.score.RocketFarRightBays[i]);
|
||||
}
|
||||
for (var i = 0; i < 8; i++) {
|
||||
var i1 = i + 1;
|
||||
getSelectElement(alliance, "CargoBayPreMatch" + i1).val(result.score.CargoBaysPreMatch[i]);
|
||||
getSelectElement(alliance, "CargoBay" + i1).val(result.score.CargoBays[i]);
|
||||
|
||||
if (i < 2) {
|
||||
getInputElement(alliance, "AutoCellsBottom" + i1).val(result.score.AutoCellsBottom[i]);
|
||||
getInputElement(alliance, "AutoCellsOuter" + i1).val(result.score.AutoCellsOuter[i]);
|
||||
getInputElement(alliance, "AutoCellsInner" + i1).val(result.score.AutoCellsInner[i]);
|
||||
}
|
||||
|
||||
if (i < 3) {
|
||||
getInputElement(alliance, "ExitedInitiationLine" + i1).prop("checked", result.score.ExitedInitiationLine[i]);
|
||||
getInputElement(alliance, "EndgameStatuses" + i1, result.score.EndgameStatuses[i]).prop("checked", true);
|
||||
}
|
||||
|
||||
getInputElement(alliance, "TeleopCellsBottom" + i1).val(result.score.TeleopCellsBottom[i]);
|
||||
getInputElement(alliance, "TeleopCellsOuter" + i1).val(result.score.TeleopCellsOuter[i]);
|
||||
getInputElement(alliance, "TeleopCellsInner" + i1).val(result.score.TeleopCellsInner[i]);
|
||||
}
|
||||
getInputElement(alliance, "ControlPanelStatus", result.score.ControlPanelStatus).prop("checked", true);
|
||||
getInputElement(alliance, "RungIsLevel").prop("checked", result.score.RungIsLevel);
|
||||
|
||||
if (result.score.Fouls != null) {
|
||||
$.each(result.score.Fouls, function(k, v) {
|
||||
@@ -71,28 +76,34 @@ var updateResults = function(alliance) {
|
||||
formData[v.name] = v.value;
|
||||
});
|
||||
|
||||
result.score.RobotStartLevels = [];
|
||||
result.score.SandstormBonuses = [];
|
||||
result.score.CargoBaysPreMatch = [];
|
||||
result.score.CargoBays = [];
|
||||
result.score.RocketNearLeftBays = [];
|
||||
result.score.RocketNearRightBays = [];
|
||||
result.score.RocketFarLeftBays = [];
|
||||
result.score.RocketFarRightBays = [];
|
||||
result.score.RobotEndLevels = [];
|
||||
for (var i = 0; i < 3; i++) {
|
||||
result.score.RobotStartLevels[i] = parseInt(formData[alliance + "RobotStartLevel" + (i + 1)]);
|
||||
result.score.SandstormBonuses[i] = formData[alliance + "SandstormBonus" + (i + 1)] === "on";
|
||||
result.score.RobotEndLevels[i] = parseInt(formData[alliance + "RobotEndLevel" + (i + 1)]);
|
||||
result.score.RocketNearLeftBays[i] = parseInt(formData[alliance + "RocketNearLeftBay" + (i + 1)]);
|
||||
result.score.RocketNearRightBays[i] = parseInt(formData[alliance + "RocketNearRightBay" + (i + 1)]);
|
||||
result.score.RocketFarLeftBays[i] = parseInt(formData[alliance + "RocketFarLeftBay" + (i + 1)]);
|
||||
result.score.RocketFarRightBays[i] = parseInt(formData[alliance + "RocketFarRightBay" + (i + 1)]);
|
||||
}
|
||||
for (var i = 0; i < 8; i++) {
|
||||
result.score.CargoBaysPreMatch[i] = parseInt(formData[alliance + "CargoBayPreMatch" + (i + 1)]);
|
||||
result.score.CargoBays[i] = parseInt(formData[alliance + "CargoBay" + (i + 1)]);
|
||||
result.score.ExitedInitiationLine = [];
|
||||
result.score.AutoCellsBottom = [];
|
||||
result.score.AutoCellsOuter = [];
|
||||
result.score.AutoCellsInner = [];
|
||||
result.score.TeleopCellsBottom = [];
|
||||
result.score.TeleopCellsOuter = [];
|
||||
result.score.TeleopCellsInner = [];
|
||||
result.score.EndgameStatuses = [];
|
||||
for (var i = 0; i < 4; i++) {
|
||||
var i1 = i + 1;
|
||||
|
||||
if (i < 2) {
|
||||
result.score.AutoCellsBottom[i] = parseInt(formData[alliance + "AutoCellsBottom" + i1]);
|
||||
result.score.AutoCellsOuter[i] = parseInt(formData[alliance + "AutoCellsOuter" + i1]);
|
||||
result.score.AutoCellsInner[i] = parseInt(formData[alliance + "AutoCellsInner" + i1]);
|
||||
}
|
||||
|
||||
if (i < 3) {
|
||||
result.score.ExitedInitiationLine[i] = formData[alliance + "ExitedInitiationLine" + i1] === "on";
|
||||
result.score.EndgameStatuses[i] = parseInt(formData[alliance + "EndgameStatuses" + i1]);
|
||||
}
|
||||
|
||||
result.score.TeleopCellsBottom[i] = parseInt(formData[alliance + "TeleopCellsBottom" + i1]);
|
||||
result.score.TeleopCellsOuter[i] = parseInt(formData[alliance + "TeleopCellsOuter" + i1]);
|
||||
result.score.TeleopCellsInner[i] = parseInt(formData[alliance + "TeleopCellsInner" + i1]);
|
||||
}
|
||||
result.score.ControlPanelStatus = parseInt(formData[alliance + "ControlPanelStatus"]);
|
||||
result.score.RungIsLevel = formData[alliance + "RungIsLevel"] === "on";
|
||||
|
||||
result.score.Fouls = [];
|
||||
for (var i = 0; formData[alliance + "Foul" + i + "Time"]; i++) {
|
||||
|
||||
@@ -26,104 +26,62 @@
|
||||
<div id="scoreTemplate" style="display: none;">
|
||||
<div class="well well-{{"{{alliance}}"}}">
|
||||
<fieldset>
|
||||
<legend>Pre-Match</legend>
|
||||
<b>Robot Starting Levels</b>
|
||||
<div class="form-group">
|
||||
{{range $i := seq 3}}
|
||||
<div class="row">
|
||||
<label class="col-lg-4 control-label">Team {{"{{team"}}{{$i}}{{"}}"}}</label>
|
||||
<div class="radio col-lg-2">
|
||||
<input type="radio" name="{{"{{alliance}}"}}RobotStartLevel{{$i}}" value="1">Level 1
|
||||
</div>
|
||||
<div class="radio col-lg-2">
|
||||
<input type="radio" name="{{"{{alliance}}"}}RobotStartLevel{{$i}}" value="2">Level 2
|
||||
</div>
|
||||
<div class="radio col-lg-4">
|
||||
<input type="radio" name="{{"{{alliance}}"}}RobotStartLevel{{$i}}" value="3">No-Show
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<b>Cargo Ship Prepopulation</b>
|
||||
<p>Counting starts nearest center field on scoring table side and wraps around</p>
|
||||
<div class="form-group">
|
||||
{{range $i, $unused := seq 2}}
|
||||
<div class="row">
|
||||
{{range $j := seq 4}}
|
||||
{{$bayNumber := add $j (multiply $i 4)}}
|
||||
<div class="col-lg-3">
|
||||
{{$bayNumber}}:
|
||||
<select name="{{"{{alliance}}"}}CargoBayPreMatch{{$bayNumber}}">
|
||||
<option value="0">Empty</option>
|
||||
<option value="1">Null Hatch</option>
|
||||
<option value="3">Cargo</option>
|
||||
</select>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>In-Match</legend>
|
||||
<b>Sandstorm Bonus</b>
|
||||
<legend>Autonomous</legend>
|
||||
<b>Exited Initiation Line</b>
|
||||
<div class="form-group">
|
||||
<div class="row">
|
||||
{{range $i := seq 3}}
|
||||
<div class="col-lg-4">
|
||||
<label class="col-lg-8 control-label">Team {{"{{team"}}{{$i}}{{"}}"}}</label>
|
||||
<input type="checkbox" class="input-sm" name="{{"{{alliance}}"}}SandstormBonus{{$i}}">
|
||||
<input type="checkbox" class="input-sm" name="{{"{{alliance}}"}}ExitedInitiationLine{{$i}}">
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
<b>Cargo Ship</b>
|
||||
<p>Counting starts nearest center field on scoring table side and wraps around</p>
|
||||
<b>Power Cells</b>
|
||||
{{template "powerCells" dict "period" "Auto" "stages" 2}}
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Teleoperated</legend>
|
||||
<b>Power Cells</b>
|
||||
{{template "powerCells" dict "period" "Teleop" "stages" 4}}
|
||||
<b>Control Panel</b>
|
||||
<div class="form-group">
|
||||
{{range $i, $unused := seq 2}}
|
||||
<div class="row">
|
||||
{{range $j := seq 4}}
|
||||
{{$bayNumber := add $j (multiply $i 4)}}
|
||||
<div class="col-lg-3">
|
||||
{{$bayNumber}}:
|
||||
<select name="{{"{{alliance}}"}}CargoBay{{$bayNumber}}">
|
||||
<option value="0">Empty</option>
|
||||
<option value="1">Hatch Only</option>
|
||||
<option value="2">H+Cargo</option>
|
||||
</select>
|
||||
</div>
|
||||
{{end}}
|
||||
<div class="row">
|
||||
<div class="radio col-lg-3 col-lg-offset-1">
|
||||
<input type="radio" name="{{"{{alliance}}"}}ControlPanelStatus" value="0">None
|
||||
</div>
|
||||
<div class="radio col-lg-4">
|
||||
<input type="radio" name="{{"{{alliance}}"}}ControlPanelStatus" value="1">Rotation Control
|
||||
</div>
|
||||
<div class="radio col-lg-4">
|
||||
<input type="radio" name="{{"{{alliance}}"}}ControlPanelStatus" value="2">Position Control
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<b>Rockets</b>
|
||||
<div class="form-group">
|
||||
<div class="row text-center">
|
||||
{{template "rocketHalf" dict "rocketName" "Near Left" "rocketId" "NearLeft"}}
|
||||
{{template "rocketHalf" dict "rocketName" "Near Right" "rocketId" "NearRight"}}
|
||||
{{template "rocketHalf" dict "rocketName" "Far Left" "rocketId" "FarLeft"}}
|
||||
{{template "rocketHalf" dict "rocketName" "Far Right" "rocketId" "FarRight"}}
|
||||
</div>
|
||||
</div>
|
||||
<b>Robot Ending Levels</b>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Endgame</legend>
|
||||
<b>Robot Status</b>
|
||||
<div class="form-group">
|
||||
{{range $i := seq 3}}
|
||||
<div class="row">
|
||||
<label class="col-lg-2 control-label">Team {{"{{team"}}{{$i}}{{"}}"}}</label>
|
||||
<div class="radio col-lg-3">
|
||||
<input type="radio" name="{{"{{alliance}}"}}RobotEndLevel{{$i}}" value="0">Not On Hab
|
||||
<label class="col-lg-2 col-lg-offset-1 control-label">Team {{"{{team"}}{{$i}}{{"}}"}}</label>
|
||||
<div class="radio col-lg-2">
|
||||
<input type="radio" name="{{"{{alliance}}"}}EndgameStatuses{{$i}}" value="0">None
|
||||
</div>
|
||||
<div class="radio col-lg-2">
|
||||
<input type="radio" name="{{"{{alliance}}"}}RobotEndLevel{{$i}}" value="1">Level 1
|
||||
<input type="radio" name="{{"{{alliance}}"}}EndgameStatuses{{$i}}" value="1">Park
|
||||
</div>
|
||||
<div class="radio col-lg-2">
|
||||
<input type="radio" name="{{"{{alliance}}"}}RobotEndLevel{{$i}}" value="2">Level 2
|
||||
</div>
|
||||
<div class="radio col-lg-2">
|
||||
<input type="radio" name="{{"{{alliance}}"}}RobotEndLevel{{$i}}" value="3">Level 3
|
||||
<input type="radio" name="{{"{{alliance}}"}}EndgameStatuses{{$i}}" value="2">Hang
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
<div class="row">
|
||||
<label class="col-lg-3 control-label">Rung Is Level</label>
|
||||
<input type="checkbox" class="input-sm" name="{{"{{alliance}}"}}RungIsLevel">
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
@@ -229,18 +187,26 @@
|
||||
renderResults("blue");
|
||||
</script>
|
||||
{{end}}
|
||||
{{define "rocketHalf"}}
|
||||
<div class="col-lg-3">
|
||||
<div class="row">{{.rocketName}}</div>
|
||||
<div class="row">H: {{template "rocketBay" dict "rocketId" .rocketId "level" "3"}}</div>
|
||||
<div class="row">M: {{template "rocketBay" dict "rocketId" .rocketId "level" "2"}}</div>
|
||||
<div class="row">L: {{template "rocketBay" dict "rocketId" .rocketId "level" "1"}}</div>
|
||||
{{define "powerCells"}}
|
||||
<div class="form-group">
|
||||
<div class="row">
|
||||
<label class="col-lg-2 col-lg-offset-3 text-center">Stage 1</label>
|
||||
{{range $i := seq (add .stages -1)}}
|
||||
<label class="col-lg-2 text-center">{{if lt $i 3}}Stage {{add $i 1}}{{else}}Extra{{end}}</label>
|
||||
{{end}}
|
||||
</div>
|
||||
{{template "powerCellGoal" dict "period" .period "stages" .stages "goal" "Inner"}}
|
||||
{{template "powerCellGoal" dict "period" .period "stages" .stages "goal" "Outer"}}
|
||||
{{template "powerCellGoal" dict "period" .period "stages" .stages "goal" "Bottom"}}
|
||||
</div>
|
||||
{{end}}
|
||||
{{define "rocketBay"}}
|
||||
<select name="{{"{{alliance}}"}}Rocket{{.rocketId}}Bay{{.level}}">
|
||||
<option value="0">Empty</option>
|
||||
<option value="1">Hatch Only</option>
|
||||
<option value="2">H+Cargo</option>
|
||||
</select>
|
||||
{{define "powerCellGoal"}}
|
||||
<div class="row">
|
||||
<label class="col-lg-2 col-lg-offset-1">{{.goal}}</label>
|
||||
{{range $i := seq .stages}}
|
||||
<div class="col-lg-2">
|
||||
<input type="text" class="form-control input-sm" name="{{"{{alliance}}"}}{{$.period}}Cells{{$.goal}}{{$i}}">
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
@@ -62,18 +62,17 @@ func TestMatchReviewEditExistingResult(t *testing.T) {
|
||||
assert.Contains(t, recorder.Body.String(), " QF4-3 ")
|
||||
|
||||
// Update the score to something else.
|
||||
postBody := "redScoreJson={\"RobotEndLevels\":[0,3,0]}&blueScoreJson={\"AutoCellsOuter\":[3, 4]," +
|
||||
postBody := "redScoreJson={\"EndgameStatuses\":[0,2,1]}&blueScoreJson={\"AutoCellsOuter\":[3, 4]," +
|
||||
"\"Fouls\":[{\"TeamId\":973,\"RuleId\":1}]}&redCardsJson={\"105\":\"yellow\"}&blueCardsJson={}"
|
||||
recorder = web.postHttpResponse(fmt.Sprintf("/match_review/%d/edit", match.Id), postBody)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
|
||||
// TODO(pat): Update for 2020.
|
||||
// Check for the updated scores back on the match list page.
|
||||
recorder = web.getHttpResponse("/match_review")
|
||||
assert.Equal(t, 200, recorder.Code)
|
||||
assert.Contains(t, recorder.Body.String(), ">QF4-3<")
|
||||
assert.Contains(t, recorder.Body.String(), ">0<") // The red score
|
||||
assert.Contains(t, recorder.Body.String(), ">0<") // The blue score
|
||||
assert.Contains(t, recorder.Body.String(), ">33<") // The red score
|
||||
assert.Contains(t, recorder.Body.String(), ">28<") // The blue score
|
||||
}
|
||||
|
||||
func TestMatchReviewCreateNewResult(t *testing.T) {
|
||||
@@ -95,16 +94,15 @@ func TestMatchReviewCreateNewResult(t *testing.T) {
|
||||
assert.Contains(t, recorder.Body.String(), " QF4-3 ")
|
||||
|
||||
// Update the score to something else.
|
||||
postBody := "redScoreJson={\"RocketNearLeftBays\":[1,0,2]}&blueScoreJson={\"RocketFarRightBays\":[2,2,2]," +
|
||||
postBody := "redScoreJson={\"TeleopCellsBottom\":[5,1,7,2]}&blueScoreJson={\"TeleopCellsInner\":[2,2,2,2]," +
|
||||
"\"Fouls\":[{\"TeamId\":973,\"RuleId\":1}]}&redCardsJson={\"105\":\"yellow\"}&blueCardsJson={}"
|
||||
recorder = web.postHttpResponse(fmt.Sprintf("/match_review/%d/edit", match.Id), postBody)
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
|
||||
// TODO(pat): Update for 2020.
|
||||
// Check for the updated scores back on the match list page.
|
||||
recorder = web.getHttpResponse("/match_review")
|
||||
assert.Equal(t, 200, recorder.Code)
|
||||
assert.Contains(t, recorder.Body.String(), ">QF4-3<")
|
||||
assert.Contains(t, recorder.Body.String(), ">0<") // The red score
|
||||
assert.Contains(t, recorder.Body.String(), ">0<") // The blue score
|
||||
assert.Contains(t, recorder.Body.String(), ">18<") // The red score
|
||||
assert.Contains(t, recorder.Body.String(), ">24<") // The blue score
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user