mapgrid award
This commit is contained in:
parent
9c5c6e5281
commit
0e3b035077
@ -9,6 +9,7 @@ import (
|
||||
"main/service"
|
||||
"main/vo"
|
||||
"math/rand"
|
||||
"q5"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -34,7 +35,7 @@ func (this *ActivityApi) RollDice(c *gin.Context) {
|
||||
}
|
||||
user := new(model.User)
|
||||
nowTime := f5.GetApp().GetRealSeconds()
|
||||
if err, found := user.Find(s.GetAccountId(), nowTime); err != nil {
|
||||
if err, found := user.Find(s.GetAccountId(), nowTime); err != nil {
|
||||
f5.RspErr(c, 500, "server internal error1")
|
||||
return
|
||||
} else if !found {
|
||||
@ -68,7 +69,7 @@ func (this *ActivityApi) RollDice(c *gin.Context) {
|
||||
f5.RspErr(c, 500, "server internal error5")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if err := user.AddScore(score); err != nil {
|
||||
f5.RspErr(c, 500, "server internal error6")
|
||||
return
|
||||
@ -91,7 +92,7 @@ func (this *ActivityApi) RollDice(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
var gridMeta *mt.MapGrid
|
||||
if user.CurrGrid + rspObj.Point > mt.Table.MapGrid.GetMaxGridId() {
|
||||
if user.CurrGrid+rspObj.Point > mt.Table.MapGrid.GetMaxGridId() {
|
||||
user.CurrGrid = user.CurrGrid + rspObj.Point - mt.Table.MapGrid.GetMaxGridId()
|
||||
gridMeta = mt.Table.MapGrid.GetById(int64(user.CurrGrid))
|
||||
if gridMeta == nil {
|
||||
@ -112,10 +113,49 @@ func (this *ActivityApi) RollDice(c *gin.Context) {
|
||||
f5.RspErr(c, 500, "server internal error7")
|
||||
return
|
||||
}
|
||||
for _, item := range(*items) {
|
||||
for _, item := range *items {
|
||||
rspObj.GetOrCreateAward().AddItem(item.ItemId, item.ItemNum)
|
||||
}
|
||||
rspObj.GetOrCreateAward().AddItem(constant.VIRTUAL_ITEM_SCORE, score)
|
||||
|
||||
totalaward := rspObj.GetOrCreateAward()
|
||||
bageffect := false
|
||||
for _, awarditem := range totalaward.Items {
|
||||
itemcfg := mt.Table.Item.GetById(int64(awarditem.ItemId))
|
||||
switch itemcfg.GetItemType() {
|
||||
case constant.ITEM_TYPE_SCORE:
|
||||
user.AddScore(awarditem.ItemNum)
|
||||
case constant.ITEM_TYPE_DICE:
|
||||
user.AddDice(awarditem.ItemNum)
|
||||
case constant.ITEM_TYPE_SPEC_DICE:
|
||||
user.AddSpecDice(awarditem.ItemNum)
|
||||
case constant.ITEM_TYPE_CHIP:
|
||||
for i := int32(0); i < awarditem.ItemNum; i++ {
|
||||
chip := new(model.Chip)
|
||||
chip.AccountId = user.AccountId
|
||||
chip.ItemId = awarditem.ItemId
|
||||
chip.ItemNum = 1
|
||||
chip.ExpireTime = int32(nowTime) + itemcfg.GetTime()*60
|
||||
chip.CreateTime = int32(nowTime)
|
||||
chip.ModifyTime = int32(nowTime)
|
||||
if chip.Create() != nil {
|
||||
f5.GetSysLog().Error("internal error, mapgrid chip award fail:%s, %d, %d", user.AccountId, user.CurrGrid, awarditem.ItemId)
|
||||
}
|
||||
}
|
||||
case constant.ITEM_TYPE_SCORE_DOUBLE_CARD:
|
||||
fallthrough
|
||||
case constant.ITEM_TYPE_SCORE_SMALL_GIFT_PACK:
|
||||
fallthrough
|
||||
case constant.ITEM_TYPE_SCORE_BIG_GIFT_PACK:
|
||||
service.Award.AddItem(user.AccountId, awarditem.ItemId, awarditem.ItemNum, nil)
|
||||
bageffect = true
|
||||
}
|
||||
}
|
||||
|
||||
if bageffect {
|
||||
q5.AppendSlice(&rspObj.BaseVo.GetOrCreateSideEffect().Effects, "bag")
|
||||
}
|
||||
rspObj.GetOrCreateSideEffect().GetOrCreateUser().FromModel(user)
|
||||
|
||||
c.JSON(200, rspObj)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user