Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
7d115768a5
@ -90,6 +90,7 @@ func (this *apiComp) Train(session comm.IUserSession, req *pb.DragonTrainReq) (e
|
|||||||
}
|
}
|
||||||
preLv = dragon.Lv
|
preLv = dragon.Lv
|
||||||
preType = conf.Type
|
preType = conf.Type
|
||||||
|
curType = conf.Type
|
||||||
dragon.Exp += playConf.Exp // 加经验
|
dragon.Exp += playConf.Exp // 加经验
|
||||||
for {
|
for {
|
||||||
var addexp int32
|
var addexp int32
|
||||||
@ -106,13 +107,13 @@ func (this *apiComp) Train(session comm.IUserSession, req *pb.DragonTrainReq) (e
|
|||||||
dragon.Exp += addexp
|
dragon.Exp += addexp
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
curType = conf.Type
|
||||||
} else {
|
} else {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update["exp"] = dragon.Exp
|
update["exp"] = dragon.Exp
|
||||||
update["lv"] = dragon.Lv
|
update["lv"] = dragon.Lv
|
||||||
curType = conf.Type
|
|
||||||
curLv = dragon.Lv
|
curLv = dragon.Lv
|
||||||
} else {
|
} else {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
|
@ -185,7 +185,7 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.FriendAgreeReq) (e
|
|||||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeAgree, resp)
|
session.SendMsg(string(this.module.GetType()), FriendSubTypeAgree, resp)
|
||||||
|
|
||||||
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
||||||
this.module.maincity.AddMainCityFriends(session.GetUserId(), req.FriendIds)
|
//this.module.maincity.AddMainCityFriends(session.GetUserId(), req.FriendIds)
|
||||||
if len(tasks) > 0 {
|
if len(tasks) > 0 {
|
||||||
this.module.ModuleBuried.TriggerBuried(session, tasks...)
|
this.module.ModuleBuried.TriggerBuried(session, tasks...)
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,9 @@ func (this *ModelFriend) GetFriend(uid string) (info *pb.DBFriend, err error) {
|
|||||||
this.moduole.Errorln(err)
|
this.moduole.Errorln(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if !user.Created {
|
||||||
|
return
|
||||||
|
}
|
||||||
info = &pb.DBFriend{
|
info = &pb.DBFriend{
|
||||||
Id: primitive.NewObjectID().Hex(),
|
Id: primitive.NewObjectID().Hex(),
|
||||||
Uid: uid,
|
Uid: uid,
|
||||||
@ -79,6 +82,9 @@ func (this *ModelFriend) GetFriend(uid string) (info *pb.DBFriend, err error) {
|
|||||||
this.moduole.Errorln(err)
|
this.moduole.Errorln(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if !user.Created {
|
||||||
|
return
|
||||||
|
}
|
||||||
info = &pb.DBFriend{
|
info = &pb.DBFriend{
|
||||||
Id: primitive.NewObjectID().Hex(),
|
Id: primitive.NewObjectID().Hex(),
|
||||||
Uid: uid,
|
Uid: uid,
|
||||||
|
@ -33,7 +33,7 @@ func NewModule() core.IModule {
|
|||||||
|
|
||||||
type Friend struct {
|
type Friend struct {
|
||||||
modules.ModuleBase
|
modules.ModuleBase
|
||||||
maincity comm.IMainCity
|
//maincity comm.IMainCity
|
||||||
api *apiComp
|
api *apiComp
|
||||||
modelFriend *ModelFriend
|
modelFriend *ModelFriend
|
||||||
ModelFriendQiecuo *ModelFriendQiecuo
|
ModelFriendQiecuo *ModelFriendQiecuo
|
||||||
@ -74,11 +74,11 @@ func (this *Friend) Start() (err error) {
|
|||||||
if this.globalConf == nil {
|
if this.globalConf == nil {
|
||||||
err = errors.New("global config not found")
|
err = errors.New("global config not found")
|
||||||
}
|
}
|
||||||
var module core.IModule
|
// var module core.IModule
|
||||||
if module, err = this.service.GetModule(comm.ModuleMaincity); err != nil {
|
// if module, err = this.service.GetModule(comm.ModuleMaincity); err != nil {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
this.maincity = module.(comm.IMainCity)
|
// this.maincity = module.(comm.IMainCity)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/sys/event"
|
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
@ -52,8 +51,8 @@ func (this *MainCity) Start() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.sociaty = module.(comm.ISociaty)
|
this.sociaty = module.(comm.ISociaty)
|
||||||
event.Register(comm.EventUserLogin, this.EventUserLogin)
|
// event.Register(comm.EventUserLogin, this.EventUserLogin)
|
||||||
event.Register(comm.EventUserOffline, this.EventUserOffline)
|
// event.Register(comm.EventUserOffline, this.EventUserOffline)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,9 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PlunderCha
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if lock, err = this.module.modelLand.landMutexLock(list.Landid); err != nil {
|
lock, err = this.module.modelLand.landMutexLock(list.Landid)
|
||||||
|
lock.Lock()
|
||||||
|
if err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_DBError,
|
Code: pb.ErrorCode_DBError,
|
||||||
Title: pb.ErrorCode_DBError.ToString(),
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
|
@ -4,9 +4,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/lego/sys/redis"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
)
|
)
|
||||||
@ -103,6 +105,36 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PlunderGetListRe
|
|||||||
update["ctime"] = list.Ctime
|
update["ctime"] = list.Ctime
|
||||||
update["freecount"] = list.Freecount
|
update["freecount"] = list.Freecount
|
||||||
}
|
}
|
||||||
|
if user, err := this.module.ModuleUser.GetUser(session.GetUserId()); err == nil {
|
||||||
|
uinfo := comm.GetUserBaseInfo(user)
|
||||||
|
if !reflect.DeepEqual(uinfo, list.Uinfo) {
|
||||||
|
update["uinfo"] = uinfo
|
||||||
|
// 同步岛屿上的信息
|
||||||
|
var lock *redis.RedisMutex
|
||||||
|
lock, err = this.module.modelLand.landMutexLock(list.Landid)
|
||||||
|
lock.Lock()
|
||||||
|
if err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_DBError,
|
||||||
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer lock.Unlock()
|
||||||
|
|
||||||
|
for _, v := range land.Uinfo {
|
||||||
|
if v == list.Uinfo {
|
||||||
|
v = uinfo
|
||||||
|
this.module.modelLand.changePlunderLandData(list.Landid, map[string]interface{}{
|
||||||
|
"uinfo": land.Uinfo,
|
||||||
|
})
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list.Uinfo = uinfo
|
||||||
|
}
|
||||||
|
}
|
||||||
if len(update) > 0 {
|
if len(update) > 0 {
|
||||||
this.module.modelPlunder.changePlunderData(session.GetUserId(), update)
|
this.module.modelPlunder.changePlunderData(session.GetUserId(), update)
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,9 @@ func (this *apiComp) PvpChallenge(session comm.IUserSession, req *pb.PlunderPvpC
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if lock, err = this.module.modelLand.landMutexLock(list.Landid); err != nil {
|
lock, err = this.module.modelLand.landMutexLock(list.Landid)
|
||||||
|
lock.Lock()
|
||||||
|
if err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_DBError,
|
Code: pb.ErrorCode_DBError,
|
||||||
Title: pb.ErrorCode_DBError.ToString(),
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
|
@ -46,7 +46,9 @@ func (this *apiComp) PvpChallengeOver(session comm.IUserSession, req *pb.Plunder
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if lock, err = this.module.modelLand.landMutexLock(list.Landid); err != nil {
|
lock, err = this.module.modelLand.landMutexLock(list.Landid)
|
||||||
|
lock.Lock()
|
||||||
|
if err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_DBError,
|
Code: pb.ErrorCode_DBError,
|
||||||
Title: pb.ErrorCode_DBError.ToString(),
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
|
@ -46,7 +46,9 @@ func (this *apiComp) Reach(session comm.IUserSession, req *pb.PlunderReachReq) (
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if lock, err = this.module.modelLand.landMutexLock(list.Landid); err != nil {
|
lock, err = this.module.modelLand.landMutexLock(list.Landid)
|
||||||
|
lock.Lock()
|
||||||
|
if err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_DBError,
|
Code: pb.ErrorCode_DBError,
|
||||||
Title: pb.ErrorCode_DBError.ToString(),
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
|
@ -131,7 +131,7 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) (
|
|||||||
this.module.Errorln(err)
|
this.module.Errorln(err)
|
||||||
}
|
}
|
||||||
this.module.ModuleBuried.TriggerBuried(session, tasks...)
|
this.module.ModuleBuried.TriggerBuried(session, tasks...)
|
||||||
this.module.maincity.AddMainCityFriends(req.Uid, uids)
|
//this.module.maincity.AddMainCityFriends(req.Uid, uids)
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ var _ comm.ISociaty = (*Sociaty)(nil)
|
|||||||
|
|
||||||
type Sociaty struct {
|
type Sociaty struct {
|
||||||
modules.ModuleBase
|
modules.ModuleBase
|
||||||
maincity comm.IMainCity
|
//maincity comm.IMainCity
|
||||||
api *apiComp
|
api *apiComp
|
||||||
service base.IRPCXService
|
service base.IRPCXService
|
||||||
modelSociaty *ModelSociaty
|
modelSociaty *ModelSociaty
|
||||||
@ -89,11 +89,11 @@ func (this *Sociaty) Start() (err error) {
|
|||||||
if err = this.checkSociatyConf(); err != nil {
|
if err = this.checkSociatyConf(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var module core.IModule
|
// var module core.IModule
|
||||||
if module, err = this.service.GetModule(comm.ModuleMaincity); err != nil {
|
// if module, err = this.service.GetModule(comm.ModuleMaincity); err != nil {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
this.maincity = module.(comm.IMainCity)
|
// this.maincity = module.(comm.IMainCity)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (err
|
|||||||
})
|
})
|
||||||
|
|
||||||
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
||||||
if user.Name != "" { // 没创角就没必要通知
|
if !user.Created { // 没创角就没必要通知
|
||||||
event.TriggerEvent(comm.EventUserLogin, session)
|
event.TriggerEvent(comm.EventUserLogin, session)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,6 @@ import (
|
|||||||
"go_dreamfactory/modules/library"
|
"go_dreamfactory/modules/library"
|
||||||
"go_dreamfactory/modules/linestory"
|
"go_dreamfactory/modules/linestory"
|
||||||
"go_dreamfactory/modules/mail"
|
"go_dreamfactory/modules/mail"
|
||||||
"go_dreamfactory/modules/maincity"
|
|
||||||
"go_dreamfactory/modules/mainline"
|
"go_dreamfactory/modules/mainline"
|
||||||
"go_dreamfactory/modules/monkey"
|
"go_dreamfactory/modules/monkey"
|
||||||
"go_dreamfactory/modules/moonfantasy"
|
"go_dreamfactory/modules/moonfantasy"
|
||||||
@ -186,7 +185,7 @@ func main() {
|
|||||||
jielong.NewModule(),
|
jielong.NewModule(),
|
||||||
entertainment.NewModule(),
|
entertainment.NewModule(),
|
||||||
dcolor.NewModule(),
|
dcolor.NewModule(),
|
||||||
maincity.NewModule(),
|
//maincity.NewModule(),
|
||||||
treasuremap.NewModule(),
|
treasuremap.NewModule(),
|
||||||
gameinvite.NewModule(),
|
gameinvite.NewModule(),
|
||||||
caninerabbit.NewModule(),
|
caninerabbit.NewModule(),
|
||||||
|
Loading…
Reference in New Issue
Block a user