Permalink
Browse files

Added penalties.

  • Loading branch information...
1 parent 5c04814 commit 5dd2ed033ba51956986d549f8e66b94b1f9eef52 @alexhenning committed Jan 27, 2011
Showing with 78 additions and 2 deletions.
  1. +52 −1 index.html
  2. +26 −1 scoring.js
View
@@ -57,7 +57,45 @@
cursor: pointer;
padding: 0px;
z-index: 99;
- }
+ }
+ .wide-penalty {
+ float: left;
+ width: 130px;
+ text-align: center;
+ border: 2px solid dimgray;
+ cursor: pointer;
+ -moz-user-select: none;
+ -khtml-user-select: none;
+ -webkit-user-select: none;
+ user-select: none;
+ }
+ .wide-penalty:hover {
+ background: dimgray;
+ }
+ .narrow-penalty {
+ float: left;
+ width: 60px;
+ text-align: center;
+ border: 2px solid dimgray;
+ cursor: pointer;
+ -moz-user-select: none;
+ -khtml-user-select: none;
+ -webkit-user-select: none;
+ user-select: none;
+ }
+ .narrow-penalty:hover {
+ background: dimgray;
+ }
+ #penalty {
+ float: left;
+ width: 190px;
+ text-align: center;
+ color: lightgray;
+ font-weight: bold;
+ font-size: 16pt;
+ background: dimgray;
+ border: 4px solid dimgray;
+ }
#wrapper {
width: 744px;
margin: auto;
@@ -132,10 +170,23 @@
</div>
<div id="bin">
</div>
+ <div id="penalties">
+ <center><h2>Penalties</h2></center>
+ <input id="penalty" onchange="handlePenaltyChange()" value="0" type="text"/>
+ <div onclick="changePenalties(1)"
+ class="wide-penalty">+1</div>
+ <div onclick="changePenalties(10)"
+ class="narrow-penalty">+10</div>
+ <div onclick="changePenalties(-1)"
+ class="wide-penalty">-1</div>
+ <div onclick="changePenalties(-10)"
+ class="narrow-penalty">-10</div>
+ </div>
<div id="scores">
Autonomous score: <span id="auton-score">0</span><br/>
Teleop score: <span id="teleop-score">0</span><br/>
Race score: <span id="race-score">0</span><br/>
+ Penalties: <span id="penalty-score">0</span><br/>
<b>Total score: <span id="score">0</span></b>
<div id="errors"></div>
</div>
View
@@ -179,17 +179,42 @@ Racer.prototype.getScore = function() {
};
/**
+ * Code for penalties
+ */
+var penalties = 0;
+
+function changePenalties(num) {
+ penalties += num;
+ if (penalties < 0) {
+ penalties = 0;
+ }
+ $("#penalty")[0].value = penalties;
+ updateScore();
+}
+
+function handlePenaltyChange() {
+ penalties = parseInt($("#penalty")[0].value);
+ if (penalties < 0) {
+ penalties = 0;
+ }
+ $("#penalty")[0].value = penalties;
+ updateScore();
+}
+
+/**
* Code for updating the score
*/
function updateScore() {
var autonScore = getAutonScore();
var teleopScore = getTeleopScore();
var raceScore = getRaceScore();
- var score = autonScore + teleopScore + raceScore;
+ var penaltyScore = -3 * penalties;
+ var score = autonScore + teleopScore + raceScore + penaltyScore;
$("#auton-score").text(autonScore);
$("#teleop-score").text(teleopScore);
$("#race-score").text(raceScore);
+ $("#penalty-score").text(penaltyScore);
$("#score").text(score);
}
function isLogo(p1, p2, p3) {

0 comments on commit 5dd2ed0

Please sign in to comment.