Documentation
¶
Overview ¶
Example (ParseModuleItem) ¶
const example = "int_powerplant_size3_class5" base, size, class := parseModuleItem(example) fmt.Println(base, size, class)
Output: int_powerplant 3 5
Index ¶
- Constants
- Variables
- func EconomyKey(k string) string
- func GovernmentKey(k string) string
- func LoadJSON(file string, allowEmpty bool, into interface{}, logTmpl string) error
- func ParseEDLang(edlang string) (lang, region string)
- func PortSvcKey(k string) string
- func SaveJSON(file string, data interface{}, logTmpl string) error
- func ShipFromLoadout(e *journal.Loadout, types ships.TypeRepo) (ship *ships.Ship, err error)
- func ShipKey(k string) string
- func SysSecurityKey(k string) string
- type Cargo
- type ChangeEvent
- type CmdrFile
- type Commander
- type Config
- type EDState
- func (ed *EDState) Close() error
- func (ed *EDState) FindShip(id int) *Ship
- func (ed *EDState) GetShip(id int) *Ship
- func (ed *EDState) Load(file string) error
- func (ed *EDState) MustCommander(where string) *Commander
- func (ed *EDState) OnJournalEvent(e watched.JounalEvent) (err error)
- func (ed *EDState) OnStatusEvent(e watched.StatusEvent) error
- func (es *EDState) RdLocked(do func() error) error
- func (ed *EDState) Reset()
- func (ed *EDState) Save() error
- func (es *EDState) SetEDVersion(v string)
- func (es *EDState) SetLanguage(lang string)
- func (ed *EDState) SwitchCommander(fid string, name string) error
- func (es *EDState) WrLocked(do func() error) error
- type FSDJump
- type HandlerFunc
- type JSONLocation
- type Location
- type Materials
- type Port
- type Rank
- type RankType
- type Ranks
- type Ship
- type SysCoos
- type System
- func (s *System) FromMap(m map[string]interface{}) (err error)
- func (s *System) Same(name string, coos ...float32) bool
- func (s *System) Set(name string, coos ...float32) (changed bool)
- func (s *System) System() *System
- func (s *System) ToMap(m *map[string]interface{}, setType bool) error
- func (sys *System) Update(addr uint64, name string, coos ...float32) (*System, bool)
Examples ¶
Constants ¶
View Source
const ( ChgGame change.Flags = (1 << iota) ChgCommander ChgSystem ChgLocation ChgShip ChgEND )
View Source
const ( LocTypeSystem = "system" LocTypePort = "port" LocTypeFSDJump = "jump" )
Variables ¶
View Source
var (
LogCfg c4hgol.LogConfig = log
)
Functions ¶
func EconomyKey ¶
func GovernmentKey ¶
func ParseEDLang ¶
func PortSvcKey ¶
func ShipFromLoadout ¶
func SysSecurityKey ¶
Types ¶
type Commander ¶
type Commander struct { FID string Name change.Val[string] Ranks Ranks ShipID change.Val[int] // contains filtered or unexported fields }
func NewCommander ¶
type EDState ¶
type EDState struct { Config `json:"-"` EDVersion string `json:"-"` Beta bool `json:"-"` Language string `json:"-"` L10n struct { Lang string Region string } `json:"-"` Cmdr *Commander Loc JSONLocation Ships map[int]*Ship Mats Materials Cargo map[string]*Cargo Notify []chan<- ChangeEvent `json:"-"` // contains filtered or unexported fields }
Example (Marshal) ¶
eds := NewEDState(&Config{ CmdrFile: CmdrFile{Dir: "."}.Filename, }) eds.Cmdr = NewCommander("F4711") eds.Cmdr.Name = change.NewVal("John Doe") _, err := json.Marshal(eds) fmt.Println(err)
Output: <nil>
func NewEDState ¶
func (*EDState) MustCommander ¶
func (*EDState) OnJournalEvent ¶
func (ed *EDState) OnJournalEvent(e watched.JounalEvent) (err error)
func (*EDState) OnStatusEvent ¶
func (ed *EDState) OnStatusEvent(e watched.StatusEvent) error
func (*EDState) SetEDVersion ¶
func (*EDState) SetLanguage ¶
type JSONLocation ¶
type JSONLocation struct {
Location
}
func (JSONLocation) FSDJump ¶
func (jl JSONLocation) FSDJump() *FSDJump
func (JSONLocation) MarshalJSON ¶
func (jloc JSONLocation) MarshalJSON() ([]byte, error)
func (JSONLocation) Port ¶
func (jl JSONLocation) Port() *Port
func (JSONLocation) System ¶
func (jl JSONLocation) System() *System
func (*JSONLocation) UnmarshalJSON ¶
func (jloc *JSONLocation) UnmarshalJSON(data []byte) (err error)
type Port ¶
Example ¶
p := Port{ Sys: &System{ Addr: 4711, Name: "Köln", Coos: ToSysCoos(3, 2, 1), }, Name: "Hafen", Type: "Orbis", Docked: true, } var sb bytes.Buffer enc := json.NewEncoder(&sb) enc.SetIndent("", " ") enc.Encode(&p) os.Stdout.Write(sb.Bytes()) sb.Reset() enc.Encode(JSONLocation{&p}) os.Stdout.Write(sb.Bytes()) var jloc JSONLocation fmt.Println(json.Unmarshal(sb.Bytes(), &jloc)) sb.Reset() enc.Encode(&p) os.Stdout.Write(sb.Bytes())
Output: { "Sys": { "Addr": 4711, "Name": "Köln", "Coos": [ 3, 2, 1 ] }, "Name": "Hafen", "Type": "Orbis", "Docked": true } { "@type": "port", "Docked": true, "Name": "Hafen", "Sys": { "Addr": 4711, "Coos": [ 3, 2, 1 ], "Name": "Köln" }, "Type": "Orbis" } <nil> { "Sys": { "Addr": 4711, "Name": "Köln", "Coos": [ 3, 2, 1 ] }, "Name": "Hafen", "Type": "Orbis", "Docked": true }
type Ranks ¶
Example ¶
var rs Ranks enc := json.NewEncoder(os.Stdout) enc.Encode(rs)
Output: {"CQC":{"L":0,"P":0},"Combat":{"L":0,"P":0},"Empire":{"L":0,"P":0},"Explore":{"L":0,"P":0},"Federation":{"L":0,"P":0},"Trade":{"L":0,"P":0}}
func (Ranks) MarshalJSON ¶
func (*Ranks) UnmarshalJSON ¶
type System ¶
Example ¶
s := NewSystem(4711, "Köln", 3, 2, 1) var sb bytes.Buffer enc := json.NewEncoder(&sb) enc.SetIndent("", " ") enc.Encode(s) os.Stdout.Write(sb.Bytes()) sb.Reset() enc.Encode(JSONLocation{s}) os.Stdout.Write(sb.Bytes()) var jloc JSONLocation fmt.Println(json.Unmarshal(sb.Bytes(), &jloc)) sb.Reset() enc.Encode(&s) os.Stdout.Write(sb.Bytes())
Output: { "Addr": 4711, "Name": "Köln", "Coos": [ 3, 2, 1 ] } { "@type": "system", "Addr": 4711, "Coos": [ 3, 2, 1 ], "Name": "Köln" } <nil> { "Addr": 4711, "Name": "Köln", "Coos": [ 3, 2, 1 ] }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.