core/internal/tw/server_config.go

187 lines
5.9 KiB
Go
Raw Normal View History

2023-12-15 07:16:51 +00:00
package tw
import (
"encoding/xml"
"fmt"
"strings"
)
type ServerConfigBuild struct {
Destroy int `xml:"destroy"`
}
type ServerConfigMisc struct {
KillRanking int `xml:"kill_ranking"`
TradeCancelTime int `xml:"trade_cancel_time"`
2024-02-10 12:28:41 +00:00
Tutorial int `xml:"tutorial"`
2023-12-15 07:16:51 +00:00
}
type ServerConfigCommands struct {
CommandCancelTime int `xml:"command_cancel_time"`
2024-02-10 12:28:41 +00:00
MillisArrival int `xml:"millis_arrival"`
2023-12-15 07:16:51 +00:00
}
type ServerConfigNewbie struct {
Days int `xml:"days"`
Ratio int `xml:"ratio"`
2024-02-10 12:28:41 +00:00
RatioDays int `xml:"ratio_days"`
2023-12-15 07:16:51 +00:00
RemoveNewbieVillages int `xml:"removeNewbieVillages"`
}
type KnightNewItems int
func (k KnightNewItems) Int() int {
return int(k)
}
func (k *KnightNewItems) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var s string
if err := d.DecodeElement(&s, &start); err != nil {
return err
}
switch strings.ToUpper(s) {
case "ON", "1":
*k = 1
case "OFF", "0", "":
*k = 0
default:
return xml.UnmarshalError(fmt.Sprintf(`KnightNewItems: parsing "%s": invalid syntax`, s))
}
return nil
}
type ServerConfigGame struct {
Archer int `xml:"archer"`
2024-02-10 12:28:41 +00:00
BarbarianMaxPoints int `xml:"barbarian_max_points"`
2023-12-15 07:16:51 +00:00
BarbarianRise float64 `xml:"barbarian_rise"`
BarbarianShrink int `xml:"barbarian_shrink"`
2024-02-10 12:28:41 +00:00
BaseProduction int `xml:"base_production"`
BuildtimeFormula int `xml:"buildtime_formula"`
Church int `xml:"church"`
Event int `xml:"event"`
FakeLimit float64 `xml:"fake_limit"`
FarmLimit int `xml:"farm_limit"`
2023-12-15 07:16:51 +00:00
Hauls int `xml:"hauls"`
HaulsBase int `xml:"hauls_base"`
HaulsMax int `xml:"hauls_max"`
2024-02-10 12:28:41 +00:00
Knight int `xml:"knight"`
KnightNewItems KnightNewItems `xml:"knight_new_items"`
Scavenging int `xml:"scavenging"`
Stronghold int `xml:"stronghold"`
2023-12-15 07:16:51 +00:00
SuppressEvents int `xml:"suppress_events"`
2024-02-10 12:28:41 +00:00
Tech int `xml:"tech"`
Watchtower int `xml:"watchtower"`
2023-12-15 07:16:51 +00:00
}
type ServerConfigBuildings struct {
CustomBarracks int `xml:"custom_barracks"`
CustomChurch int `xml:"custom_church"`
2024-02-10 12:28:41 +00:00
CustomFarm int `xml:"custom_farm"`
2023-12-15 07:16:51 +00:00
CustomGarage int `xml:"custom_garage"`
CustomHide int `xml:"custom_hide"`
2024-02-10 12:28:41 +00:00
CustomIron int `xml:"custom_iron"`
CustomMain int `xml:"custom_main"`
CustomMarket int `xml:"custom_market"`
CustomPlace int `xml:"custom_place"`
CustomSmith int `xml:"custom_smith"`
2023-12-15 07:16:51 +00:00
CustomSnob int `xml:"custom_snob"`
2024-02-10 12:28:41 +00:00
CustomStable int `xml:"custom_stable"`
2023-12-15 07:16:51 +00:00
CustomStatue int `xml:"custom_statue"`
2024-02-10 12:28:41 +00:00
CustomStone int `xml:"custom_stone"`
CustomStorage int `xml:"custom_storage"`
CustomWall int `xml:"custom_wall"`
2023-12-15 07:16:51 +00:00
CustomWatchtower int `xml:"custom_watchtower"`
2024-02-10 12:28:41 +00:00
CustomWood int `xml:"custom_wood"`
2023-12-15 07:16:51 +00:00
}
type ServerConfigSnob struct {
CheapRebuild int `xml:"cheap_rebuild"`
CoinIron int `xml:"coin_iron"`
2024-02-10 12:28:41 +00:00
CoinStone int `xml:"coin_stone"`
CoinWood int `xml:"coin_wood"`
Factor float64 `xml:"factor"`
Gold int `xml:"gold"`
MaxDist int `xml:"max_dist"`
2023-12-15 07:16:51 +00:00
NoBarbConquer int `xml:"no_barb_conquer"`
2024-02-10 12:28:41 +00:00
Rise int `xml:"rise"`
2023-12-15 07:16:51 +00:00
}
type ServerConfigAlly struct {
2024-02-10 12:28:41 +00:00
AllytimeSupport int `xml:"allytime_support"`
FixedAllies int `xml:"fixed_allies"`
Levels int `xml:"levels"`
Limit int `xml:"limit"`
2023-12-15 07:16:51 +00:00
NoHarm int `xml:"no_harm"`
2024-02-10 12:28:41 +00:00
NoJoin int `xml:"no_join"`
NoLeave int `xml:"no_leave"`
2023-12-15 07:16:51 +00:00
NoOtherSupport int `xml:"no_other_support"`
NoOtherSupportType int `xml:"no_other_support_type"`
PointsMemberCount int `xml:"points_member_count"`
2024-02-10 12:28:41 +00:00
WarsAutoacceptDays int `xml:"wars_autoaccept_days"`
2023-12-15 07:16:51 +00:00
WarsMemberRequirement int `xml:"wars_member_requirement"`
WarsPointsRequirement int `xml:"wars_points_requirement"`
XpRequirements string `xml:"xp_requirements"`
}
type ServerConfigCoord struct {
BonusNew int `xml:"bonus_new"`
2024-02-10 12:28:41 +00:00
BonusVillages int `xml:"bonus_villages"`
EmptyVillages int `xml:"empty_villages"`
Func int `xml:"func"`
2023-12-15 07:16:51 +00:00
Inner int `xml:"inner"`
2024-02-10 12:28:41 +00:00
MapSize int `xml:"map_size"`
2023-12-15 07:16:51 +00:00
NobleRestart int `xml:"noble_restart"`
2024-02-10 12:28:41 +00:00
SelectStart int `xml:"select_start"`
2023-12-15 07:16:51 +00:00
StartVillages int `xml:"start_villages"`
2024-02-10 12:28:41 +00:00
VillageMoveWait int `xml:"village_move_wait"`
2023-12-15 07:16:51 +00:00
}
type ServerConfigSitter struct {
Allow int `xml:"allow"`
}
type ServerConfigSleep struct {
Active int `xml:"active"`
Delay int `xml:"delay"`
Max int `xml:"max"`
MaxAwake int `xml:"max_awake"`
2024-02-10 12:28:41 +00:00
Min int `xml:"min"`
MinAwake int `xml:"min_awake"`
2023-12-15 07:16:51 +00:00
WarnTime int `xml:"warn_time"`
}
type ServerConfigNight struct {
Active int `xml:"active"`
DefFactor float64 `xml:"def_factor"`
Duration int `xml:"duration"`
2024-02-10 12:28:41 +00:00
EndHour int `xml:"end_hour"`
StartHour int `xml:"start_hour"`
2023-12-15 07:16:51 +00:00
}
type ServerConfigWin struct {
Check int `xml:"check"`
}
type ServerConfig struct {
XMLName xml.Name `xml:"config"`
Speed float64 `xml:"speed"`
UnitSpeed float64 `xml:"unit_speed"`
Moral int `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"`
}