Compare commits

...

64 Commits

Author SHA1 Message Date
aozhiwei
128038beda 1 2024-10-29 14:05:45 +08:00
aozhiwei
a4305759fc 1 2024-10-23 10:46:27 +08:00
aozhiwei
37aa2028aa 1 2024-10-18 17:40:20 +08:00
aozhiwei
dc42e3b8d4 1 2024-10-18 15:30:38 +08:00
aozhiwei
30b200467e 1 2024-10-18 15:30:29 +08:00
1216a7d741 调整 2024-10-17 15:36:44 +08:00
3b1bbffc6c Merge branch 'dev' of git.kingsome.cn:server/game2006go into dev 2024-10-17 14:44:17 +08:00
3957d8f9a8 calc vip_lv 2024-10-17 14:44:11 +08:00
aozhiwei
0cbc90c4f1 1 2024-10-17 14:16:08 +08:00
aozhiwei
69b2db191e 1 2024-10-17 13:59:16 +08:00
aozhiwei
f32e1fe47f 1 2024-10-17 11:44:58 +08:00
aozhiwei
97a7af158d 1 2024-10-17 11:43:22 +08:00
aozhiwei
eda59f8c72 1 2024-10-17 11:37:04 +08:00
aozhiwei
e57b3051f5 1 2024-10-16 17:27:50 +08:00
aozhiwei
a66806a724 1 2024-10-16 16:12:04 +08:00
aozhiwei
c75ad6e121 1 2024-10-16 15:40:38 +08:00
aozhiwei
5bb52d4342 1 2024-10-16 11:36:53 +08:00
aozhiwei
baa20f27a2 1 2024-10-16 10:43:42 +08:00
aozhiwei
1f1400f101 1 2024-10-16 10:32:05 +08:00
aozhiwei
8feb0e1050 1 2024-10-16 10:21:52 +08:00
aozhiwei
c7509063d1 1 2024-10-15 19:26:48 +08:00
aozhiwei
a7c69faee1 1 2024-10-15 19:21:49 +08:00
aozhiwei
0dc104abdf 1 2024-10-15 19:13:02 +08:00
aozhiwei
ac48074909 1 2024-10-15 19:05:17 +08:00
aozhiwei
ea36a05b14 1 2024-10-15 17:47:46 +08:00
aozhiwei
9a2930cec4 1 2024-10-15 17:47:36 +08:00
ec837c26b3 fix 2024-10-15 17:44:33 +08:00
aozhiwei
fcdeb03d01 1 2024-10-15 17:43:13 +08:00
aozhiwei
839ecb8bd9 1 2024-10-15 17:24:40 +08:00
aozhiwei
6736982cc2 1 2024-10-15 17:20:27 +08:00
aozhiwei
01c6c386a9 1 2024-10-15 17:17:48 +08:00
aozhiwei
46fcb8c57c 1 2024-10-12 15:19:35 +08:00
aozhiwei
9f10f02d80 1 2024-10-12 15:18:06 +08:00
aozhiwei
7c260b04cb 1 2024-10-12 15:16:42 +08:00
aozhiwei
bc43c9e28f 1 2024-10-12 15:01:09 +08:00
aozhiwei
7bc0fb7164 1 2024-10-12 14:57:47 +08:00
aozhiwei
a66f1d9a02 1 2024-10-12 14:53:58 +08:00
aozhiwei
4547820c28 1 2024-10-12 14:52:34 +08:00
aozhiwei
8fe90377b7 1 2024-10-12 14:52:02 +08:00
aozhiwei
a9cac80248 1 2024-10-12 14:49:35 +08:00
aozhiwei
829f535c8f 1 2024-10-12 14:41:02 +08:00
aozhiwei
3f32e28de4 1 2024-10-12 14:03:06 +08:00
aozhiwei
17c04e0697 1 2024-10-12 14:00:31 +08:00
aozhiwei
4577aab939 1 2024-10-12 13:58:33 +08:00
aozhiwei
4e2973a6c6 1 2024-10-12 13:57:22 +08:00
aozhiwei
ba34ecc95a 1 2024-10-12 13:43:11 +08:00
aozhiwei
7c3e85aa59 1 2024-10-12 13:33:31 +08:00
aozhiwei
84188ac723 1 2024-10-12 13:24:16 +08:00
aozhiwei
c7bc4d165f 1 2024-10-11 19:12:25 +08:00
aozhiwei
873447d84b 1 2024-10-11 17:27:42 +08:00
c4977b93a2 1 2024-10-11 16:19:46 +08:00
e39a25d864 调整 2024-09-26 13:51:00 +08:00
ed5855a780 inapp order query 2024-09-25 16:51:13 +08:00
7885698e0e Merge branch 'market' into dev 2024-09-25 14:20:20 +08:00
f295141c04 调整 2024-09-24 17:42:44 +08:00
2b1ceec576 fix 2024-09-23 14:04:58 +08:00
1d6d47d305 Merge branch 'dev' of git.kingsome.cn:server/game2006go into dev 2024-09-20 19:00:38 +08:00
fbb6812101 game switch serverlist 2024-09-20 19:00:32 +08:00
aozhiwei
1622ca5f09 1 2024-08-30 15:25:17 +08:00
aozhiwei
4ad76b5aec 1 2024-08-27 14:08:39 +08:00
aozhiwei
521708177c 1 2024-08-20 14:29:41 +08:00
aozhiwei
09f2d92207 1 2024-08-20 14:24:36 +08:00
aozhiwei
1b5b5b63e0 1 2024-08-20 11:37:10 +08:00
aozhiwei
ac5a180cd1 1 2024-08-20 10:51:15 +08:00
26 changed files with 751 additions and 200 deletions

View File

@ -115,6 +115,10 @@
"switch_name": "ui.officeSite",
"switch_desc": "29-官网"
},
{
"switch_name": "circuitTask",
"switch_desc": "30-巡回赛任务"
},
{
"switch_name": "only.allowed.superWhiteList",
"switch_desc": "100-只允许至尊白名单用户登录登录"

View File

@ -4,5 +4,6 @@
"immutable_base_url": "https://api.sandbox.immutable.com",
"hero_contract_address": "0x65570A86E5aA2B14325f8a13C70b74f7d1E2f5c9",
"immutable_api_key": "sk_imapik-test-kbe8ZWVEzySQPmdiOd8H_ac92cd",
"chain_name": "imtbl-zkevm-testnet"
"chain_name": "imtbl-zkevm-testnet",
"scoreboard_height": 100
}

View File

@ -5,5 +5,5 @@
"game_start_notify_time": 20,
"delay_delete_time": 60,
"match_real_player": 1,
"circuit_mode_interval_time": 120
"circuit_mode_interval_time": 0
}

View File

