85 lines
2.7 KiB
Go
85 lines
2.7 KiB
Go
package logic
|
|
|
|
//type PlayerAchievement struct {
|
|
// Key uint64 `bson:"key" key:"1"` //Type<<32|Extra
|
|
// Process uint32 `bson:"process"`
|
|
// Statuses map[uint32]uint32 `bson:"statuses"`
|
|
//}
|
|
//
|
|
//func (this *PlayerAchievement) BuildMsgAchievement() *proto.Achievement {
|
|
// var statusList []*proto.AchievementRewardStatus
|
|
// for id, status := range this.Statuses {
|
|
// statusList = append(statusList, &proto.AchievementRewardStatus{Id: id, Status: status})
|
|
// }
|
|
// sort.Slice(statusList, func(i, j int) bool {
|
|
// return statusList[i].Id < statusList[j].Id
|
|
// })
|
|
// tipe, extra := util.Split2uint32(this.Key)
|
|
// return &proto.Achievement{Type: tipe, Extra: extra, Process: this.Process, StatusList: statusList}
|
|
//}
|
|
//
|
|
//func (this *Player) CheckAchievement(tipe proto.AchievementType, extra uint32, value uint32) bool {
|
|
// if value == 0 {
|
|
// return false
|
|
// }
|
|
//
|
|
// var achievementTables = this.manager.tables.AchievementExtend.Get(int(tipe), int(extra))
|
|
// if len(achievementTables) == 0 {
|
|
// return false
|
|
// }
|
|
//
|
|
// var key = util.Compose2uint32(uint32(tipe), extra)
|
|
// var achievement = this.Achievement[key]
|
|
// if achievement == nil {
|
|
// achievement = &PlayerAchievement{
|
|
// Key: key,
|
|
// Process: 0,
|
|
// Statuses: map[uint32]uint32{},
|
|
// }
|
|
// }
|
|
//
|
|
// switch proto.AchievementMode(achievementTables[0].Mode) {
|
|
// case proto.AchievementModeCounting:
|
|
// achievement.Process += value
|
|
// case proto.AchievementModeHistory:
|
|
// if value < achievement.Process {
|
|
// return false
|
|
// }
|
|
// achievement.Process = value
|
|
// default:
|
|
// this.manager.logger.Errorf("Invalid achievement mode %d", achievementTables[0].Mode)
|
|
// return false
|
|
// }
|
|
//
|
|
// var list []*proto.Achievement
|
|
// for _, achievementTable := range achievementTables {
|
|
// if proto.RewardStatus(achievement.Statuses[uint32(achievementTable.Id)]) != proto.RewardStatusUnable {
|
|
// continue
|
|
// }
|
|
//
|
|
// if achievement.Process >= uint32(achievementTable.AchievementNum) {
|
|
// achievement.Statuses[uint32(achievementTable.Id)] = uint32(proto.RewardStatusCanGet)
|
|
// list = append(list, achievement.BuildMsgAchievement())
|
|
// } else {
|
|
// list = append(list, achievement.BuildMsgAchievement())
|
|
// break
|
|
// }
|
|
// }
|
|
//
|
|
// this.Achievement[key] = achievement
|
|
// this.SaveModel(achievement)
|
|
//
|
|
// _ = this.Send(proto.ModIdAchievement, proto.MsgIdAchievementChange, &proto.MsgAchievementChangeListAck{
|
|
// MsgAchievementListAck: proto.MsgAchievementListAck{List: list},
|
|
// })
|
|
// return true
|
|
//}
|
|
//
|
|
//func (this *Player) BuildMsgAchievementListAck() *proto.MsgAchievementListAck {
|
|
// var list []*proto.Achievement
|
|
// for _, achievement := range this.Achievement {
|
|
// list = append(list, achievement.BuildMsgAchievement())
|
|
// }
|
|
// return &proto.MsgAchievementListAck{List: list}
|
|
//}
|