-
Notifications
You must be signed in to change notification settings - Fork 0
/
evecharacter.go
54 lines (45 loc) · 1.18 KB
/
evecharacter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Package model contains the entity objects, which are used across the app.
package model
import (
"time"
"fyne.io/fyne/v2"
"github.com/ErikKalkoken/evebuddy/internal/api/images"
)
// An Eve Online character.
type EveCharacter struct {
Alliance *EveEntity
Birthday time.Time
Corporation *EveEntity
Description string
Faction *EveEntity
Gender string
ID int32
Name string
Race *EveRace
SecurityStatus float64
Title string
}
func (c *EveCharacter) AllianceName() string {
if !c.HasAlliance() {
return ""
}
return c.Alliance.Name
}
func (c *EveCharacter) FactionName() string {
if !c.HasFaction() {
return ""
}
return c.Faction.Name
}
// HasAlliance reports wether the character is member of an alliance.
func (c *EveCharacter) HasAlliance() bool {
return c.Alliance != nil
}
// HasFaction reports wether the character is member of a faction.
func (c *EveCharacter) HasFaction() bool {
return c.Faction != nil
}
// PortraitURL returns an image URL for a portrait of a character
func (c *EveCharacter) PortraitURL(size int) (fyne.URI, error) {
return images.CharacterPortraitURL(int32(c.ID), size)
}