lawless/server/internal/domain/realm.go

174 行
3.4 KiB
Go

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

// Package domain 定义境界/渡劫/破界相关的领域常量与通用计算。
package domain
import "fmt"
const (
// 角色境界状态
RealmStatusNormal = "normal"
RealmStatusTribulationPending = "tribulation_pending"
RealmStatusBreakthroughReady = "breakthrough_ready"
// 渡劫类型
TribulationTypeNormal = "normal"
TribulationTypeHeartDevil = "heart_devil"
TribulationTypeQiDeviation = "qi_deviation"
TribulationTypeChaos = "chaos"
TribulationTypeHeti = "heti"
// 渡劫结果
TribulationResultSuccess = "success"
TribulationResultFail = "fail"
TribulationResultBacklash = "backlash"
TribulationResultDeath = "death"
TribulationResultPending = "pending"
// 突破记录来源/目标状态
BreakthroughSourceWorldTierKey = "source_world_tier"
BreakthroughTargetWorldTierKey = "target_world_tier"
)
var (
// RealmNames 大境界名称
RealmNames = map[int32]string{
1: "炼气期",
2: "筑基期",
3: "金丹期",
4: "元婴期",
5: "化神期",
6: "合体期",
}
// MinorRealmNames 小境界名称
MinorRealmNames = map[int32]string{
1: "初期",
2: "中期",
3: "圆满",
}
)
// RealmFullName 返回完整境界名,如 "筑基期·中期"。
func RealmFullName(tier, minor int32) string {
name := RealmNames[tier]
if name == "" {
name = "未知境界"
}
minorName := MinorRealmNames[minor]
if minorName == "" {
minorName = "未知"
}
return fmt.Sprintf("%s·%s", name, minorName)
}
// ExpConfigKey 返回当前小境界升级到下一小境界所需修为的 Nacos 配置键。
func ExpConfigKey(tier, minor int32) string {
return fmt.Sprintf("realm.exp.l%d_m%d_to_next", tier, minor)
}
// DefaultExpToNext 当 Nacos 未配置时使用的默认修为阈值。
// 数值按境界指数放大,同一境界内中期→圆满显著高于初期→中期。
func DefaultExpToNext(tier, minor int32) int64 {
var base int64
switch tier {
case 1:
base = 1000
case 2:
base = 5000
case 3:
base = 25000
case 4:
base = 120000
case 5:
base = 600000
case 6:
base = 3000000
default:
base = 1000
}
switch minor {
case 1:
return base
case 2:
return base * 5 / 2
case 3:
return base * 10
default:
return base
}
}
// TribulationBaseRateKey 返回渡劫基础成功率配置键。
// isBig 为 true 表示大境界渡劫圆满→下境初期,false 表示层内小境界突破。
func TribulationBaseRateKey(tier int32, isBig bool) string {
if isBig {
return fmt.Sprintf("tribulation.base_rate_l%d_big", tier)
}
return fmt.Sprintf("tribulation.base_rate_l%d_small", tier)
}
// DefaultTribulationBaseRate 默认渡劫基础成功率。
func DefaultTribulationBaseRate(tier int32, isBig bool) float64 {
if isBig {
switch tier {
case 2:
return 0.55
case 3:
return 0.50
case 4:
return 0.45
case 5:
return 0.40
case 6:
return 0.35
}
return 0.50
}
switch tier {
case 2:
return 0.70
case 3:
return 0.65
case 4:
return 0.60
case 5:
return 0.55
case 6:
return 0.50
}
return 1.0
}
// ThunderLayerCoef 雷劫境界系数。
func ThunderLayerCoef(tier int32) float64 {
switch tier {
case 2:
return 1.0
case 3:
return 1.2
case 4:
return 1.5
case 5:
return 1.8
case 6:
return 2.2
}
return 1.0
}
// FireLayerCoef 业火境界系数。
func FireLayerCoef(tier int32) float64 {
switch tier {
case 2:
return 1.0
case 3:
return 1.3
case 4:
return 1.6
case 5:
return 2.0
case 6:
return 2.5
}
return 1.0
}