update position method when players attack multiple portals at once. It now takes repetition into account, e.g. if one burster destroys 4 resos on porta A and only one on B she is now placed closer to A rather than in the middle of both.

This commit is contained in:
Stefan Breunig 2013-02-25 09:21:48 +01:00
parent 67d4fbbe03
commit 286a4ba376

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @id iitc-plugin-player-tracker@breunigs // @id iitc-plugin-player-tracker@breunigs
// @name iitc: player tracker // @name iitc: player tracker
// @version 0.5 // @version 0.6
// @namespace https://github.com/breunigs/ingress-intel-total-conversion // @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/player-tracker.user.js // @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/player-tracker.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/player-tracker.user.js // @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/player-tracker.user.js
@ -163,13 +163,14 @@ window.plugin.playerTracker.processNewData = function(data) {
} }
window.plugin.playerTracker.getLatLngFromEvent = function(ev) { window.plugin.playerTracker.getLatLngFromEvent = function(ev) {
var lats = $.map(ev.latlngs, function(ll) { return [ll[0]] }); var lats = 0;
var lngs = $.map(ev.latlngs, function(ll) { return [ll[1]] }); var lngs = 0;
var latmax = Math.max.apply(null, lats); $.each(ev.latlngs, function() {
var latmin = Math.min.apply(null, lats); lats += this[0];
var lngmax = Math.max.apply(null, lngs); lngs += this[1];
var lngmin = Math.min.apply(null, lngs); });
return L.latLng((latmax + latmin) / 2, (lngmax + lngmin) / 2);
return L.latLng(lats / ev.latlngs.length, lngs / ev.latlngs.length);
} }
window.plugin.playerTracker.ago = function(time, now) { window.plugin.playerTracker.ago = function(time, now) {