Dawid Wysokiński
be8892e532
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: twhelp/core#4
69 lines
1.8 KiB
Go
69 lines
1.8 KiB
Go
package tw
|
|
|
|
import (
|
|
"encoding/xml"
|
|
|
|
"gitea.dwysokinski.me/twhelp/core/internal/domain"
|
|
)
|
|
|
|
type unit struct {
|
|
Text string `xml:",chardata"`
|
|
BuildTime float64 `xml:"build_time"`
|
|
Pop int16 `xml:"pop"`
|
|
Speed float64 `xml:"speed"`
|
|
Attack int16 `xml:"attack"`
|
|
Defense int16 `xml:"defense"`
|
|
DefenseCavalry int16 `xml:"defense_cavalry"`
|
|
DefenseArcher int16 `xml:"defense_archer"`
|
|
Carry int16 `xml:"carry"`
|
|
}
|
|
|
|
func (u unit) toDomain() domain.Unit {
|
|
return domain.Unit{
|
|
BuildTime: u.BuildTime,
|
|
Pop: u.Pop,
|
|
Speed: u.Speed,
|
|
Attack: u.Attack,
|
|
Defense: u.Defense,
|
|
DefenseCavalry: u.DefenseCavalry,
|
|
DefenseArcher: u.DefenseArcher,
|
|
Carry: u.Carry,
|
|
}
|
|
}
|
|
|
|
type unitConfig struct {
|
|
XMLName xml.Name `xml:"config"`
|
|
Text string `xml:",chardata"`
|
|
Spear unit `xml:"spear"`
|
|
Sword unit `xml:"sword"`
|
|
Axe unit `xml:"axe"`
|
|
Archer unit `xml:"archer"`
|
|
Spy unit `xml:"spy"`
|
|
Light unit `xml:"light"`
|
|
Marcher unit `xml:"marcher"`
|
|
Heavy unit `xml:"heavy"`
|
|
Ram unit `xml:"ram"`
|
|
Catapult unit `xml:"catapult"`
|
|
Knight unit `xml:"knight"`
|
|
Snob unit `xml:"snob"`
|
|
Militia unit `xml:"militia"`
|
|
}
|
|
|
|
func (c unitConfig) toDomain() domain.UnitConfig {
|
|
return domain.UnitConfig{
|
|
Spear: c.Spear.toDomain(),
|
|
Sword: c.Sword.toDomain(),
|
|
Axe: c.Axe.toDomain(),
|
|
Archer: c.Archer.toDomain(),
|
|
Spy: c.Spy.toDomain(),
|
|
Light: c.Light.toDomain(),
|
|
Marcher: c.Marcher.toDomain(),
|
|
Heavy: c.Heavy.toDomain(),
|
|
Ram: c.Ram.toDomain(),
|
|
Catapult: c.Catapult.toDomain(),
|
|
Knight: c.Knight.toDomain(),
|
|
Snob: c.Snob.toDomain(),
|
|
Militia: c.Militia.toDomain(),
|
|
}
|
|
}
|