剧情事件

This commit is contained in:
meixiongfeng 2023-08-11 14:42:33 +08:00
parent 2a67942996
commit 8855903a7c
5 changed files with 110 additions and 15 deletions

View File

@ -93,15 +93,21 @@ func (this *apiComp) Event(session comm.IUserSession, req *pb.StonehengeEventReq
if lenSelect == 0 || lenSelect <= pos {
return
}
stone.Userbuff[stone.Rooms.Selectbuff[pos]] = 1
stone.Rooms.Selectbuff = []int32{}
update["userbuff"] = stone.Userbuff
buffid := stone.Rooms.Selectbuff[pos]
// 加入收藏
if conf, err := this.module.configure.GetStoneBuffDataById(buffid); err != nil {
stone.Userbuff[buffid] = 1
stone.Rooms.Selectbuff = []int32{}
update["userbuff"] = stone.Userbuff
this.module.modelStonehengeBook.addStonehengeBook(session.GetUserId(), conf.Type, buffid)
}
} else { // 参数错误
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
Message: err.Error(),
}
return
}
case EventType14:
case EventType28: // 战斗事件
@ -208,12 +214,63 @@ func (this *apiComp) Event(session comm.IUserSession, req *pb.StonehengeEventReq
stone.Hero[objId].Currhp -= int32(math.Floor(float64(stone.Hero[objId].Currhp*eventConf.Value1) / 1000)) // 扣除当前生命值X千分比
}
update["hero"] = stone.Hero
case EventType20: // 克隆一名英雄
if _, ok := stone.Hero[req.Param1]; ok {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_StonehengeHeroRepeated,
Message: pb.ErrorCode_StonehengeHeroRepeated.ToString(),
}
return
}
// 查库
if hero, err := this.module.ModuleHero.GetHeroByObjID(session.GetUserId(), req.Param1); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_HeroNoExist,
Message: pb.ErrorCode_HeroNoExist.ToString(),
}
return
} else {
var roles []*pb.BattleRole
if roles, errdata = this.module.battle.CreateRolesByHeros([]*pb.DBHero{hero}); errdata != nil {
return
}
if len(roles) == 1 {
roles[0].Tid = 100 + int32(len(stone.Hero))
stone.Hero[req.Param1] = roles[0]
}
}
update["hero"] = stone.Hero
case EventType11: // 剧情事件
var (
num1 int
num2 int
err error
conf *cfg.GameStoneStoryData
)
num1, err = strconv.Atoi(req.Param1)
if err != nil {
return
}
num2, err = strconv.Atoi(req.Param1)
if err != nil {
return
}
if conf, err = this.module.configure.GetStoneStoryConf(int32(num1), int32(num2)); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
return
}
this.module.Debugf("%v", conf)
}
stone.Rooms.Eventid[req.Eventid] = true //
// 校验事件有后续事件
if eventConf.Probability >= comm.GetRandNum(0, 1000) { // 命中
newEvent = eventConf.PostEvent
stone.Rooms.Eventid[newEvent] = false //
if newEventConf, err = this.module.configure.GetStoneEventDataById(newEvent); err != nil {
errdata = &pb.ErrorData{

View File

@ -69,7 +69,7 @@ func (this *apiComp) Store(session comm.IUserSession, req *pb.StonehengeStoreReq
stone.Rooms.Eventid[storeConf.EventId] = false
update["rooms"] = stone.Rooms
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)
session.SendMsg(string(this.module.GetType()), "activatetalent", &pb.StonehengeStoreResp{
session.SendMsg(string(this.module.GetType()), "store", &pb.StonehengeStoreResp{
StoreId: req.StoreId,
Shop: stone.Rooms.Shop,
})

View File

@ -1,6 +1,7 @@
package stonehenge
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
@ -24,6 +25,7 @@ const (
game_stonetalent = "game_stonetalent.json"
game_storeconf = "game_stonestore.json" // 商店配置
game_stoneillustrated = "game_stoneillustrated.json"
game_storyconf = "game_stonestory.json" // 剧情表
)
///背包配置管理组件
@ -66,6 +68,8 @@ type configureComp struct {
// buff 随机
buffLottery map[int32]map[int32]*cfg.GameBufflotteryData
story map[int32]*cfg.GameStoneStoryData
}
//组件初始化接口
@ -89,8 +93,10 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
err = this.LoadConfigure(game_battleconf, cfg.NewGameStoneBattle)
err = this.LoadConfigure(game_stonetalent, cfg.NewGameStoneTalent)
err = this.LoadConfigure(game_storeconf, cfg.NewGameStoneStore)
//err = this.LoadConfigure(game_storyconf, cfg.NewGameStoneStory)
configure.RegisterConfigure(game_stageconf, cfg.NewGameStoneStage, this.LoadGameStoneStage)
configure.RegisterConfigure(game_buffconf, cfg.NewGameStoneBuff, this.LoadGameStoneBuff)
configure.RegisterConfigure(game_storyconf, cfg.NewGameStoneStory, this.LoadGameStoneStory)
return
}
@ -724,3 +730,28 @@ func (this *configureComp) getGameStoneIllustratedDatas() (confs []*cfg.GameSton
return
}
func (this *configureComp) LoadGameStoneStory() {
if v, err := this.GetConfigure(game_storyconf); err == nil {
if configure, ok := v.(*cfg.GameStoneStory); ok {
this.hlock.Lock()
defer this.hlock.Unlock()
this.story = make(map[int32]*cfg.GameStoneStoryData)
for _, v := range configure.GetDataList() {
key := v.StoryGroupId<<8 + v.StepId
this.story[key] = v
}
}
}
return
}
func (this *configureComp) GetStoneStoryConf(id, step int32) (data *cfg.GameStoneStoryData, err error) {
var ok bool
if data, ok = this.story[id<<8+step]; ok {
return
}
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_stonetalent, fmt.Sprintf("StoryGroupId:%d,step:%d", id, step))
return
}

View File

@ -3,11 +3,13 @@ package stonehenge
// 事件类型
const (
EventType10 = 10 // 宝箱事件
EventType11 = 11 // 剧情事件
EventType14 = 14 // 战斗事件
EventType16 = 16 // 捡垃圾事件
EventType17 = 17 // 回血事件
EventType18 = 18 // 回血事件 非场景
EventType19 = 19 // 扣血事件 非场景
EventType20 = 20 // 克隆一名英雄
EventType25 = 25 // buff三选一
EventType28 = 28 // BOSS 战斗
)

View File

@ -428,6 +428,7 @@ const (
ErrorCode_StonehengeNoComplete ErrorCode = 4908 // 房间还没有通关
ErrorCode_StonehengeStoreMax ErrorCode = 4909 // 购买上限
ErrorCode_StonehengeCantBuy ErrorCode = 4910 // 已有事件不能重复购买
ErrorCode_StonehengeHeroRepeated ErrorCode = 4911 // 重复英雄
// 活动错误码
ErrorCode_ActivityOver ErrorCode = 5001 //活动结束
ErrorCode_ActivityUnOpened ErrorCode = 5002 // 活动未开启
@ -803,6 +804,7 @@ var (
4908: "StonehengeNoComplete",
4909: "StonehengeStoreMax",
4910: "StonehengeCantBuy",
4911: "StonehengeHeroRepeated",
5001: "ActivityOver",
5002: "ActivityUnOpened",
5003: "ActivityRepatReward",
@ -1174,6 +1176,7 @@ var (
"StonehengeNoComplete": 4908,
"StonehengeStoreMax": 4909,
"StonehengeCantBuy": 4910,
"StonehengeHeroRepeated": 4911,
"ActivityOver": 5001,
"ActivityUnOpened": 5002,
"ActivityRepatReward": 5003,
@ -1214,7 +1217,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
var file_errorcode_proto_rawDesc = []byte{
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2a, 0xab, 0x44, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x6f, 0x2a, 0xc8, 0x44, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10,
0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76,
@ -1752,16 +1755,18 @@ var file_errorcode_proto_rawDesc = []byte{
0x10, 0xac, 0x26, 0x12, 0x17, 0x0a, 0x12, 0x53, 0x74, 0x6f, 0x6e, 0x65, 0x68, 0x65, 0x6e, 0x67,
0x65, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x4d, 0x61, 0x78, 0x10, 0xad, 0x26, 0x12, 0x16, 0x0a, 0x11,
0x53, 0x74, 0x6f, 0x6e, 0x65, 0x68, 0x65, 0x6e, 0x67, 0x65, 0x43, 0x61, 0x6e, 0x74, 0x42, 0x75,
0x79, 0x10, 0xae, 0x26, 0x12, 0x11, 0x0a, 0x0c, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79,
0x4f, 0x76, 0x65, 0x72, 0x10, 0x89, 0x27, 0x12, 0x15, 0x0a, 0x10, 0x41, 0x63, 0x74, 0x69, 0x76,
0x69, 0x74, 0x79, 0x55, 0x6e, 0x4f, 0x70, 0x65, 0x6e, 0x65, 0x64, 0x10, 0x8a, 0x27, 0x12, 0x18,
0x0a, 0x13, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x52, 0x65, 0x70, 0x61, 0x74, 0x52,
0x65, 0x77, 0x61, 0x72, 0x64, 0x10, 0x8b, 0x27, 0x12, 0x16, 0x0a, 0x11, 0x41, 0x63, 0x74, 0x69,
0x76, 0x69, 0x74, 0x79, 0x4e, 0x6f, 0x74, 0x49, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x10, 0x8c, 0x27,
0x12, 0x14, 0x0a, 0x0f, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x76, 0x61,
0x6c, 0x69, 0x64, 0x10, 0x8d, 0x27, 0x12, 0x17, 0x0a, 0x12, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69,
0x74, 0x79, 0x43, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x10, 0x8e, 0x27, 0x42,
0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x79, 0x10, 0xae, 0x26, 0x12, 0x1b, 0x0a, 0x16, 0x53, 0x74, 0x6f, 0x6e, 0x65, 0x68, 0x65, 0x6e,
0x67, 0x65, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x10, 0xaf,
0x26, 0x12, 0x11, 0x0a, 0x0c, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4f, 0x76, 0x65,
0x72, 0x10, 0x89, 0x27, 0x12, 0x15, 0x0a, 0x10, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79,
0x55, 0x6e, 0x4f, 0x70, 0x65, 0x6e, 0x65, 0x64, 0x10, 0x8a, 0x27, 0x12, 0x18, 0x0a, 0x13, 0x41,
0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x52, 0x65, 0x70, 0x61, 0x74, 0x52, 0x65, 0x77, 0x61,
0x72, 0x64, 0x10, 0x8b, 0x27, 0x12, 0x16, 0x0a, 0x11, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74,
0x79, 0x4e, 0x6f, 0x74, 0x49, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x10, 0x8c, 0x27, 0x12, 0x14, 0x0a,
0x0f, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64,
0x10, 0x8d, 0x27, 0x12, 0x17, 0x0a, 0x12, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x43,
0x61, 0x6e, 0x74, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x10, 0x8e, 0x27, 0x42, 0x06, 0x5a, 0x04,
0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (