From 23c232d0d31bbe9afc5fb5a29162d5468d19f6c9 Mon Sep 17 00:00:00 2001 From: hahwu <31872165+hahwu@users.noreply.github.com> Date: Tue, 21 Oct 2025 16:57:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/game/mod/charge/Charge.go | 8 ++++++-- src/server/game/mod/playroom/playroom.go | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/server/game/mod/charge/Charge.go b/src/server/game/mod/charge/Charge.go index 19f2e577..d79f302e 100644 --- a/src/server/game/mod/charge/Charge.go +++ b/src/server/game/mod/charge/Charge.go @@ -406,7 +406,7 @@ func (c *ChargeMod) BuyEnergy() ([]*item.Item, []*item.Item, int) { LimitNum := c.WeeklyDiscount[0] Discount, WeeklyLimit := chargeCfg.GetWeeklyInfo(0) if LimitNum < WeeklyLimit { - diamond = int(math.Round(float64(diamond) * float64(Discount) / 100)) + diamond = int(math.Ceil(float64(diamond) * float64(Discount) / 100.0)) c.WeeklyDiscount[0] = LimitNum + 1 } } @@ -433,7 +433,11 @@ func (c *ChargeMod) BuyChess(Chess int) ([]*item.Item, []*item.Item, int, error) LimitNum := c.WeeklyDiscount[Chess] Discount, WeeklyLimit := chargeCfg.GetWeeklyInfo(Chess) if LimitNum < WeeklyLimit { - diamond = int(math.Round(float64(diamond) * float64(Discount) / 100)) + diamond = int(math.Ceil(float64(diamond) * float64(Discount) / 100)) + if diamond == v.Diamond { + diamond -= 1 + } + diamond = max(1, diamond) c.WeeklyDiscount[Chess] = LimitNum + 1 } } diff --git a/src/server/game/mod/playroom/playroom.go b/src/server/game/mod/playroom/playroom.go index 9e2c498a..3328d04f 100644 --- a/src/server/game/mod/playroom/playroom.go +++ b/src/server/game/mod/playroom/playroom.go @@ -2,6 +2,7 @@ package playroom import ( "fmt" + "math" "server/GoUtil" limitedTimeEventCfg "server/conf/limitedTimeEvent" playroomCfg "server/conf/playroom" @@ -937,14 +938,15 @@ func (p *PlayroomMod) ShopBuy(Id, Num int, WeeklyDiscount bool) ([]*item.Item, [ if AddItemId == 0 { return nil, nil, fmt.Errorf("ShopBuy AddItemId is 0") } - NewCostItem := item.MutilItem(CostItem, Num) + NewCostItem := CostItem[0].Num * Num if WeeklyDiscount { LimitNum := p.WeeklyDiscount[Id] if LimitNum < Limit { - NewCostItem = item.MutilItemFloat(NewCostItem, float64(Discount)/100.0) + NewCostItem = int(math.Ceil(float64(NewCostItem) * float64(Discount) / 100)) } } - return []*item.Item{item.NewItem(AddItemId, Num)}, NewCostItem, nil + CostItem[0].Num = NewCostItem + return []*item.Item{item.NewItem(AddItemId, Num)}, CostItem, nil } func (p *PlayroomMod) UnlockDress(Type, Id int) error {