Files
safer-eve/data/main.go
T

85 lines
2.1 KiB
Go

package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
)
// EveEyeKspace + https://mholt.github.io/json-to-go/
// NOTE.. don't paste the whole json file in here.. just one region or else the tool won't notice gates
type EveEyeKspace struct {
Maps []struct {
MapID int `json:"mapID"`
MapName string `json:"mapName"`
Scale float64 `json:"scale"`
Gates []struct {
S int `json:"s,omitempty"`
T int `json:"t,omitempty"`
P int `json:"p,omitempty"`
} `json:"gates"`
Fid int `json:"fid,omitempty"`
AvgSec float64 `json:"avgSec,omitempty"`
MaxSec float64 `json:"maxSec,omitempty"`
MinSec float64 `json:"minSec,omitempty"`
X float64 `json:"x,omitempty"`
Y int `json:"y,omitempty"`
Systems []struct {
Sid int `json:"sid"`
Sn string `json:"sn"`
Cid int `json:"cid"`
Cn string `json:"cn"`
Rid int `json:"rid"`
Rn string `json:"rn"`
Sec float64 `json:"sec"`
D float64 `json:"d"`
Pi []int `json:"pi"`
Cel []int `json:"cel"`
Fid int `json:"fid"`
Fw bool `json:"fw"`
X float64 `json:"x"`
Y float64 `json:"y"`
Sta int `json:"sta,omitempty"`
Stasrv []int `json:"stasrv,omitempty"`
} `json:"systems"`
Npc int `json:"npc,omitempty"`
} `json:"maps"`
}
func main() {
// we're gonna read these json files and create something sensible..
jsonFile, err := os.Open("kspace.json")
if err != nil {
fmt.Println(err)
}
defer jsonFile.Close()
byteValue, _ := ioutil.ReadAll(jsonFile)
var OrigKspace EveEyeKspace
json.Unmarshal(byteValue, &OrigKspace)
for _, data := range OrigKspace.Maps {
Region := data.MapName
if Region == "Delve" {
fmt.Printf("######################## \n#### %v\n", Region)
for _, system := range data.Systems {
SystemName := system.Sn
SystemID := system.Sid
fmt.Printf("[%v]: (%v) %v\n", Region, SystemID, SystemName)
}
for _, gate := range data.Gates {
fmt.Printf("T: %v\n", gate.T)
fmt.Printf("S: %v\n", gate.S)
}
}
}
}