Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
da347d68fe
@ -34,8 +34,7 @@ type (
|
|||||||
IHero interface {
|
IHero interface {
|
||||||
//查询用户卡片数量
|
//查询用户卡片数量
|
||||||
QueryHeroAmount(uId string, heroCfgId string) (amount uint32)
|
QueryHeroAmount(uId string, heroCfgId string) (amount uint32)
|
||||||
//创建新英雄
|
|
||||||
CreateHeroes(uid string, heroCfgId ...string) error
|
|
||||||
//创建指定数量
|
//创建指定数量
|
||||||
CreateRepeatHero(session IUserSession, heroCfgId string, num int32, bPush bool) (code pb.ErrorCode)
|
CreateRepeatHero(session IUserSession, heroCfgId string, num int32, bPush bool) (code pb.ErrorCode)
|
||||||
// 批量创建英雄
|
// 批量创建英雄
|
||||||
|
@ -47,7 +47,6 @@ func (this *apiComp) GetRandUser(session comm.IUserSession, req *pb.GourmetGetRa
|
|||||||
if v.Uid == session.GetUserId() || v.Uid == "" { // 过滤自己信息
|
if v.Uid == session.GetUserId() || v.Uid == "" { // 过滤自己信息
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
mapUser[v.Uid] = struct{}{}
|
|
||||||
szUid = append(szUid, v.Uid)
|
szUid = append(szUid, v.Uid)
|
||||||
}
|
}
|
||||||
// 随机在线玩家信息
|
// 随机在线玩家信息
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
"go_dreamfactory/sys/db"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
"math"
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
@ -126,91 +127,77 @@ func (this *ModelHero) CloneNewHero(hero *pb.DBHero) (newHero *pb.DBHero) {
|
|||||||
|
|
||||||
//初始化可叠加的英雄
|
//初始化可叠加的英雄
|
||||||
func (this *ModelHero) initHeroOverlying(uid string, heroCfgId string, count int32) (hero *pb.DBHero, err error) {
|
func (this *ModelHero) initHeroOverlying(uid string, heroCfgId string, count int32) (hero *pb.DBHero, err error) {
|
||||||
|
var (
|
||||||
|
model *db.DBModel
|
||||||
|
)
|
||||||
hero = this.InitHero(uid, heroCfgId)
|
hero = this.InitHero(uid, heroCfgId)
|
||||||
if hero != nil {
|
if hero != nil {
|
||||||
|
|
||||||
hero.SameCount = count
|
hero.SameCount = count
|
||||||
if err = this.AddList(uid, hero.Id, hero); err != nil {
|
if this.moduleHero.IsCross() {
|
||||||
this.moduleHero.Errorf("%v", err)
|
if model, err = this.moduleHero.GetDBNoduleByUid(uid, this.TableName, this.Expired); err != nil {
|
||||||
return
|
this.moduleHero.Errorln(err)
|
||||||
|
} else {
|
||||||
|
if err = model.AddLists(uid, hero); err != nil {
|
||||||
|
this.moduleHero.Errorf("err:%v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if err = this.AddLists(uid, hero); err != nil {
|
||||||
|
this.moduleHero.Errorln(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 该方法适用创建初始英雄 叠加英雄 count叠加数量
|
// 该方法适用创建初始英雄 叠加英雄 count叠加数量
|
||||||
func (this *ModelHero) createHeroOverlying(uid string, heroCfgId string, count int32) (hero *pb.DBHero, err error) {
|
func (this *ModelHero) createHeroOverlying(uid string, heroCfgId string, count int32) (hero *pb.DBHero, err error) {
|
||||||
heroes := this.getHeroList(uid)
|
heros := make([]*pb.DBHero, 0)
|
||||||
if len(heroes) == 0 {
|
if this.moduleHero.IsCross() {
|
||||||
return this.initHeroOverlying(uid, heroCfgId, count)
|
if dbModel, err := this.moduleHero.GetDBNoduleByUid(uid, this.TableName, this.Expired); err != nil {
|
||||||
|
this.moduleHero.Errorln(err)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
var isExist bool
|
if err = dbModel.GetList(uid, &heros); err != nil {
|
||||||
for _, h := range heroes {
|
this.moduleHero.Errorf("err:%v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err = this.GetList(uid, &heros); err != nil {
|
||||||
|
this.moduleHero.Errorf("err:%v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(heros) >= 0 {
|
||||||
|
for _, h := range heros {
|
||||||
if h.HeroID == heroCfgId &&
|
if h.HeroID == heroCfgId &&
|
||||||
h.IsOverlying {
|
h.IsOverlying {
|
||||||
isExist = true
|
|
||||||
h.SameCount += count
|
h.SameCount += count
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"sameCount": h.SameCount, //叠加数
|
"sameCount": h.SameCount, //叠加数
|
||||||
}
|
}
|
||||||
hero = h
|
hero = h
|
||||||
|
|
||||||
|
if this.moduleHero.IsCross() {
|
||||||
|
if model, err := this.moduleHero.GetDBNoduleByUid(uid, this.TableName, this.Expired); err != nil {
|
||||||
|
this.moduleHero.Errorln(err)
|
||||||
|
} else {
|
||||||
|
if err := model.ChangeList(uid, h.Id, data); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if err := this.ChangeList(uid, h.Id, data); err != nil {
|
if err := this.ChangeList(uid, h.Id, data); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if !isExist {
|
|
||||||
return this.initHeroOverlying(uid, heroCfgId, count)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
|
||||||
|
|
||||||
//创建多个指定的英雄 heroCfgIds可填入多个英雄ID
|
|
||||||
func (this *ModelHero) createMultiHero(uid string, heroCfgIds ...string) error {
|
|
||||||
heroes := this.getHeroList(uid)
|
|
||||||
|
|
||||||
if len(heroes) == 0 {
|
|
||||||
for _, v := range heroCfgIds {
|
|
||||||
if _, err := this.createOneHero(uid, v); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
findHero := func(heroId string) (*pb.DBHero, bool) {
|
|
||||||
for _, h := range heroes {
|
|
||||||
if h.HeroID == heroId {
|
|
||||||
return h, true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
for _, v := range heroCfgIds {
|
|
||||||
if h, ok := findHero(v); ok {
|
|
||||||
//允许叠加
|
|
||||||
if h.IsOverlying {
|
|
||||||
h.SameCount++
|
|
||||||
data := map[string]interface{}{
|
|
||||||
"sameCount": h.SameCount, //叠加数
|
|
||||||
}
|
|
||||||
if err := this.ChangeList(uid, h.Id, data); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if _, err := this.createOneHero(uid, v); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if _, err := this.createOneHero(uid, v); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return this.initHeroOverlying(uid, heroCfgId, count)
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取一个英雄(参数唯一objID)
|
//获取一个英雄(参数唯一objID)
|
||||||
|
@ -61,11 +61,6 @@ func (this *Hero) Start() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//创建新英雄
|
|
||||||
func (this *Hero) CreateHeroes(uid string, heroCfgId ...string) error {
|
|
||||||
return this.modelHero.createMultiHero(uid, heroCfgId...)
|
|
||||||
}
|
|
||||||
|
|
||||||
//创建单个叠加英雄
|
//创建单个叠加英雄
|
||||||
func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string, num int32, bPush bool) (code pb.ErrorCode) {
|
func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string, num int32, bPush bool) (code pb.ErrorCode) {
|
||||||
_hero, err := this.modelHero.createHeroOverlying(session.GetUserId(), heroCfgId, num)
|
_hero, err := this.modelHero.createHeroOverlying(session.GetUserId(), heroCfgId, num)
|
||||||
@ -343,7 +338,6 @@ func (this *Hero) CreateMonster(heroCid string, star, lv int32) (hero *pb.DBHero
|
|||||||
|
|
||||||
// 只通过唯一id 查询英雄信息
|
// 只通过唯一id 查询英雄信息
|
||||||
func (this *Hero) QueryCrossHeroinfo(oid string) (hero *pb.DBHero, err error) {
|
func (this *Hero) QueryCrossHeroinfo(oid string) (hero *pb.DBHero, err error) {
|
||||||
|
|
||||||
if this.IsCross() {
|
if this.IsCross() {
|
||||||
for _, tag := range db.GetServerTags() {
|
for _, tag := range db.GetServerTags() {
|
||||||
conn, err1 := db.ServerDBConn(tag) // 遍历连接对象
|
conn, err1 := db.ServerDBConn(tag) // 遍历连接对象
|
||||||
@ -361,7 +355,7 @@ func (this *Hero) QueryCrossHeroinfo(oid string) (hero *pb.DBHero, err error) {
|
|||||||
this.modelHero.moduleHero.Errorf("find hero error: %v", err)
|
this.modelHero.moduleHero.Errorf("find hero error: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // 不是跨服就查本服
|
} else { // 不是跨服就查本服 注意 这个接口是给跨服玩法调用 理论上这个分支是不会执行的
|
||||||
if res := this.modelHero.DB.FindOne(comm.TableHero, bson.M{
|
if res := this.modelHero.DB.FindOne(comm.TableHero, bson.M{
|
||||||
"_id": oid,
|
"_id": oid,
|
||||||
}); res == nil {
|
}); res == nil {
|
||||||
|
@ -47,7 +47,6 @@ func (this *apiComp) GetRandUser(session comm.IUserSession, req *pb.SmithyGetRan
|
|||||||
if v.Uid == session.GetUserId() || v.Uid == "" { // 过滤自己信息
|
if v.Uid == session.GetUserId() || v.Uid == "" { // 过滤自己信息
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
mapUser[v.Uid] = struct{}{}
|
|
||||||
szUid = append(szUid, v.Uid)
|
szUid = append(szUid, v.Uid)
|
||||||
}
|
}
|
||||||
// 随机在线玩家信息
|
// 随机在线玩家信息
|
||||||
|
Loading…
Reference in New Issue
Block a user