@ -1,6 +1,7 @@
package system
import (
"encoding/json"
"f5"
"fmt"
"main/constant"
@ -8,6 +9,7 @@ import (
"main/mt"
"net/http"
"q5"
"sort"
"github.com/gin-gonic/gin"
)
@ -54,6 +56,7 @@ func (this *GameSwitchApi) List(c *gin.Context) {
page := c.DefaultQuery("page", "")
result := []struct {
system.GameSwitch
Servers []int32 `json:"serverList"`
Remark string `json:"remark"`
}{}
f5.GetGoStyleDb().PageQuery(
@ -82,6 +85,8 @@ func (this *GameSwitchApi) List(c *gin.Context) {
if exist {
p.Remark = desc
}
p.Servers = make([]int32, 0)
json.Unmarshal([]byte(pg.Rows.GetByName("server_list")), &p.Servers)
p.AuditOpen = q5.SafeToInt32(pg.Rows.GetByName("audit_is_open"))
p.CreateTime = q5.SafeToInt32(pg.Rows.GetByName("createtime"))
p.ModifyTime = q5.SafeToInt32(pg.Rows.GetByName("modifytime"))
@ -141,6 +146,7 @@ func (this *GameSwitchApi) Edit(c *gin.Context) {
req := struct {
Name string `binding:"required" json:"switch_name"`
Open *int32 `binding:"required" json:"is_open"`
Servers []int `json:"serverList"`
AuditOpen *int32 `binding:"required" json:"audit_is_open"`
Remark string `json:"remark"`
}{}
@ -151,7 +157,10 @@ func (this *GameSwitchApi) Edit(c *gin.Context) {
})
return
}
gswitch := new(system.GameSwitch)
gswitch := new(struct {
system.GameSwitch
Servers string `gorm:"column:server_list" json:"serverList"`
})
db := f5.GetApp().GetOrmDb(constant.CONF_DB)
if err := db.Take(gswitch, "switch_name = ?", req.Name).Error; err != nil {
if !f5.IsOrmErrRecordNotFound(err) {
@ -169,8 +178,11 @@ func (this *GameSwitchApi) Edit(c *gin.Context) {
}
}
sort.Ints(req.Servers)
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
gswitch.Opened = *req.Open
serverbytes, _ := json.Marshal(req.Servers)
gswitch.Servers = string(serverbytes)
gswitch.AuditOpen = *req.AuditOpen
gswitch.ModifyTime = nowDaySeconds
if err := db.Where("switch_name = ?", req.Name).Save(gswitch).Error; err != nil {

View File

@ -65,11 +65,7 @@ func (pai *PlayerApi) Info(c *gin.Context) {
})
if len(accountids) == 0 {
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "",
})
f5.RspErr2(c, 0, "")
return
}
@ -81,10 +77,7 @@ func (pai *PlayerApi) Info(c *gin.Context) {
filterstr += ")"
} else {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": "input one of playername, account_id, address, email",
})
f5.RspErr2(c, 1, "input one of playername, account_id, address, email")
return
}
sql := fmt.Sprintf(`SELECT * FROM t_user WHERE idx > %d AND %s `, cursor, filterstr)
@ -139,10 +132,7 @@ func (pai *PlayerApi) BagQuery(c *gin.Context) {
}
if len(reqJson.Account_id) > 0xFF {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": "输入过长",
})
f5.RspErr2(c, 1, "输入过长")
return
}
@ -168,10 +158,7 @@ func (pai *PlayerApi) HeroesQuery(c *gin.Context) {
}
if len(reqJson.Account_id) > 0xFF {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": "输入过长",
})
f5.RspErr2(c, 1, "输入过长")
return
}
@ -267,10 +254,7 @@ func (pai *PlayerApi) GoldBullionQuery(c *gin.Context) {
} else if reqJson.Open_address != "" {
filterstr = " open_address = '" + reqJson.Open_address + "'"
} else {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": "input one of token_id, open_address",
})
f5.RspErr2(c, 1, "input one of token_id, open_address")
return
}
@ -330,10 +314,7 @@ func (pai *PlayerApi) GameMallQuery(c *gin.Context) {
} else if reqJson.Seller_address != "" {
filterstr = " seller_address = '" + reqJson.Seller_address + "'"
} else {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": "input one of order_id, seller, seller_address",
})
f5.RspErr2(c, 1, "input one of order_id, seller, seller_address")
return
}
@ -347,6 +328,51 @@ func (pai *PlayerApi) GameMallQuery(c *gin.Context) {
})
}
func (pai *PlayerApi) InappOrderQuery(c *gin.Context) {
type InappOrderQueryForm struct {
Order_id string `json:"order_id"`
SP_Order_id string `json:"sp_order_id"`
Account_id string `json:"account_id"`
}
reqJson := InappOrderQueryForm{}
if !checkparam(&reqJson, c) {
return
}
filterstr := ""
if reqJson.Order_id != "" {
filterstr = " order_id = '" + reqJson.Order_id + "'"
} else if reqJson.SP_Order_id != "" {
filterstr = " sp_order_id = '" + reqJson.SP_Order_id + "'"
} else if reqJson.Account_id != "" {
filterstr = " account_id = '" + reqJson.Account_id + "'"
} else {
f5.RspErr2(c, 1, "input one of order_id, app store order_id, account_id")
return
}
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
sql := fmt.Sprintf(`SELECT * FROM t_inapp_order WHERE idx > %d AND %s `, cursor, filterstr)
query(constant.GAME_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
p := new(struct {
Idx int64 `gorm:"column:idx" json:"idx"`
Order_id string `gorm:"column:order_id" json:"order_id"`
SP_Order_id string `gorm:"column:sp_order_id" json:"sp_order_id"`
Platform int `gorm:"column:platform" json:"platform"`
Account_id string `gorm:"column:account_id" json:"account_id"`
Goods_id int `gorm:"column:goods_id" json:"goods_id"`
Price float64 `gorm:"column:price" json:"price"`
Status int `gorm:"column:status" json:"status"`
Createtime int `gorm:"column:createtime" json:"createtime"`
Modifytime int `gorm:"column:modifytime" json:"modifytime"`
})
f5.UnmarshalModel(ds, p)
return p
})
}
func (pai *PlayerApi) RechargeQuery(c *gin.Context) {
type RechargeQueryForm struct {
Identity string `binding:"required" json:"identity"`

View File

@ -19,6 +19,7 @@ func (pr *PlayerRouter) InitPlayerRouter(priRouter *gin.RouterGroup) {
group.POST("goldbullionquery", middleware.Permission("api/v1/player/goldbullionquery", api.GoldBullionQuery))
group.POST("ticketconsumequery", middleware.Permission("api/v1/player/ticketconsumequery", api.TicketConsumeQuery))
group.POST("gamemallquery", middleware.Permission("api/v1/player/gamemallquery", api.GameMallQuery))
group.POST("inapporderquery", middleware.Permission("api/v1/player/inapporderquery", api.InappOrderQuery))
group.POST("rechargequery", middleware.Permission("api/v1/player/rechargequery", api.RechargeQuery))
group.POST("vipbindquery", middleware.Permission("api/v1/player/vipbindquery", api.VipBindQuery))
group.POST("vipuserquery", middleware.Permission("api/v1/player/vipuserquery", api.VipUserQuery))

View File

@ -64,6 +64,11 @@ func (this *recharge) deliverGoods(ds *f5.DataSet) bool {
userIdentity = passportAddress
accountId = service.GetAccountIdByAddress(passportAddress)
}
if returnContribution > 0.0 {
if this.returnContribution(netId, shortOrderId, userIdentity, returnContribution, payTime) != nil {
return true
}
}
if accountId == "" {
return true
}
@ -73,11 +78,6 @@ func (this *recharge) deliverGoods(ds *f5.DataSet) bool {
if this.markOk(idx, accountId) != nil {
return true
}
if returnContribution > 0.0 {
if this.returnContribution(netId, shortOrderId, userIdentity, returnContribution, payTime) != nil {
return true
}
}
service.UserAddDiamond(accountId, diamond, netId, orderId)
return true
}

View File

@ -14,7 +14,7 @@ var Friend = new (friend)
func (this *friend) Force(accountId1 string, accountId2 string, nowTime int64,
cb func (error, int64, int64)) {
f5.GetJsStyleDb().Upsert(
f5.GetJsStyleDb().UpsertEx(
constant.FRIEND_DB,
"t_friend_relationship",
[][]string{
@ -33,7 +33,14 @@ func (this *friend) Force(accountId1 string, accountId2 string, nowTime int64,
{"createtime", q5.ToString(nowTime)},
{"modifytime", q5.ToString(nowTime)},
},
cb)
func (err error, lastInsertId int64, rowsAffected int64) {
cb(err, lastInsertId, rowsAffected)
this.updateAddFriendTask(accountId1, nowTime)
this.updateAddFriendTask(accountId2, nowTime)
},
func (ds *f5.DataSet) bool {
return true
})
}
func (this *friend) DeleteSoft(accountId1 string, accountId2 string,
@ -51,3 +58,26 @@ func (this *friend) DeleteSoft(accountId1 string, accountId2 string,
},
cb)
}
func (this *friend) updateAddFriendTask(accountId string, nowTime int64) {
f5.GetJsStyleDb().Upsert(
constant.GAME_DB,
"t_rookie_task_value",
[][]string{
{"account_id", accountId},
{"task_type", "16"},
},
[][]string{
{"!value", "value + 1"},
{"modifytime", q5.ToString(nowTime)},
},
[][]string{
{"account_id", accountId},
{"task_type", "16"},
{"value", "1"},
{"createtime", q5.ToString(nowTime)},
{"modifytime", q5.ToString(nowTime)},
},
func (err error, lastInsertId int64, rowsAffected int64) {
})
}

View File

@ -0,0 +1,14 @@
package mt
import (
"f5"
"main/mtb"
)
type StakingVip struct {
mtb.StakingVip
}
type StakingVipTable struct {
f5.IdMetaTable[StakingVip]
}

View File

@ -19,6 +19,7 @@ type table struct {
HashRateCommon *HashRateCommonTable
Contract *ContractTable
BcCurrency *BcCurrencyTable
StakingVip *StakingVipTable
}
var Table = f5.New(func(this *table) {
@ -86,4 +87,9 @@ var Table = f5.New(func(this *table) {
this.PrimKey = "name"
})
this.StakingVip = f5.New(func(this *StakingVipTable) {
this.FileName = "../res/stakingVip@stakingVip.json"
this.PrimKey = "rank"
})
})

View File

@ -84,6 +84,7 @@ type Config struct {
immutable_base_url string
chain_name string
immutable_api_key string
scoreboard_height int32
_flags1_ uint64
_flags2_ uint64
@ -137,6 +138,21 @@ type HashRateCommon struct {
_flags2_ uint64
}
type StakingVip struct {
rights string
require int64
thisPoint int64
rank int32
vip_name string
rate float64
vip_working_tips string
vip_unworking_tips string
id int32
_flags1_ uint64
_flags2_ uint64
}
func (this *BackTaskCluster) GetInstanceId() int32 {
return this.instance_id
}
@ -481,6 +497,14 @@ func (this *Config) HasImmutableApiKey() bool {
return (this._flags1_ & (uint64(1) << 6)) > 0
}
func (this *Config) GetScoreboardHeight() int32 {
return this.scoreboard_height
}
func (this *Config) HasScoreboardHeight() bool {
return (this._flags1_ & (uint64(1) << 7)) > 0
}
func (this *Item) GetName() string {
return this.name
}
@ -625,6 +649,78 @@ func (this *HashRateCommon) HasCecPool() bool {
return (this._flags1_ & (uint64(1) << 4)) > 0
}
func (this *StakingVip) GetRights() string {
return this.rights
}
func (this *StakingVip) HasRights() bool {
return (this._flags1_ & (uint64(1) << 1)) > 0
}
func (this *StakingVip) GetRequire() int64 {
return this.require
}
func (this *StakingVip) HasRequire() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0
}
func (this *StakingVip) GetThisPoint() int64 {
return this.thisPoint
}
func (this *StakingVip) HasThisPoint() bool {
return (this._flags1_ & (uint64(1) << 3)) > 0
}
func (this *StakingVip) GetRank() int32 {
return this.rank
}
func (this *StakingVip) HasRank() bool {
return (this._flags1_ & (uint64(1) << 4)) > 0
}
func (this *StakingVip) GetVipName() string {
return this.vip_name
}
func (this *StakingVip) HasVipName() bool {
return (this._flags1_ & (uint64(1) << 5)) > 0
}
func (this *StakingVip) GetRate() float64 {
return this.rate
}
func (this *StakingVip) HasRate() bool {
return (this._flags1_ & (uint64(1) << 6)) > 0
}
func (this *StakingVip) GetVipWorkingTips() string {
return this.vip_working_tips
}
func (this *StakingVip) HasVipWorkingTips() bool {
return (this._flags1_ & (uint64(1) << 7)) > 0
}
func (this *StakingVip) GetVipUnworkingTips() string {
return this.vip_unworking_tips
}
func (this *StakingVip) HasVipUnworkingTips() bool {
return (this._flags1_ & (uint64(1) << 8)) > 0
}
func (this *StakingVip) GetId() int32 {
return this.id
}
func (this *StakingVip) HasId() bool {
return (this._flags1_ & (uint64(1) << 9)) > 0
}
func (this *BackTaskCluster) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv)
@ -688,6 +784,7 @@ func (this *Config) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.immutable_base_url, "immutable_base_url", &this._flags1_, 3, kv)
f5.ReadMetaTableField(&this.chain_name, "chain_name", &this._flags1_, 4, kv)
f5.ReadMetaTableField(&this.immutable_api_key, "immutable_api_key", &this._flags1_, 6, kv)
f5.ReadMetaTableField(&this.scoreboard_height, "scoreboard_height", &this._flags1_, 7, kv)
}
func (this *Item) LoadFromKv(kv map[string]interface{}) {
@ -722,3 +819,15 @@ func (this *HashRateCommon) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.end_time, "end_time", &this._flags1_, 3, kv)
f5.ReadMetaTableField(&this.cec_pool, "cec_pool", &this._flags1_, 4, kv)
}
func (this *StakingVip) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.rights, "rights", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.require, "require", &this._flags1_, 2, kv)
f5.ReadMetaTableField(&this.thisPoint, "thisPoint", &this._flags1_, 3, kv)
f5.ReadMetaTableField(&this.rank, "rank", &this._flags1_, 4, kv)
f5.ReadMetaTableField(&this.vip_name, "vip_name", &this._flags1_, 5, kv)
f5.ReadMetaTableField(&this.rate, "rate", &this._flags1_, 6, kv)
f5.ReadMetaTableField(&this.vip_working_tips, "vip_working_tips", &this._flags1_, 7, kv)
f5.ReadMetaTableField(&this.vip_unworking_tips, "vip_unworking_tips", &this._flags1_, 8, kv)
f5.ReadMetaTableField(&this.id, "id", &this._flags1_, 9, kv)
}

