This commit is contained in:
aozhiwei 2024-11-27 13:39:00 +08:00
parent c0673007d3
commit 3f17b23e6b
2 changed files with 23 additions and 0 deletions

View File

@ -54,6 +54,16 @@ func (this *ActivityApi) RollDice(c *gin.Context) {
f5.RspErr(c, 500, "server internal error4")
return
}
if reqJson.ForwardPoint > 0 {
if user.SpecDice <= 0 {
f5.RspErr(c, 1, "spec dice not enough")
return
}
if err := user.DecSpecDice(1); err != nil {
f5.RspErr(c, 500, "server internal error5")
return
}
}
if err := user.DecDice(1); err != nil {
f5.RspErr(c, 500, "server internal error5")
return

View File

@ -90,6 +90,19 @@ func (this *User) AddSpecDice(num int32) error {
return nil
}
func (this *User) DecSpecDice(num int32) error {
if this.Score < int64(num) {
return errors.New("")
}
oldSpecDice := this.SpecDice
this.SpecDice -= num
if err := this.UpdateFields([]string{"spec_dice"}); err != nil {
this.SpecDice = oldSpecDice
return err
}
return nil
}
func (this *User) DecScore(num int32) error {
if this.Score < int64(num) {
return errors.New("")