商队测试 + 铁匠铺掉落
This commit is contained in:
parent
5b41afb95c
commit
c08678a30a
@ -74,12 +74,14 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.EnchantCha
|
||||
this.module.CheckRank(session.GetUserId(), req.BossType, req.Report, userinfo, req.Score)
|
||||
}
|
||||
//this.module.CheckRank(session.GetUserId(), req.BossType, enchant, req.Report, req.Score)
|
||||
user := this.module.ModuleUser.GetUser(session.GetUserId())
|
||||
enchant.Boss[req.BossType] = req.Score // 获得的积分
|
||||
// 发放通关随机奖励
|
||||
for _, v := range cfgEnchant {
|
||||
if score >= v.ScoreLow && score <= v.ScoreUp {
|
||||
for _, v1 := range v.RewardDrop {
|
||||
reward := this.module.configure.GetDropReward(v1) // 获取掉落奖励
|
||||
reward := this.module.ModuleTools.GetGroupDataByLottery(v1, user.Vip, user.Lv)
|
||||
//reward := this.module.configure.GetDropReward(v1) // 获取掉落奖励
|
||||
if errdata = this.module.DispenseRes(session, reward, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package equipment
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
@ -10,7 +9,6 @@ import (
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"go_dreamfactory/sys/db"
|
||||
"math"
|
||||
"math/big"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
@ -258,7 +256,6 @@ func (this *modelEquipmentComp) newEquipment(uid string, conf *cfg.GameEquipData
|
||||
equipatt *cfg.GameEquipAttributeData
|
||||
weight []int32
|
||||
index int32
|
||||
total int64
|
||||
maxindex int
|
||||
satterNum int32
|
||||
)
|
||||
@ -309,16 +306,17 @@ func (this *modelEquipmentComp) newEquipment(uid string, conf *cfg.GameEquipData
|
||||
weight[i] += dyweight[i]
|
||||
}
|
||||
}
|
||||
for _, v := range weight {
|
||||
total += int64(v)
|
||||
}
|
||||
result, _ := rand.Int(rand.Reader, big.NewInt(total))
|
||||
for i, v := range weight {
|
||||
if int32(result.Int64()) <= v {
|
||||
satterNum = conf.Addattrnum[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
satterNum = conf.Addattrnum[comm.GetRandW(weight)]
|
||||
// for _, v := range weight {
|
||||
// total += int64(v)
|
||||
// }
|
||||
// result, _ := rand.Int(rand.Reader, big.NewInt(total))
|
||||
// for i, v := range weight {
|
||||
// if int32(result.Int64()) <= v {
|
||||
// satterNum = conf.Addattrnum[i]
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
if satterNum > int32(len(sattr)) {
|
||||
satterNum = int32(len(sattr))
|
||||
}
|
||||
|
116
modules/robot/modulerobot_caravan.go
Normal file
116
modules/robot/modulerobot_caravan.go
Normal file
@ -0,0 +1,116 @@
|
||||
package robot
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
//商队模块 机器人
|
||||
type ModuleRobot_Caravan struct {
|
||||
goods map[pb.ShopType][]*pb.ShopItem
|
||||
}
|
||||
|
||||
func (this *ModuleRobot_Caravan) Init() (err error) {
|
||||
this.goods = make(map[pb.ShopType][]*pb.ShopItem)
|
||||
return
|
||||
}
|
||||
|
||||
//接收到消息
|
||||
func (this *ModuleRobot_Caravan) Receive(robot IRobot, stype string, message proto.Message) (err error) {
|
||||
switch stype {
|
||||
case "getlist":
|
||||
resp := message.(*pb.ShopGetListResp)
|
||||
this.goods[resp.SType] = resp.Goods
|
||||
break
|
||||
}
|
||||
return
|
||||
}
|
||||
func (this *ModuleRobot_Caravan) OncePipeline(robot IRobot) (err error) {
|
||||
var (
|
||||
errdata *pb.ErrorData
|
||||
)
|
||||
if _, errdata = robot.SendMessage("shop", "getlist", &pb.ShopGetListReq{
|
||||
SType: pb.ShopType_DiamondShop,
|
||||
}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//机器人执行流
|
||||
func (this *ModuleRobot_Caravan) DoPipeline(robot IRobot) (err error) {
|
||||
var (
|
||||
errdata *pb.ErrorData
|
||||
usermodule *ModuleRobot_User
|
||||
)
|
||||
usermodule = robot.GetModule(comm.ModuleUser).(*ModuleRobot_User)
|
||||
for _, v := range this.goods[pb.ShopType_GoldShop] {
|
||||
if v.LeftBuyNum > 0 && usermodule.user.Gold >= int64(v.Consume[0].N) {
|
||||
if _, errdata = robot.SendMessage("shop", "buy", &pb.ShopBuyReq{
|
||||
ShopType: pb.ShopType_GoldShop,
|
||||
Gid: v.Gid,
|
||||
BuyNum: 1,
|
||||
}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, v := range this.goods[pb.ShopType_DiamondShop] {
|
||||
if v.LeftBuyNum > 0 && usermodule.user.Diamond >= int64(v.Consume[0].N) {
|
||||
if _, errdata = robot.SendMessage("shop", "buy", &pb.ShopBuyReq{
|
||||
ShopType: pb.ShopType_DiamondShop,
|
||||
Gid: v.Gid,
|
||||
BuyNum: 1,
|
||||
}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//做任务
|
||||
func (this *ModuleRobot_Caravan) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) {
|
||||
var (
|
||||
errdata *pb.ErrorData
|
||||
)
|
||||
switch comm.TaskType(condconf.Type) {
|
||||
case comm.Rtype104:
|
||||
var (
|
||||
usermodule *ModuleRobot_User
|
||||
)
|
||||
usermodule = robot.GetModule(comm.ModuleUser).(*ModuleRobot_User)
|
||||
if _, errdata = robot.SendMessage("shop", "getlist", &pb.ShopGetListReq{
|
||||
SType: pb.ShopType_DiamondShop,
|
||||
}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range this.goods[pb.ShopType_DiamondShop] {
|
||||
if v.LeftBuyNum > 0 && usermodule.user.Diamond >= int64(v.Consume[0].N) {
|
||||
if _, errdata = robot.SendMessage("shop", "buy", &pb.ShopBuyReq{
|
||||
ShopType: pb.ShopType_DiamondShop,
|
||||
Gid: v.Gid,
|
||||
BuyNum: 1,
|
||||
}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return
|
||||
}
|
@ -70,6 +70,7 @@ func (this *Robot) Init(addr string, client IClient) (err error) {
|
||||
this.modules[comm.ModuleViking] = new(ModuleRobot_Viking)
|
||||
this.modules[comm.ModuleChat] = new(ModuleRobot_Chat)
|
||||
this.modules[comm.ModuleShop] = new(ModuleRobot_Shop)
|
||||
this.modules[comm.ModuleShop] = new(ModuleRobot_Caravan)
|
||||
this.modules[comm.ModuleHoroscope] = new(ModuleRobot_Horoscope)
|
||||
for _, v := range this.modules {
|
||||
v.Init()
|
||||
|
@ -243,9 +243,11 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq
|
||||
} else { // 普通打造
|
||||
// 获取掉落id
|
||||
newdrop := this.module.modelStove.CheckUnlockSuid(req.ReelId, stove.Data[req.ReelId].Lv, reelcfg.BasicDrop)
|
||||
user := this.module.ModuleUser.GetUser(session.GetUserId())
|
||||
// 检查是否命中双倍打造
|
||||
for i := 0; i < int(req.Count); i++ {
|
||||
res := this.module.configure.GetDropReward(newdrop)
|
||||
res := this.module.ModuleTools.GetGroupDataByLottery(newdrop, user.Vip, user.Lv)
|
||||
//res := this.module.configure.GetDropReward(newdrop)
|
||||
if ok := this.module.modelStove.CheckForgetwoEquip(req.ReelId, stove.Data[req.ReelId].Lv, addProbability); ok {
|
||||
resReward = append(resReward, res...)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user