123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- package model
- import (
- "fmt"
- "math"
- )
- 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 //游戏货币购买道具
- CostSourceChapterSettle = 17 // 章节结算
- CostSourceEmojiUnlock = 18 //表情解锁
- CostSourceLegendReset = 19 //铭文重铸
- CostSourceLegendExcelIn = 20 //铭文精通
- CostSourcePatrol = 21 //巡逻
- CostSourceTask = 22 //任务
- CostSourceDrawLetterExtra = 23 //邮件
- CostSourceUnlock = 24 //解锁
- CostSourcePlayerLevelUp = 25 //玩家升级
- CostSourceRefreshShop = 26 //刷新商店
- CostSourceShopBuy = 27 //商店购买商品
- CostSourceUseBox = 28 //开箱子
- CostSourceActivities = 29 //精彩活动
- CostSourcePayBuy = 30 //充值
- CostSourceInviteFriend = 31 //邀请好友
- CostSourceSevenDayTask = 32 //七日任务
- CostSourceGacha = 33 //扭蛋
- CostSourceHuntTreasure = 34 //寻宝
- CostSourceFirstCharge = 35 //首充
- CostSourceWarOrder = 36 //战令
- CostSourceSevenDaySignIn = 37 //7日签到
- CostSourceDailyDeal = 38 //每日特惠
- CostSourceDiscountPack = 39 //特惠礼包
- CostSourceFriendGive = 40 //好友赠送体力
- )
- 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
- // }
|