View File

@ -71,6 +71,7 @@ message Config
optional string immutable_base_url = 3;
optional string chain_name = 4;
optional string immutable_api_key = 6;
optional int32 scoreboard_height = 7;
}
message Item
@ -110,3 +111,16 @@ message HashRateCommon
optional string end_time = 3;
optional int32 cec_pool = 4;
}
message StakingVip
{
optional string rights = 1;
optional int64 require = 2;
optional int64 thisPoint = 3;
optional int32 rank = 4;
optional string vip_name = 5;
optional double rate = 6;
optional string vip_working_tips = 7;
optional string vip_unworking_tips = 8;
optional int32 id = 9;
}

View File

@ -1,12 +1,13 @@
package service
import (
"q5"
"f5"
"sync"
"strings"
"main/constant"
"main/mt"
"math/big"
"q5"
"strings"
"sync"
)
type vip struct {
@ -31,6 +32,8 @@ func (this *vip) Add(accountAddress string, val string, idx int64, valField stri
defer this.lock.Unlock()
extKv := [][]string{}
lvParams := map[string]string{}
accountAddress = strings.ToLower(accountAddress)
err, ds := f5.GetGoStyleDb().NewOrmSelect(
constant.BCNFT_DB,
@ -67,6 +70,15 @@ func (this *vip) Add(accountAddress string, val string, idx int64, valField stri
bnNewVal := bnOldVal.Add(bnOldVal, bnVal)
updateKv = append(updateKv, [][]string{{valField, bnNewVal.String()}}...)
lvParams["escec_balance"] = ds.GetByName("escec_balance")
lvParams["escec_stacking"] = ds.GetByName("escec_stacking")
lvParams["escec_convert"] = ds.GetByName("escec_convert")
lvParams["last_convert_time"] = ds.GetByName("last_convert_time")
lvParams[valField] = bnNewVal.String()
newlv := this.calcVipLv(lvParams)
updateKv = append(updateKv, []string{"vip_lv", q5.SafeToString(newlv)})
err1, _, _ := f5.GetGoStyleDb().NewUpdate(
constant.BCNFT_DB,
"t_vip_user",
@ -78,6 +90,10 @@ func (this *vip) Add(accountAddress string, val string, idx int64, valField stri
return false
}
} else {
lvParams[valField] = val
newlv := this.calcVipLv(lvParams)
insertKv = append(insertKv, []string{"vip_lv", q5.SafeToString(newlv)})
err1, _, _ := f5.GetGoStyleDb().NewInsert(
constant.BCNFT_DB,
"t_vip_user",
@ -104,6 +120,17 @@ func (this *vip) Replace(accountAddress string, val string, idx int64, valField
if err != nil {
return false
}
lvParams := map[string]string{}
replaceFields:= func() {
lvParams[valField] = val
for _, sli := range extKv {
if len(sli) > 1 {
lvParams[sli[0]] = sli[1]
}
}
}
nowTime := f5.GetApp().GetRealSeconds()
updateKv := [][]string {
{valField, val},
@ -123,6 +150,16 @@ func (this *vip) Replace(accountAddress string, val string, idx int64, valField
if q5.ToInt64(ds.GetByName(idxField)) >= idx {
return true
}
lvParams["escec_balance"] = ds.GetByName("escec_balance")
lvParams["escec_stacking"] = ds.GetByName("escec_stacking")
lvParams["escec_convert"] = ds.GetByName("escec_convert")
lvParams["last_convert_time"] = ds.GetByName("last_convert_time")
replaceFields()
newlv := this.calcVipLv(lvParams)
updateKv = append(updateKv, []string{"vip_lv", q5.SafeToString(newlv)})
err1, _, _ := f5.GetGoStyleDb().NewUpdate(
constant.BCNFT_DB,
"t_vip_user",
@ -134,6 +171,10 @@ func (this *vip) Replace(accountAddress string, val string, idx int64, valField
return false
}
} else {
replaceFields()
newlv := this.calcVipLv(lvParams)
insertKv = append(insertKv, []string{"vip_lv", q5.SafeToString(newlv)})
err1, _, _ := f5.GetGoStyleDb().NewInsert(
constant.BCNFT_DB,
"t_vip_user",
@ -151,7 +192,7 @@ Withdraw 所有
按时间排序处理事件的先后顺序
通过Vester.sol的remainingEsToken方法获取, 如果要本地计算的话, 那就取每次Deposit事件的时间和amount, 加上先前的转换的余额, 再按total * (now - deposit_time) / (365 * 24 * 2600)
通过Vester.sol的remainingEsToken方法获取, 如果要本地计算的话, 那就取每次Deposit事件的时间和amount, 加上先前的转换的余额, 再按total * (now - deposit_time) / (365 * 24 * 3600)
*/
func (this *vip) RecalcEsCecConvert(accountAddress string) error {
@ -202,7 +243,7 @@ func (this *vip) RecalcEsCecConvert(accountAddress string) error {
if lastDeposit != nil {
if nowTime > lastDeposit.chainTimestamp {
bnPassTime := new(big.Int).SetInt64(int64(nowTime - lastDeposit.chainTimestamp))
bnTotalTime := new(big.Int).SetInt64(int64(365 * 24 * 2600))
bnTotalTime := new(big.Int).SetInt64(int64(365 * 24 * 3600))
bnTmp := bnTotal.Mul(bnTotal, bnPassTime)
bnInterest := bnTmp.Div(bnTmp, bnTotalTime)
bnTotal = bnTotal.Sub(bnTotal, bnInterest)
@ -234,3 +275,66 @@ func (this *vip) RecalcEsCecConvert(accountAddress string) error {
}
return nil
}
func (this *vip) calcVipLv(params map[string]string) (lv int64) {
balancestr := params["escec_balance"]
if balancestr == "" {
balancestr = "0"
}
escec_balance, ok := new(big.Int).SetString(balancestr, 10)
if !ok {
escec_balance = new(big.Int).SetInt64(0)
}
stackingstr := params["escec_stacking"]
if stackingstr == "" {
stackingstr = "0"
}
escec_stacking, ok := new(big.Int).SetString(stackingstr, 10)
if !ok {
escec_stacking = new(big.Int).SetInt64(0)
}
curExec := new(big.Int).Add(escec_balance, escec_stacking)
convertstr := params["escec_convert"]
if convertstr == "" {
convertstr = "0"
}
escec_convert, ok := new(big.Int).SetString(convertstr, 10)
if !ok {
escec_convert = new(big.Int).SetInt64(0)
}
last_convert_time := q5.SafeToInt64(params["last_convert_time"])
nowsecs := f5.GetApp().GetRealSeconds()
diff := nowsecs - last_convert_time
if diff < 0 {
diff = 0
}
elapse := new(big.Int).SetInt64(diff)
depositExec := new(big.Int).Mul(escec_convert, elapse)
depositExec = depositExec.Div(depositExec, new(big.Int).SetInt64(365*24*3600))
if depositExec.Cmp(escec_convert) < 0 {
depositExec = new(big.Int).Sub(escec_convert, depositExec)
} else {
depositExec.SetInt64(0)
}
curExec = curExec.Add(curExec, depositExec)
convercurExec := new(big.Int).Div(curExec, new(big.Int).SetInt64(1000*1000*1000*1000*1000*1000)).Int64()
lv = 0
for {
cfg := mt.Table.StakingVip.GetById(lv)
nextlvcfg := mt.Table.StakingVip.GetById(lv + 1)
if cfg != nil && nextlvcfg != nil {
if cfg.GetRequire() <= convercurExec && nextlvcfg.GetRequire() > convercurExec {
return lv
}
} else {
break
}
lv++
}
return
}

View File

@ -0,0 +1,99 @@
package task
import (
"encoding/json"
"f5"
"main/constant"
"main/mt"
"q5"
"time"
)
type rankchart struct {
}
type rankitem struct {
Idx int64 `json:"idx"`
Account string `json:"account_id"`
Name string `json:"name"`
Head int32 `json:"head_id"`
HeadFrame int32 `json:"head_frame"`
Score int32 `json:"score"`
Rank int32 `json:"rank"`
}
func (r *rankchart) init() {
// go r.processLoop()
}
func (r *rankchart) unInit() {
}
func (r *rankchart) processLoop() {
for {
height := mt.Table.Config.GetById(0).GetScoreboardHeight()
r.processScoreRank(height)
time.Sleep(time.Minute)
}
}
func (r *rankchart) processScoreRank(height int32) {
sql := `SELECT idx, account_id, name, head_id, head_frame, score, score_modifytime FROM t_user WHERE idx > 0`
order := " ORDER BY score DESC, score_modifytime ASC, idx ASC "
const perpage = int32(512)
pageno := int32(1)
item := new(rankitem)
for {
datalist := []string{}
var queryerr error
lastpage := false
f5.GetGoStyleDb().PageQuery(
constant.GAME_DB,
perpage,
pageno,
sql,
[]string{},
f5.GetDbFilter().Comp([]f5.DbQueryFilter{}...),
order,
func(err error, p *f5.Pagination) {
if err != nil {
queryerr = err
return
}
if p.CurrentPage == p.TotalPages {
lastpage = true
}
for p.Rows.Next() {
item.Rank = int32(p.Rows.NumOfReaded()) + (pageno-1)*(perpage)
if height > 0 && item.Rank > height {
lastpage = true
return
}
item.Idx = q5.SafeToInt64(p.Rows.GetByName("idx"))
item.Account = p.Rows.GetByName("account_id")
item.Name = p.Rows.GetByName("name")
item.Head = q5.SafeToInt32(p.Rows.GetByName("head_id"))
item.HeadFrame = q5.SafeToInt32(p.Rows.GetByName("head_frame"))
item.Score = q5.SafeToInt32(p.Rows.GetByName("score"))
rankdata, _ := json.Marshal(item)
datalist = append(datalist, string(rankdata))
}
})
if len(datalist) > 0 {
// push to redis
// fmt.Println(datalist)
}
if queryerr != nil || lastpage {
break
}
pageno++
}
}

View File

@ -1,8 +1,5 @@
package task
import (
)
type taskMgr struct {
webHook
repairNft
@ -16,6 +13,7 @@ type taskMgr struct {
esCecTransfer
stackingCec
vester
rankchart
}
func (this *taskMgr) Init() {
@ -31,6 +29,7 @@ func (this *taskMgr) Init() {
this.esCecTransfer.init()
this.stackingCec.init()
this.vester.init()
this.rankchart.init()
}
func (this *taskMgr) UnInit() {
@ -46,4 +45,5 @@ func (this *taskMgr) UnInit() {
this.sysMail.unInit()
this.repairNft.unInit()
this.webHook.unInit()
this.rankchart.unInit()
}

View File

@ -77,6 +77,8 @@ func (this *player) MarkMails(mails []common.Mail) error {
mi.expireTime = m.GetExpireTime()
this.inboxHash[mi.mailId] = mi
} else if mi.state != constant.INBOX_STATE_NONE {
if mi.state != constant.INBOX_STATE_DELETED &&
mi.state != constant.INBOX_STATE_RECEIVED {
err := model.Inbox.Mark(this.GetAccountId(), m.GetMailId(), nowTime, m.GetExpireTime())
if err != nil {
resultErr = err
@ -87,6 +89,7 @@ func (this *player) MarkMails(mails []common.Mail) error {
}
}
}
}
return resultErr
}

View File

@ -24,6 +24,7 @@ func (ac *accountContribution) sum() float64 {
type contribution struct {
historyContribution float64
stakingContribution float64
rechargeContribution float64
gameContribution float64
gcTime int64
@ -44,7 +45,7 @@ func (this *contribution) unInit() {
}
func (c *contribution) sum() float64 {
return c.historyContribution + c.rechargeContribution + c.gameContribution
return c.historyContribution + c.stakingContribution + c.rechargeContribution + c.gameContribution
}
func (this *contribution) GetEmailContributionAccountid(email string) (float64, string, error) {
@ -252,8 +253,10 @@ func (this *contribution) GetGlobalContribution(instant bool) (float64, error) {
this.historyContribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0))
}
})
}
sql = `SELECT SUM(contribution) FROM t_staking_daily_settlement WHERE idx > 0`
if nowseconds := f5.GetApp().GetRealSeconds(); nowseconds > this.gcTime+60 || instant {
sql := `SELECT SUM(contribution) FROM t_staking_daily_settlement WHERE idx > 0`
f5.GetGoStyleDb().RawQuery(
constant.BCNFT_DB,
sql,
@ -264,14 +267,11 @@ func (this *contribution) GetGlobalContribution(instant bool) (float64, error) {
}
if ds.Next() {
tmp, _ := q5.ToFloat64Ex(ds.GetByIndex(0))
this.historyContribution += tmp
this.stakingContribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0))
}
})
}
if nowseconds := f5.GetApp().GetRealSeconds(); nowseconds > this.gcTime+60 || instant {
sql := `SELECT SUM(contribution) FROM t_contribution WHERE idx > 0`
sql = `SELECT SUM(contribution) FROM t_contribution WHERE idx > 0`
f5.GetGoStyleDb().RawQuery(
constant.GAME_DB,
sql,

View File

@ -10,23 +10,31 @@ import (
proto "github.com/golang/protobuf/proto"
)
type LoginRsp struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
Info struct {
UserInfo struct {
Activated string `json:"activated"`
RenameCount string `json:"rename_count"`
type BattleItem struct {
ItemId int32 `json:"item_id"`
ItemNum int32 `json:"item_num"`
ItemType int32 `json:"item_type"`
ItemSubType int32 `json:"item_sub_type"`
}
type UserInfo struct {
//Activated string `json:"activated"`
//RenameCount string `json:"rename_count"`
AccountId string `json:"account_id"`
Name string `json:"name"`
HeadId string `json:"head_id"`
HeroId string `json:"hero_id"`
//HeroId string `json:"hero_id"`
HeadFrame string `json:"head_frame"`
TotalLucky interface{} `json:"total_lucky"`
AdmissionItemNum interface{} `json:"admission_item_num"`
CircuitScore interface{} `json:"circuit_score"`
} `json:"user_info"`
HeroInfo struct {
VipLv interface{} `json:"vip_lv"`
VipExp interface{} `json:"vip_exp"`
HasVipLucky interface{} `json:"has_vip_lucky"`
HasLuckySymbol interface{} `json:"has_lucky_symbol"`
}
type HeroInfo struct {
HeroUniId string `json:"hero_uniid"`
HeroId string `json:"hero_id"`
Quality string `json:"quality"`
@ -36,7 +44,14 @@ type LoginRsp struct {
CurrentTimes interface{} `json:"current_times"`
TotalTimes interface{} `json:"total_times"`
SkinId interface{} `json:"skin_id"`
} `json:"hero_info"`
}
type LoginRsp struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
Info struct {
UserInfo UserInfo `json:"user_info"`
HeroInfo HeroInfo `json:"hero_info"`
MapInfo *MapInfoRsp `json:"map_info"`
} `json:"info"`
}
@ -45,29 +60,8 @@ type UserRsp struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
Info struct {
UserInfo struct {
Activated string `json:"activated"`
RenameCount string `json:"rename_count"`
AccountId string `json:"account_id"`
Name string `json:"name"`
HeadId string `json:"head_id"`
HeroId string `json:"hero_id"`
HeadFrame string `json:"head_frame"`
TotalLucky interface{} `json:"total_lucky"`
AdmissionItemNum interface{} `json:"admission_item_num"`
CircuitScore interface{} `json:"circuit_score"`
} `json:"user_info"`
HeroInfo struct {
HeroUniId string `json:"hero_uniid"`
HeroId string `json:"hero_id"`
Quality string `json:"quality"`
SpecSkill string `json:"spec_skill"`
Wealth interface{} `json:"wealth"`
ValidLefttime interface{} `json:"valid_lefttime"`
CurrentTimes interface{} `json:"current_times"`
TotalTimes interface{} `json:"total_times"`
SkinId interface{} `json:"skin_id"`
} `json:"hero_info"`
UserInfo UserInfo `json:"user_info"`
HeroInfo HeroInfo `json:"hero_info"`
} `json:"info"`
}
@ -93,30 +87,8 @@ type UpdateBattleInfoRsp struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
Info struct {
UserInfo struct {
Activated string `json:"activated"`
RenameCount string `json:"rename_count"`
AccountId string `json:"account_id"`
Name string `json:"name"`
HeadId string `json:"head_id"`
HeroId string `json:"hero_id"`
HeadFrame string `json:"head_frame"`
SpecSkill string `json:"spec_skill"`
TotalLucky interface{} `json:"total_lucky"`
AdmissionItemNum interface{} `json:"admission_item_num"`
CircuitScore interface{} `json:"circuit_score"`
} `json:"user_info"`
HeroInfo struct {
HeroUniId string `json:"hero_uniid"`
HeroId string `json:"hero_id"`
Quality string `json:"quality"`
SpecSkill string `json:"spec_skill"`
Wealth interface{} `json:"wealth"`
ValidLefttime interface{} `json:"valid_lefttime"`
CurrentTimes interface{} `json:"current_times"`
TotalTimes interface{} `json:"total_times"`
SkinId interface{} `json:"skin_id"`
} `json:"hero_info"`
UserInfo UserInfo `json:"user_info"`
HeroInfo HeroInfo `json:"hero_info"`
} `json:"info"`
}
@ -178,6 +150,7 @@ type Player interface {
IsBattling() bool
SetBattling(bool)
GenNextCopy() Player
GetBattleItems() []*BattleItem
}
type PlayerMgr interface {

View File

@ -41,3 +41,13 @@ const (
HISTORY_MGR_MODULE_IDX
MAX_MODULE_IDX
)
const (
LUCKY_SYMBOL_ITEM_ID = 900007
)
const (
FUNC_TYPE_ITEM_TYPE = 9
LUCKY_SYMBOL_ITEM_SUB_TYPE = 8
)

View File

@ -49,6 +49,7 @@ type MsgHandler interface {
CMChooseHero(*f5.MsgHdr, *CMChooseHero)
CMChooseMap(*f5.MsgHdr, *CMChooseMap)
CMRefreshUser(*f5.MsgHdr, *CMRefreshUser)
CMChooseBattleItem(*f5.MsgHdr, *CMChooseBattleItem)
CMGrantInvitePermission(*f5.MsgHdr, *CMGrantInvitePermission)
}
@ -94,6 +95,9 @@ func (this *MsgHandlerImpl) CMChooseMap(hdr *f5.MsgHdr, msg *CMChooseMap) {
func (this *MsgHandlerImpl) CMRefreshUser(hdr *f5.MsgHdr, msg *CMRefreshUser) {
}
func (this *MsgHandlerImpl) CMChooseBattleItem(hdr *f5.MsgHdr, msg *CMChooseBattleItem) {
}
func (this *MsgHandlerImpl) CMGrantInvitePermission(hdr *f5.MsgHdr, msg *CMGrantInvitePermission) {
}
@ -213,6 +217,14 @@ func (this *SMRefreshUser) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMRefreshUser)
}
func (this *CMChooseBattleItem) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMChooseBattleItem)
}
func (this *SMChooseBattleItem) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMChooseBattleItem)
}
func (this *CMGrantInvitePermission) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMGrantInvitePermission)
}
@ -313,6 +325,12 @@ func (this *SMChooseMap) Err(errCode int32, errMsg string) *SMChooseMap {
return this
}
func (this *SMChooseBattleItem) Err(errCode int32, errMsg string) *SMChooseBattleItem {
this.Errcode = proto.Int32(errCode)
this.Errmsg = proto.String(errMsg)
return this
}
func (this *SMGrantInvitePermission) Err(errCode int32, errMsg string) *SMGrantInvitePermission {
this.Errcode = proto.Int32(errCode)
this.Errmsg = proto.String(errMsg)
@ -489,6 +507,18 @@ func init() {
},
}
handlers[int(CMMessageIdE__CMChooseBattleItem)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMChooseBattleItem),
ParseCb: func (data []byte) interface{} {
msg := &CMChooseBattleItem{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMChooseBattleItem(hdr, hdr.Msg.(*CMChooseBattleItem))
},
}
handlers[int(CMMessageIdE__CMGrantInvitePermission)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMGrantInvitePermission),
ParseCb: func (data []byte) interface{} {

View File

@ -56,7 +56,7 @@ func (this *historyMgr) PushLastBattleInfo(hum common.Player) {
func (this *historyMgr) CanStart(accountId string, mapId int32, modeId int32) bool {
u := this.getUser(accountId)
if u == nil && modeId == jccommon.MAP_MODE_CIRCUIT {
if u != nil && modeId == jccommon.MAP_MODE_CIRCUIT {
key := q5.MkInt64(mapId, modeId)
if startTime, ok := u.mapAndModeHash[key]; ok {
nowTime := q5.ToInt32(f5.GetApp().GetRealSeconds())

View File

@ -30,6 +30,7 @@ func (this *HandlerMgr) Init() {
cs.RegHandlerId(int(cs.CMMessageIdE__CMChooseMap), constant.PLAYER_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMGrantInvitePermission), constant.PLAYER_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMRefreshUser), constant.PLAYER_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMChooseBattleItem), constant.PLAYER_HANDLER_ID)
}
func (this *HandlerMgr) UnInit() {

View File

@ -6,6 +6,7 @@ import (
"f5"
"github.com/golang/protobuf/proto"
"main/common"
"main/constant"
. "main/global"
"fmt"
"encoding/json"
@ -44,6 +45,11 @@ type player struct {
team common.Team
battling bool
sortIdx int32
vipLv int32
vipExp int64
hasVipLucky int32
hasLuckySymbol int32
battleItems []*common.BattleItem
}
func (this *player) SendMsg(rspMsg proto.Message) {
@ -52,29 +58,39 @@ func (this *player) SendMsg(rspMsg proto.Message) {
}
}
func (this *player) parseUserInfo(userInfo *common.UserInfo){
this.name = userInfo.Name
this.avatarUrl = userInfo.HeadId
this.headFrame = userInfo.HeadFrame
q5.DuckToSimple(userInfo.TotalLucky, &this.totalLucky)
q5.DuckToSimple(userInfo.AdmissionItemNum, &this.admissionItemNum)
q5.DuckToSimple(userInfo.CircuitScore, &this.circuitScore)
q5.DuckToSimple(userInfo.VipLv, &this.vipLv)
q5.DuckToSimple(userInfo.VipExp, &this.vipExp)
q5.DuckToSimple(userInfo.HasVipLucky, &this.hasVipLucky)
q5.DuckToSimple(userInfo.HasLuckySymbol, &this.hasLuckySymbol)
}
func (this *player) parseHeroInfo(heroInfo *common.HeroInfo){
this.hero.heroUniId = heroInfo.HeroUniId
this.hero.heroId = q5.ToInt32(heroInfo.HeroId)
this.hero.quality = q5.ToInt32(heroInfo.Quality)
this.hero.specSkill = q5.ToInt32(heroInfo.SpecSkill)
q5.DuckToSimple(heroInfo.Wealth, &this.hero.wealth)
q5.DuckToSimple(heroInfo.ValidLefttime, &this.hero.validLeftTime)
q5.DuckToSimple(heroInfo.CurrentTimes, &this.hero.currentTimes)
q5.DuckToSimple(heroInfo.TotalTimes, &this.hero.totalTimes)
q5.DuckToSimple(heroInfo.SkinId, &this.hero.skinId)
}
func (this *player) init(req *pendingLoginRequest, rsp *common.LoginRsp){
this.socket = req.hdr.GetSocket()
this.accountId = req.msg.GetAccountId()
this.sessionId = req.msg.GetSessionId()
this.zoneId = req.msg.GetZoneId()
this.nodeId = req.msg.GetNodeId()
this.name = rsp.Info.UserInfo.Name
this.avatarUrl = rsp.Info.UserInfo.HeadId
this.headFrame = rsp.Info.UserInfo.HeadFrame
q5.DuckToSimple(rsp.Info.UserInfo.AdmissionItemNum, &this.admissionItemNum)
q5.DuckToSimple(rsp.Info.UserInfo.CircuitScore, &this.circuitScore)
q5.DuckToSimple(rsp.Info.UserInfo.TotalLucky, &this.totalLucky)
{
this.hero.heroUniId = rsp.Info.HeroInfo.HeroUniId
this.hero.heroId = q5.ToInt32(rsp.Info.HeroInfo.HeroId)
this.hero.quality = q5.ToInt32(rsp.Info.HeroInfo.Quality)
this.hero.specSkill = q5.ToInt32(rsp.Info.HeroInfo.SpecSkill)
q5.DuckToSimple(rsp.Info.HeroInfo.Wealth, &this.hero.wealth)
q5.DuckToSimple(rsp.Info.HeroInfo.ValidLefttime, &this.hero.validLeftTime)
q5.DuckToSimple(rsp.Info.HeroInfo.CurrentTimes, &this.hero.currentTimes)
q5.DuckToSimple(rsp.Info.HeroInfo.TotalTimes, &this.hero.totalTimes)
q5.DuckToSimple(rsp.Info.HeroInfo.SkinId, &this.hero.skinId)
}
this.parseUserInfo(&rsp.Info.UserInfo)
this.parseHeroInfo(&rsp.Info.HeroInfo)
}
func (this *player) againInit(req *pendingLoginRequest, rsp *common.LoginRsp){
@ -83,23 +99,8 @@ func (this *player) againInit(req *pendingLoginRequest, rsp *common.LoginRsp){
this.sessionId = req.msg.GetSessionId()
this.zoneId = req.msg.GetZoneId()
this.nodeId = req.msg.GetNodeId()
this.name = rsp.Info.UserInfo.Name
this.avatarUrl = rsp.Info.UserInfo.HeadId
this.headFrame = rsp.Info.UserInfo.HeadFrame
q5.DuckToSimple(rsp.Info.UserInfo.AdmissionItemNum, &this.admissionItemNum)
q5.DuckToSimple(rsp.Info.UserInfo.CircuitScore, &this.circuitScore)
q5.DuckToSimple(rsp.Info.UserInfo.TotalLucky, &this.totalLucky)
{
this.hero.heroUniId = rsp.Info.HeroInfo.HeroUniId
this.hero.heroId = q5.ToInt32(rsp.Info.HeroInfo.HeroId)
this.hero.quality = q5.ToInt32(rsp.Info.HeroInfo.Quality)
this.hero.specSkill = q5.ToInt32(rsp.Info.HeroInfo.SpecSkill)
q5.DuckToSimple(rsp.Info.HeroInfo.Wealth, &this.hero.wealth)
q5.DuckToSimple(rsp.Info.HeroInfo.ValidLefttime, &this.hero.validLeftTime)
q5.DuckToSimple(rsp.Info.HeroInfo.CurrentTimes, &this.hero.currentTimes)
q5.DuckToSimple(rsp.Info.HeroInfo.TotalTimes, &this.hero.totalTimes)
q5.DuckToSimple(rsp.Info.HeroInfo.SkinId, &this.hero.skinId)
}
this.parseUserInfo(&rsp.Info.UserInfo)
this.parseHeroInfo(&rsp.Info.HeroInfo)
}
func (this *player) GetSocket() f5.WspCliConn {
@ -207,6 +208,19 @@ func (this *player) GenNextCopy() common.Player {
return nextCopy
}
func (this *player) GetBattleItems() []*common.BattleItem {
var result = this.battleItems[0:]
if this.isLuckySymbolMap() {
p := new(common.BattleItem)
p.ItemId = constant.LUCKY_SYMBOL_ITEM_ID
p.ItemNum = 1
p.ItemType = constant.FUNC_TYPE_ITEM_TYPE
p.ItemSubType = constant.LUCKY_SYMBOL_ITEM_SUB_TYPE
q5.AppendSlice(&result, p)
}
return result
}
func (this *player) FillMFTeamMember(member_pb *cs.MFTeamMember) {
member_pb.AccountId = proto.String(this.accountId)
member_pb.Name = proto.String(this.name)
@ -238,6 +252,22 @@ func (this *player) FillMFTeamMember(member_pb *cs.MFTeamMember) {
member_pb.ValidLefttime = proto.Int32(this.hero.validLeftTime)
member_pb.AdmissionItemNum = proto.Int32(this.admissionItemNum)
member_pb.CircuitScore = proto.Int32(this.circuitScore)
member_pb.VipLv = proto.Int32(this.vipLv)
member_pb.VipExp = proto.Int64(this.vipExp)
member_pb.HasVipLucky = proto.Int32(this.hasVipLucky)
q5.NewSlice(&member_pb.BattleItems, 0, 0)
for _, p := range(this.battleItems) {
item_pb := new(cs.MFBattleItem)
item_pb.ItemId = proto.Int32(p.ItemId)
item_pb.ItemNum = proto.Int32(p.ItemNum)
q5.AppendSlice(&member_pb.BattleItems, item_pb)
}
if this.hasLuckySymbol != 0 && this.isLuckySymbolMap() {
item_pb := new(cs.MFBattleItem)
item_pb.ItemId = proto.Int32(constant.LUCKY_SYMBOL_ITEM_ID)
item_pb.ItemNum = proto.Int32(1)
q5.AppendSlice(&member_pb.BattleItems, item_pb)
}
}
func (this *player) CMLeaveTeam(hdr *f5.MsgHdr, msg *cs.CMLeaveTeam) {
@ -432,23 +462,8 @@ func (this *player) CMRefreshUser(hdr *f5.MsgHdr, msg *cs.CMRefreshUser) {
func(rsp f5.HttpCliResponse) {
this.SendMsg(rspMsg)
if rsp.GetErr() == nil && rsp.JsonParseOk() {
this.name = rspObj.Info.UserInfo.Name
this.avatarUrl = rspObj.Info.UserInfo.HeadId
this.headFrame = rspObj.Info.UserInfo.HeadFrame
q5.DuckToSimple(rspObj.Info.UserInfo.AdmissionItemNum, &this.admissionItemNum)
q5.DuckToSimple(rspObj.Info.UserInfo.CircuitScore, &this.circuitScore)
q5.DuckToSimple(rspObj.Info.UserInfo.TotalLucky, &this.totalLucky)
{
this.hero.heroUniId = rspObj.Info.HeroInfo.HeroUniId
this.hero.heroId = q5.ToInt32(rspObj.Info.HeroInfo.HeroId)
this.hero.quality = q5.ToInt32(rspObj.Info.HeroInfo.Quality)
this.hero.specSkill = q5.ToInt32(rspObj.Info.HeroInfo.SpecSkill)
q5.DuckToSimple(rspObj.Info.HeroInfo.Wealth, &this.hero.wealth)
q5.DuckToSimple(rspObj.Info.HeroInfo.ValidLefttime, &this.hero.validLeftTime)
q5.DuckToSimple(rspObj.Info.HeroInfo.CurrentTimes, &this.hero.currentTimes)
q5.DuckToSimple(rspObj.Info.HeroInfo.TotalTimes, &this.hero.totalTimes)
q5.DuckToSimple(rspObj.Info.HeroInfo.SkinId, &this.hero.skinId)
}
this.parseUserInfo(&rspObj.Info.UserInfo)
this.parseHeroInfo(&rspObj.Info.HeroInfo)
if this.GetTeam() != nil {
this.GetTeam().SendUpdateNotify()
}
@ -486,25 +501,9 @@ func (this *player) updateChoose(skillId int32, heroUniId string,
return
}
{
this.name = rspObj.Info.UserInfo.Name
this.avatarUrl = rspObj.Info.UserInfo.HeadId
this.headFrame = rspObj.Info.UserInfo.HeadFrame
q5.DuckToSimple(rspObj.Info.UserInfo.AdmissionItemNum, &this.admissionItemNum)
q5.DuckToSimple(rspObj.Info.UserInfo.CircuitScore, &this.circuitScore)
q5.DuckToSimple(rspObj.Info.UserInfo.TotalLucky, &this.totalLucky)
{
this.hero.heroUniId = rspObj.Info.HeroInfo.HeroUniId
this.hero.heroId = q5.ToInt32(rspObj.Info.HeroInfo.HeroId)
this.hero.quality = q5.ToInt32(rspObj.Info.HeroInfo.Quality)
this.hero.specSkill = q5.ToInt32(rspObj.Info.HeroInfo.SpecSkill)
q5.DuckToSimple(rspObj.Info.HeroInfo.Wealth, &this.hero.wealth)
q5.DuckToSimple(rspObj.Info.HeroInfo.ValidLefttime, &this.hero.validLeftTime)
q5.DuckToSimple(rspObj.Info.HeroInfo.CurrentTimes, &this.hero.currentTimes)
q5.DuckToSimple(rspObj.Info.HeroInfo.TotalTimes, &this.hero.totalTimes)
q5.DuckToSimple(rspObj.Info.HeroInfo.SkinId, &this.hero.skinId)
}
this.parseUserInfo(&rspObj.Info.UserInfo)
this.parseHeroInfo(&rspObj.Info.HeroInfo)
cb(0, "")
}
}
})
@ -570,6 +569,88 @@ func (this *player) CMGrantInvitePermission(hdr *f5.MsgHdr, msg *cs.CMGrantInvit
this.GetTeam().SendUpdateNotify()
}
func (this *player) CMChooseBattleItem(hdr *f5.MsgHdr, msg *cs.CMChooseBattleItem) {
rspMsg := &cs.SMChooseBattleItem{}
if this.GetTeam().IsLock() {
rspMsg.Errcode = proto.Int32(1)
rspMsg.Errmsg = proto.String("team already started")
this.SendMsg(rspMsg)
return
}
params := map[string]string{
"c": "User",
"a": "getBattleItem",
"account_id": this.accountId,
"session_id": this.sessionId,
"item_id": q5.ToString(*msg.ItemId),
}
url := fmt.Sprintf("%s/webapp/index.php", mt.Table.Config.GetById(0).GetGameapiUrl())
f5.GetHttpCliMgr().SendJsStyleRequest(
url,
params,
func(rsp f5.HttpCliResponse) {
f5.GetSysLog().Info("getBattleItem:%s", rsp.GetRawData())
if this.GetTeam() != nil && !this.GetTeam().IsLock() {
if rsp.GetErr() != nil {
rspMsg.Errcode = proto.Int32(1)
rspMsg.Errmsg = proto.String("team already started")
this.SendMsg(rspMsg)
return
}
}
rspObj := struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
ItemId interface{} `json:"item_id"`
ItemNum interface{} `json:"item_num"`
ItemType interface{} `json:"item_type"`
ItemSubType interface{} `json:"item_sub_type"`
HasLuckySymbol interface{} `json:"has_lucky_symbol"`
TotalLucky interface{} `json:"total_lucky"`
}{}
err := json.Unmarshal([]byte(rsp.GetRawData()), &rspObj)
if err != nil || rspObj.Errcode != 0 {
rspMsg.Errcode = proto.Int32(500)
rspMsg.Errmsg = proto.String("server internal error")
this.SendMsg(rspMsg)
return
}
var itemId int32
var itemNum int32
var itemType int32
var itemSubType int32
q5.DuckToSimple(rspObj.ItemId, &itemId)
q5.DuckToSimple(rspObj.ItemNum, &itemNum)
q5.DuckToSimple(rspObj.ItemType, &itemType)
q5.DuckToSimple(rspObj.ItemSubType, &itemSubType)
q5.DuckToSimple(rspObj.HasLuckySymbol, &this.hasLuckySymbol)
q5.DuckToSimple(rspObj.TotalLucky, &this.totalLucky)
if itemNum > 0 {
found := false
for _, p := range(this.battleItems) {
if p.ItemType == itemType && p.ItemSubType == itemSubType {
p.ItemId = itemId
p.ItemNum = itemNum
p.ItemType = itemType
p.ItemSubType = itemSubType
found = true
break
}
}
if !found && itemId != constant.LUCKY_SYMBOL_ITEM_ID {
p := new(common.BattleItem)
p.ItemId = itemId
p.ItemNum = itemNum
p.ItemType = itemType
p.ItemSubType = itemSubType
q5.AppendSlice(&this.battleItems, p)
}
}
this.SendMsg(rspMsg)
this.GetTeam().SendUpdateNotify()
})
}
func (this *player) IsBattling() bool {
return this.battling
}
@ -578,7 +659,12 @@ func (this *player) SetBattling(state bool) {
this.battling = state
}
func (this *player) isLuckySymbolMap() bool {
return this.GetTeam().GetModeId() == 4
}
func newPlayer() *player {
hum := new(player)
q5.NewSlice(&hum.battleItems, 0, 2)
return hum
}

View File

@ -21,6 +21,7 @@ enum CMMessageId_e
_CMChooseHero = 116;
_CMChooseMap = 117;
_CMRefreshUser = 118;
_CMChooseBattleItem = 119;
}
enum SMMessageId_e
@ -41,6 +42,7 @@ enum SMMessageId_e
_SMChooseHero = 116;
_SMChooseMap = 117;
_SMRefreshUser = 118;
_SMChooseBattleItem = 120;
_SMTeamUpdateNotify = 1001;
_SMTeamStateNotify = 1002;

View File

@ -122,6 +122,13 @@ message MFJoinMsg
optional string payload = 2; //
}
//
message MFBattleItem
{
optional int32 item_id = 1; //id
optional int32 item_num = 2; //
}
//
message MFTeamMember
{
@ -141,6 +148,10 @@ message MFTeamMember
optional int32 admission_item_num = 14; //
optional int32 battling = 15; //
optional int32 circuit_score = 16; //
optional int32 vip_lv = 17; //vip等级
optional int64 vip_exp = 18; //vip经验
optional int32 has_vip_lucky = 19; //vip幸运值加成
repeated MFBattleItem battle_items = 20; //
}
//
@ -332,6 +343,18 @@ message SMRefreshUser
{
}
//
message CMChooseBattleItem
{
optional int32 item_id = 1; //id
}
message SMChooseBattleItem
{
optional int32 errcode = 1; // 0
optional string errmsg = 2; //
}
//
message CMGrantInvitePermission
{

View File

@ -100,7 +100,7 @@ func (this *team) GetMapId() int32 {
}
func (this *team) GetModeId() int32 {
return this.mapInfo.MapId
return q5.SafeToInt32(this.mapInfo.ModeId)
}
func (this *team) GetZnKey() int64 {
@ -385,6 +385,8 @@ func (this *team) genStartGameInfo() {
HeroUniId string `json:"hero_uniid"`
IsAndroid int32 `json:"is_android"`
RobotId int32 `json:"robot_id"`
HasLuckySymbol int32 `json:"has_lucky_symbol"`
BattleItems []*common.BattleItem `json:"battle_items"`
} `json:"members"`
} `json:"team_list"`
ObList []struct {
@ -436,6 +438,7 @@ func (this *team) genStartGameInfo() {
ele2.AccountId = m.GetAccountId()
ele2.SpecSkill = m.GetSpecSkill()
ele2.HeroUniId = m.GetHeroUniid()
ele2.BattleItems = m.GetBattleItems()
GetHistoryMgr().AddBattle(m.GetAccountId(),
this.mapInfo.MapId,
q5.SafeToInt32(this.mapInfo.ModeId))