Files
bd2/go/internal/server/gamedata/quest_difficulty.go
T
Flechazo d8771caef2 feat(all): add hunting and events, commerce and rewards, binary calendars, GameData caching and login diagnostics
Implement hunting AP and progress, event tasks, exchanges, games, stories and actions; connect battle and reward handling.

Add CashShop plugin and installation, server purchases and entitlements, recharge rules and plugin version metadata.

Distribute binary calendars independently; cache GameData in memory and fix single-connection query deadlocks.

Improve automatic login and recovery diagnostics; document configuration and release flows.
2026-10-05 11:50:31 +08:00

40 lines
1.0 KiB
Go

package gamedata
import (
"database/sql"
"fmt"
)
// LoadQuestDifficulties reads the pack-specific selectable difficulties;
// normal (zero) is the base story chain and is absent from this table.
func LoadQuestDifficulties(root, version string) (map[int]map[int]bool, error) {
db, release, err := OpenDatabase(root, version, "common")
if err != nil {
return nil, err
}
defer release()
return loadQuestDifficultiesDB(db)
}
func loadQuestDifficultiesDB(db *sql.DB) (map[int]map[int]bool, error) {
rows, err := db.Query("SELECT groupId,id FROM QuestDifficultyTable ORDER BY groupId,id")
if err != nil {
return nil, err
}
defer rows.Close()
result := map[int]map[int]bool{}
for rows.Next() {
var pack, level int
if err := rows.Scan(&pack, &level); err != nil {
return nil, err
}
if pack <= 0 || level < 1 || level > 4 {
return nil, fmt.Errorf("gamedata: invalid difficulty pack%d level%d", pack, level)
}
if result[pack] == nil {
result[pack] = map[int]bool{0: true}
}
result[pack][level] = true
}
return result, rows.Err()
}