playroom房间点数
This commit is contained in:
parent
cd3edb76fb
commit
6139208d0e
@ -15,6 +15,7 @@ const (
|
||||
CFG_PLAYROOM_SHOP = "PlayroomShop"
|
||||
CFG_PLAYROOM_DRESS = "PlayroomDress"
|
||||
CFG_PLAYROOM_AIR = "PlayroomAir"
|
||||
CFG_PLAYROOM_LOCK = "PlayroomLock"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -26,6 +27,7 @@ func init() {
|
||||
gamedata.InitCfg(CFG_PLAYROOM_SHOP)
|
||||
gamedata.InitCfg(CFG_PLAYROOM_DRESS)
|
||||
gamedata.InitCfg(CFG_PLAYROOM_AIR)
|
||||
gamedata.InitCfg(CFG_PLAYROOM_LOCK)
|
||||
}
|
||||
|
||||
func GetShopItem(Id int) (int, []*item.Item) {
|
||||
@ -264,6 +266,22 @@ func IsTakeCat(Id int) bool {
|
||||
return GoUtil.InArray(Id, Ids)
|
||||
}
|
||||
|
||||
func GetRoomPointInvite() int {
|
||||
data, err := gamedata.GetDataByKey(CFG_PLAYROOM_CONST, "RoomPointInvite")
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
return gamedata.GetIntValue(data, "Value")
|
||||
}
|
||||
|
||||
func GetRoomPointAdd() int {
|
||||
data, err := gamedata.GetDataByKey(CFG_PLAYROOM_CONST, "RoomPointAdd")
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
return gamedata.GetIntValue(data, "Value")
|
||||
}
|
||||
|
||||
func IsPlayCat(Id int) bool {
|
||||
data, err := gamedata.GetDataByKey(CFG_PLAYROOM_CONST, "PlayCatId")
|
||||
if err != nil {
|
||||
@ -332,3 +350,11 @@ func GetDressPart(Id int) int {
|
||||
}
|
||||
return gamedata.GetIntValue(data, "IPart")
|
||||
}
|
||||
|
||||
func GetUnlockNeed(Type int) int {
|
||||
data, err := gamedata.GetDataByIntKey(CFG_PLAYROOM_LOCK, Type)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
return gamedata.GetIntValue(data, "Need")
|
||||
}
|
||||
|
||||
@ -791,6 +791,7 @@ func (ad *GameLogic) RegisterNetWorkFunc() {
|
||||
RegisterMsgProcessFunc("ReqPlayroomShop", ReqPlayroomShop) // playroom 商店
|
||||
RegisterMsgProcessFunc("ReqPlayroomBuyItem", ReqPlayroomBuyItem) // 购买playroom物品
|
||||
RegisterMsgProcessFunc("ReqPlayroomUpvote", ReqPlayroomUpvote) // 点赞别人的playroom
|
||||
RegisterMsgProcessFunc("ReqPlayroomUnlock", ReqPlayroomUnlock) // 解锁房间
|
||||
|
||||
// 宠物宝藏
|
||||
RegisterMsgProcessFunc("ReqFriendTreasure", ReqFriendTreasure) // 请求好友宝藏数据
|
||||
|
||||
@ -64,6 +64,8 @@ func handle(p *Player, m *msg.Msg) error {
|
||||
return nil
|
||||
}
|
||||
FriendMod.AddFriend(m.From)
|
||||
PlayroomMod := p.PlayMod.getPlayroomMod()
|
||||
PlayroomMod.AddRoomPointAdd()
|
||||
p.TeLog("friend_add", map[string]interface{}{
|
||||
"player_id": m.From,
|
||||
"add_type": "invite add friend",
|
||||
@ -293,6 +295,8 @@ func HandleFriendMsg(p *Player, m *msg.Msg) error {
|
||||
Type: friend.FRIEND_NOTIFY_AGREE,
|
||||
Time: int32(GoUtil.Now()),
|
||||
})
|
||||
PlayroomMod := p.PlayMod.getPlayroomMod()
|
||||
PlayroomMod.AddRoomPointAdd()
|
||||
p.TeLog("friend_add", map[string]interface{}{
|
||||
"player_id": m.From,
|
||||
"add_type": "agree",
|
||||
@ -732,6 +736,7 @@ func PlayroomBackData(p *Player) {
|
||||
r.AllMood = int32(PlayroomMod.AllMood)
|
||||
r.Jackpot = int32(PlayroomMod.JackpotNum)
|
||||
r.Upvote = int32(PlayroomMod.Upvote)
|
||||
r.RoomPoint = int32(PlayroomMod.RoomPoint)
|
||||
p.PushClientRes(r)
|
||||
}
|
||||
|
||||
|
||||
@ -1492,6 +1492,8 @@ func ReqApplyFriend(player *Player, buf []byte) error {
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
Uid: req.Uid,
|
||||
})
|
||||
PlayroomMod := player.PlayMod.getPlayroomMod()
|
||||
PlayroomMod.AddRoomPointInvite()
|
||||
player.TeLog("friend_add", map[string]interface{}{
|
||||
"player_id": Uid,
|
||||
"add_type": "apply",
|
||||
@ -2744,6 +2746,8 @@ func ReqAutoAddInviteFriend(player *Player, buf []byte) error {
|
||||
To: Uid,
|
||||
Type: MsqMod.HANDLE_TYPE_INVITE_ADD_FRIEND,
|
||||
})
|
||||
PlayroomMod := player.PlayMod.getPlayroomMod()
|
||||
PlayroomMod.AddRoomPointAdd()
|
||||
player.TeLog("friend_add", map[string]interface{}{
|
||||
"player_id": req.Id,
|
||||
"add_type": "invite add friend",
|
||||
@ -2780,6 +2784,8 @@ func ReqAutoAddInviteFriend2(player *Player, buf []byte) error {
|
||||
To: Uid,
|
||||
Type: MsqMod.HANDLE_TYPE_INVITE_ADD_FRIEND,
|
||||
})
|
||||
PlayroomMod := player.PlayMod.getPlayroomMod()
|
||||
PlayroomMod.AddRoomPointAdd()
|
||||
player.TeLog("friend_add", map[string]interface{}{
|
||||
"player_id": req.Id,
|
||||
"add_type": "invite add friend",
|
||||
@ -3503,6 +3509,26 @@ func ReqPlayroomUpvote(player *Player, buf []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func ReqPlayroomUnlock(player *Player, buf []byte) error {
|
||||
req := &msg.ReqPlayroomUnlock{}
|
||||
proto.Unmarshal(buf, req)
|
||||
PlayroomMod := player.PlayMod.getPlayroomMod()
|
||||
err := PlayroomMod.Unlock(int(req.Id))
|
||||
if err != nil {
|
||||
player.SendErrClienRes(&msg.ResPlayroomUnlock{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
Msg: err.Error(),
|
||||
})
|
||||
return err
|
||||
}
|
||||
player.PlayMod.save()
|
||||
player.PushClientRes(&msg.ResPlayroomUnlock{
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
Id: int32(req.Id),
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func ReqOfflineReconnectFunc(a gate.Agent, buf []byte) error {
|
||||
req := &msg.ReqOfflineReconnect{}
|
||||
proto.Unmarshal(buf, req)
|
||||
|
||||
@ -46,6 +46,8 @@ type PlayroomMod struct {
|
||||
JackpotNum int // 每日转盘数量
|
||||
Upvote int // 收到点赞次数
|
||||
UpvoteList []int // 点赞列表
|
||||
RoomPoint int // 房间点数
|
||||
UnlockList map[int]int64 // 解锁
|
||||
Physiology map[int]*Physiology
|
||||
}
|
||||
|
||||
@ -146,6 +148,9 @@ func (p *PlayroomMod) InitData() {
|
||||
if p.Flip == nil {
|
||||
p.Flip = make(map[int]int)
|
||||
}
|
||||
if p.UnlockList == nil {
|
||||
p.UnlockList = make(map[int]int64)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PlayroomMod) ZeroUpdate() {
|
||||
@ -657,6 +662,15 @@ func (p *PlayroomMod) PlayroomPetAirSet(Id int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PlayroomMod) Unlock(Id int) error {
|
||||
Need := playroomCfg.GetUnlockNeed(Id)
|
||||
if Need == 0 || Need > p.RoomPoint {
|
||||
return fmt.Errorf("unlock need is 0 or need > RoomPoint")
|
||||
}
|
||||
p.UnlockList[Id] = GoUtil.Now()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PlayroomMod) GetDressSet() map[int]int {
|
||||
return p.DressSet
|
||||
}
|
||||
@ -672,3 +686,26 @@ func (p *PlayroomMod) GetDress() map[int][]int {
|
||||
func (p *PlayroomMod) GetPetAir() []int {
|
||||
return p.PetAir
|
||||
}
|
||||
|
||||
// RoomPoint Get Set
|
||||
func (p *PlayroomMod) GetRoomPoint() int {
|
||||
return p.RoomPoint
|
||||
}
|
||||
func (p *PlayroomMod) SetRoomPoint(Point int) {
|
||||
p.RoomPoint = Point
|
||||
}
|
||||
func (p *PlayroomMod) AddRoomPointInvite() {
|
||||
Point := playroomCfg.GetRoomPointInvite()
|
||||
p.RoomPoint += Point
|
||||
if p.RoomPoint < 0 {
|
||||
p.RoomPoint = 0
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PlayroomMod) AddRoomPointAdd() {
|
||||
Point := playroomCfg.GetRoomPointAdd()
|
||||
p.RoomPoint += Point
|
||||
if p.RoomPoint < 0 {
|
||||
p.RoomPoint = 0
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user