From 43eac6b4088e21a18ef3a473c7728650d71b2bd1 Mon Sep 17 00:00:00 2001 From: yangduo Date: Mon, 9 Dec 2024 11:35:16 +0800 Subject: [PATCH] fullgrid award --- bin/wheelserver/res/buff@buff.json | 2 +- bin/wheelserver/res/item@item.json | 36 +++--- bin/wheelserver/res/mapGrid@mapGrid.json | 14 +- bin/wheelserver/res/shopGoods@shopGoods.json | 122 +++++++++++------- bin/wheelserver/res/task@task.json | 96 +++++++++++--- .../wheelserver/api/v1/activity/activity.go | 92 ++++++++++--- server/wheelserver/api/v1/user/user.go | 33 +---- .../wheelserver/router/activity/activity.go | 5 +- 8 files changed, 258 insertions(+), 142 deletions(-) diff --git a/bin/wheelserver/res/buff@buff.json b/bin/wheelserver/res/buff@buff.json index 3acf9956..06073bd6 100644 --- a/bin/wheelserver/res/buff@buff.json +++ b/bin/wheelserver/res/buff@buff.json @@ -3,7 +3,7 @@ "can_stack": 1, "duration_time": 3600, "buff_id": 10001, - "name": "\u53cc\u500d\u79ef\u5206\u5361", + "name": "\u4e09\u500d\u79ef\u5206\u5361", "buff_effect": 1 } ] \ No newline at end of file diff --git a/bin/wheelserver/res/item@item.json b/bin/wheelserver/res/item@item.json index e6e29052..1b5d871a 100644 --- a/bin/wheelserver/res/item@item.json +++ b/bin/wheelserver/res/item@item.json @@ -13,7 +13,7 @@ "time": 1440, "buff_list": "", "id": 10001, - "icon": "chip/chip01" + "icon": "item/icon_chip" }, { "name": "Vision", @@ -29,7 +29,7 @@ "time": 1440, "buff_list": "", "id": 10002, - "icon": "chip/chip01" + "icon": "item/icon_chip" }, { "name": "Vision", @@ -45,7 +45,7 @@ "time": 1440, "buff_list": "", "id": 10003, - "icon": "chip/chip01" + "icon": "item/icon_chip" }, { "name": "Vision", @@ -61,7 +61,7 @@ "time": 1440, "buff_list": "", "id": 10004, - "icon": "chip/chip01" + "icon": "item/icon_chip" }, { "name": "Vision", @@ -77,7 +77,7 @@ "time": 1440, "buff_list": "", "id": 10005, - "icon": "chip/chip01" + "icon": "item/icon_chip" }, { "name": "Vision", @@ -93,7 +93,7 @@ "time": 1440, "buff_list": "", "id": 10006, - "icon": "chip/chip01" + "icon": "item/icon_chip" }, { "name": "Vision", @@ -109,7 +109,7 @@ "time": 1440, "buff_list": "", "id": 10007, - "icon": "chip/chip01" + "icon": "item/icon_chip" }, { "name": "score", @@ -125,10 +125,10 @@ "time": "", "buff_list": "", "id": 20001, - "icon": "" + "icon": "item/Gem_icon" }, { - "name": "", + "name": "Universal Dice", "level": 1, "price_type": "", "price": "", @@ -141,10 +141,10 @@ "time": "", "buff_list": "", "id": 20002, - "icon": "" + "icon": "item/Monopoly_dice_icon2" }, { - "name": "", + "name": "Triple Points Card", "level": 1, "price_type": "", "price": "", @@ -157,10 +157,10 @@ "time": "", "buff_list": 10001, "id": 20003, - "icon": "" + "icon": "item/triple_card" }, { - "name": "", + "name": "Points gift (small)", "level": 1, "price_type": "", "price": "", @@ -173,10 +173,10 @@ "time": "", "buff_list": "", "id": 20004, - "icon": "" + "icon": "item/gift01" }, { - "name": "", + "name": "Points gift (big)", "level": 1, "price_type": "", "price": "", @@ -189,10 +189,10 @@ "time": "", "buff_list": "", "id": 20005, - "icon": "" + "icon": "item/gift02" }, { - "name": "", + "name": "Dice", "level": 1, "price_type": "", "price": "", @@ -205,6 +205,6 @@ "time": "", "buff_list": "", "id": 20006, - "icon": "" + "icon": "item/Monopoly_dice_icon" } ] \ No newline at end of file diff --git a/bin/wheelserver/res/mapGrid@mapGrid.json b/bin/wheelserver/res/mapGrid@mapGrid.json index 2a077c5a..3547b059 100644 --- a/bin/wheelserver/res/mapGrid@mapGrid.json +++ b/bin/wheelserver/res/mapGrid@mapGrid.json @@ -1,7 +1,7 @@ [ { "direction": 1, - "reward": "20002:1000", + "reward": "20001:3000", "id": 1, "pos": "326:93" }, @@ -67,7 +67,7 @@ }, { "direction": "", - "reward": "20002:1000", + "reward": "20002:2", "id": 12, "pos": "90:14" }, @@ -97,7 +97,7 @@ }, { "direction": "", - "reward": "20002:1000", + "reward": "20003:1", "id": 17, "pos": "45:-130" }, @@ -133,7 +133,7 @@ }, { "direction": "", - "reward": "20002:1000", + "reward": "20006:2", "id": 23, "pos": "-248:-80" }, @@ -157,7 +157,7 @@ }, { "direction": 1, - "reward": "20002:1000", + "reward": "20001:1000", "id": 27, "pos": "-344:34" }, @@ -187,7 +187,7 @@ }, { "direction": 1, - "reward": "20002:1000", + "reward": "20002:2", "id": 32, "pos": "-270:204" }, @@ -217,7 +217,7 @@ }, { "direction": 1, - "reward": "20002:1000", + "reward": "20003:2", "id": 37, "pos": "10:202" }, diff --git a/bin/wheelserver/res/shopGoods@shopGoods.json b/bin/wheelserver/res/shopGoods@shopGoods.json index 82bc7527..5afd73dc 100644 --- a/bin/wheelserver/res/shopGoods@shopGoods.json +++ b/bin/wheelserver/res/shopGoods@shopGoods.json @@ -2,121 +2,151 @@ { "goods_id": 1001, "price": 1, - "introduce": "1\u4e2a\u9ab0\u5b50", + "introduce": "Dice*1", "amount": 1, - "shop_id": 1, - "item_id": 20006 + "item_id": 20006, + "type": 1, + "id": 1, + "icon": "item/Monopoly_dice_icon" }, { "goods_id": 1002, "price": 1, - "introduce": "2\u4e2a\u9ab0\u5b50", + "introduce": "Dice*2", "amount": 2, - "shop_id": 2, - "item_id": 20006 + "item_id": 20006, + "type": 1, + "id": 2, + "icon": "item/Monopoly_dice_icon12" }, { "goods_id": 1003, "price": 1, - "introduce": "3\u4e2a\u9ab0\u5b50", + "introduce": "Dice*3", "amount": 3, - "shop_id": 3, - "item_id": 20006 + "item_id": 20006, + "type": 1, + "id": 3, + "icon": "item/Monopoly_dice_icon13" }, { "goods_id": 1004, "price": 1, - "introduce": "4\u4e2a\u9ab0\u5b50", + "introduce": "Dice*4", "amount": 4, - "shop_id": 4, - "item_id": 20006 + "item_id": 20006, + "type": 1, + "id": 4, + "icon": "item/Monopoly_dice_icon14" }, { "goods_id": 1005, "price": 1, - "introduce": "1\u4e2aspecify\u9ab0\u5b50", + "introduce": "universal Dice*1", "amount": 1, - "shop_id": 5, - "item_id": 20002 + "item_id": 20002, + "type": 1, + "id": 5, + "icon": "item/Monopoly_dice_icon2" }, { "goods_id": 1006, "price": 1, - "introduce": "2\u4e2aspecify\u9ab0\u5b50", + "introduce": "universal Dice*2", "amount": 2, - "shop_id": 6, - "item_id": 20002 + "item_id": 20002, + "type": 1, + "id": 6, + "icon": "item/Monopoly_dice_icon22" }, { "goods_id": 1007, "price": 1, - "introduce": "3\u4e2aspecify\u9ab0\u5b50", + "introduce": "universal Dice*3", "amount": 3, - "shop_id": 7, - "item_id": 20002 + "item_id": 20002, + "type": 1, + "id": 7, + "icon": "item/Monopoly_dice_icon23" }, { "goods_id": 1008, "price": 1, - "introduce": "1\u5f203\u500d\u79ef\u5206\u5361", - "amount": 4, - "shop_id": 8, - "item_id": 20003 + "introduce": "Triple Points Card", + "amount": 1, + "item_id": 20003, + "type": 1, + "id": 8, + "icon": "item/triple_card" }, { "goods_id": 1009, "price": 1, - "introduce": "1\u4e2a1\u7ea7\u82af\u7247", + "introduce": "Level 1 chip", "amount": 1, - "shop_id": 9, - "item_id": 10001 + "item_id": 10001, + "type": 2, + "id": 9, + "icon": "item/icon_chip" }, { "goods_id": 1010, "price": 1, - "introduce": "1\u4e2a2\u7ea7\u82af\u7247", + "introduce": "Level 2 chip", "amount": 1, - "shop_id": 10, - "item_id": 10002 + "item_id": 10002, + "type": 2, + "id": 10, + "icon": "item/icon_chip" }, { "goods_id": 1011, "price": 1, - "introduce": "1\u4e2a3\u7ea7\u82af\u7247", + "introduce": "Level 3 chip", "amount": 1, - "shop_id": 11, - "item_id": 10003 + "item_id": 10003, + "type": 2, + "id": 11, + "icon": "item/icon_chip" }, { "goods_id": 1012, "price": 1, - "introduce": "1\u4e2a4\u7ea7\u82af\u7247", + "introduce": "Level 4 chip", "amount": 1, - "shop_id": 12, - "item_id": 10004 + "item_id": 10004, + "type": 2, + "id": 12, + "icon": "item/icon_chip" }, { "goods_id": 1013, "price": 1, - "introduce": "1\u4e2a5\u7ea7\u82af\u7247", + "introduce": "Level 5 chip", "amount": 1, - "shop_id": 13, - "item_id": 10005 + "item_id": 10005, + "type": 2, + "id": 13, + "icon": "item/icon_chip" }, { "goods_id": 1014, "price": 1, - "introduce": "1\u4e2a6\u7ea7\u82af\u7247", + "introduce": "Level 6 chip", "amount": 1, - "shop_id": 14, - "item_id": 10006 + "item_id": 10006, + "type": 2, + "id": 14, + "icon": "item/icon_chip" }, { "goods_id": 1015, "price": 1, - "introduce": "1\u4e2a7\u7ea7\u82af\u7247", + "introduce": "Level 7 chip", "amount": 1, - "shop_id": 15, - "item_id": 10007 + "item_id": 10007, + "type": 2, + "id": 15, + "icon": "item/icon_chip" } ] \ No newline at end of file diff --git a/bin/wheelserver/res/task@task.json b/bin/wheelserver/res/task@task.json index 73afae1d..c549aa95 100644 --- a/bin/wheelserver/res/task@task.json +++ b/bin/wheelserver/res/task@task.json @@ -3,42 +3,98 @@ "reward_type": 1, "Icon1": "", "des": "\u7d2f\u8ba1\u8d5a\u53d6\u591a\u5c11\u79ef\u5206", - "name": "\u7d2f\u8ba1\u8d5a\u53d6\u591a\u5c11\u79ef\u5206", - "param2": 0, + "name": "Earn points cumulatively", + "param2": 2, "param1": 1000, "reward": 100, "_Beizhu": "", - "type": 1, + "type": 2, "id": 10001, - "condition": 1, - "icon": "" - }, - { - "reward_type": 1, - "Icon1": "", - "des": "\u9080\u8bf7\u591a\u5c11\u597d\u53cb", - "name": "\u9080\u8bf7\u591a\u5c11\u597d\u53cb", - "param2": 0, - "param1": 10, - "reward": 100, - "_Beizhu": "", - "type": 1, - "id": 10002, "condition": 2, "icon": "" }, + { + "reward_type": 1, + "Icon1": "", + "des": "\u9080\u8bf7\u591a\u5c11\u597d\u53cb", + "name": "Invite friends", + "param2": 0, + "param1": 2, + "reward": 100, + "_Beizhu": "", + "type": 2, + "id": 10002, + "condition": 1, + "icon": "" + }, { "reward_type": 1, "Icon1": "", "des": "\u6210\u529f\u8f6c\u53d1\u7ed9\u5176\u4ed6\u4eba", - "name": "\u6210\u529f\u8f6c\u53d1\u7ed9\u5176\u4ed6\u4eba", - "param2": 300, + "name": "Successfully forwarded to others", + "param2": 0, + "param1": 1, + "reward": 100, + "_Beizhu": "", + "type": 1, + "id": 10003, + "condition": 1, + "icon": "" + }, + { + "reward_type": 1, + "Icon1": "", + "des": "\u6295\u63b7\u9ab0\u5b50", + "name": "Throw the dice", + "param2": 7, + "param1": 3, + "reward": 100, + "_Beizhu": "", + "type": 2, + "id": 10004, + "condition": 3, + "icon": "" + }, + { + "reward_type": 1, + "Icon1": "", + "des": "\u4f7f\u7528\u7279\u6b8a\u9ab0\u5b50", + "name": "Use universal dice", + "param2": 3, "param1": 1, "reward": 100, "_Beizhu": "", "type": 2, - "id": 10003, + "id": 10005, "condition": 3, "icon": "" + }, + { + "reward_type": 1, + "Icon1": "", + "des": "\u4f7f\u75283\u500d\u79ef\u5206\u5361", + "name": "Use triple points card", + "param2": 4, + "param1": 1, + "reward": 100, + "_Beizhu": "", + "type": 2, + "id": 10006, + "condition": 3, + "icon": "" + }, + { + "reward_type": 1, + "Icon1": "", + "des": "\u8d2d\u4e70\u82af\u7247", + "name": "buy chips", + "param2": 1, + "param1": 1, + "reward": 100, + "_Beizhu": "", + "type": 2, + "id": 10007, + "condition": 4, + "icon": "" } ] \ No newline at end of file diff --git a/server/wheelserver/api/v1/activity/activity.go b/server/wheelserver/api/v1/activity/activity.go index ac388bd7..bd0e721d 100644 --- a/server/wheelserver/api/v1/activity/activity.go +++ b/server/wheelserver/api/v1/activity/activity.go @@ -70,10 +70,6 @@ func (this *ActivityApi) RollDice(c *gin.Context) { return } - if err := user.AddScore(score); err != nil { - f5.RspErr(c, 500, "server internal error6") - return - } rspObj := struct { vo.BaseVo Point int32 `json:"point"` @@ -114,7 +110,7 @@ func (this *ActivityApi) RollDice(c *gin.Context) { return } - awardgridids := mt.Table.MapGrid.GetAwardGridIdList() + fullgrid := false if len(*items) > 0 { gridawarded := false userAwardgrids := user.GetAwardGrids() @@ -130,17 +126,83 @@ func (this *ActivityApi) RollDice(c *gin.Context) { rspObj.GetOrCreateAward().AddItem(item.ItemId, item.ItemNum) } - if len(awardgridids) > len(userAwardgrids) + 1 { + awardgridids := mt.Table.MapGrid.GetAwardGridIdList() + if len(awardgridids) > len(userAwardgrids)+1 { user.AddAwardGrid(user.CurrGrid) } else { - user.ClearAwardGrid() + fullgrid = true } } } rspObj.GetOrCreateAward().AddItem(constant.VIRTUAL_ITEM_SCORE, score) - totalaward := rspObj.GetOrCreateAward() + if this.handleAwards(user, rspObj.GetOrCreateAward()) { + q5.AppendSlice(&rspObj.BaseVo.GetOrCreateSideEffect().Effects, "bag") + } + + if fullgrid { + q5.AppendSlice(&rspObj.BaseVo.GetOrCreateSideEffect().Effects, "fullgrid") + } + rspObj.GetOrCreateSideEffect().GetOrCreateUser().FromModel(user) + + c.JSON(200, rspObj) +} + +func (this *ActivityApi) Claim(c *gin.Context) { + s := c.MustGet(constant.SESSION_KEY).(common.Session) + if s == nil { + return + } + + user := new(model.User) + nowTime := f5.GetApp().GetRealSeconds() + if err, found := user.Find(s.GetAccountId(), nowTime); err != nil { + f5.RspErr(c, 500, "server internal error1") + return + } else if !found { + f5.RspErr(c, 500, "server internal error2") + return + } + + awardgridids := mt.Table.MapGrid.GetAwardGridIdList() + userAwardgrids := user.GetAwardGrids() + if len(awardgridids) != len(userAwardgrids) { + f5.RspErr(c, 500, "bad reques") + return + } + + rspObj := vo.BaseVo{} + + gridMeta := mt.Table.MapGrid.GetById(0) + if gridMeta == nil { + f5.RspErr(c, 500, "server internal error7") + return + } + + items := gridMeta.GetRewardItems() + if items == nil { + f5.RspErr(c, 500, "server internal error7") + return + } + + user.CurrGrid = 1 + user.AwardGrids = "" + user.UpdateFields([]string{"curr_grid", "award_grids"}) + + for _, item := range *items { + rspObj.GetOrCreateAward().AddItem(item.ItemId, item.ItemNum) + } + + if this.handleAwards(user, rspObj.GetOrCreateAward()) { + q5.AppendSlice(&rspObj.GetOrCreateSideEffect().Effects, "bag") + } + rspObj.GetOrCreateSideEffect().GetOrCreateUser().FromModel(user) + + c.JSON(200, rspObj) +} + +func (aa *ActivityApi) handleAwards(user *model.User, totalaward *vo.Award) bool { bageffect := false for _, awarditem := range totalaward.Items { itemcfg := mt.Table.Item.GetById(int64(awarditem.ItemId)) @@ -152,14 +214,15 @@ func (this *ActivityApi) RollDice(c *gin.Context) { case constant.ITEM_TYPE_SPEC_DICE: user.AddSpecDice(awarditem.ItemNum) case constant.ITEM_TYPE_CHIP: + nowTime := int32(f5.GetApp().GetRealSeconds()) 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) + chip.ExpireTime = nowTime + itemcfg.GetTime()*60 + chip.CreateTime = nowTime + chip.ModifyTime = nowTime if chip.Create() != nil { f5.GetSysLog().Error("internal error, mapgrid chip award fail:%s, %d, %d", user.AccountId, user.CurrGrid, awarditem.ItemId) } @@ -174,10 +237,5 @@ func (this *ActivityApi) RollDice(c *gin.Context) { } } - if bageffect { - q5.AppendSlice(&rspObj.BaseVo.GetOrCreateSideEffect().Effects, "bag") - } - rspObj.GetOrCreateSideEffect().GetOrCreateUser().FromModel(user) - - c.JSON(200, rspObj) + return bageffect } diff --git a/server/wheelserver/api/v1/user/user.go b/server/wheelserver/api/v1/user/user.go index b9ba6e08..57594ffb 100644 --- a/server/wheelserver/api/v1/user/user.go +++ b/server/wheelserver/api/v1/user/user.go @@ -90,35 +90,4 @@ func (this *UserApi) Info(c *gin.Context) { rspObj.UserInfo.FromModel(user) rspObj.UserInfo.HourlyEarnings = service.Chip.GetHourEarning(user.AccountId) c.JSON(200, rspObj) -} - -func (this *UserApi) ClaimEarning(c *gin.Context) { - s := c.MustGet(constant.SESSION_KEY).(common.Session) - if s == nil { - return - } - - rspObj := struct { - vo.BaseVo - Earning int32 `json:"earning"` - Score int64 `json:"score"` - }{} - - rspObj.Earning = service.Chip.CalcScore(s.GetAccountId()) - if rspObj.Earning > 0 { - user := new(model.User) - nowTime := f5.GetApp().GetRealSeconds() - if err, found := user.Find(s.GetAccountId(), nowTime); err != nil { - f5.RspErr(c, 500, "server internal error") - return - } else if !found { - f5.RspErr(c, 1, "server internal error") - return - } - - user.AddScore(rspObj.Earning) - rspObj.Score = user.Score - } - - c.JSON(200, rspObj) -} +} \ No newline at end of file diff --git a/server/wheelserver/router/activity/activity.go b/server/wheelserver/router/activity/activity.go index 64569aad..99686189 100644 --- a/server/wheelserver/router/activity/activity.go +++ b/server/wheelserver/router/activity/activity.go @@ -2,8 +2,8 @@ package activity import ( "f5" + v1 "main/api/v1" "main/middleware" - "main/api/v1" ) type ActivityRouter struct{} @@ -13,4 +13,7 @@ func (this *ActivityRouter) InitRouter() { f5.GetApp().GetGinEngine().POST("/api/v1/activity/roll_dice", middleware.JwtAuth, api.ActivityApi.RollDice) + f5.GetApp().GetGinEngine().GET("/api/v1/activity/claim", + middleware.JwtAuth, + api.ActivityApi.Claim) }