coming together

This commit is contained in:
2019-12-06 13:59:12 +00:00
parent 3fd31ffb27
commit 56605158ec
+60 -60
View File
@@ -57,19 +57,14 @@ type EveEyeKspace struct {
} `json:"maps"`
}
// // EveSystemList asd
// type EveSystemList struct {
// Systems []EveSystem `json:"systems"`
// }
// EveSystem ss
type EveSystem struct {
Constellation string `json:"constellation"`
Links []string `json:"links"`
Name string `json:"name"`
// Sec float64 `json:"sec"`
Region string `json:"region"`
SystemID int `json:"sid"`
Sec float64 `json:"sec"`
Region string `json:"region"`
SystemID int `json:"sid"`
}
// we'll record both directions here in-memory
@@ -92,37 +87,21 @@ func main() {
json.Unmarshal(byteValue, &OrigKspace)
// jsonObjJumps := gabs.New()
// jsonObjSystems := gabs.New()
List := CreateSystemList(OrigKspace)
// for _, data := range OrigKspace.Maps {
// Region := data.MapName
// if Region == "Delve" {
// for _, gate := range data.Gates {
// jsonObjSystems.Set(gate.S, "jumps", fmt.Sprintf("%v-%v", gate.S, gate.T), "s")
// jsonObjSystems.Set(gate.T, "jumps", fmt.Sprintf("%v-%v", gate.S, gate.T), "t")
// // jsonObjSystems.Set(gate.T, "jumps", "t")
// // fmt.Printf("T: %v\n", gate.T)
// // fmt.Printf("S: %v\n", gate.S)
// }
// }
// }
// fmt.Println(jsonObjSystems.String())
err = jsonFile.Close()
if err != nil {
fmt.Printf("error closing file")
}
for _, data := range List {
fmt.Printf("[%v/%v] (%v) %v\n", data.Region, data.Name, data.Constellation, data.SystemID)
fmt.Printf("[%v/%v] (const: %v, sec: %v) %v ->", data.Region, data.Name, data.Constellation, data.Sec, data.SystemID)
for _, link := range data.Links {
fmt.Printf(" {%v}", link)
}
fmt.Printf("\n")
}
foo := SidToName(30004764, List)
fmt.Println(foo)
}
// SidToName returns the system name from a SystemID
@@ -133,13 +112,11 @@ func SidToName(in int, List []EveSystem) string {
if in < 10000 {
in = in + 30000000
}
fmt.Println("in", in)
answer := ""
for _, data := range List {
if in == data.SystemID {
// fmt.Printf("%v matched to %v\n", in, data.Name)
answer = data.Name
// fmt.Printf(len(data.SystemID))
}
}
return answer
@@ -149,7 +126,10 @@ func SidToName(in int, List []EveSystem) string {
func CreateSystemList(input EveEyeKspace) []EveSystem {
// FauxRegion := data.MapName
List := []EveSystem{}
TmpList := []EveSystem{}
ReturnList := []EveSystem{}
// First loop.. just the system IDs and SystemNames
for _, input := range input.Maps {
FauxRegion := input.MapName
@@ -166,40 +146,60 @@ func CreateSystemList(input EveEyeKspace) []EveSystem {
// and this.. whatever it is
if Region != "UUA-F4" {
if Region == "Delve" {
// if Region == "Delve" {
SystemName := system.Sn
SystemID := system.Sid
SystemName := system.Sn
SystemID := system.Sid
Constellation := system.Cn
// SystemSec := system.Sec
// fmt.Println(SystemName)
// fmt.Printf("[%v/%v]: (%v) %v -> ", Region, Constellation, SystemID, SystemName)
// for _, link := range system.Links {
// // s := strconv.FormatInt(link, 10) // convert int64 into string
// // linkID := fmt.Sprint(link)
// linkName := SidToName(link, List)
// fmt.Printf(" %v", linkName)
// }
fmt.Printf("\n")
d := EveSystem{
Constellation: Constellation,
Name: SystemName,
Region: Region,
SystemID: SystemID,
}
List = append(List, d)
// jsonObjSystems.Set(SystemID, "systems", SystemName, "id")
// jsonObjSystems.Set(SystemSec, "systems", SystemName, "sec")
d := EveSystem{
Name: SystemName,
SystemID: SystemID,
}
TmpList = append(TmpList, d)
// }
}
}
}
}
}
}
return List
// Now we have a list of system names and ID's we can loop again and change the Links to system names
for _, input := range input.Maps {
FauxRegion := input.MapName
for _, system := range input.Systems {
Region := system.Rn
if Region == FauxRegion {
if Region != "J7HZ-F" {
if Region != "A821-A" {
if Region != "UUA-F4" {
// if Region == "Delve" {
SystemName := system.Sn
SystemID := system.Sid
SystemSec := system.Sec
Constellation := system.Cn
linkList := []string{}
for _, link := range system.Links {
linkName := SidToName(link, TmpList)
linkList = append(linkList, linkName)
}
d := EveSystem{
Constellation: Constellation,
Name: SystemName,
Region: Region,
SystemID: SystemID,
Sec: SystemSec,
Links: linkList,
}
ReturnList = append(ReturnList, d)
}
}
}
}
}
}
return ReturnList
}