playroom优化
This commit is contained in:
parent
03f153c45b
commit
83305772e4
@ -13,6 +13,8 @@ const (
|
||||
CFG_PLAYROOM_PHYSIOLOGY = "PlayroomPhysiology"
|
||||
CFG_PLAYROOM_PHYSIOLOGY_TYPE = "PlayroomPhysiologyType"
|
||||
CFG_PLAYROOM_SHOP = "PlayroomShop"
|
||||
CFG_PLAYROOM_DRESS = "PlayroomDress"
|
||||
CFG_PLAYROOM_AIR = "PlayroomAir"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -22,6 +24,8 @@ func init() {
|
||||
gamedata.InitCfg(CFG_PLAYROOM_PHYSIOLOGY)
|
||||
gamedata.InitCfg(CFG_PLAYROOM_PHYSIOLOGY_TYPE)
|
||||
gamedata.InitCfg(CFG_PLAYROOM_SHOP)
|
||||
gamedata.InitCfg(CFG_PLAYROOM_DRESS)
|
||||
gamedata.InitCfg(CFG_PLAYROOM_AIR)
|
||||
}
|
||||
|
||||
func GetShopItem(Id int) (int, []*item.Item) {
|
||||
@ -252,3 +256,63 @@ func IsPlayCat(Id int) bool {
|
||||
Ids := gamedata.GetIntSliceValue(data, "Value")
|
||||
return GoUtil.InArray(Id, Ids)
|
||||
}
|
||||
|
||||
func GetInitAirList() []int {
|
||||
r := make([]int, 0)
|
||||
data, err := gamedata.GetData(CFG_PLAYROOM_AIR)
|
||||
if err != nil {
|
||||
return []int{}
|
||||
}
|
||||
for k, v := range data {
|
||||
if gamedata.GetIntValue(v, "Init") == 1 {
|
||||
r = append(r, GoUtil.Int(k))
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func GetAirList() []int {
|
||||
r := make([]int, 0)
|
||||
data, err := gamedata.GetData(CFG_PLAYROOM_AIR)
|
||||
if err != nil {
|
||||
return []int{}
|
||||
}
|
||||
for k := range data {
|
||||
r = append(r, GoUtil.Int(k))
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func GetInitDressList() []int {
|
||||
r := make([]int, 0)
|
||||
data, err := gamedata.GetData(CFG_PLAYROOM_DRESS)
|
||||
if err != nil {
|
||||
return []int{}
|
||||
}
|
||||
for k, v := range data {
|
||||
if gamedata.GetIntValue(v, "Init") == 1 {
|
||||
r = append(r, GoUtil.Int(k))
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func GetDressList() []int {
|
||||
r := make([]int, 0)
|
||||
data, err := gamedata.GetData(CFG_PLAYROOM_DRESS)
|
||||
if err != nil {
|
||||
return []int{}
|
||||
}
|
||||
for k := range data {
|
||||
r = append(r, GoUtil.Int(k))
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func GetDressPart(Id int) int {
|
||||
data, err := gamedata.GetDataByIntKey(CFG_PLAYROOM_DRESS, Id)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
return gamedata.GetIntValue(data, "IPart")
|
||||
}
|
||||
|
||||
@ -774,6 +774,8 @@ func (ad *GameLogic) RegisterNetWorkFunc() {
|
||||
// #region playroom
|
||||
RegisterMsgProcessFunc("ReqPlayroom", ReqPlayroom) // 请求playroom数据
|
||||
RegisterMsgProcessFunc("ReqPlayroomInfo", ReqPlayroomInfo) // 请求playroom拜访信息
|
||||
RegisterMsgProcessFunc("ReqPlayroomDressSet", ReqPlayroomDressSet) // 设置服装
|
||||
RegisterMsgProcessFunc("ReqPlayroomPetAirSet", ReqPlayroomPetAirSet) // 获取宠物空气
|
||||
RegisterMsgProcessFunc("ReqPlayroomGame", ReqPlayroomGame) // 游戏结果
|
||||
RegisterMsgProcessFunc("ReqPlayroomInteract", ReqPlayroomInteract) // 宠物交互
|
||||
RegisterMsgProcessFunc("ReqPlayroomSetRoom", ReqPlayroomSetRoom) // playroom装饰
|
||||
|
||||
@ -237,6 +237,23 @@ func ReqGmCommand_(player *Player, Command string) error {
|
||||
for _, v := range CollectList {
|
||||
PlayroomMod.AddCollect(v)
|
||||
}
|
||||
case "playroomDress":
|
||||
PlayroomMod := player.PlayMod.getPlayroomMod()
|
||||
PlayroomMod.Dress = make(map[int][]int)
|
||||
DressList := playroomCfg.GetDressList()
|
||||
for _, v := range DressList {
|
||||
Part := playroomCfg.GetDressPart(v)
|
||||
PlayroomMod.UnlockDress(Part, v)
|
||||
}
|
||||
PlayroomBackData(player)
|
||||
case "playroomAir":
|
||||
PlayroomMod := player.PlayMod.getPlayroomMod()
|
||||
PlayroomMod.PetAir = make([]int, 0)
|
||||
AirList := playroomCfg.GetAirList()
|
||||
for _, v := range AirList {
|
||||
PlayroomMod.UnlockPetAir(v)
|
||||
}
|
||||
PlayroomBackData(player)
|
||||
case "resetRetire":
|
||||
ChessMod := player.PlayMod.getChessMod()
|
||||
ChessMod.Retire = make(map[string]int)
|
||||
|
||||
@ -581,6 +581,7 @@ func PlayroomBackData(p *Player) {
|
||||
r.Items = item.ItemToMsg(PlayroomMod.Reward)
|
||||
Opponent := make([]*proto.RoomOpponent, 0)
|
||||
FriendList := make([]*proto.FriendRoom, 0)
|
||||
|
||||
for k, v := range PlayroomMod.Visitor {
|
||||
ps := G_GameLogicPtr.GetSimplePlayerByUid(k)
|
||||
if ps == nil {
|
||||
@ -620,6 +621,16 @@ func PlayroomBackData(p *Player) {
|
||||
}
|
||||
}
|
||||
r.Collect = Collect
|
||||
Dress := make(map[int32]*proto.PlayroomDress)
|
||||
for k, v := range PlayroomMod.GetDress() {
|
||||
Dress[int32(k)] = &proto.PlayroomDress{
|
||||
List: GoUtil.IntToInt32(v),
|
||||
}
|
||||
}
|
||||
r.Dress = Dress
|
||||
r.DressSet = GoUtil.MapIntToInt32(PlayroomMod.GetDressSet())
|
||||
r.PetAir = GoUtil.IntToInt32(PlayroomMod.GetPetAir())
|
||||
r.PetAirSet = int32(PlayroomMod.GetPetAirSet())
|
||||
r.Chip = int32(PlayroomMod.Chip)
|
||||
r.StartTime = int32(PlayroomMod.Starttime)
|
||||
r.WorkStatus = int32(PlayroomMod.WorkStatus)
|
||||
|
||||
@ -3743,3 +3743,29 @@ func ReqSellChessNum(player *Player, buf []byte) error {
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func ReqPlayroomDressSet(player *Player, buf []byte) error {
|
||||
req := &msg.ReqPlayroomDressSet{}
|
||||
proto.Unmarshal(buf, req)
|
||||
PlayroomMod := player.PlayMod.getPlayroomMod()
|
||||
PlayroomMod.PlayroomDressSet(GoUtil.MapInt32ToInt(req.DressSet))
|
||||
player.PlayMod.save()
|
||||
PlayroomBackData(player)
|
||||
player.PushClientRes(&msg.ResPlayroomDressSet{
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func ReqPlayroomPetAirSet(player *Player, buf []byte) error {
|
||||
req := &msg.ReqPlayroomPetAirSet{}
|
||||
proto.Unmarshal(buf, req)
|
||||
PlayroomMod := player.PlayMod.getPlayroomMod()
|
||||
PlayroomMod.PlayroomPetAirSet(int(req.PetAirSet))
|
||||
player.PlayMod.save()
|
||||
PlayroomBackData(player)
|
||||
player.PushClientRes(&msg.ResPlayroomPetAirSet{
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -198,8 +198,7 @@ func UnitOrder2(p *Player, Lv, EnergyMul int) float64 {
|
||||
|
||||
func UnitPlayroom(p *Player) error {
|
||||
PlayroomMod := p.PlayMod.getPlayroomMod()
|
||||
PlayroomMod.Physiology[1].Num = 10
|
||||
PlayroomMod.Physiology[1].Time = 1738978968
|
||||
LimitedTimePlayroomTrigger(p)
|
||||
PlayroomMod.UnLock(15)
|
||||
PlayroomBackData(p)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -13,6 +13,10 @@ import (
|
||||
type PlayroomMod struct {
|
||||
Collect map[int]int // 装饰
|
||||
Room map[int]int // 房间
|
||||
Dress map[int][]int // 服装仓库
|
||||
DressSet map[int]int // 服装穿戴
|
||||
PetAir []int // 宠物空气背包
|
||||
PetAirSet int // 宠物空气背包穿戴
|
||||
Status int // 0: 未拜访 1: 拜访
|
||||
Endtime int64 // 结束时间
|
||||
Starttime int64 // 开始时间
|
||||
@ -88,6 +92,12 @@ func (p *PlayroomMod) InitData() {
|
||||
if p.Collect == nil {
|
||||
p.Collect = make(map[int]int)
|
||||
}
|
||||
if p.Dress == nil {
|
||||
p.Dress = make(map[int][]int)
|
||||
}
|
||||
if p.DressSet == nil {
|
||||
p.DressSet = make(map[int]int)
|
||||
}
|
||||
InitCollect := playroomCfg.GetInitDecorate()
|
||||
for _, v := range InitCollect {
|
||||
p.Collect[v] = 1
|
||||
@ -521,6 +531,19 @@ func (p *PlayroomMod) UnLock(Lv int) {
|
||||
p.MoodInfo[k] = &Mood{Id: k, Num: 100}
|
||||
}
|
||||
}
|
||||
if len(p.Dress) == 0 {
|
||||
p.Dress = make(map[int][]int)
|
||||
InitDressList := playroomCfg.GetInitDressList()
|
||||
for _, v := range InitDressList {
|
||||
Part := playroomCfg.GetDressPart(v)
|
||||
p.Dress[Part] = append(p.Dress[Part], v)
|
||||
}
|
||||
}
|
||||
if len(p.PetAir) == 0 {
|
||||
p.PetAir = make([]int, 0)
|
||||
InitPetAir := playroomCfg.GetInitAirList()
|
||||
p.PetAir = append(p.PetAir, InitPetAir...)
|
||||
}
|
||||
}
|
||||
|
||||
// shop
|
||||
@ -532,3 +555,56 @@ func (p *PlayroomMod) ShopBuy(Id, Num int) ([]*item.Item, []*item.Item, error) {
|
||||
NewCostItem := item.MutilItem(CostItem, Num)
|
||||
return []*item.Item{item.NewItem(AddItemId, Num)}, NewCostItem, nil
|
||||
}
|
||||
|
||||
func (p *PlayroomMod) UnlockDress(Type, Id int) error {
|
||||
_, ok := p.Dress[Type]
|
||||
if !ok {
|
||||
p.Dress[Type] = make([]int, 0)
|
||||
}
|
||||
p.Dress[Type] = append(p.Dress[Type], Id)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PlayroomMod) UnlockPetAir(Id int) {
|
||||
p.PetAir = append(p.PetAir, Id)
|
||||
}
|
||||
|
||||
func (p *PlayroomMod) PlayroomDressSet(DressSet map[int]int) error {
|
||||
// 判断服装是否存在
|
||||
for Type, Id := range DressSet {
|
||||
dresses, ok := p.Dress[Type]
|
||||
if !ok {
|
||||
return fmt.Errorf("dress type not found")
|
||||
}
|
||||
|
||||
if !GoUtil.InArray(Id, dresses) {
|
||||
return fmt.Errorf("dress not found")
|
||||
}
|
||||
}
|
||||
p.DressSet = DressSet
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PlayroomMod) PlayroomPetAirSet(Id int) error {
|
||||
if !GoUtil.InArray(Id, p.PetAir) {
|
||||
return fmt.Errorf("pet air not found")
|
||||
}
|
||||
p.PetAirSet = Id
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PlayroomMod) GetDressSet() map[int]int {
|
||||
return p.DressSet
|
||||
}
|
||||
|
||||
func (p *PlayroomMod) GetPetAirSet() int {
|
||||
return p.PetAirSet
|
||||
}
|
||||
|
||||
func (p *PlayroomMod) GetDress() map[int][]int {
|
||||
return p.Dress
|
||||
}
|
||||
|
||||
func (p *PlayroomMod) GetPetAir() []int {
|
||||
return p.PetAir
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user