55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
package service
|
|
|
|
import (
|
|
"f5"
|
|
"main/model"
|
|
"main/constant"
|
|
"main/mt"
|
|
)
|
|
|
|
type buff struct {
|
|
|
|
}
|
|
|
|
func (this *buff) init() {
|
|
}
|
|
|
|
func (this *buff) unInit() {
|
|
}
|
|
|
|
func (this *buff) List(accountId string) (error, []*model.Buff) {
|
|
buffs := []*model.Buff{}
|
|
result := f5.GetApp().GetOrmDb(constant.WHEEL_DB).Table(new(model.Buff).TableName()).Where(
|
|
"account_id = ?", accountId).Find(&buffs)
|
|
return result.Error, buffs
|
|
}
|
|
|
|
func (this *buff) Add(accountId string, buffList []int32) {
|
|
nowTime := int32(f5.GetApp().GetRealSeconds())
|
|
for buffId := range(buffList) {
|
|
buffMeta := mt.Table.Buff.GetById(int64(buffId))
|
|
if buffMeta != nil {
|
|
buffModel := new(model.Buff)
|
|
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
|
|
buffModel.EffectiveTime = buffMeta.GetDurationTime()
|
|
buffModel.CreateTime = nowTime
|
|
buffModel.ModifyTime = nowTime
|
|
buffModel.Create()
|
|
} else {
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|