Procházet zdrojové kódy

Fix security status calculation.

master
Ben Kurtovic před 4 roky
rodič
revize
846e5e3886
4 změnil soubory, kde provedl 18 přidání a 10 odebrání
  1. +2
    -2
      calefaction/eve/universe.py
  2. +2
    -2
      calefaction/format.py
  3. +9
    -1
      calefaction/modules/map.py
  4. +5
    -5
      static/map.js

+ 2
- 2
calefaction/eve/universe.py Zobrazit soubor

@@ -84,12 +84,12 @@ class _SolarSystem(_UniqueObject):
@property
def is_nullsec(self):
"""Whether the solar system is in nullsec."""
return self.security < 0.05
return self.security <= 0.0

@property
def is_lowsec(self):
"""Whether the solar system is in nullsec."""
return self.security >= 0.05 and self.security < 0.45
return self.security > 0.0 and self.security < 0.45

@property
def is_highsec(self):


+ 2
- 2
calefaction/format.py Zobrazit soubor

@@ -79,6 +79,6 @@ def format_security(value):

def get_security_class(value):
"""Given a system security status, return the corresponding CSS class."""
if value < 0.05:
if value <= 0.0:
return "sec-null"
return "sec-" + str(round(value, 1)).replace(".", "_")
return "sec-" + str(round(max(value, 0.1), 1)).replace(".", "_")

+ 9
- 1
calefaction/modules/map.py Zobrazit soubor

@@ -22,9 +22,10 @@ def map():
def mapdata():
"""Render and return the map data as a JSON object."""
payload = {
"galaxy": {
"systems": {
system.id: {
"name": system.name,
"region": system.region.id,
"security": system.security,
"coords": system.coords,
"gates": [dest.id for dest in system.gates],
@@ -32,6 +33,13 @@ def mapdata():
}
for system in g.eve.universe.systems() if not system.is_whspace
},
"regions": {
region.id: {
"name": region.name,
"faction": region.faction.id if region.faction else -1
}
for region in g.eve.universe.regions() if not region.is_whspace
},
"factions": {
faction.id: {
"name": faction.name


+ 5
- 5
static/map.js Zobrazit soubor

@@ -21,7 +21,7 @@ var get_bounds = function(galaxy) {
$(function() {
$("#map .preload").append($("<p>").text("Loading map data..."));
$.getJSON( "map/data.json", data => {
var galaxy = data["galaxy"];
var galaxy = data["systems"];
var systems = Object.values(galaxy);
var jumps = [].concat
.apply([], Object.keys(galaxy)
@@ -67,8 +67,8 @@ $(function() {
.attr("r", 2)
.attr("class", d => {
var sec = d["security"];
var klass = sec < 0.05 ? "null" :
Number(sec).toFixed(1).replace(".", "_");
var klass = sec <= 0.0 ? "null" :
Number(Math.max(sec, 0.1)).toFixed(1).replace(".", "_");
return "system sec-" + klass;
});

@@ -82,13 +82,13 @@ $(function() {
trans.x = Math.max(Math.min(trans.x, clamp), -clamp);
trans.y = Math.max(Math.min(trans.y, clamp), -clamp);
stars.attr("transform", trans);
$("#map-scale").val(Math.log2(trans.k + 1));

if (trans.k != lastk) {
if (Math.abs((trans.k - lastk) / lastk) > 0.1) {
stars.selectAll("circle")
.attr("r", 6 / (trans.k + 2));
stars.selectAll("line")
.style("stroke-width", 2 / (trans.k + 1));
$("#map-scale").val(Math.log2(trans.k + 1));
lastk = trans.k;
}
});


Načítá se…
Zrušit
Uložit