Add authentication server, dev CLI, Docker multi-service setup, and cross-platform improvements

This commit is contained in:
Ilya Groshev
2026-04-21 16:49:44 +03:00
parent 43d6527b42
commit a3fbb1aeba
121 changed files with 4523 additions and 2888 deletions
+15 -64
View File
@@ -8,96 +8,47 @@ import (
"lunar-tear/server/internal/utils"
)
type ShopItemRow struct {
ShopItemId int32 `json:"ShopItemId"`
PriceType int32 `json:"PriceType"`
PriceId int32 `json:"PriceId"`
Price int32 `json:"Price"`
ShopItemLimitedStockId int32 `json:"ShopItemLimitedStockId"`
}
type ShopContentRow struct {
ShopItemId int32 `json:"ShopItemId"`
PossessionType int32 `json:"PossessionType"`
PossessionId int32 `json:"PossessionId"`
Count int32 `json:"Count"`
}
type ShopContentEffectRow struct {
ShopItemId int32 `json:"ShopItemId"`
EffectTargetType int32 `json:"EffectTargetType"`
EffectValueType int32 `json:"EffectValueType"`
EffectValue int32 `json:"EffectValue"`
}
type shopItemLimitedStockRow struct {
ShopItemLimitedStockId int32 `json:"ShopItemLimitedStockId"`
MaxCount int32 `json:"MaxCount"`
}
type shopRow struct {
ShopId int32 `json:"ShopId"`
ShopGroupType int32 `json:"ShopGroupType"`
ShopItemCellGroupId int32 `json:"ShopItemCellGroupId"`
}
type shopItemCellGroupRow struct {
ShopItemCellGroupId int32 `json:"ShopItemCellGroupId"`
ShopItemCellId int32 `json:"ShopItemCellId"`
SortOrder int32 `json:"SortOrder"`
}
type shopItemCellRow struct {
ShopItemCellId int32 `json:"ShopItemCellId"`
ShopItemId int32 `json:"ShopItemId"`
}
type ExchangeShopCell struct {
SortOrder int32
ShopItemId int32
}
type ShopCatalog struct {
Items map[int32]ShopItemRow
Contents map[int32][]ShopContentRow
Effects map[int32][]ShopContentEffectRow
Items map[int32]EntityMShopItem
Contents map[int32][]EntityMShopItemContentPossession
Effects map[int32][]EntityMShopItemContentEffect
MaxStaminaMillis map[int32]int32 // level -> max stamina in millis
LimitedStock map[int32]int32 // stock id -> max count
ItemShopPool []int32 // shop item IDs for the replaceable item shop, sorted by cell sort order
ExchangeShopCells map[int32][]ExchangeShopCell // shopId -> sorted cells for exchange shops
}
type userLevelEntry struct {
UserLevel int32 `json:"UserLevel"`
MaxStamina int32 `json:"MaxStamina"`
}
func LoadShopCatalog() (*ShopCatalog, error) {
items, err := utils.ReadJSON[ShopItemRow]("EntityMShopItemTable.json")
items, err := utils.ReadTable[EntityMShopItem]("m_shop_item")
if err != nil {
return nil, fmt.Errorf("load shop item table: %w", err)
}
contents, err := utils.ReadJSON[ShopContentRow]("EntityMShopItemContentPossessionTable.json")
contents, err := utils.ReadTable[EntityMShopItemContentPossession]("m_shop_item_content_possession")
if err != nil {
return nil, fmt.Errorf("load shop content possession table: %w", err)
}
effects, err := utils.ReadJSON[ShopContentEffectRow]("EntityMShopItemContentEffectTable.json")
effects, err := utils.ReadTable[EntityMShopItemContentEffect]("m_shop_item_content_effect")
if err != nil {
return nil, fmt.Errorf("load shop content effect table: %w", err)
}
userLevels, err := utils.ReadJSON[userLevelEntry]("EntityMUserLevelTable.json")
userLevels, err := utils.ReadTable[EntityMUserLevel]("m_user_level")
if err != nil {
return nil, fmt.Errorf("load user level table: %w", err)
}
stockRows, err := utils.ReadJSON[shopItemLimitedStockRow]("EntityMShopItemLimitedStockTable.json")
stockRows, err := utils.ReadTable[EntityMShopItemLimitedStock]("m_shop_item_limited_stock")
if err != nil {
return nil, fmt.Errorf("load shop item limited stock table: %w", err)
}
catalog := &ShopCatalog{
Items: make(map[int32]ShopItemRow, len(items)),
Contents: make(map[int32][]ShopContentRow, len(contents)),
Effects: make(map[int32][]ShopContentEffectRow, len(effects)),
Items: make(map[int32]EntityMShopItem, len(items)),
Contents: make(map[int32][]EntityMShopItemContentPossession, len(contents)),
Effects: make(map[int32][]EntityMShopItemContentEffect, len(effects)),
MaxStaminaMillis: make(map[int32]int32, len(userLevels)),
LimitedStock: make(map[int32]int32, len(stockRows)),
}
@@ -117,15 +68,15 @@ func LoadShopCatalog() (*ShopCatalog, error) {
catalog.LimitedStock[row.ShopItemLimitedStockId] = row.MaxCount
}
shops, err := utils.ReadJSON[shopRow]("EntityMShopTable.json")
shops, err := utils.ReadTable[EntityMShop]("m_shop")
if err != nil {
return nil, fmt.Errorf("load shop table: %w", err)
}
cellGroups, err := utils.ReadJSON[shopItemCellGroupRow]("EntityMShopItemCellGroupTable.json")
cellGroups, err := utils.ReadTable[EntityMShopItemCellGroup]("m_shop_item_cell_group")
if err != nil {
return nil, fmt.Errorf("load shop item cell group table: %w", err)
}
cells, err := utils.ReadJSON[shopItemCellRow]("EntityMShopItemCellTable.json")
cells, err := utils.ReadTable[EntityMShopItemCell]("m_shop_item_cell")
if err != nil {
return nil, fmt.Errorf("load shop item cell table: %w", err)
}
@@ -135,7 +86,7 @@ func LoadShopCatalog() (*ShopCatalog, error) {
cellIdToItemId[c.ShopItemCellId] = c.ShopItemId
}
cellGroupByCGId := make(map[int32][]shopItemCellGroupRow, len(cellGroups))
cellGroupByCGId := make(map[int32][]EntityMShopItemCellGroup, len(cellGroups))
for _, cg := range cellGroups {
cellGroupByCGId[cg.ShopItemCellGroupId] = append(cellGroupByCGId[cg.ShopItemCellGroupId], cg)
}