Dawid Wysokiński
742a9046e0
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: twhelp/core#16
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 unitInfo 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 (u unitInfo) toDomain() domain.UnitInfo {
|
|
return domain.UnitInfo{
|
|
Spear: u.Spear.toDomain(),
|
|
Sword: u.Sword.toDomain(),
|
|
Axe: u.Axe.toDomain(),
|
|
Archer: u.Archer.toDomain(),
|
|
Spy: u.Spy.toDomain(),
|
|
Light: u.Light.toDomain(),
|
|
Marcher: u.Marcher.toDomain(),
|
|
Heavy: u.Heavy.toDomain(),
|
|
Ram: u.Ram.toDomain(),
|
|
Catapult: u.Catapult.toDomain(),
|
|
Knight: u.Knight.toDomain(),
|
|
Snob: u.Snob.toDomain(),
|
|
Militia: u.Militia.toDomain(),
|
|
}
|
|
}
|