This commit is contained in:
liwei1dao 2023-01-03 14:14:56 +08:00
commit 277a7fa688
5 changed files with 115 additions and 70 deletions

View File

@ -2,7 +2,7 @@
{
"key": 10100,
"lock": 1,
"ontxe": 0,
"ontxe": 999999,
"id_after": 10101,
"group": 1,
"des": 2,
@ -17,7 +17,7 @@
1001
],
"completetask": 0,
"auto_accept": 1,
"auto_accept": 0,
"overtips": 1,
"reword": [
{
@ -1730,9 +1730,9 @@
},
{
"key": 30001,
"lock": 999,
"lock": 1,
"ontxe": 0,
"id_after": 0,
"id_after": 30002,
"group": 101,
"des": 3,
"icon": "",
@ -1775,7 +1775,7 @@
{
"key": 30003,
"lock": 1,
"ontxe": 30001,
"ontxe": 0,
"id_after": 0,
"group": 101,
"des": 3,
@ -1796,7 +1796,7 @@
},
{
"key": 30004,
"lock": 999,
"lock": 1,
"ontxe": 0,
"id_after": 0,
"group": 101,
@ -1818,7 +1818,7 @@
},
{
"key": 30005,
"lock": 999,
"lock": 1,
"ontxe": 0,
"id_after": 0,
"group": 101,
@ -1840,7 +1840,7 @@
},
{
"key": 30006,
"lock": 999,
"lock": 1,
"ontxe": 0,
"id_after": 0,
"group": 101,
@ -1856,13 +1856,13 @@
300011
],
"completetask": 0,
"auto_accept": 1,
"auto_accept": 0,
"overtips": 1,
"reword": []
},
{
"key": 30007,
"lock": 999,
"lock": 1,
"ontxe": 0,
"id_after": 0,
"group": 101,
@ -1884,7 +1884,7 @@
},
{
"key": 30008,
"lock": 999,
"lock": 1,
"ontxe": 0,
"id_after": 0,
"group": 101,
@ -1906,7 +1906,7 @@
},
{
"key": 30009,
"lock": 999,
"lock": 1,
"ontxe": 0,
"id_after": 0,
"group": 101,
@ -1928,7 +1928,7 @@
},
{
"key": 30010,
"lock": 999,
"lock": 1,
"ontxe": 0,
"id_after": 0,
"group": 101,
@ -1950,7 +1950,7 @@
},
{
"key": 30011,
"lock": 999,
"lock": 1,
"ontxe": 0,
"id_after": 0,
"group": 101,

View File

@ -1,9 +1,11 @@
package hero
import (
"crypto/rand"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"math/big"
"google.golang.org/protobuf/proto"
)
@ -30,7 +32,10 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
pool string
_mapAddHero map[string]int32
strPool []string // 10连跨多个卡池情况
update map[string]interface{}
normalDraw bool // 是否是普通抽
)
update = make(map[string]interface{})
_mapAddHero = make(map[string]int32, 0)
cfgDraw = this.module.configure.GetGlobalConf() // 读取抽卡配置文件
if cfgDraw == nil {
@ -41,12 +46,12 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
return
}
szCards = make([]string, 0)
rsp := &pb.HeroDrawCardResp{}
heroRecord, _ = this.module.modelRecord.GetHeroRecord(session.GetUserId())
drawCount = heroRecord.Drawcount
if req.DrawType == 0 { // 普通卡池抽卡
normalDraw = true
// 获取普通抽卡池
if req.DrawCount == 1 {
costAtn = cfgDraw.BasePoolCost
@ -79,6 +84,28 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
sz = append(sz, cfgDraw.BasePoolStar5)
}
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.Star5++ // 5星保底数量+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)
if code != pb.ErrorCode_Success {
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 {
_mapAddHero[heroId]++
@ -231,48 +259,9 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
_, code = this.module.CreateRepeatHeros(session, _mapAddHero, true)
///英雄招募 【玩家名称】在招募中获得了【英雄名称】!
for hid := range _mapAddHero {
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)
this.module.SendChatMsg(session, _mapAddHero, szCards)
// 任务统计
if req.DrawType == 0 { //普通招募
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)
this.module.SendTaskMsg(session, szStar, req.DrawCount, normalDraw)
return
}

View File

@ -30,6 +30,7 @@ type Hero struct {
moduleFetter comm.IHeroFetter
service core.IService
moduleHoroscope comm.IHoroscope
chat comm.IChat
}
//模块名
@ -65,6 +66,10 @@ func (this *Hero) Start() (err error) {
}
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()
event.RegisterGO(comm.EventUserOffline, this.EventUserOffline)
return
@ -738,3 +743,52 @@ func (this *Hero) GetAllMaxHero(session comm.IUserSession) (code pb.ErrorCode) {
}
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)
}

View File

@ -165,9 +165,11 @@ func (this *User) CleanSession(session comm.IUserSession) {
// 在线玩家列表
func (this *User) UserOnlineList() ([]*pb.CacheUser, error) {
var cache []*pb.CacheUser
if !this.IsCross() {
if err := this.modelSession.GetList(comm.RDS_EMPTY, &cache); err != nil {
return nil, err
}
}
return cache, nil
}

View File

@ -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
return
}
@ -80,15 +80,14 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
hero = make([]string, 0)
newhero = make([]string, 0)
var nextTaskId int32
nextTaskId = curTaskConf.IdAfter
finishRsp := func() {
if err := session.SendMsg(string(this.module.GetType()), WorldtaskSubtypeFinish, rsp); err != nil {
code = pb.ErrorCode_SystemError
return
}
// 世界任务类型
if curTaskConf.Des == 2 {
if curTaskConf.IdAfter != 0 {
nextTaskId = curTaskConf.IdAfter
// 任务完成推送
if err := session.SendMsg(string(this.module.GetType()), WorldtaskNexttaskPush, &pb.WorldtaskNexttaskPush{
NextTaskId: nextTaskId,
@ -97,6 +96,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
return
}
}
}
finishCall := func() {