diff options
author | Aki <please@ignore.pl> | 2021-05-14 20:13:31 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2021-05-14 20:13:31 +0200 |
commit | ebfa9e1a72b10f15ff30329bf31697eaeb71ad5e (patch) | |
tree | 5254f3c74311e93e628aff975981313c40cf7405 | |
parent | f49a11e686addcd8e3ce5160a0170c7bdb01f4bd (diff) | |
download | field-ebfa9e1a72b10f15ff30329bf31697eaeb71ad5e.zip field-ebfa9e1a72b10f15ff30329bf31697eaeb71ad5e.tar.gz field-ebfa9e1a72b10f15ff30329bf31697eaeb71ad5e.tar.bz2 |
Switched to int32 as esi scheme dictates
-rw-r--r-- | esi.go | 2 | ||||
-rw-r--r-- | models.go | 19 | ||||
-rw-r--r-- | storage.go | 4 |
3 files changed, 14 insertions, 11 deletions
@@ -6,7 +6,7 @@ import ( "net/http" ) -func GetKillmail(id uint64, hash string) (EsiKillmail, error) { +func GetKillmail(id int32, hash string) (EsiKillmail, error) { r, err := http.Get(fmt.Sprintf("https://esi.evetech.net/latest/killmails/%d/%s/", id, hash)) if err != nil { return EsiKillmail{}, err @@ -4,12 +4,18 @@ import ( "time" ) +type Vector3 struct { + X float64 `json:"x"` + Y float64 `json:"y"` + Z float64 `json:"z"` +} + type Killmail struct { - Id uint64 `json:"id"` + Id int32 `json:"id"` Hash string `json:"hash"` } -type Team []uint32 +type Team []int32 type Battle struct { Id string `json:"-"` @@ -24,11 +30,10 @@ type Battle struct { type EsiKillmail struct { SolarSystemId int32 `json:"solar_system_id"` Victim struct { - Position struct { - X float64 `json:"x"` - Y float64 `json:"y"` - Z float64 `json:"z"` - } `json:"position"` + Position Vector3 `json:"position"` + ShipTypeId int32 `json:"ship_type_id"` + CorporationId int32 `json:"corporation_id"` + AllianceId int32 `json:"alliance_id"` } `json:"victim"` Time time.Time `json:"killmail_time"` } @@ -6,13 +6,11 @@ import ( "encoding/json" "errors" "fmt" - "io" "io/ioutil" "net/http" "os" "regexp" "sort" - "strconv" ) type Storage struct { @@ -45,7 +43,7 @@ func (b *Battle) CalculateHash() { return killmails[lhs].Id < killmails[rhs].Id }) for _, km := range killmails { - io.WriteString(hash, strconv.FormatUint(km.Id, 10)) + fmt.Fprint(hash, km.Id) } sum := hash.Sum(nil) b.Id = hex.EncodeToString(sum[:]) |