94 lines
2.8 KiB
Go
94 lines
2.8 KiB
Go
package desc
|
|
|
|
import (
|
|
"mongo.games.com/game/gamesrv/slotspkg/internal/exported/excel2go/structs"
|
|
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/errors"
|
|
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shell"
|
|
"sort"
|
|
)
|
|
|
|
type (
|
|
// FormationSeqDesc describes a formation of node type
|
|
FormationSeqDesc = structs.Formation
|
|
|
|
// FormationSeqsDesc describes all formation of node type
|
|
FormationSeqsDesc = []*structs.Formation
|
|
|
|
// NodeDesc describes all machine related config
|
|
NodeDesc struct {
|
|
Theme string
|
|
Category string
|
|
NodeType string
|
|
DataSet *shell.Shell
|
|
Class int64 // set when `ResetClass` called
|
|
FormationSeqsDesc FormationSeqsDesc
|
|
}
|
|
)
|
|
|
|
// NewNodeDesc gets config upgrade by player
|
|
func NewNodeDesc(theme, category, nodeType string, class int64, shell *shell.Shell) *NodeDesc {
|
|
return &NodeDesc{
|
|
Theme: theme,
|
|
Category: category,
|
|
NodeType: nodeType,
|
|
DataSet: shell,
|
|
Class: class,
|
|
}
|
|
}
|
|
|
|
func (n *NodeDesc) ExistSheet(excel string, sheet string) bool {
|
|
return n.DataSet.ExistMachineSheet(n.Theme, excel, sheet, n.Class)
|
|
}
|
|
|
|
// DefaultSheet gets default machine config by excel name
|
|
func (n *NodeDesc) DefaultSheet(excel string) interface{} {
|
|
return n.DataSet.GetMachineDefaultSheet(n.Theme, excel, n.Class)
|
|
}
|
|
|
|
// Sheet gets machine config by excel name & sheet name
|
|
func (n *NodeDesc) Sheet(excel string, sheet string) interface{} {
|
|
return n.DataSet.GetMachineSheet(n.Theme, excel, sheet, n.Class)
|
|
}
|
|
|
|
// Sheet gets machine config by excel name & sheet name
|
|
func (n *NodeDesc) KeySheet(excel string, sheet string, keyName string) interface{} {
|
|
return n.DataSet.GetMachineKeySheet(n.Theme, excel, sheet, n.Class, keyName)
|
|
}
|
|
|
|
// Excel gets machine excel config by excel name
|
|
func (n *NodeDesc) Excel(excel string) map[string]interface{} {
|
|
return n.DataSet.GetMachineExcel(n.Theme, excel, n.Class)
|
|
}
|
|
|
|
// GetFormationSeqDescs gets nodeType related all formations
|
|
func (n *NodeDesc) GetFormationSeqDescs(typ string) FormationSeqsDesc {
|
|
formationSeqsDesc := make(FormationSeqsDesc, 0)
|
|
v := n.DefaultSheet("Formation")
|
|
formations, ok := v.([]*structs.Formation)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.ErrorWith(n.Theme, "Formation"))
|
|
}
|
|
seqIndexes := make(map[int]int)
|
|
var seqs []int
|
|
for idx, formation := range formations {
|
|
if formation.NodeType == typ && formation.SeqID > 0 {
|
|
seqIndexes[int(formation.SeqID)] = idx
|
|
seqs = append(seqs, int(formation.SeqID))
|
|
}
|
|
}
|
|
sort.Ints(seqs)
|
|
for _, seq := range seqs {
|
|
idx := seqIndexes[seq]
|
|
formationSeqsDesc = append(formationSeqsDesc, formations[idx])
|
|
}
|
|
return formationSeqsDesc
|
|
}
|
|
func (n *NodeDesc) GetThemeRTPModes() map[int64]*structs.MapRTPMode {
|
|
v := n.Sheet("Map", "RTPMode")
|
|
rtpModeRows, ok := v.(map[int64]*structs.MapRTPMode)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.ErrorWith(n.Theme, "Map", "RTPMode"))
|
|
}
|
|
return rtpModeRows
|
|
}
|