1
This commit is contained in:
parent
13cc4bf78b
commit
d4ab444303
@ -25,8 +25,24 @@ type SideEffect struct {
|
||||
Effects []string `json:"effects"`
|
||||
}
|
||||
|
||||
func (this *Award) getById(itemId int32) *AwardItem {
|
||||
for _, val := range this.Items {
|
||||
if val.ItemId == itemId {
|
||||
return val
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *Award) AddItem(itemId int32, itemNum int32) {
|
||||
p := new(AwardItem)
|
||||
p := this.getById(itemId)
|
||||
if p == nil {
|
||||
p = new(AwardItem)
|
||||
p.ItemId = itemId
|
||||
p.ItemNum = itemNum
|
||||
} else {
|
||||
p.ItemNum += itemNum
|
||||
}
|
||||
q5.AppendSlice(&this.Items, p)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user