Commits

Johan Euphrosine committed 1760b3f

add inactive player feedback [Finished: #9021837]

Comments (0)

Files changed (2)

websocket/public/lib/client.js

           h = 6,
           dx = 3,
           dy = 25;
+          if (obj.active === true) {
+            marker.opacity = 1.0;
+          } else if (obj.active === false) {
+            marker.opacity = 0.5;
+          }
           drawMarker.apply(marker, arguments);
           if (obj.t == 'C' || obj.t == 'P') {
             context.shadowOffsetX = 3;
         obj_map[e.id] = e;
         obj_map[e.id].max_health = e.health;
       } else {
-        if (e.health) {
+        if (e.health !== undefined) {
           obj_map[e.id].health = e.health;
         }
+        if (e.active !== undefined) {
+          obj_map[e.id].active = e.active;
+        }
         T5.GeoXY.updatePos(obj_map[e.id].marker.xy, T5.Geo.Position.init(e.lat, e.lon));
         map.markers.changed();
       }

websocket/public/test/test.js

 });
 
 test('drawMarker', function() {
-  expect(2);
+  expect(6);
   
   var capture = {}, conn = mockup.conn(capture), c = client({
     conn: conn,
     T5: mockup.T5(capture),
     resources: mockup.resources
   });
-  conn.onmessage({data: JSON.stringify({t: 'P', lon: 1, lat: 2, id: 3, oc: 4, health: 100})});
+  conn.onmessage({data: JSON.stringify({t: 'P', lon: 1, lat: 2, id: 3, oc: 4, health: 100, active: true})});
   conn.onmessage({data: JSON.stringify({t: 'P', lon: 1, lat: 2, id: 3, oc: 4, health: 50})});
   var ws = [];
-  capture.markers[0].drawMarker({
-    fillRect: function(x, y, w, h) {
-      ws.push(w);
-    }
-  }, undefined, 0, 0, undefined, undefined, undefined);
+  function draw() {
+    capture.markers[0].drawMarker({
+      fillRect: function(x, y, w, h) {
+        ws.push(w);
+      }
+    }, undefined, 0, 0, undefined, undefined, undefined);
+  }
+  draw();
   equal(ws[0], 50);
   equal(ws[1], 25);
+  equal(1.0, capture.markers[0].opacity);
+  conn.onmessage({data: JSON.stringify({t: 'P', lon: 1, lat: 2, id: 3, oc: 4, health: 0, active: false})});
+  draw();
+  equal(ws[2], 50);
+  equal(ws[3], 0);
+  equal(0.5, capture.markers[0].opacity);
 });