package island import ( "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" ) // 参数校验 func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.IsLandReceiveReq) (errdata *pb.ErrorData) { return } // /获取系统公告 func (this *apiComp) Receive(session comm.IUserSession, req *pb.IsLandReceiveReq) (errdata *pb.ErrorData) { var ( info *pb.DBIsland warorder *pb.Warorder confs []*cfg.GamePuggsyPasscheckData awards []*cfg.Gameatn award []*pb.UserAtno err error ) if errdata = this.ReceiveCheck(session, req); errdata != nil { return } if info, err = this.module.model.getmodel(session.GetUserId()); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), Message: err.Error(), } return } if confs, err = this.module.configure.getGamePuggsyPasscheckData(); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Title: pb.ErrorCode_ConfigNoFound.ToString(), Message: err.Error(), } return } awards = make([]*cfg.Gameatn, 0) for _, v := range confs { if v.Parameter <= int32(len(info.Nodes)) { if warorder.Freeprogress < v.Parameter { awards = append(awards, v.FreeReward) } if warorder.Vip { if warorder.Payprogress < v.Parameter { awards = append(awards, v.PayReward...) } } } } warorder.Freeprogress = int32(len(info.Nodes)) if warorder.Vip { warorder.Payprogress = int32(len(info.Nodes)) } if errdata, award = this.module.DispenseAtno(session, awards, true); errdata != nil { return } this.module.model.Change(session.GetUserId(), map[string]interface{}{ "freeprogress": info.Freeprogress, "payprogress": info.Payprogress, }) session.SendMsg(string(this.module.GetType()), "receive", &pb.IsLandReceiveResp{Info: info, Award: award}) go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "IsLandReceiveReq", award) }) return }