adjust
This commit is contained in:
parent
adf2337fde
commit
c03212df1c
@ -117,7 +117,8 @@ func (this *ActivityApi) RollDice(c *gin.Context) {
|
|||||||
awardgridids := mt.Table.MapGrid.GetAwardGridIdList()
|
awardgridids := mt.Table.MapGrid.GetAwardGridIdList()
|
||||||
if len(*items) > 0 {
|
if len(*items) > 0 {
|
||||||
gridawarded := false
|
gridawarded := false
|
||||||
for _, id := range user.AwardGridsList {
|
userAwardgrids := user.GetAwardGrids()
|
||||||
|
for _, id := range userAwardgrids {
|
||||||
if id == user.CurrGrid {
|
if id == user.CurrGrid {
|
||||||
gridawarded = true
|
gridawarded = true
|
||||||
break
|
break
|
||||||
@ -129,7 +130,7 @@ func (this *ActivityApi) RollDice(c *gin.Context) {
|
|||||||
rspObj.GetOrCreateAward().AddItem(item.ItemId, item.ItemNum)
|
rspObj.GetOrCreateAward().AddItem(item.ItemId, item.ItemNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(awardgridids) > len(user.AwardGridsList) + 1 {
|
if len(awardgridids) > len(userAwardgrids) + 1 {
|
||||||
user.AddAwardGrid(user.CurrGrid)
|
user.AddAwardGrid(user.CurrGrid)
|
||||||
} else {
|
} else {
|
||||||
user.ClearAwardGrid()
|
user.ClearAwardGrid()
|
||||||
|
@ -28,8 +28,7 @@ type User struct {
|
|||||||
SpecDice int32 `gorm:"column:spec_dice"`
|
SpecDice int32 `gorm:"column:spec_dice"`
|
||||||
LastPresentDiceTime int32 `gorm:"column:last_present_dice_time"`
|
LastPresentDiceTime int32 `gorm:"column:last_present_dice_time"`
|
||||||
CurrGrid int32 `gorm:"column:curr_grid"`
|
CurrGrid int32 `gorm:"column:curr_grid"`
|
||||||
AwardGrids string `gorm:"column:award_grids"`
|
awardGrids string `gorm:"column:award_grids"`
|
||||||
AwardGridsList []int32 `gorm:"-`
|
|
||||||
CreateTime int32 `gorm:"column:createtime;<-:create"`
|
CreateTime int32 `gorm:"column:createtime;<-:create"`
|
||||||
ModifyTime int32 `gorm:"column:modifytime"`
|
ModifyTime int32 `gorm:"column:modifytime"`
|
||||||
}
|
}
|
||||||
@ -67,13 +66,6 @@ func (this *User) Find(accountId string, nowTime int64) (error, bool) {
|
|||||||
return err, false
|
return err, false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gridstr := strings.Split(this.AwardGrids, ",")
|
|
||||||
this.AwardGridsList = []int32{}
|
|
||||||
for _, item := range gridstr {
|
|
||||||
if item != "" {
|
|
||||||
this.AwardGridsList = append(this.AwardGridsList, q5.SafeToInt32(item))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nil, result.RowsAffected > 0
|
return nil, result.RowsAffected > 0
|
||||||
}
|
}
|
||||||
@ -170,12 +162,12 @@ func (this *User) UpdateName() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *User) AddAwardGrid(gridid int32) error {
|
func (this *User) AddAwardGrid(gridid int32) error {
|
||||||
this.AwardGridsList = append(this.AwardGridsList, gridid)
|
awardGridsList := this.GetAwardGrids()
|
||||||
if len(this.AwardGridsList) > 1 {
|
if len(awardGridsList) > 1 {
|
||||||
this.AwardGrids += ","
|
this.awardGrids += ","
|
||||||
}
|
}
|
||||||
|
|
||||||
this.AwardGrids += q5.SafeToString(gridid)
|
this.awardGrids += q5.SafeToString(gridid)
|
||||||
if err := this.UpdateFields([]string{"award_grids"}); err != nil {
|
if err := this.UpdateFields([]string{"award_grids"}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -183,10 +175,22 @@ func (this *User) AddAwardGrid(gridid int32) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *User) ClearAwardGrid() error {
|
func (this *User) ClearAwardGrid() error {
|
||||||
this.AwardGridsList = []int32{}
|
this.awardGrids = ""
|
||||||
this.AwardGrids = ""
|
|
||||||
if err := this.UpdateFields([]string{"award_grids"}); err != nil {
|
if err := this.UpdateFields([]string{"award_grids"}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *User) GetAwardGrids() []int32 {
|
||||||
|
|
||||||
|
gridstr := strings.Split(this.awardGrids, ",")
|
||||||
|
awardGridsList := []int32{}
|
||||||
|
for _, item := range gridstr {
|
||||||
|
if item != "" {
|
||||||
|
awardGridsList = append(awardGridsList, q5.SafeToInt32(item))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return awardGridsList
|
||||||
|
}
|
||||||
|
@ -27,5 +27,5 @@ func (this *User) FromModel(m *model.User) {
|
|||||||
this.SpecDice = m.SpecDice
|
this.SpecDice = m.SpecDice
|
||||||
this.CurrGrid = m.CurrGrid
|
this.CurrGrid = m.CurrGrid
|
||||||
this.LastPresentDiceTime = m.LastPresentDiceTime
|
this.LastPresentDiceTime = m.LastPresentDiceTime
|
||||||
this.AwardGrids = m.AwardGridsList
|
this.AwardGrids = m.GetAwardGrids()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user