优化代码结构

This commit is contained in:
源文雨
2023-02-01 15:03:05 +08:00
parent b6ce9f7b2e
commit 93625f9c4f
2 changed files with 23 additions and 17 deletions

View File

@@ -26,9 +26,7 @@ type world struct {
hassync uintptr
}
var (
gameWorld world
)
var gameWorld = newworld()
// String 根据传入的世界编号,获取对应的游戏时间文本
func (t *timezone) String() string {
@@ -49,6 +47,15 @@ func (t *timezone) String() string {
return sb.String()
}
func newworld() (w world) {
w.w = [3]*timezone{
{Name: "地球平原", DayDesc: "白天", NightDesc: "夜晚", DayLen: 100 * 60, NightLen: 50 * 60},
{Name: "金星平原", DayDesc: "温暖", NightDesc: "寒冷", DayLen: 400, NightLen: 20 * 60},
{Name: "火卫二平原", DayDesc: "fass", NightDesc: "vome", DayLen: 100 * 60, NightLen: 50 * 60},
}
return
}
func (w *world) hasSync() bool {
return atomic.LoadUintptr(&w.hassync) != 0
}