This commit is contained in:
aozhiwei 2024-11-22 14:24:47 +08:00
parent eded5d0f8a
commit 4796f7e205
2 changed files with 19 additions and 1 deletions

View File

@ -45,3 +45,13 @@ func (this *Buff) FindByBuffUniId(accountId string, buffUniId int64) (error, boo
return nil, result.RowsAffected > 0
}
}
func (this *Buff) FindByBuffId(accountId string, buffId int32) (error, bool) {
if result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Table(this.TableName()).Take(
this, "account_id = ? and buff_id = ?", accountId, buffId); result.Error != nil &&
!errors.Is(result.Error, gorm.ErrRecordNotFound) {
return result.Error, false
} else {
return nil, result.RowsAffected > 0
}
}

View File

@ -30,7 +30,15 @@ func (this *buff) Add(accountId string, buffList []int32) {
buffMeta := mt.Table.Buff.GetById(int64(buffId))
if buffMeta != nil {
buffModel := new(model.Buff)
if buffMeta.GetCanStack() == 0 {
isCreate := false
if buffMeta.GetCanStack() == 1 {
if err, found := buffModel.FindByBuffId(accountId, buffMeta.GetBuffId()); err == nil {
isCreate = !found
} else {
continue
}
}
if isCreate {
buffModel.AccountId = accountId
buffModel.BuffId = buffMeta.GetBuffId()
buffModel.StartTime = nowTime