123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- package model
- import (
- "fmt"
- "math"
- )
- const (
- MaterilaId_Coin = 2001 // 金币道具id
- MaterilaId_Diamond = 2002 // 钻石道具id
- CommonHeroTicket = 4301 // 普通抽奖劵
- MythHeroTicket = 4401 // 神话抽奖劵
- TreasuresTicket = 4501 // 宝物抽奖劵
- HeroCoin = 5301 // 英雄金币
- )
- const (
- LoginPlatAccount = "h5"
- LoginPlatWeiXin = "wx"
- LoginPlatQQ = "qq"
- LoginPlatTouTiao = "tt"
- LoginPlatMgc = "mt"
- LoginPlatQuick = "QuickSDK"
- )
- const (
- CostSourceFortLevel = 1 //联盟升级
- CostSourceEnterChapter = 2 //进入章节
- CostSourcePartRuneLevel = 3 //符文升级
- CostSourcePartRuneRecast = 4 //符文重铸
- CostSourceHeroLevel = 5 //英雄升级
- CostSourceTreasureLevel = 6 //宝物升级
- CostSourceTreasureStar = 7 //宝物升星
- CostSourceHeroRecruit = 8 //英雄招募
- CostSourceTreasureRecruit = 9 //宝物招募
- CostSourceEpigraphRecruit = 10 //铭文招募
- CostSourcePointsRecruit = 11 //积分招募
- CostSourceRuneDisintegration = 12 //符文分解
- CostSourceHeroBuy = 13 //购买英雄
- CostSourceHeroSkinActive = 14 //英雄皮肤兑换
- CostSourceAdmin = 15 //后台添加
- CostItemBuy = 16 //游戏货币购买道具
- )
- const (
- LineBit = 12
- LineMask = 0x0fff
- )
- func CalcDocId2(dbId int64, line int64) int64 {
- return (dbId << LineBit) + int64(line)
- }
- func SplitDocId(docId int64) (dbId int64, line int) {
- // 分离出 dbId 和 line
- dbId = (docId >> LineBit) & math.MaxInt64 // 这里使用右移和位与操作来提取 dbId
- line = int(docId & LineMask)
- return
- }
- type VersionControl struct {
- Version string `json:"version"`
- }
- type PlatGroup struct {
- GId int `json:"id"`
- Plats []string `json:"group"`
- ChangeItems [][]int64 `json:"change"`
- }
- // SumMaterialToSlice 材料信息切片到map的转换
- func SumMaterialToMap(materials [][]int64) (map[int64]int64, error) {
- if len(materials) == 0 {
- return make(map[int64]int64), nil
- }
- costMap := make(map[int64]int64)
- for _, v := range materials {
- if len(v) != 2 {
- return nil, fmt.Errorf("material slice must have length of 2, but got %d", len(v))
- }
- costMap[v[0]] += v[1] // 使用 += 操作符更简洁
- }
- return costMap, nil
- }
- // func ExtractLineId(docId int64) int {
- // return int(docId & LineMask)
- // }
- // 合并同种材料
- // func MergeSameMaterials(lst []*MaterialData) []*MaterialData {
- // ret := make([]*MaterialData, 0)
- // for _, v := range lst {
- // isOk := false
- // for _, vv := range ret {
- // if vv.ID == v.ID {
- // vv.Count += v.Count
- // isOk = true
- // break
- // }
- // }
- // if !isOk {
- // tmp := &MaterialData{ID: v.ID, Count: v.Count}
- // ret = append(ret, tmp)
- // }
- // }
- // return ret
- // }
|