115 lines
1.6 KiB
Go
115 lines
1.6 KiB
Go
package domain
|
|
|
|
type Unit struct {
|
|
BuildTime float64
|
|
Pop int
|
|
Speed float64
|
|
Attack int
|
|
Defense int
|
|
DefenseCavalry int
|
|
DefenseArcher int
|
|
Carry int
|
|
}
|
|
|
|
type UnitInfo struct {
|
|
spear Unit
|
|
sword Unit
|
|
axe Unit
|
|
archer Unit
|
|
spy Unit
|
|
light Unit
|
|
marcher Unit
|
|
heavy Unit
|
|
ram Unit
|
|
catapult Unit
|
|
knight Unit
|
|
snob Unit
|
|
militia Unit
|
|
}
|
|
|
|
type NullUnitInfo = NullValue[UnitInfo]
|
|
|
|
func NewUnitInfo(
|
|
spear Unit,
|
|
sword Unit,
|
|
axe Unit,
|
|
archer Unit,
|
|
spy Unit,
|
|
light Unit,
|
|
marcher Unit,
|
|
heavy Unit,
|
|
ram Unit,
|
|
catapult Unit,
|
|
knight Unit,
|
|
snob Unit,
|
|
militia Unit,
|
|
) (UnitInfo, error) {
|
|
return UnitInfo{
|
|
spear: spear,
|
|
sword: sword,
|
|
axe: axe,
|
|
archer: archer,
|
|
spy: spy,
|
|
light: light,
|
|
marcher: marcher,
|
|
heavy: heavy,
|
|
ram: ram,
|
|
catapult: catapult,
|
|
knight: knight,
|
|
snob: snob,
|
|
militia: militia,
|
|
}, nil
|
|
}
|
|
|
|
func (u UnitInfo) Spear() Unit {
|
|
return u.spear
|
|
}
|
|
|
|
func (u UnitInfo) Sword() Unit {
|
|
return u.sword
|
|
}
|
|
|
|
func (u UnitInfo) Axe() Unit {
|
|
return u.axe
|
|
}
|
|
|
|
func (u UnitInfo) Archer() Unit {
|
|
return u.archer
|
|
}
|
|
|
|
func (u UnitInfo) Spy() Unit {
|
|
return u.spy
|
|
}
|
|
|
|
func (u UnitInfo) Light() Unit {
|
|
return u.light
|
|
}
|
|
|
|
func (u UnitInfo) Marcher() Unit {
|
|
return u.marcher
|
|
}
|
|
|
|
func (u UnitInfo) Heavy() Unit {
|
|
return u.heavy
|
|
}
|
|
|
|
func (u UnitInfo) Ram() Unit {
|
|
return u.ram
|
|
}
|
|
|
|
func (u UnitInfo) Catapult() Unit {
|
|
return u.catapult
|
|
}
|
|
|
|
func (u UnitInfo) Knight() Unit {
|
|
return u.knight
|
|
}
|
|
|
|
func (u UnitInfo) Snob() Unit {
|
|
return u.snob
|
|
}
|
|
|
|
func (u UnitInfo) Militia() Unit {
|
|
return u.militia
|
|
}
|