Dawid Wysokiński
2639976eb8
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: twhelp/core#26
355 lines
11 KiB
Go
355 lines
11 KiB
Go
package tw
|
|
|
|
import (
|
|
"encoding/xml"
|
|
|
|
"gitea.dwysokinski.me/twhelp/core/internal/domain"
|
|
)
|
|
|
|
type serverConfigBuild struct {
|
|
Text string `xml:",chardata"`
|
|
Destroy int8 `xml:"destroy"`
|
|
}
|
|
|
|
func (b serverConfigBuild) toDomain() domain.ServerConfigBuild {
|
|
return domain.ServerConfigBuild{
|
|
Destroy: b.Destroy,
|
|
}
|
|
}
|
|
|
|
type serverConfigMisc struct {
|
|
Text string `xml:",chardata"`
|
|
KillRanking int8 `xml:"kill_ranking"`
|
|
Tutorial int8 `xml:"tutorial"`
|
|
TradeCancelTime int16 `xml:"trade_cancel_time"`
|
|
}
|
|
|
|
func (m serverConfigMisc) toDomain() domain.ServerConfigMisc {
|
|
return domain.ServerConfigMisc{
|
|
KillRanking: m.KillRanking,
|
|
Tutorial: m.Tutorial,
|
|
TradeCancelTime: m.TradeCancelTime,
|
|
}
|
|
}
|
|
|
|
type serverConfigCommands struct {
|
|
Text string `xml:",chardata"`
|
|
MillisArrival int16 `xml:"millis_arrival"`
|
|
CommandCancelTime int16 `xml:"command_cancel_time"`
|
|
}
|
|
|
|
func (c serverConfigCommands) toDomain() domain.ServerConfigCommands {
|
|
return domain.ServerConfigCommands{
|
|
MillisArrival: c.MillisArrival,
|
|
CommandCancelTime: c.CommandCancelTime,
|
|
}
|
|
}
|
|
|
|
type serverConfigNewbie struct {
|
|
Text string `xml:",chardata"`
|
|
Days int16 `xml:"days"`
|
|
RatioDays int16 `xml:"ratio_days"`
|
|
Ratio int16 `xml:"ratio"`
|
|
RemoveNewbieVillages int8 `xml:"removeNewbieVillages"`
|
|
}
|
|
|
|
func (n serverConfigNewbie) toDomain() domain.ServerConfigNewbie {
|
|
return domain.ServerConfigNewbie{
|
|
Days: n.Days,
|
|
RatioDays: n.RatioDays,
|
|
Ratio: n.Ratio,
|
|
RemoveNewbieVillages: n.RemoveNewbieVillages,
|
|
}
|
|
}
|
|
|
|
type serverConfigGame struct {
|
|
Text string `xml:",chardata"`
|
|
BuildtimeFormula int8 `xml:"buildtime_formula"`
|
|
Knight int8 `xml:"knight"`
|
|
KnightNewItems int8 `xml:"knight_new_items"`
|
|
Archer int8 `xml:"archer"`
|
|
Tech int8 `xml:"tech"`
|
|
FarmLimit int32 `xml:"farm_limit"`
|
|
Church int8 `xml:"church"`
|
|
Watchtower int8 `xml:"watchtower"`
|
|
Stronghold int8 `xml:"stronghold"`
|
|
FakeLimit float64 `xml:"fake_limit"`
|
|
BarbarianRise float64 `xml:"barbarian_rise"`
|
|
BarbarianShrink int8 `xml:"barbarian_shrink"`
|
|
BarbarianMaxPoints int32 `xml:"barbarian_max_points"`
|
|
Hauls int8 `xml:"hauls"`
|
|
HaulsBase int32 `xml:"hauls_base"`
|
|
HaulsMax int32 `xml:"hauls_max"`
|
|
BaseProduction int32 `xml:"base_production"`
|
|
Event int16 `xml:"event"`
|
|
SuppressEvents int8 `xml:"suppress_events"`
|
|
}
|
|
|
|
func (g serverConfigGame) toDomain() domain.ServerConfigGame {
|
|
return domain.ServerConfigGame{
|
|
BuildtimeFormula: g.BuildtimeFormula,
|
|
Knight: g.Knight,
|
|
KnightNewItems: g.KnightNewItems,
|
|
Archer: g.Archer,
|
|
Tech: g.Tech,
|
|
FarmLimit: g.FarmLimit,
|
|
Church: g.Church,
|
|
Watchtower: g.Watchtower,
|
|
Stronghold: g.Stronghold,
|
|
FakeLimit: g.FakeLimit,
|
|
BarbarianRise: g.BarbarianRise,
|
|
BarbarianShrink: g.BarbarianShrink,
|
|
BarbarianMaxPoints: g.BarbarianMaxPoints,
|
|
Hauls: g.Hauls,
|
|
HaulsBase: g.HaulsBase,
|
|
HaulsMax: g.HaulsMax,
|
|
BaseProduction: g.BaseProduction,
|
|
Event: g.Event,
|
|
SuppressEvents: g.SuppressEvents,
|
|
}
|
|
}
|
|
|
|
type serverConfigBuildings struct {
|
|
Text string `xml:",chardata"`
|
|
CustomMain int8 `xml:"custom_main"`
|
|
CustomFarm int8 `xml:"custom_farm"`
|
|
CustomStorage int8 `xml:"custom_storage"`
|
|
CustomPlace int8 `xml:"custom_place"`
|
|
CustomBarracks int8 `xml:"custom_barracks"`
|
|
CustomChurch int8 `xml:"custom_church"`
|
|
CustomSmith int8 `xml:"custom_smith"`
|
|
CustomWood int8 `xml:"custom_wood"`
|
|
CustomStone int8 `xml:"custom_stone"`
|
|
CustomIron int8 `xml:"custom_iron"`
|
|
CustomMarket int8 `xml:"custom_market"`
|
|
CustomStable int8 `xml:"custom_stable"`
|
|
CustomWall int8 `xml:"custom_wall"`
|
|
CustomGarage int8 `xml:"custom_garage"`
|
|
CustomHide int8 `xml:"custom_hide"`
|
|
CustomSnob int8 `xml:"custom_snob"`
|
|
CustomStatue int8 `xml:"custom_statue"`
|
|
CustomWatchtower int8 `xml:"custom_watchtower"`
|
|
}
|
|
|
|
func (b serverConfigBuildings) toDomain() domain.ServerConfigBuildings {
|
|
return domain.ServerConfigBuildings{
|
|
CustomMain: b.CustomMain,
|
|
CustomFarm: b.CustomFarm,
|
|
CustomStorage: b.CustomStorage,
|
|
CustomPlace: b.CustomPlace,
|
|
CustomBarracks: b.CustomBarracks,
|
|
CustomChurch: b.CustomChurch,
|
|
CustomSmith: b.CustomSmith,
|
|
CustomWood: b.CustomWood,
|
|
CustomStone: b.CustomStone,
|
|
CustomIron: b.CustomIron,
|
|
CustomMarket: b.CustomMarket,
|
|
CustomStable: b.CustomStable,
|
|
CustomWall: b.CustomWall,
|
|
CustomGarage: b.CustomGarage,
|
|
CustomHide: b.CustomHide,
|
|
CustomSnob: b.CustomSnob,
|
|
CustomStatue: b.CustomStatue,
|
|
CustomWatchtower: b.CustomWatchtower,
|
|
}
|
|
}
|
|
|
|
type serverConfigSnob struct {
|
|
Text string `xml:",chardata"`
|
|
Gold int8 `xml:"gold"`
|
|
CheapRebuild int8 `xml:"cheap_rebuild"`
|
|
Rise int8 `xml:"rise"`
|
|
MaxDist int16 `xml:"max_dist"`
|
|
Factor float64 `xml:"factor"`
|
|
CoinWood int32 `xml:"coin_wood"`
|
|
CoinStone int32 `xml:"coin_stone"`
|
|
CoinIron int32 `xml:"coin_iron"`
|
|
NoBarbConquer int8 `xml:"no_barb_conquer"`
|
|
}
|
|
|
|
func (s serverConfigSnob) toDomain() domain.ServerConfigSnob {
|
|
return domain.ServerConfigSnob{
|
|
Gold: s.Gold,
|
|
CheapRebuild: s.CheapRebuild,
|
|
Rise: s.Rise,
|
|
MaxDist: s.MaxDist,
|
|
Factor: s.Factor,
|
|
CoinWood: s.CoinWood,
|
|
CoinStone: s.CoinStone,
|
|
CoinIron: s.CoinIron,
|
|
NoBarbConquer: s.NoBarbConquer,
|
|
}
|
|
}
|
|
|
|
type serverConfigAlly struct {
|
|
Text string `xml:",chardata"`
|
|
NoHarm int8 `xml:"no_harm"`
|
|
NoOtherSupport int8 `xml:"no_other_support"`
|
|
NoOtherSupportType int8 `xml:"no_other_support_type"`
|
|
AllytimeSupport int32 `xml:"allytime_support"`
|
|
NoLeave int8 `xml:"no_leave"`
|
|
NoJoin int8 `xml:"no_join"`
|
|
Limit int16 `xml:"limit"`
|
|
FixedAllies int8 `xml:"fixed_allies"`
|
|
PointsMemberCount int32 `xml:"points_member_count"`
|
|
WarsMemberRequirement int16 `xml:"wars_member_requirement"`
|
|
WarsPointsRequirement int32 `xml:"wars_points_requirement"`
|
|
WarsAutoacceptDays int16 `xml:"wars_autoaccept_days"`
|
|
Levels int8 `xml:"levels"`
|
|
XpRequirements string `xml:"xp_requirements"`
|
|
}
|
|
|
|
func (a serverConfigAlly) toDomain() domain.ServerConfigAlly {
|
|
return domain.ServerConfigAlly{
|
|
NoHarm: a.NoHarm,
|
|
NoOtherSupport: a.NoOtherSupport,
|
|
NoOtherSupportType: a.NoOtherSupportType,
|
|
AllytimeSupport: a.AllytimeSupport,
|
|
NoLeave: a.NoLeave,
|
|
NoJoin: a.NoJoin,
|
|
Limit: a.Limit,
|
|
FixedAllies: a.FixedAllies,
|
|
PointsMemberCount: a.PointsMemberCount,
|
|
WarsMemberRequirement: a.WarsMemberRequirement,
|
|
WarsPointsRequirement: a.WarsPointsRequirement,
|
|
WarsAutoacceptDays: a.WarsAutoacceptDays,
|
|
Levels: a.Levels,
|
|
XpRequirements: a.XpRequirements,
|
|
}
|
|
}
|
|
|
|
type serverConfigCoord struct {
|
|
Text string `xml:",chardata"`
|
|
MapSize int16 `xml:"map_size"`
|
|
Func int8 `xml:"func"`
|
|
EmptyVillages int16 `xml:"empty_villages"`
|
|
BonusVillages int16 `xml:"bonus_villages"`
|
|
BonusNew int16 `xml:"bonus_new"`
|
|
Inner int16 `xml:"inner"`
|
|
SelectStart int8 `xml:"select_start"`
|
|
VillageMoveWait int32 `xml:"village_move_wait"`
|
|
NobleRestart int8 `xml:"noble_restart"`
|
|
StartVillages int8 `xml:"start_villages"`
|
|
}
|
|
|
|
func (c serverConfigCoord) toDomain() domain.ServerConfigCoord {
|
|
return domain.ServerConfigCoord{
|
|
MapSize: c.MapSize,
|
|
Func: c.Func,
|
|
EmptyVillages: c.EmptyVillages,
|
|
BonusVillages: c.BonusVillages,
|
|
BonusNew: c.BonusNew,
|
|
Inner: c.Inner,
|
|
SelectStart: c.SelectStart,
|
|
VillageMoveWait: c.VillageMoveWait,
|
|
NobleRestart: c.NobleRestart,
|
|
StartVillages: c.StartVillages,
|
|
}
|
|
}
|
|
|
|
type serverConfigSitter struct {
|
|
Text string `xml:",chardata"`
|
|
Allow int8 `xml:"allow"`
|
|
}
|
|
|
|
func (s serverConfigSitter) toDomain() domain.ServerConfigSitter {
|
|
return domain.ServerConfigSitter{
|
|
Allow: s.Allow,
|
|
}
|
|
}
|
|
|
|
type serverConfigSleep struct {
|
|
Text string `xml:",chardata"`
|
|
Active int8 `xml:"active"`
|
|
Delay int16 `xml:"delay"`
|
|
Min int16 `xml:"min"`
|
|
Max int16 `xml:"max"`
|
|
MinAwake int16 `xml:"min_awake"`
|
|
MaxAwake int16 `xml:"max_awake"`
|
|
WarnTime int16 `xml:"warn_time"`
|
|
}
|
|
|
|
func (s serverConfigSleep) toDomain() domain.ServerConfigSleep {
|
|
return domain.ServerConfigSleep{
|
|
Active: s.Active,
|
|
Delay: s.Delay,
|
|
Min: s.Min,
|
|
Max: s.Max,
|
|
MinAwake: s.MinAwake,
|
|
MaxAwake: s.MaxAwake,
|
|
WarnTime: s.WarnTime,
|
|
}
|
|
}
|
|
|
|
type serverConfigNight struct {
|
|
Text string `xml:",chardata"`
|
|
Active int8 `xml:"active"`
|
|
StartHour int8 `xml:"start_hour"`
|
|
EndHour int8 `xml:"end_hour"`
|
|
DefFactor float64 `xml:"def_factor"`
|
|
Duration int8 `xml:"duration"`
|
|
}
|
|
|
|
func (n serverConfigNight) toDomain() domain.ServerConfigNight {
|
|
return domain.ServerConfigNight{
|
|
Active: n.Active,
|
|
StartHour: n.StartHour,
|
|
EndHour: n.EndHour,
|
|
DefFactor: n.DefFactor,
|
|
Duration: n.Duration,
|
|
}
|
|
}
|
|
|
|
type serverConfigWin struct {
|
|
Text string `xml:",chardata"`
|
|
Check int16 `xml:"check"`
|
|
}
|
|
|
|
func (w serverConfigWin) toDomain() domain.ServerConfigWin {
|
|
return domain.ServerConfigWin{
|
|
Check: w.Check,
|
|
}
|
|
}
|
|
|
|
type serverConfig struct {
|
|
XMLName xml.Name `xml:"config"`
|
|
Text string `xml:",chardata"`
|
|
Speed float64 `xml:"speed"`
|
|
UnitSpeed float64 `xml:"unit_speed"`
|
|
Moral int16 `xml:"moral"`
|
|
Build serverConfigBuild `xml:"build"`
|
|
Misc serverConfigMisc `xml:"misc"`
|
|
Commands serverConfigCommands `xml:"commands"`
|
|
Newbie serverConfigNewbie `xml:"newbie"`
|
|
Game serverConfigGame `xml:"game"`
|
|
Buildings serverConfigBuildings `xml:"buildings"`
|
|
Snob serverConfigSnob `xml:"snob"`
|
|
Ally serverConfigAlly `xml:"ally"`
|
|
Coord serverConfigCoord `xml:"coord"`
|
|
Sitter serverConfigSitter `xml:"sitter"`
|
|
Sleep serverConfigSleep `xml:"sleep"`
|
|
Night serverConfigNight `xml:"night"`
|
|
Win serverConfigWin `xml:"win"`
|
|
}
|
|
|
|
func (s serverConfig) toDomain() domain.ServerConfig {
|
|
return domain.ServerConfig{
|
|
Speed: s.Speed,
|
|
UnitSpeed: s.UnitSpeed,
|
|
Moral: s.Moral,
|
|
Build: s.Build.toDomain(),
|
|
Misc: s.Misc.toDomain(),
|
|
Commands: s.Commands.toDomain(),
|
|
Newbie: s.Newbie.toDomain(),
|
|
Game: s.Game.toDomain(),
|
|
Buildings: s.Buildings.toDomain(),
|
|
Snob: s.Snob.toDomain(),
|
|
Ally: s.Ally.toDomain(),
|
|
Coord: s.Coord.toDomain(),
|
|
Sitter: s.Sitter.toDomain(),
|
|
Sleep: s.Sleep.toDomain(),
|
|
Night: s.Night.toDomain(),
|
|
Win: s.Win.toDomain(),
|
|
}
|
|
}
|