randomly generated seasons

This commit is contained in:
wish
2022-07-17 04:39:40 +10:00
parent 3f82259583
commit b0b39eb4f8

View File

@@ -6,6 +6,7 @@ import (
"os/signal" "os/signal"
"syscall" "syscall"
"time" "time"
"math/rand"
"erupe-ce/config" "erupe-ce/config"
"erupe-ce/server/channelserver" "erupe-ce/server/channelserver"
@@ -146,6 +147,9 @@ func main() {
ci := 0 ci := 0
count := 1 count := 1
for _, ee := range erupeConfig.Entrance.Entries { for _, ee := range erupeConfig.Entrance.Entries {
rand.Seed(time.Now().UnixNano())
// Randomly generate a season for the World
season := rand.Intn(3)+1
for _, ce := range ee.Channels { for _, ce := range ee.Channels {
sid := (4096 + si * 256) + (16 + ci) sid := (4096 + si * 256) + (16 + ci)
c := *channelserver.NewServer(&channelserver.Config{ c := *channelserver.NewServer(&channelserver.Config{
@@ -159,7 +163,7 @@ func main() {
if err != nil { if err != nil {
logger.Fatal("Failed to start channel", zap.Error(err)) logger.Fatal("Failed to start channel", zap.Error(err))
} else { } else {
channelQuery += fmt.Sprintf("INSERT INTO servers (server_id, season, current_players) VALUES (%d, 0, 0);", sid) channelQuery += fmt.Sprintf("INSERT INTO servers (server_id, season, current_players) VALUES (%d, %d, 0);", sid, season)
channels = append(channels, c) channels = append(channels, c)
logger.Info(fmt.Sprintf("Started channel server %d on port %d", count, ce.Port)) logger.Info(fmt.Sprintf("Started channel server %d on port %d", count, ce.Port))
ci++ ci++