心愿单活动

This commit is contained in:
hahwu 2025-04-02 09:56:58 +08:00
parent dd7840ffbd
commit e5e75f9436
4 changed files with 969 additions and 943 deletions

View File

@ -16,6 +16,7 @@ const (
CFG_FREE_SHOP = "FreeShop"
CFG_CHARGE_CONST = "ChargeConst"
CFG_CHARGE_GIFT = "ChargeGift"
CFG_CHARGE_WISH = "ChargeWish"
)
func init() {
@ -26,6 +27,7 @@ func init() {
gamedata.InitCfg(CFG_FREE_SHOP)
gamedata.InitCfg(CFG_CHARGE_CONST)
gamedata.InitCfg(CFG_CHARGE_GIFT)
gamedata.InitCfg(CFG_CHARGE_WISH)
}
func GetMoneyCharge(ChargeId int) float64 {
@ -251,3 +253,11 @@ func GetChargeInfo(ChargeId int) (float64, string) {
}
return gamedata.GetFloatValue(data, "Money"), gamedata.GetStringValue(data, "Unit")
}
func GetWishCount(ItemId int) int {
data, err := gamedata.GetDataByIntKey(CFG_CHARGE_WISH, ItemId)
if err != nil {
return 0
}
return gamedata.GetIntValue(data, "Wish")
}

View File

@ -4017,7 +4017,7 @@ func ReqAddWish(player *Player, buf []byte) error {
req := &msg.ReqAddWish{}
proto.Unmarshal(buf, req)
ChargeMod := player.PlayMod.getChargeMod()
Items, err := ChargeMod.AddWish(int(req.Id))
Items, err := ChargeMod.AddWish(int(req.Id), int(req.Type))
if err != nil {
player.SendErrClienRes(&msg.ResAddWish{
Code: msg.RES_CODE_FAIL,

View File

@ -62,7 +62,12 @@ var ChessDiamondCfg = map[int]int{
const (
SPECIAL_TYPE_1 = 1 // 特惠礼包1
SPECIAL_TYPE_2 = 2 // 特惠礼包2
)
const (
PLAYROOM_SHOP = 1 // playroom商店
CHESS_SHOP = 2 // 棋子商店
ENERGY_SHOP = 3 // 能量商店
)
func (c *ChargeMod) InitData() {
@ -316,8 +321,12 @@ func (c *ChargeMod) TriggerChargeUnlock(Lv int, Emit []int) {
c.InitChessShop(Emit)
}
func (c *ChargeMod) AddWish(Id int) ([]*item.Item, error) {
ItemId, _ := playroomCfg.GetShopItem(Id)
func (c *ChargeMod) AddWish(Id, Type int) ([]*item.Item, error) {
ItemId := 0
switch Type {
case PLAYROOM_SHOP:
ItemId, _ = playroomCfg.GetShopItem(Id)
}
if ItemId == 0 {
return nil, fmt.Errorf("AddWish itemid not exist id:%d", Id)
}
@ -337,8 +346,7 @@ func (c *ChargeMod) GetWish() ([]*item.Item, error) {
if c.WishList.ItemId == 0 {
return nil, fmt.Errorf("AddWishCount itemid not exist")
}
// TODO 需要修改成chargeCfg
Max := playroomCfg.GetShopWish(c.WishList.ItemId)
Max := chargeCfg.GetWishCount(c.WishList.ItemId)
if c.WishList.Count < Max {
return nil, fmt.Errorf("AddWishCount count max")
}
@ -361,8 +369,7 @@ func (c *ChargeMod) AddWishCount() {
if c.WishList.ItemId == 0 {
return
}
// TODO 需要修改成chargeCfg
Max := playroomCfg.GetShopWish(c.WishList.ItemId)
Max := chargeCfg.GetWishCount(c.WishList.ItemId)
if c.WishList.Count >= Max {
return
}

File diff suppressed because it is too large Load Diff