Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
277a7fa688
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"key": 10100,
|
"key": 10100,
|
||||||
"lock": 1,
|
"lock": 1,
|
||||||
"ontxe": 0,
|
"ontxe": 999999,
|
||||||
"id_after": 10101,
|
"id_after": 10101,
|
||||||
"group": 1,
|
"group": 1,
|
||||||
"des": 2,
|
"des": 2,
|
||||||
@ -17,7 +17,7 @@
|
|||||||
1001
|
1001
|
||||||
],
|
],
|
||||||
"completetask": 0,
|
"completetask": 0,
|
||||||
"auto_accept": 1,
|
"auto_accept": 0,
|
||||||
"overtips": 1,
|
"overtips": 1,
|
||||||
"reword": [
|
"reword": [
|
||||||
{
|
{
|
||||||
@ -1730,9 +1730,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": 30001,
|
"key": 30001,
|
||||||
"lock": 999,
|
"lock": 1,
|
||||||
"ontxe": 0,
|
"ontxe": 0,
|
||||||
"id_after": 0,
|
"id_after": 30002,
|
||||||
"group": 101,
|
"group": 101,
|
||||||
"des": 3,
|
"des": 3,
|
||||||
"icon": "",
|
"icon": "",
|
||||||
@ -1775,7 +1775,7 @@
|
|||||||
{
|
{
|
||||||
"key": 30003,
|
"key": 30003,
|
||||||
"lock": 1,
|
"lock": 1,
|
||||||
"ontxe": 30001,
|
"ontxe": 0,
|
||||||
"id_after": 0,
|
"id_after": 0,
|
||||||
"group": 101,
|
"group": 101,
|
||||||
"des": 3,
|
"des": 3,
|
||||||
@ -1796,7 +1796,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": 30004,
|
"key": 30004,
|
||||||
"lock": 999,
|
"lock": 1,
|
||||||
"ontxe": 0,
|
"ontxe": 0,
|
||||||
"id_after": 0,
|
"id_after": 0,
|
||||||
"group": 101,
|
"group": 101,
|
||||||
@ -1818,7 +1818,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": 30005,
|
"key": 30005,
|
||||||
"lock": 999,
|
"lock": 1,
|
||||||
"ontxe": 0,
|
"ontxe": 0,
|
||||||
"id_after": 0,
|
"id_after": 0,
|
||||||
"group": 101,
|
"group": 101,
|
||||||
@ -1840,7 +1840,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": 30006,
|
"key": 30006,
|
||||||
"lock": 999,
|
"lock": 1,
|
||||||
"ontxe": 0,
|
"ontxe": 0,
|
||||||
"id_after": 0,
|
"id_after": 0,
|
||||||
"group": 101,
|
"group": 101,
|
||||||
@ -1856,13 +1856,13 @@
|
|||||||
300011
|
300011
|
||||||
],
|
],
|
||||||
"completetask": 0,
|
"completetask": 0,
|
||||||
"auto_accept": 1,
|
"auto_accept": 0,
|
||||||
"overtips": 1,
|
"overtips": 1,
|
||||||
"reword": []
|
"reword": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": 30007,
|
"key": 30007,
|
||||||
"lock": 999,
|
"lock": 1,
|
||||||
"ontxe": 0,
|
"ontxe": 0,
|
||||||
"id_after": 0,
|
"id_after": 0,
|
||||||
"group": 101,
|
"group": 101,
|
||||||
@ -1884,7 +1884,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": 30008,
|
"key": 30008,
|
||||||
"lock": 999,
|
"lock": 1,
|
||||||
"ontxe": 0,
|
"ontxe": 0,
|
||||||
"id_after": 0,
|
"id_after": 0,
|
||||||
"group": 101,
|
"group": 101,
|
||||||
@ -1906,7 +1906,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": 30009,
|
"key": 30009,
|
||||||
"lock": 999,
|
"lock": 1,
|
||||||
"ontxe": 0,
|
"ontxe": 0,
|
||||||
"id_after": 0,
|
"id_after": 0,
|
||||||
"group": 101,
|
"group": 101,
|
||||||
@ -1928,7 +1928,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": 30010,
|
"key": 30010,
|
||||||
"lock": 999,
|
"lock": 1,
|
||||||
"ontxe": 0,
|
"ontxe": 0,
|
||||||
"id_after": 0,
|
"id_after": 0,
|
||||||
"group": 101,
|
"group": 101,
|
||||||
@ -1950,7 +1950,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": 30011,
|
"key": 30011,
|
||||||
"lock": 999,
|
"lock": 1,
|
||||||
"ontxe": 0,
|
"ontxe": 0,
|
||||||
"id_after": 0,
|
"id_after": 0,
|
||||||
"group": 101,
|
"group": 101,
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package hero
|
package hero
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/rand"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
"math/big"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -30,7 +32,10 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
|||||||
pool string
|
pool string
|
||||||
_mapAddHero map[string]int32
|
_mapAddHero map[string]int32
|
||||||
strPool []string // 10连跨多个卡池情况
|
strPool []string // 10连跨多个卡池情况
|
||||||
|
update map[string]interface{}
|
||||||
|
normalDraw bool // 是否是普通抽
|
||||||
)
|
)
|
||||||
|
update = make(map[string]interface{})
|
||||||
_mapAddHero = make(map[string]int32, 0)
|
_mapAddHero = make(map[string]int32, 0)
|
||||||
cfgDraw = this.module.configure.GetGlobalConf() // 读取抽卡配置文件
|
cfgDraw = this.module.configure.GetGlobalConf() // 读取抽卡配置文件
|
||||||
if cfgDraw == nil {
|
if cfgDraw == nil {
|
||||||
@ -41,12 +46,12 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
szCards = make([]string, 0)
|
szCards = make([]string, 0)
|
||||||
rsp := &pb.HeroDrawCardResp{}
|
|
||||||
|
|
||||||
heroRecord, _ = this.module.modelRecord.GetHeroRecord(session.GetUserId())
|
heroRecord, _ = this.module.modelRecord.GetHeroRecord(session.GetUserId())
|
||||||
drawCount = heroRecord.Drawcount
|
drawCount = heroRecord.Drawcount
|
||||||
|
|
||||||
if req.DrawType == 0 { // 普通卡池抽卡
|
if req.DrawType == 0 { // 普通卡池抽卡
|
||||||
|
normalDraw = true
|
||||||
// 获取普通抽卡池
|
// 获取普通抽卡池
|
||||||
if req.DrawCount == 1 {
|
if req.DrawCount == 1 {
|
||||||
costAtn = cfgDraw.BasePoolCost
|
costAtn = cfgDraw.BasePoolCost
|
||||||
@ -79,6 +84,28 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
|||||||
sz = append(sz, cfgDraw.BasePoolStar5)
|
sz = append(sz, cfgDraw.BasePoolStar5)
|
||||||
}
|
}
|
||||||
starIndex := this.module.modelHero.GetRandW(sz)
|
starIndex := this.module.modelHero.GetRandW(sz)
|
||||||
|
// 特殊规则 DrawCard_5StarsInRange 第2-30次抽奖必出一个5星英雄(普通卡池)
|
||||||
|
inRangeConf := this.module.configure.GetGlobalConf().DrawCard5StarsInRange
|
||||||
|
if len(inRangeConf) == 3 {
|
||||||
|
iStart := inRangeConf[0] // 抽卡开始
|
||||||
|
iEnd := inRangeConf[1] // 抽卡结束
|
||||||
|
star := inRangeConf[2]
|
||||||
|
if heroRecord.Inevitable == 0 && heroRecord.Drawcount > iStart && heroRecord.Drawcount < iEnd && iEnd >= iStart {
|
||||||
|
n, _ := rand.Int(rand.Reader, big.NewInt(int64(iEnd-iStart)))
|
||||||
|
if n.Int64() < 1 { // 抽中
|
||||||
|
starIndex = star - 3
|
||||||
|
heroRecord.Inevitable = heroRecord.Drawcount
|
||||||
|
update["inevitable"] = heroRecord.Drawcount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 保底情况
|
||||||
|
if heroRecord.Drawcount == iEnd && heroRecord.Inevitable == 0 {
|
||||||
|
starIndex = star - 3
|
||||||
|
heroRecord.Inevitable = heroRecord.Drawcount
|
||||||
|
update["inevitable"] = heroRecord.Drawcount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
heroRecord.Star4++ // 4星保底数量+1
|
heroRecord.Star4++ // 4星保底数量+1
|
||||||
heroRecord.Star5++ // 5星保底数量+1
|
heroRecord.Star5++ // 5星保底数量+1
|
||||||
if starIndex == 1 {
|
if starIndex == 1 {
|
||||||
@ -212,18 +239,19 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.DrawType == 0 {
|
|
||||||
update := map[string]interface{}{}
|
|
||||||
update["star4"] = heroRecord.Star4
|
|
||||||
update["star5"] = heroRecord.Star5
|
|
||||||
update["drawcount"] = drawCount
|
|
||||||
this.module.modelRecord.ChangeHeroRecord(session.GetUserId(), update)
|
|
||||||
}
|
|
||||||
// 消耗道具
|
// 消耗道具
|
||||||
code = this.module.ConsumeRes(session, costRes, true)
|
code = this.module.ConsumeRes(session, costRes, true)
|
||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
heroRecord.Totalcount += req.DrawCount
|
||||||
|
heroRecord.Daycount += req.DrawCount
|
||||||
|
update["star4"] = heroRecord.Star4
|
||||||
|
update["star5"] = heroRecord.Star5
|
||||||
|
update["drawcount"] = drawCount
|
||||||
|
update["totalcount"] = heroRecord.Totalcount
|
||||||
|
update["daycount"] = heroRecord.Daycount
|
||||||
|
this.module.modelRecord.ChangeHeroRecord(session.GetUserId(), update)
|
||||||
for _, heroId := range szCards {
|
for _, heroId := range szCards {
|
||||||
|
|
||||||
_mapAddHero[heroId]++
|
_mapAddHero[heroId]++
|
||||||
@ -231,48 +259,9 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
|||||||
_, code = this.module.CreateRepeatHeros(session, _mapAddHero, true)
|
_, code = this.module.CreateRepeatHeros(session, _mapAddHero, true)
|
||||||
|
|
||||||
///英雄招募 【玩家名称】在招募中获得了【英雄名称】!
|
///英雄招募 【玩家名称】在招募中获得了【英雄名称】!
|
||||||
for hid := range _mapAddHero {
|
this.module.SendChatMsg(session, _mapAddHero, szCards)
|
||||||
if user := this.module.ModuleUser.GetUser(session.GetUserId()); user != nil {
|
|
||||||
this.chat.SendSysChatToWorld(comm.ChatSystem13, nil, 0, 0, user.Name, hid)
|
|
||||||
} else {
|
|
||||||
this.module.Errorf("no found userdata uid:%s", session.GetUserId())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rsp.Heroes = szCards
|
|
||||||
session.SendMsg(string(this.module.GetType()), DrawCard, rsp)
|
|
||||||
|
|
||||||
// 任务统计
|
// 任务统计
|
||||||
if req.DrawType == 0 { //普通招募
|
this.module.SendTaskMsg(session, szStar, req.DrawCount, normalDraw)
|
||||||
if drawCount == 10 {
|
|
||||||
sz := make(map[int32]int32, 0)
|
|
||||||
for _, star := range szStar {
|
|
||||||
sz[star]++
|
|
||||||
}
|
|
||||||
for k := range sz {
|
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype17, 1, k)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//this.module.ModuleRtask.SendToRtask(session, comm.Rtype14, req.DrawCount)
|
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype18, req.DrawCount)
|
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype141, req.DrawCount)
|
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype143, req.DrawCount)
|
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype145, req.DrawCount)
|
|
||||||
} else { // 阵营招募
|
|
||||||
//this.module.ModuleRtask.SendToRtask(session, comm.Rtype15, req.DrawCount)
|
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype19, req.DrawCount)
|
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype142, req.DrawCount)
|
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype144, req.DrawCount)
|
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype146, req.DrawCount)
|
|
||||||
if drawCount == 10 {
|
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype91, 1) // 阵营10连
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, star := range szStar {
|
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype16, star, 1)
|
|
||||||
}
|
|
||||||
if drawCount == 10 {
|
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype90, 1)
|
|
||||||
}
|
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype89, req.DrawCount)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ type Hero struct {
|
|||||||
moduleFetter comm.IHeroFetter
|
moduleFetter comm.IHeroFetter
|
||||||
service core.IService
|
service core.IService
|
||||||
moduleHoroscope comm.IHoroscope
|
moduleHoroscope comm.IHoroscope
|
||||||
|
chat comm.IChat
|
||||||
}
|
}
|
||||||
|
|
||||||
//模块名
|
//模块名
|
||||||
@ -65,6 +66,10 @@ func (this *Hero) Start() (err error) {
|
|||||||
}
|
}
|
||||||
this.moduleHoroscope = module.(comm.IHoroscope)
|
this.moduleHoroscope = module.(comm.IHoroscope)
|
||||||
|
|
||||||
|
if module, err = this.service.GetModule(comm.ModuleChat); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.chat = module.(comm.IChat)
|
||||||
err = this.ModuleBase.Start()
|
err = this.ModuleBase.Start()
|
||||||
event.RegisterGO(comm.EventUserOffline, this.EventUserOffline)
|
event.RegisterGO(comm.EventUserOffline, this.EventUserOffline)
|
||||||
return
|
return
|
||||||
@ -738,3 +743,52 @@ func (this *Hero) GetAllMaxHero(session comm.IUserSession) (code pb.ErrorCode) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *Hero) SendChatMsg(session comm.IUserSession, _mapAddHero map[string]int32, cards []string) {
|
||||||
|
rsp := &pb.HeroDrawCardResp{}
|
||||||
|
///英雄招募 【玩家名称】在招募中获得了【英雄名称】!
|
||||||
|
for hid := range _mapAddHero {
|
||||||
|
if user := this.ModuleUser.GetUser(session.GetUserId()); user != nil {
|
||||||
|
|
||||||
|
this.chat.SendSysChatToWorld(comm.ChatSystem13, nil, 0, 0, user.Name, hid)
|
||||||
|
} else {
|
||||||
|
this.Errorf("no found userdata uid:%s", session.GetUserId())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rsp.Heroes = cards
|
||||||
|
session.SendMsg(string(this.GetType()), DrawCard, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Hero) SendTaskMsg(session comm.IUserSession, szStar []int32, drawCount int32, itype bool) {
|
||||||
|
// 任务统计
|
||||||
|
if itype { //普通招募
|
||||||
|
if drawCount == 10 {
|
||||||
|
sz := make(map[int32]int32, 0)
|
||||||
|
for _, star := range szStar {
|
||||||
|
sz[star]++
|
||||||
|
}
|
||||||
|
for k := range sz {
|
||||||
|
this.ModuleRtask.SendToRtask(session, comm.Rtype17, 1, k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.ModuleRtask.SendToRtask(session, comm.Rtype18, drawCount)
|
||||||
|
this.ModuleRtask.SendToRtask(session, comm.Rtype141, drawCount)
|
||||||
|
this.ModuleRtask.SendToRtask(session, comm.Rtype143, drawCount)
|
||||||
|
this.ModuleRtask.SendToRtask(session, comm.Rtype145, drawCount)
|
||||||
|
} else { // 阵营招募
|
||||||
|
this.ModuleRtask.SendToRtask(session, comm.Rtype19, drawCount)
|
||||||
|
this.ModuleRtask.SendToRtask(session, comm.Rtype142, drawCount)
|
||||||
|
this.ModuleRtask.SendToRtask(session, comm.Rtype144, drawCount)
|
||||||
|
this.ModuleRtask.SendToRtask(session, comm.Rtype146, drawCount)
|
||||||
|
if drawCount == 10 {
|
||||||
|
this.ModuleRtask.SendToRtask(session, comm.Rtype91, 1) // 阵营10连
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, star := range szStar {
|
||||||
|
this.ModuleRtask.SendToRtask(session, comm.Rtype16, star, 1)
|
||||||
|
}
|
||||||
|
if drawCount == 10 {
|
||||||
|
this.ModuleRtask.SendToRtask(session, comm.Rtype90, 1)
|
||||||
|
}
|
||||||
|
this.ModuleRtask.SendToRtask(session, comm.Rtype89, drawCount)
|
||||||
|
}
|
||||||
|
@ -165,8 +165,10 @@ func (this *User) CleanSession(session comm.IUserSession) {
|
|||||||
// 在线玩家列表
|
// 在线玩家列表
|
||||||
func (this *User) UserOnlineList() ([]*pb.CacheUser, error) {
|
func (this *User) UserOnlineList() ([]*pb.CacheUser, error) {
|
||||||
var cache []*pb.CacheUser
|
var cache []*pb.CacheUser
|
||||||
if err := this.modelSession.GetList(comm.RDS_EMPTY, &cache); err != nil {
|
if !this.IsCross() {
|
||||||
return nil, err
|
if err := this.modelSession.GetList(comm.RDS_EMPTY, &cache); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return cache, nil
|
return cache, nil
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 判断玩家等级要求
|
// 判断玩家等级要求
|
||||||
if user.Lv < curTaskConf.Lock {
|
if curTaskConf.Des == 2 && user.Lv < curTaskConf.Lock {
|
||||||
code = pb.ErrorCode_WorldtaskLvNotEnough
|
code = pb.ErrorCode_WorldtaskLvNotEnough
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -80,15 +80,14 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
|
|||||||
hero = make([]string, 0)
|
hero = make([]string, 0)
|
||||||
newhero = make([]string, 0)
|
newhero = make([]string, 0)
|
||||||
var nextTaskId int32
|
var nextTaskId int32
|
||||||
nextTaskId = curTaskConf.IdAfter
|
|
||||||
finishRsp := func() {
|
finishRsp := func() {
|
||||||
if err := session.SendMsg(string(this.module.GetType()), WorldtaskSubtypeFinish, rsp); err != nil {
|
if err := session.SendMsg(string(this.module.GetType()), WorldtaskSubtypeFinish, rsp); err != nil {
|
||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if curTaskConf.IdAfter != 0 {
|
||||||
// 世界任务类型
|
nextTaskId = curTaskConf.IdAfter
|
||||||
if curTaskConf.Des == 2 {
|
|
||||||
// 任务完成推送
|
// 任务完成推送
|
||||||
if err := session.SendMsg(string(this.module.GetType()), WorldtaskNexttaskPush, &pb.WorldtaskNexttaskPush{
|
if err := session.SendMsg(string(this.module.GetType()), WorldtaskNexttaskPush, &pb.WorldtaskNexttaskPush{
|
||||||
NextTaskId: nextTaskId,
|
NextTaskId: nextTaskId,
|
||||||
@ -97,6 +96,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
finishCall := func() {
|
finishCall := func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user