Hidden shields endorsement.
authorCMDR furrycat <elite@furrycat.net>
Wed, 3 Feb 2016 13:09:47 +0000 (08:09 -0500)
committerCMDR furrycat <elite@furrycat.net>
Wed, 3 Feb 2016 13:27:29 +0000 (08:27 -0500)
entry.js
lib/race.php
propel/build/classes/buckyball/Entry.php

index f42fbba..63f2d8b 100644 (file)
--- a/entry.js
+++ b/entry.js
@@ -240,17 +240,29 @@ function format_speed(speed, suffix) {
   return format_distance(speed, suffix);
 }
 
-/* Find the joker checkbox. */
-function get_joker() {
-  var inputs = document.getElementsByName('endorsement_j');
+/* Find an endorsement checkbox. */
+function get_endorsement(e) {
+  var inputs = document.getElementsByName('endorsement_' + e);
   if (! inputs.length) return null;
   return inputs[0];
 }
 
+/* Find the joker checkbox. */
+function get_joker() {
+  return get_endorsement('j');
+}
+
+/* Find the shields checkbox. */
+function get_shields() {
+  return get_endorsement('s');
+}
+
 /* Is joker in effect? */
 function joker() {
+  var shields = get_shields();
+  if (shields && shields.checked) return false;
   var joker = get_joker();
-  if (joker) return (get_joker().checked);
+  if (joker) return (joker.checked);
   else return false;
 }
 
index 953ccbd..056859c 100644 (file)
       echo "<td style=\"vertical-align: top\">\n";
       echo "<table>\n";
       foreach ($endorsements as $e) {
+        if (Entry::EndorsementHidden($e)) continue;
         $description = Entry::EndorsementDescription($e);
         echo "<tr><td>$e</td><td>$description</td></tr>\n";
       }
       echo "[td]\n";
       echo "[table]\n";
       foreach ($endorsements as $e) {
+        if (Entry::EndorsementHidden($e)) continue;
         $description = Entry::EndorsementDescription($e);
         echo "[tr]";
         echo "[td]";
index d4501b8..5f65ec4 100644 (file)
 class Entry extends BaseEntry
 {
   private static $ENDORSEMENTS = array(
-    'c' => array('entry cut short', 1 << 0),
-    'd' => array('docking computer', 1 << 1),
-    'f' => array('FSD injection', 1 << 2),
-    'j' => array('joker card', 1 << 3),
-    'x' => array('excluded from ranking', 1 << 4),
-    'm' => array('missing evidence', 1 << 5)
+    'c' => array('entry cut short', false, 1 << 0),
+    'd' => array('docking computer', false, 1 << 1),
+    'f' => array('FSD injection', false, 1 << 2),
+    'j' => array('joker card', false, 1 << 3),
+    'x' => array('excluded from ranking', false, 1 << 4),
+    'm' => array('missing evidence', false, 1 << 5),
+    's' => array('shields', true, 1 << 6)
   );
 
   function Endorsements() {
@@ -40,10 +41,14 @@ class Entry extends BaseEntry
     return self::Endorsement($e)[0];
   }
 
-  function EndorsementValue($e) {
+  function EndorsementHidden($e) {
     return self::Endorsement($e)[1];
   }
 
+  function EndorsementValue($e) {
+    return self::Endorsement($e)[2];
+  }
+
   function Sort($a, $b, $method, $reverse = false) {
     $A = $a->$method(); $B = $b->$method();
     if ($A == $B) return 0;
@@ -139,9 +144,14 @@ class Entry extends BaseEntry
     return $this->hasEndorsement('m');
   }
 
+  function shields() {
+    return $this->hasEndorsement('s');
+  }
+
   function getEndorsementString($delimiter = '') {
     $ret = array();
     foreach ($this->EndorsementKeys() as $e) {
+      if ($this->EndorsementHidden($e)) continue;
       if ($this->hasEndorsement($e)) $ret[] = $e;
     }
     return implode($delimiter, $ret);