62 lines
1.6 KiB
Go
62 lines
1.6 KiB
Go
package caninerabbit
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
"math"
|
|
)
|
|
|
|
//接受切磋
|
|
|
|
func (this *apiComp) SingleOverCheck(session comm.IUserSession, req *pb.DColorSingleOverReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) SingleOver(session comm.IUserSession, req *pb.DColorSingleOverReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBCanineRabbit
|
|
conf *cfg.GameGColorGetfractionData
|
|
tconf *cfg.GameGColortTmedecayData
|
|
err error
|
|
)
|
|
if errdata = this.SingleOverCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
if info, err = this.module.model.getModel(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if conf, err = this.module.configure.getGameGColorGetfractionData(int32(req.Difficulty)+1, req.Repeat, len(req.Handles)-1); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if tconf, err = this.module.configure.getGameGColortTmedecayData(req.Time); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
info.Integral += int32(math.Floor(float64(conf.Fraction) * float64(tconf.Pro) / float64(1000)))
|
|
if err = this.module.model.Change(session.GetUserId(), map[string]interface{}{
|
|
"integral": info.Integral,
|
|
}); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "singleover", &pb.DColorSingleOverResp{Integral: info.Integral})
|
|
return
|
|
}
|