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"` } `json:"maps"`
} }
// // EveSystemList asd
// type EveSystemList struct {
// Systems []EveSystem `json:"systems"`
// }
// EveSystem ss // EveSystem ss
type EveSystem struct { type EveSystem struct {
Constellation string `json:"constellation"` Constellation string `json:"constellation"`
Links []string `json:"links"` Links []string `json:"links"`
Name string `json:"name"` Name string `json:"name"`
// Sec float64 `json:"sec"` Sec float64 `json:"sec"`
Region string `json:"region"` Region string `json:"region"`
SystemID int `json:"sid"` SystemID int `json:"sid"`
} }
// we'll record both directions here in-memory // we'll record both directions here in-memory
@@ -92,37 +87,21 @@ func main() {
json.Unmarshal(byteValue, &OrigKspace) json.Unmarshal(byteValue, &OrigKspace)
// jsonObjJumps := gabs.New()
// jsonObjSystems := gabs.New()
List := CreateSystemList(OrigKspace) 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() err = jsonFile.Close()
if err != nil { if err != nil {
fmt.Printf("error closing file") fmt.Printf("error closing file")
} }
for _, data := range List { 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 // SidToName returns the system name from a SystemID
@@ -133,13 +112,11 @@ func SidToName(in int, List []EveSystem) string {
if in < 10000 { if in < 10000 {
in = in + 30000000 in = in + 30000000
} }
fmt.Println("in", in)
answer := "" answer := ""
for _, data := range List { for _, data := range List {
if in == data.SystemID { if in == data.SystemID {
// fmt.Printf("%v matched to %v\n", in, data.Name)
answer = data.Name answer = data.Name
// fmt.Printf(len(data.SystemID))
} }
} }
return answer return answer
@@ -149,7 +126,10 @@ func SidToName(in int, List []EveSystem) string {
func CreateSystemList(input EveEyeKspace) []EveSystem { func CreateSystemList(input EveEyeKspace) []EveSystem {
// FauxRegion := data.MapName // FauxRegion := data.MapName
List := []EveSystem{} TmpList := []EveSystem{}
ReturnList := []EveSystem{}
// First loop.. just the system IDs and SystemNames
for _, input := range input.Maps { for _, input := range input.Maps {
FauxRegion := input.MapName FauxRegion := input.MapName
@@ -166,40 +146,60 @@ func CreateSystemList(input EveEyeKspace) []EveSystem {
// and this.. whatever it is // and this.. whatever it is
if Region != "UUA-F4" { if Region != "UUA-F4" {
if Region == "Delve" { // if Region == "Delve" {
SystemName := system.Sn
SystemID := system.Sid
SystemName := system.Sn d := EveSystem{
SystemID := system.Sid Name: SystemName,
Constellation := system.Cn SystemID: SystemID,
// 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")
} }
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
} }