2023-03-09 07:48:13 +00:00
|
|
|
package config
|
|
|
|
|
2023-06-22 06:53:38 +00:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
/*
|
|
|
|
Available environment variables:
|
|
|
|
REDIS_ADDR
|
|
|
|
REDIS_USER
|
|
|
|
REDIS_PASS
|
|
|
|
DB_ADDR
|
|
|
|
DB_USER
|
|
|
|
DB_PASS
|
|
|
|
ANNOUNCE_IP
|
2023-06-27 05:36:02 +00:00
|
|
|
TDATA_PATH
|
2023-06-22 06:53:38 +00:00
|
|
|
*/
|
|
|
|
|
2023-03-22 05:30:58 +00:00
|
|
|
const (
|
|
|
|
AEQUIP_COUNT = 9
|
|
|
|
AINVEN_COUNT = 50
|
|
|
|
ABANK_COUNT = 119
|
|
|
|
|
|
|
|
NANO_COUNT = 37
|
|
|
|
)
|
|
|
|
|
2023-03-09 07:48:13 +00:00
|
|
|
var (
|
|
|
|
SPAWN_X = 632032
|
|
|
|
SPAWN_Y = 187177
|
|
|
|
SPAWN_Z = -5500
|
|
|
|
|
2023-03-17 21:27:47 +00:00
|
|
|
LOGIN_PORT = 23000
|
|
|
|
SHARD_PORT = 23001
|
2023-06-22 06:53:38 +00:00
|
|
|
|
|
|
|
LOGIN_TIMEOUT = time.Second * 30
|
2023-06-25 06:51:21 +00:00
|
|
|
VIEW_DISTANCE = 25600
|
2023-03-09 07:48:13 +00:00
|
|
|
)
|
|
|
|
|
2023-06-22 06:53:38 +00:00
|
|
|
func getEnv(key string, fallback string) string {
|
|
|
|
if value, ok := os.LookupEnv(key); ok {
|
|
|
|
return value
|
|
|
|
}
|
|
|
|
|
|
|
|
return fallback
|
|
|
|
}
|
|
|
|
|
2023-03-09 07:48:13 +00:00
|
|
|
func GetMaxHP(level int) int {
|
|
|
|
return (925 + 75*(level))
|
|
|
|
}
|
2023-06-22 06:53:38 +00:00
|
|
|
|
|
|
|
func GetRedisAddr() string {
|
|
|
|
return getEnv("REDIS_ADDR", "localhost:6379")
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetRedisCredentials() func() (string, string) {
|
|
|
|
return func() (string, string) {
|
|
|
|
return getEnv("REDIS_USER", ""), getEnv("REDIS_PASS", "")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetDBName() string {
|
|
|
|
return getEnv("DB_NAME", "postgres")
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetDBAddr() string {
|
|
|
|
return getEnv("DB_ADDR", "localhost:5432")
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetDBUser() string {
|
|
|
|
return getEnv("DB_USER", "postgres")
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetDBPass() string {
|
|
|
|
return getEnv("DB_PASS", "")
|
|
|
|
}
|
|
|
|
|
|
|
|
// needed for shard
|
|
|
|
func GetAnnounceIP() string {
|
|
|
|
return getEnv("ANNOUNCE_IP", "127.0.0.1")
|
|
|
|
}
|
2023-06-27 05:36:02 +00:00
|
|
|
|
|
|
|
func GetTDataPath() string {
|
|
|
|
return getEnv("TDATA_PATH", "./tdata")
|
|
|
|
}
|