1337 lines
67 KiB
Lua
1337 lines
67 KiB
Lua
|
|
local skynet = require "skynet"
|
|||
|
|
local oo = require "Class"
|
|||
|
|
local log = require "Log"
|
|||
|
|
local pb = require "pb"
|
|||
|
|
local redisKeyUrl = require "RedisKeyUrl"
|
|||
|
|
local json = require "json"
|
|||
|
|
local dataType = require "DataType"
|
|||
|
|
local errorInfo = require "ErrorInfo"
|
|||
|
|
local House = oo.class()
|
|||
|
|
|
|||
|
|
House.OPType_House = 1 --放房间
|
|||
|
|
House.OPType_Bag = 2 --放背包
|
|||
|
|
House.OPType_Move = 3 --移动
|
|||
|
|
House.OPType_Operate = 4 --家具原地操作
|
|||
|
|
|
|||
|
|
House.DecorateStatus_Suc = 1 --成功装修
|
|||
|
|
House.DecorateStatus_Failed = 2 --部分装修
|
|||
|
|
|
|||
|
|
House.Status_Lock = 1 --未解锁
|
|||
|
|
House.Status_NoBuy = 2 --未购买
|
|||
|
|
House.Status_AlreadyBuy = 3 --已购买
|
|||
|
|
House.Status_Live = 4 --正在居住
|
|||
|
|
|
|||
|
|
House.SchemeStatus_NoBuy = 1 --装修方案未购买
|
|||
|
|
House.SchemeStatus_AlreadyBuy = 2 --装修方案已购买
|
|||
|
|
House.SchemeStatus_Use = 3 --装修方案正在使用
|
|||
|
|
|
|||
|
|
House.ShopType_1 = 1 --恋家地产
|
|||
|
|
House.ShopType_2 = 2 --恋家置业
|
|||
|
|
House.ShopType_3 = 3 --双人空间
|
|||
|
|
|
|||
|
|
--登陆初始化数据
|
|||
|
|
function House:LoginInitData( player )
|
|||
|
|
self:CheckNew( player )
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--检查一下是否有新的房子
|
|||
|
|
function House:CheckNew( player )
|
|||
|
|
local houseId = 0
|
|||
|
|
local curHouse = player.gameData.house
|
|||
|
|
|
|||
|
|
--检查房子是否有新配置
|
|||
|
|
local cfgHouse = skynet.server.gameConfig:GetPlayerAllCfg( player , "House")
|
|||
|
|
for k, houseInfo in pairs( cfgHouse ) do
|
|||
|
|
local houseId = houseInfo.id
|
|||
|
|
local isInitHouse = true
|
|||
|
|
|
|||
|
|
if not curHouse[ houseId ] then
|
|||
|
|
--初始化房间
|
|||
|
|
curHouse[ houseId ] = {}
|
|||
|
|
curHouse[ houseId ].id = houseId
|
|||
|
|
if 4 == houseId then
|
|||
|
|
curHouse[ houseId ].status = self.Status_NoBuy
|
|||
|
|
else
|
|||
|
|
curHouse[ houseId ].status = self.Status_Lock
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
if 11 == houseId then
|
|||
|
|
--庭院需要同步家园数据 isInit 是否初始化过 archs 家园建筑信息
|
|||
|
|
curHouse[ houseId ].groupGarden = { archs = skynet.server.common:DeepCopy( skynet.server.group.InitArchs ) }
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
curHouse[ houseId ].unlockAreaList = {} --已经解锁的区域
|
|||
|
|
curHouse[ houseId ].curSchemeId = 0 --当前方案ID
|
|||
|
|
curHouse[ houseId ].scheme = {} --所有方案数据
|
|||
|
|
curHouse[ houseId ].isFirstEnter = true --是否第一次进行
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--等级够后就解锁可以购买
|
|||
|
|
if player.gameData.level >= houseInfo.level and self.Status_Lock == curHouse[ houseId ].status then
|
|||
|
|
curHouse[ houseId ].status = self.Status_NoBuy
|
|||
|
|
if self.ShopType_1 == houseInfo.shopType then
|
|||
|
|
skynet.server.msgTips:Add( player , 14 )
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--展示
|
|||
|
|
function House:Show( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHouseShow", c2sData.data ))
|
|||
|
|
|
|||
|
|
local shopTypes = c2sData.data.shopType
|
|||
|
|
local data = {}
|
|||
|
|
data.houseId = player.gameData.curHouseID
|
|||
|
|
data.showInfo = {}
|
|||
|
|
|
|||
|
|
for k1, v1 in pairs( shopTypes ) do
|
|||
|
|
for k2, v2 in pairs( player.gameData.house ) do
|
|||
|
|
local cfgCurHouse = skynet.server.gameConfig:GetPlayerCurCfg( player , "House" , v2.id )
|
|||
|
|
if cfgCurHouse and v1 == cfgCurHouse.shopType then --将指定商店类型的房间发给客户端
|
|||
|
|
table.insert( data.showInfo , { id = v2.id , status = v2.status })
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
skynet.server.msgTips:ReduceAll( player , 14 )
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HouseShow")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHouseShow", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--房子购买
|
|||
|
|
function House:Buy( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHouseBuy", c2sData.data ))
|
|||
|
|
local houseId = c2sData.data.houseId
|
|||
|
|
local data = {}
|
|||
|
|
|
|||
|
|
if not self:IsExistHouse( player , houseId) then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.NoExistHouse
|
|||
|
|
else
|
|||
|
|
data.houseId = houseId
|
|||
|
|
|
|||
|
|
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue")
|
|||
|
|
|
|||
|
|
if self:Add( player , houseId , s2cData , false ) then
|
|||
|
|
if 11 == houseId then
|
|||
|
|
--打开购买庭院的标记
|
|||
|
|
player:SetSwitch( dataType.SwitchType_GainGarden , true )
|
|||
|
|
skynet.server.levelTask:Modify( player , 3 , 1 )
|
|||
|
|
skynet.server.taskListEvent:Modify( player , 3 , 1 )
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
if player.gameData.level>=cfgSValue.storeUnlockLvl then
|
|||
|
|
skynet.server.store:InitData(player)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
local myPartnerId = player.gameData.partner.id
|
|||
|
|
local redisKey = string.format( redisKeyUrl.GameServerHouseDetailHash , myPartnerId )
|
|||
|
|
if skynet.server.redis:exists( redisKey) then
|
|||
|
|
local houseList = {}
|
|||
|
|
for k, v in pairs( player.gameData.house ) do
|
|||
|
|
if self.Status_AlreadyBuy == v.status or self.Status_Live == v.status then
|
|||
|
|
table.insert( houseList, k )
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
skynet.server.redis:hset( redisKey , "houseList" , json:encode(houseList) , "houseData_"..houseId , json:encode( player.gameData.house[ houseId ]) )
|
|||
|
|
end
|
|||
|
|
log.debug(string.format("玩家 %d 购买房子成功 房间ID %d " , player.basicInfo.userID , houseId ))
|
|||
|
|
else
|
|||
|
|
log.warning(string.format("玩家 %d 购买房子失败 房间ID %d " , player.basicInfo.userID , houseId ))
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HouseBuy")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHouseBuy", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--搬家
|
|||
|
|
function House:Move( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHouseMove", c2sData.data ))
|
|||
|
|
local houseId = c2sData.data.houseId
|
|||
|
|
local data = {}
|
|||
|
|
if not self:IsExistHouse( player , houseId ) then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.NoExistHouse
|
|||
|
|
else
|
|||
|
|
data.houseId = houseId
|
|||
|
|
for k1, v1 in pairs( player.gameData.house ) do
|
|||
|
|
--找到对应的房间ID并且是购买了
|
|||
|
|
if houseId == v1.id and self.Status_AlreadyBuy == v1.status then
|
|||
|
|
local curHouse = player.gameData.house[ houseId ]
|
|||
|
|
curHouse.isFirstEnter = false --不是第一次进了。
|
|||
|
|
|
|||
|
|
--将上一次房间状态改为已购买
|
|||
|
|
local lastHouseId = player.gameData.curHouseID
|
|||
|
|
local srcSchemeId = player.gameData.house[ lastHouseId ].curSchemeId
|
|||
|
|
player.gameData.house[ lastHouseId ].status = self.Status_AlreadyBuy
|
|||
|
|
--将该房间状态改为正在居住
|
|||
|
|
v1.status = self.Status_Live
|
|||
|
|
--找到对应的房间
|
|||
|
|
player.gameData.curHouseID = houseId
|
|||
|
|
--获取下该房间的花盆
|
|||
|
|
skynet.server.flowerpot:CheckExistFlowerpot( player )
|
|||
|
|
--找到该房间的方案ID
|
|||
|
|
data.schemeId = v1.curSchemeId
|
|||
|
|
--当前房子下所有方案信息
|
|||
|
|
data.schemeInfo = self:GetAllSchemeInfo( player , houseId )
|
|||
|
|
|
|||
|
|
--当前房子和当前方案下的家具信息
|
|||
|
|
data.furnitureInfo = self:GetCurSchemeFurniture( player , houseId , v1.curSchemeId )
|
|||
|
|
data.decorateInfo = self:GetCurSchemeDecorate( player , houseId , v1.curSchemeId )
|
|||
|
|
|
|||
|
|
--根据房间ID不同,完成的任务不同
|
|||
|
|
if 1 == houseId then
|
|||
|
|
skynet.server.levelTask:Modify( player , 12 , 1 , 3)
|
|||
|
|
elseif 2 == houseId then
|
|||
|
|
skynet.server.levelTask:Modify( player , 12 , 1 , 4)
|
|||
|
|
elseif 3 == houseId then
|
|||
|
|
skynet.server.levelTask:Modify( player , 12 , 1 , 5)
|
|||
|
|
elseif 5 == houseId then
|
|||
|
|
skynet.server.levelTask:Modify( player , 12 , 1 , 6)
|
|||
|
|
elseif 7 == houseId then
|
|||
|
|
skynet.server.levelTask:Modify( player , 12 , 1 , 14)
|
|||
|
|
elseif 8 == houseId then
|
|||
|
|
skynet.server.levelTask:Modify( player , 12 , 1 , 15)
|
|||
|
|
elseif 9 == houseId then
|
|||
|
|
skynet.server.levelTask:Modify( player , 12 , 1 , 16)
|
|||
|
|
elseif 10 == houseId then
|
|||
|
|
skynet.server.levelTask:Modify( player , 12 , 1 , 17)
|
|||
|
|
elseif 12 == houseId then
|
|||
|
|
skynet.server.levelTask:Modify( player , 12 , 1 , 18)
|
|||
|
|
elseif 13 == houseId then
|
|||
|
|
skynet.server.levelTask:Modify( player , 12 , 1 , 19) --恋家置业新户型:宜居新房配置&实装 2
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
skynet.server.taskListEvent:Modify( player , 23 , 1 )
|
|||
|
|
--发送已经解锁的区域
|
|||
|
|
data.areaId ={}
|
|||
|
|
for areaId, v in pairs( curHouse.unlockAreaList ) do
|
|||
|
|
if true == v then
|
|||
|
|
table.insert( data.areaId , areaId )
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
local myPartnerId = player.gameData.partner.id
|
|||
|
|
local redisKey = string.format( redisKeyUrl.GameServerHouseDetailHash , myPartnerId )
|
|||
|
|
if skynet.server.redis:exists( redisKey) then
|
|||
|
|
skynet.server.redis:hset( redisKey , "curHouseId", houseId, "houseData_"..houseId , json:encode( curHouse ) )
|
|||
|
|
skynet.server.redis:expire( redisKey , skynet.server.partner.HouseDetailMaxOutTime ) --设置过期时间为1小时
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HouseMove")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHouseMove", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--购买方案
|
|||
|
|
function House:BuyScheme( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHouseBuyScheme", c2sData.data ))
|
|||
|
|
local schemeId = c2sData.data.schemeId
|
|||
|
|
local data = {}
|
|||
|
|
if not schemeId then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|||
|
|
else
|
|||
|
|
local houseId = player.gameData.curHouseID
|
|||
|
|
local houseInfo = player.gameData.house[ houseId ]
|
|||
|
|
local isExist = false
|
|||
|
|
for k, v in pairs( houseInfo.scheme ) do
|
|||
|
|
--找到对应的方案ID和已经购买的方案
|
|||
|
|
if schemeId == v.id and self.SchemeStatus_NoBuy == v.status then
|
|||
|
|
isExist = true
|
|||
|
|
--根据方案ID找到配置的ID
|
|||
|
|
local curCfgId = 0
|
|||
|
|
local cfgScheme = skynet.server.gameConfig:GetPlayerAllCfg( player , "Scheme")
|
|||
|
|
for k, v in pairs(cfgScheme) do
|
|||
|
|
if schemeId == v.combineID then
|
|||
|
|
curCfgId = v.id
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
local moneyType , moneyCount = skynet.server.gameConfig:GetBuyMoney( player , "Scheme" , curCfgId )
|
|||
|
|
local eventId = pb.enum("EnumMoneyChangeEventID","EventID_31")
|
|||
|
|
if player:MoneyChange( moneyType , -moneyCount , eventId) then
|
|||
|
|
v.status = self.SchemeStatus_AlreadyBuy
|
|||
|
|
--找到该房间的方案ID
|
|||
|
|
data.schemeId = schemeId
|
|||
|
|
--当前房子下所有方案信息
|
|||
|
|
data.schemeInfo = self:GetAllSchemeInfo( player , houseId )
|
|||
|
|
skynet.server.npcTask:Modify( player , 75 , 1 )
|
|||
|
|
skynet.server.taskListEvent:Modify( player , 75 , 1 )
|
|||
|
|
log.debug(string.format("玩家 %d 购买方案成功 房间ID %d 方案ID %d" , player.basicInfo.userID , houseId , schemeId ))
|
|||
|
|
else
|
|||
|
|
log.warning(string.format("玩家 %d 购买方案失败 货币不足 房间ID %d 方案ID %d" , player.basicInfo.userID , houseId , schemeId ))
|
|||
|
|
end
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
self:UpdateDataToRedis( player , houseId )
|
|||
|
|
|
|||
|
|
if not isExist then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HouseBuyScheme")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHouseBuyScheme", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--切换方案
|
|||
|
|
function House:SwitchScheme( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHouseSwitchScheme", c2sData.data ))
|
|||
|
|
local schemeId = c2sData.data.schemeId
|
|||
|
|
local data = {}
|
|||
|
|
local houseId = player.gameData.curHouseID
|
|||
|
|
local houseInfo = player.gameData.house[ houseId ]
|
|||
|
|
if not schemeId then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|||
|
|
elseif not self:IsBuyScheme( houseInfo.scheme , schemeId ) then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.NoExistSchemeID
|
|||
|
|
else
|
|||
|
|
if houseInfo then
|
|||
|
|
for k, v in pairs( houseInfo.scheme ) do
|
|||
|
|
--如果是使用使用状态就改为购买状态
|
|||
|
|
if self.SchemeStatus_Use == v.status then
|
|||
|
|
v.status = self.SchemeStatus_AlreadyBuy
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--找到对应的方案ID和已经购买的方案
|
|||
|
|
if schemeId == v.id and self.SchemeStatus_AlreadyBuy == v.status then
|
|||
|
|
local srcSchemeId = player.gameData.house[ houseId ].curSchemeId
|
|||
|
|
player.gameData.house[ houseId ].curSchemeId = schemeId
|
|||
|
|
v.status = self.SchemeStatus_Use
|
|||
|
|
skynet.server.flowerpot:CheckExistFlowerpot( player )
|
|||
|
|
--找到该房间的方案ID
|
|||
|
|
data.schemeId = schemeId
|
|||
|
|
--当前房子下所有方案信息
|
|||
|
|
data.schemeInfo = self:GetAllSchemeInfo( player , houseId )
|
|||
|
|
--当前房子和当前方案下的家具信息
|
|||
|
|
data.furnitureInfo = self:GetCurSchemeFurniture( player , houseId , schemeId )
|
|||
|
|
data.decorateInfo = self:GetCurSchemeDecorate( player , houseId , schemeId )
|
|||
|
|
log.debug(string.format("玩家 %d 切换方案成功 房间ID %d 方案ID %d" , player.basicInfo.userID , houseId , schemeId ))
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
self:UpdateDataToRedis( player , houseId )
|
|||
|
|
else
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HouseSwitchScheme")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHouseSwitchScheme", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--修改方案名称
|
|||
|
|
function House:SchemeName( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHouseSchemeName", c2sData.data ))
|
|||
|
|
local schemeId = c2sData.data.schemeId
|
|||
|
|
local name = c2sData.data.name
|
|||
|
|
local data = {}
|
|||
|
|
if not schemeId or not name or #name > 21 then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|||
|
|
elseif skynet.server.common:IsExistSpecialChar( name ) then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.ExistSpecialChar
|
|||
|
|
elseif skynet.server.common:IsMaskWords( name ) then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.ExistMaskWords
|
|||
|
|
else
|
|||
|
|
local isExist = false
|
|||
|
|
local houseId = player.gameData.curHouseID
|
|||
|
|
local houseInfo = player.gameData.house[ houseId ]
|
|||
|
|
if houseInfo then
|
|||
|
|
for k, v in pairs( houseInfo.scheme ) do
|
|||
|
|
--找到对应的方案ID和已经购买的方案
|
|||
|
|
if schemeId == v.id and (self.SchemeStatus_AlreadyBuy == v.status or self.SchemeStatus_Use == v.status) then
|
|||
|
|
data.schemeId = schemeId
|
|||
|
|
data.name = name
|
|||
|
|
v.name = name
|
|||
|
|
isExist = true
|
|||
|
|
log.debug(string.format("玩家 %d 房子 修改方案名称 方案ID %d 修改方案名称 %s" , player.basicInfo.userID , schemeId, name))
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.NoExistHouse
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
if not isExist then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.NoExistSchemeID
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HouseSchemeName")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHouseSchemeName", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--房屋摆放家具
|
|||
|
|
function House:PutFurniture( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHousePutFurniture", c2sData.data ))
|
|||
|
|
local houseId = player.gameData.curHouseID
|
|||
|
|
local funitureOp = c2sData.data.funitureOp --操作家具信息
|
|||
|
|
local data = {}
|
|||
|
|
data.houseId = houseId
|
|||
|
|
data.funitureOp = {}
|
|||
|
|
local isSuc = nil
|
|||
|
|
for k, v in pairs( funitureOp ) do
|
|||
|
|
isSuc = false
|
|||
|
|
log.debug(string.format("玩家 %d 房屋摆放家具 操作类型 %d" , player.basicInfo.userID , v.opType))
|
|||
|
|
if self.OPType_House == v.opType and self:AddFurnitureToHouse( player , houseId , v.furnitureInfo ) then --新增家具到房间
|
|||
|
|
isSuc = true
|
|||
|
|
elseif self.OPType_Bag == v.opType and self:RemoveFurnitureFromHouse( player , houseId , v.furnitureInfo ) then --从房间中移出家具
|
|||
|
|
isSuc = true
|
|||
|
|
elseif self.OPType_Move == v.opType and v.lastPos and self:MoveFurnitureFromHouse( player , houseId , v.furnitureInfo , v.lastPos ) then --移动家具
|
|||
|
|
isSuc = true
|
|||
|
|
elseif self.OPType_Operate == v.opType and self:OperateFurnitureFromHouse( player , houseId , v.furnitureInfo ) then --家具原地操作
|
|||
|
|
isSuc = true
|
|||
|
|
end
|
|||
|
|
if isSuc then
|
|||
|
|
table.insert( data.funitureOp , v )
|
|||
|
|
else
|
|||
|
|
log.warning(string.format("玩家 %d 装修失败家具信息 操作类型 %d 家具类型 %d 家具ID %d " , player.basicInfo.userID , v.opType , v.furnitureInfo.type , v.furnitureInfo.id ))
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
self:UpdateDataToRedis( player , houseId )
|
|||
|
|
player:ResetAllUnUsedGoods()
|
|||
|
|
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HousePutFurniture")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHousePutFurniture", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--添加装修
|
|||
|
|
function House:Decorate( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHouseDecorate", c2sData.data ))
|
|||
|
|
local houseId = c2sData.data.houseId
|
|||
|
|
local schemeId = c2sData.data.schemeId
|
|||
|
|
local decorateInfo = c2sData.data.decorateInfo --装修信息
|
|||
|
|
|
|||
|
|
local data = {}
|
|||
|
|
if not houseId or not schemeId or not decorateInfo then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|||
|
|
else
|
|||
|
|
data.houseId = houseId
|
|||
|
|
data.decorateInfo = {}
|
|||
|
|
local cfgCurHouse = skynet.server.gameConfig:GetPlayerCurCfg( player , "House" , houseId )
|
|||
|
|
if not cfgCurHouse then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.NoExistHouse
|
|||
|
|
else
|
|||
|
|
local isSuc = false
|
|||
|
|
--装修信息
|
|||
|
|
for k, v in pairs( decorateInfo ) do
|
|||
|
|
isSuc = self:AddDecorate( player , v , houseId , schemeId , cfgCurHouse["function"] )
|
|||
|
|
if isSuc then
|
|||
|
|
table.insert( data.decorateInfo , v )
|
|||
|
|
else
|
|||
|
|
log.warning(string.format("玩家 %d 装修失败装修信息 装修ID %d " , player.basicInfo.userID , v.decoId ))
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
self:UpdateDataToRedis( player , houseId )
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HouseDecorate")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHouseDecorate", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--删除装修
|
|||
|
|
function House:RemoveHouseDecorate( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SRemoveHouseDecorate", c2sData.data ))
|
|||
|
|
local houseId = player.gameData.curHouseID
|
|||
|
|
local decorateInfo = c2sData.data.decorateInfo --装修信息
|
|||
|
|
local data = {}
|
|||
|
|
data.houseId = houseId
|
|||
|
|
data.decorateInfo = {}
|
|||
|
|
|
|||
|
|
local isSuc = false
|
|||
|
|
--装修信息
|
|||
|
|
isSuc = self:DeleteDecorate( player , decorateInfo )
|
|||
|
|
if isSuc then
|
|||
|
|
table.insert( data.decorateInfo , decorateInfo )
|
|||
|
|
else
|
|||
|
|
log.warning(string.format("玩家 %d 删除装修失败装修信息 装修ID %d " , player.basicInfo.userID , decorateInfo.decoId ))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
self:UpdateDataToRedis( player , houseId )
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_RemoveHouseDecorate")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CRemoveHouseDecorate", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--解锁区域
|
|||
|
|
function House:UnlockArea( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHouseUnlockArea", c2sData.data ))
|
|||
|
|
local data = {}
|
|||
|
|
data.areaId = {}
|
|||
|
|
local houseId = player.gameData.curHouseID
|
|||
|
|
local areaId = c2sData.data.areaId --这里的areaId需要与客户端对一下,传过来是1开始没问题,传过来是0,就需要减一
|
|||
|
|
if not areaId or areaId <= 0 then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|||
|
|
else
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.AlreadyUnlock
|
|||
|
|
local cfgOneHouse = skynet.server.gameConfig:GetPlayerCurCfg( player , "House" , houseId)
|
|||
|
|
local eventId = pb.enum("EnumMoneyChangeEventID","EventID_32")
|
|||
|
|
for k, v in pairs( cfgOneHouse.unlockArearID ) do
|
|||
|
|
if v == areaId and not player.gameData.house[ houseId ].unlockAreaList[ areaId ] then --未解锁的区域才处理
|
|||
|
|
if player:MoneyChange( cfgOneHouse.currencyBuy , -cfgOneHouse.unlockAreaPrice[k] , eventId ) then
|
|||
|
|
player.gameData.house[ houseId ].unlockAreaList[ areaId ] = true
|
|||
|
|
s2cData.code = errorInfo.Suc
|
|||
|
|
if 3 == houseId and 1 == areaId then --1-卫浴间 2-厨房间
|
|||
|
|
player:AddExpForType( 6 , 7 )
|
|||
|
|
skynet.server.levelTask:Modify( player , 13 , 1 , 1 )
|
|||
|
|
skynet.server.taskListEvent:Modify( player , 13 , 1 )
|
|||
|
|
elseif 3 == houseId and 2 == areaId then
|
|||
|
|
player:AddExpForType( 6 , 8 )
|
|||
|
|
skynet.server.levelTask:Modify( player , 13 , 1 , 2 )
|
|||
|
|
skynet.server.taskListEvent:Modify( player , 13 , 1 )
|
|||
|
|
elseif 5 == houseId and 3 == areaId then --复式小屋二层
|
|||
|
|
player:AddExpForType( 6 , 10 )
|
|||
|
|
skynet.server.levelTask:Modify( player , 13 , 1 , 12 )
|
|||
|
|
skynet.server.taskListEvent:Modify( player , 13 , 1 )
|
|||
|
|
elseif 10 == houseId and 4 == areaId then --三层小楼二层空间
|
|||
|
|
player:AddExpForType( 6 , 16 )
|
|||
|
|
skynet.server.levelTask:Modify( player , 13 , 1 , 13 )
|
|||
|
|
skynet.server.taskListEvent:Modify( player , 13 , 1 )
|
|||
|
|
end
|
|||
|
|
log.debug(string.format("玩家 %d 解锁区域成功 房间ID %d 区域ID %d" , player.basicInfo.userID , houseId , areaId ))
|
|||
|
|
else
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.NoEnoughMoney
|
|||
|
|
end
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
self:UpdateDataToRedis( player , houseId )
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--发送已经解锁的区域
|
|||
|
|
for areaId, v in pairs( player.gameData.house[ houseId ].unlockAreaList ) do
|
|||
|
|
if true == v then
|
|||
|
|
table.insert( data.areaId , areaId )
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HouseUnlockArea")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHouseUnlockArea", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--庭院在主页展示
|
|||
|
|
function House:HouseGardenShow( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHouseGardenShow", c2sData.data ))
|
|||
|
|
local data = {}
|
|||
|
|
if not player:GetSwitch( dataType.SwitchType_GainGarden ) then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.NoUnlockGarden
|
|||
|
|
else
|
|||
|
|
local isShow = c2sData.data.isShow
|
|||
|
|
if true == isShow then
|
|||
|
|
player:SetSwitch( dataType.SwitchType_ShowGarden , true )
|
|||
|
|
--player.gameData.lastCurHouseID = player.gameData.curHouseID
|
|||
|
|
--player.gameData.curHouseID = 11
|
|||
|
|
else
|
|||
|
|
player:SetSwitch( dataType.SwitchType_ShowGarden , false )
|
|||
|
|
--player.gameData.curHouseID = player.gameData.lastCurHouseID
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
data.isShow = isShow
|
|||
|
|
end
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HouseGardenShow")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHouseGardenShow", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--新增家具到房间
|
|||
|
|
function House:AddFurnitureToHouse( player , houseId , furnitureInfo )
|
|||
|
|
local type = furnitureInfo.type
|
|||
|
|
local id = furnitureInfo.id
|
|||
|
|
local isExistFlowerpot = false
|
|||
|
|
for k, v in pairs( player.gameData.bag ) do
|
|||
|
|
if type == v.type and id == v.id then
|
|||
|
|
--该家具在当前房间的数量要小于背包的数量
|
|||
|
|
local count = self:GetCurFurnitureCount( player , type , id )
|
|||
|
|
if count < v.count then
|
|||
|
|
--放到房间中
|
|||
|
|
if self:AddFurniture( player , furnitureInfo , count ) then
|
|||
|
|
isExistFlowerpot = true
|
|||
|
|
log.debug(string.format("玩家 %d 增加家具到房间成功 房间ID %d 家具类型 %d 家具ID %d" , player.basicInfo.userID , houseId , type , v.id ))
|
|||
|
|
return true
|
|||
|
|
else
|
|||
|
|
log.warning(string.format("玩家 %d 增加家具到房间失败 房间ID %d 家具类型 %d 家具ID %d" , player.basicInfo.userID , houseId , type , v.id ))
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--从房间中移出家具
|
|||
|
|
function House:RemoveFurnitureFromHouse( player , houseId , furnitureInfo )
|
|||
|
|
local id = furnitureInfo.id
|
|||
|
|
local type = furnitureInfo.type
|
|||
|
|
local nowPos = furnitureInfo.nowPos
|
|||
|
|
local schemeId = player.gameData.house[ houseId ].curSchemeId
|
|||
|
|
if dataType.GoodsType_Flowerpot == type then --花盆移除
|
|||
|
|
return skynet.server.flowerpot:PutBag( player , furnitureInfo )
|
|||
|
|
elseif dataType.GoodsType_Furniture == type then --家具的移除
|
|||
|
|
for k1, v1 in pairs( player.gameData.house[ houseId ].scheme ) do
|
|||
|
|
--找到对应的方案
|
|||
|
|
if schemeId == v1.id then
|
|||
|
|
--该方案下的家具
|
|||
|
|
for k2, v2 in pairs( v1.furniture ) do
|
|||
|
|
if type == v2.type and id == v2.id and skynet.server.common:Distance( nowPos.x , nowPos.y , v2.nowPos.x , v2.nowPos.y) <= 0.1 then
|
|||
|
|
table.remove( v1.furniture , k2 )
|
|||
|
|
log.debug(string.format("玩家 %d 家具从房间中移出成功 房间ID %d 家具类型 %d 家具ID %d" , player.basicInfo.userID , houseId , type ,v2.id ))
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
log.info("在房间中移出家具失败",skynet.server.common:TableToString(furnitureInfo) )
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--在房间中移动家具
|
|||
|
|
function House:MoveFurnitureFromHouse( player , houseId , furnitureInfo , lastPos )
|
|||
|
|
local type = furnitureInfo.type
|
|||
|
|
local id = furnitureInfo.id
|
|||
|
|
local targetPos = furnitureInfo.nowPos --目标位置
|
|||
|
|
local schemeId = player.gameData.house[ houseId ].curSchemeId
|
|||
|
|
local curScheme = self:GetCurScheme( player )
|
|||
|
|
|
|||
|
|
--该方案下的家具
|
|||
|
|
if dataType.GoodsType_Flowerpot == type then
|
|||
|
|
return skynet.server.flowerpot:UpdateFlowerpotPos( player , houseId , schemeId , id , targetPos.x , targetPos.y , furnitureInfo.isPutInFurniture , furnitureInfo.rotateType )
|
|||
|
|
elseif dataType.GoodsType_Furniture == type then
|
|||
|
|
for k, v in pairs( curScheme.furniture ) do
|
|||
|
|
local srcPosDistance = skynet.server.common:Distance( lastPos.x , lastPos.y , v.nowPos.x , v.nowPos.y) --原位置距离
|
|||
|
|
local dstPosDistance = skynet.server.common:Distance( targetPos.x , targetPos.y , lastPos.x , lastPos.y ) --目标位置距离
|
|||
|
|
if type == v.type and id == v.id and (srcPosDistance > 0.1 or dstPosDistance < 0 ) then
|
|||
|
|
log.info("在房间中移动家具失败" , lastPos.x , lastPos.y , v.nowPos.x , v.nowPos.y , srcPosDistance , targetPos.x , targetPos.y , v.nowPos.x , v.nowPos.y , dstPosDistance)
|
|||
|
|
end
|
|||
|
|
if type == v.type and id == v.id and srcPosDistance <= 0.1 and dstPosDistance >= 0 then
|
|||
|
|
v.nowPos = furnitureInfo.nowPos
|
|||
|
|
v.rotateType = furnitureInfo.rotateType
|
|||
|
|
v.isPutInFurniture = furnitureInfo.isPutInFurniture
|
|||
|
|
v.parentFurId = furnitureInfo.parentFurId
|
|||
|
|
log.debug(string.format("玩家 %d 家具从房间中移动成功 房间ID %d 家具类型 %d 家具ID %d" , player.basicInfo.userID , houseId , type ,v.id ))
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
log.info("在房间中移动家具失败")
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--家具原地操作
|
|||
|
|
function House:OperateFurnitureFromHouse( player , houseId , furnitureInfo )
|
|||
|
|
local type = furnitureInfo.type
|
|||
|
|
local id = furnitureInfo.id
|
|||
|
|
local nowPos = furnitureInfo.nowPos
|
|||
|
|
local schemeId = player.gameData.house[ houseId ].curSchemeId
|
|||
|
|
|
|||
|
|
for k1, v1 in pairs( player.gameData.house[ houseId ].scheme ) do
|
|||
|
|
--找到对应的方案
|
|||
|
|
if schemeId == v1.id then
|
|||
|
|
--该方案下的家具
|
|||
|
|
for k2, v2 in pairs( v1.furniture ) do
|
|||
|
|
if type == v2.type and id == v2.id and skynet.server.common:Distance( nowPos.x , nowPos.y , v2.nowPos.x , v2.nowPos.y) <= 0.1 then
|
|||
|
|
v2.nowPos = furnitureInfo.nowPos
|
|||
|
|
v2.rotateType = furnitureInfo.rotateType
|
|||
|
|
v2.isPutInFurniture = furnitureInfo.isPutInFurniture
|
|||
|
|
v2.clickType = furnitureInfo.clickType
|
|||
|
|
v2.parentFurId = furnitureInfo.parentFurId
|
|||
|
|
log.debug(string.format("玩家 %d 家具 原地操作成功 房间ID %d 家具类型 %d 家具ID %d" , player.basicInfo.userID , houseId , type ,v2.id ))
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取当前房间该家具数量
|
|||
|
|
function House:GetCurFurnitureCount( player , type , id )
|
|||
|
|
local houseId = player.gameData.curHouseID --当前房间ID
|
|||
|
|
local schemeId = player.gameData.house[ houseId ].curSchemeId
|
|||
|
|
local count = 0
|
|||
|
|
|
|||
|
|
skynet.server.flowerpot:GetAllFlowerpot( player )
|
|||
|
|
local furnitureInfo = self:GetCurSchemeFurniture( player , houseId , schemeId )
|
|||
|
|
for k, v in pairs( furnitureInfo ) do
|
|||
|
|
if type == v.type and id == v.id then
|
|||
|
|
count = count +1
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return count
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取当前家具在所有房间所有房间最大数量
|
|||
|
|
function House:GetCurFurnitureMaxCount( player , goodsType , goodsId )
|
|||
|
|
local maxCount = 0
|
|||
|
|
--遍历所有房间
|
|||
|
|
for k1, house in pairs( player.gameData.house ) do
|
|||
|
|
--遍历该房间下所有方案
|
|||
|
|
for k2, scheme in pairs( house.scheme ) do
|
|||
|
|
--当前家具在该方案下的数量
|
|||
|
|
local count = 0
|
|||
|
|
for k3, furniture in pairs( scheme.furniture ) do
|
|||
|
|
if goodsType == furniture.type and goodsId == furniture.id then
|
|||
|
|
count = count + 1
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--其它房间方案数量比该房间方案少,就赋值
|
|||
|
|
if maxCount < count then
|
|||
|
|
maxCount = count
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return maxCount
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--新增房间
|
|||
|
|
function House:Add( player , houseId , s2cData , isFree)
|
|||
|
|
isFree = isFree or false
|
|||
|
|
local curHouse = player.gameData.house[ houseId ]
|
|||
|
|
if self.Status_NoBuy ~= curHouse.status then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.AlreadyGet
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--只有没购买才会走这里
|
|||
|
|
local cfgHouse = skynet.server.gameConfig:GetPlayerAllCfg( player , "House")
|
|||
|
|
local eventId = pb.enum("EnumMoneyChangeEventID","EventID_33")
|
|||
|
|
for k1, v1 in pairs( cfgHouse ) do
|
|||
|
|
if houseId == v1.id and player.gameData.level >= v1.level then --找到对应的房间ID和等级足购
|
|||
|
|
local moneyType , moneyCount = skynet.server.gameConfig:GetBuyMoney( player , "House" , v1.id )
|
|||
|
|
if isFree or player:MoneyChange( moneyType , -moneyCount , eventId)then
|
|||
|
|
--修改为购买状态
|
|||
|
|
player.gameData.house[ houseId ].status = self.Status_AlreadyBuy
|
|||
|
|
|
|||
|
|
--初始化所有装修方案
|
|||
|
|
self:InitAllDecorateScheme( player , houseId , curHouse)
|
|||
|
|
|
|||
|
|
--赠送默认旧家具和摆放旧家具
|
|||
|
|
self:InitHouseFurniture( player , houseId )
|
|||
|
|
|
|||
|
|
--解锁一些户型功能
|
|||
|
|
for k2, v2 in pairs( v1["function"] ) do
|
|||
|
|
skynet.server.decorateShop:AddUnlockType( player ,v2 )
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--赠送一些基本装修
|
|||
|
|
for k2, v2 in pairs( v1.unlockDecorate ) do
|
|||
|
|
skynet.server.bag:AddGoods( player , dataType.GoodsType_Decorate , v2 , 1 )
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--赠送花园ID到背包里
|
|||
|
|
if 0 ~= v1.communityHouse then
|
|||
|
|
skynet.server.bag:AddGoods( player , dataType.GoodsType_Garden , v1.communityHouse , 1 )
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
if 1 == houseId then
|
|||
|
|
player:AddExpForType( 6 , 4 )
|
|||
|
|
--skynet.server.bag:AddGoods( player , dataType.GoodsType_Garden , 60 , 1)
|
|||
|
|
skynet.server.levelTask:Modify( player , 11 , 1 )
|
|||
|
|
skynet.server.taskListEvent:Modify( player , 11 , 1 )
|
|||
|
|
elseif 2 == houseId then
|
|||
|
|
player:AddExpForType( 6 , 5 )
|
|||
|
|
--skynet.server.bag:AddGoods( player , dataType.GoodsType_Garden , 63 , 1)
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_Door )
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_Bar )
|
|||
|
|
elseif 3 == houseId then
|
|||
|
|
player:AddExpForType( 6 , 6 )
|
|||
|
|
--skynet.server.bag:AddGoods( player , dataType.GoodsType_Garden , 59 , 1)
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_Door )
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_Bar )
|
|||
|
|
elseif 4 == houseId then
|
|||
|
|
player.gameData.house[ houseId ].status = self.Status_Live --新手默认房间是居住状态
|
|||
|
|
--skynet.server.bag:AddGoods( player , dataType.GoodsType_Garden , 62 , 1)
|
|||
|
|
elseif 5 == houseId then
|
|||
|
|
player:AddExpForType( 6 , 9 )
|
|||
|
|
--skynet.server.bag:AddGoods( player , dataType.GoodsType_Garden , 61 , 1)
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_Door )
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_Stair )
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_HandRail )
|
|||
|
|
elseif 6 == houseId then
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_Door )
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_Bar )
|
|||
|
|
elseif 7 == houseId then
|
|||
|
|
player:AddExpForType( 6 , 12 )
|
|||
|
|
--skynet.server.bag:AddGoods( player , dataType.GoodsType_Garden , 64 , 1)
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_Stair )
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_HandRail )
|
|||
|
|
elseif 8 == houseId then
|
|||
|
|
player:AddExpForType( 6 , 13 )
|
|||
|
|
--skynet.server.bag:AddGoods( player , dataType.GoodsType_Garden , 65 , 1)
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_Stair )
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_Door )
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_Bar )
|
|||
|
|
elseif 9 == houseId then
|
|||
|
|
player:AddExpForType( 6 , 14 )
|
|||
|
|
--skynet.server.bag:AddGoods( player , dataType.GoodsType_Garden , 66 , 1)
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_Stair )
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_HandRail )
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_Door )
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_Bar )
|
|||
|
|
elseif 10 == houseId then
|
|||
|
|
player:AddExpForType( 6 , 15 )
|
|||
|
|
--skynet.server.bag:AddGoods( player , dataType.GoodsType_Garden , 67 , 1)
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_Stair )
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_HandRail )
|
|||
|
|
--skynet.server.decorateShop:AddUnlockType( player , dataType.DecorateType_Door )
|
|||
|
|
elseif 11 == houseId then
|
|||
|
|
player:AddExpForType( 6 , 11 )
|
|||
|
|
skynet.server.bag:AddGoods( player , dataType.GoodsType_Garden , 56 , 1)
|
|||
|
|
skynet.server.bag:AddGoods( player , dataType.GoodsType_Garden , 57 , 1)
|
|||
|
|
elseif 12 == houseId then
|
|||
|
|
player:AddExpForType( 6 , 17 )
|
|||
|
|
--skynet.server.bag:AddGoods( player , dataType.GoodsType_Garden , 134 , 1)
|
|||
|
|
elseif 13 == houseId then
|
|||
|
|
player:AddExpForType( 6 , 19 ) --家置业新户型:宜居新房配置&实装 id6
|
|||
|
|
end
|
|||
|
|
return true
|
|||
|
|
else
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.NoEnoughMoney
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.NoExistHouse
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--是否存在房子
|
|||
|
|
function House:IsExistHouse( player , houseId )
|
|||
|
|
if player.gameData.house[ houseId ] then
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--是否购买房子
|
|||
|
|
function House:IsBuyHouse( player , houseId )
|
|||
|
|
if player.gameData.house[ houseId ] and self.Status_NoBuy ~= player.gameData.house[ houseId ].status and self.Status_Lock ~= player.gameData.house[ houseId ].status then
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--是否存在方案
|
|||
|
|
function House:IsExistScheme( player , houseId , schemeId )
|
|||
|
|
for k, v in pairs( player.gameData.house[ houseId ].scheme ) do
|
|||
|
|
if schemeId == v.id then
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--是否购买方案
|
|||
|
|
function House:IsBuyScheme( curScheme , schemeId)
|
|||
|
|
for k, v in pairs( curScheme ) do
|
|||
|
|
--找到对应的方案ID和已经购买的方案
|
|||
|
|
if schemeId == v.id and (self.SchemeStatus_AlreadyBuy == v.status or self.SchemeStatus_Use == v.status) then
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取方案信息
|
|||
|
|
function House:GetAllSchemeInfo( player , houseId )
|
|||
|
|
local data = {}
|
|||
|
|
for k, v in pairs( player.gameData.house[ houseId ].scheme ) do
|
|||
|
|
table.insert( data , { id = v.id , name = v.name , status = v.status })
|
|||
|
|
end
|
|||
|
|
return data
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取当前方案下的家具和花盆
|
|||
|
|
function House:GetCurSchemeFurniture( player , houseId , schemeId )
|
|||
|
|
local furnitureInfo = {}
|
|||
|
|
local curScheme = self:GetCurScheme( player )
|
|||
|
|
|
|||
|
|
--将家具和花盆打包在一起发给客户端
|
|||
|
|
for k, v in pairs( curScheme.furniture ) do
|
|||
|
|
table.insert( furnitureInfo , v )
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
for k, v in pairs( player.gameData.flowerpot ) do
|
|||
|
|
--从花盆列表中找到当前方案下的位置信息
|
|||
|
|
local flowerpotInfo = skynet.server.flowerpot:GetFlowerpot( player , v )
|
|||
|
|
if flowerpotInfo then
|
|||
|
|
table.insert( furnitureInfo , flowerpotInfo )
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return furnitureInfo
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取当前方案下的装修
|
|||
|
|
function House:GetCurSchemeDecorate( player , houseId , schemeId )
|
|||
|
|
local furnitureInfo = {}
|
|||
|
|
for k1, v1 in pairs( player.gameData.house[ houseId ].scheme ) do
|
|||
|
|
if schemeId == v1.id then
|
|||
|
|
return v1.decorate
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return nil
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取当前方案
|
|||
|
|
function House:GetCurScheme( player )
|
|||
|
|
local houseId = player.gameData.curHouseID
|
|||
|
|
local schemeId = player.gameData.house[ houseId ].curSchemeId
|
|||
|
|
for k, v in pairs( player.gameData.house[ houseId ].scheme ) do
|
|||
|
|
if schemeId == v.id then
|
|||
|
|
return v
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return nil
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取当前方案
|
|||
|
|
function House:GetCurSchemeForID( player , houseId , schemeId )
|
|||
|
|
for k, v in pairs( player.gameData.house[ houseId ].scheme ) do
|
|||
|
|
if schemeId == v.id then
|
|||
|
|
return v
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return nil
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取当前方案下的家具
|
|||
|
|
function House:AddFurniture( player , furnitureInfo , count )
|
|||
|
|
if dataType.GoodsType_Flowerpot == furnitureInfo.type then --花盆
|
|||
|
|
skynet.server.flowerpot:PutHouse( player , furnitureInfo.id , furnitureInfo )
|
|||
|
|
return true
|
|||
|
|
elseif dataType.GoodsType_Furniture == furnitureInfo.type then --家具
|
|||
|
|
local cfgGoods = skynet.server.gameConfig:GetPlayerCurCfg( player , "Furniture", furnitureInfo.id )
|
|||
|
|
if skynet.server.shop.BuyShopType_DoubleSpace == cfgGoods.shopType then
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
--找到当前的方案ID
|
|||
|
|
local curScheme = self:GetCurScheme( player )
|
|||
|
|
table.insert( curScheme.furniture , self:InitFurniture( furnitureInfo ))
|
|||
|
|
--修改任务
|
|||
|
|
if skynet.server.shop.FurnitureType_Cinnabar == cfgGoods.type then
|
|||
|
|
skynet.server.levelTask:Modify( player , 7 , 1 , nil , furnitureInfo.id)
|
|||
|
|
skynet.server.dailyTask:Modify( player , 7 , 1 , furnitureInfo.id)
|
|||
|
|
skynet.server.npcTask:Modify( player , 7 , 1 )
|
|||
|
|
skynet.server.taskListEvent:Modify( player , 7 , 1)
|
|||
|
|
else
|
|||
|
|
skynet.server.levelTask:Modify( player , 6 , 1 , nil , furnitureInfo.id)
|
|||
|
|
skynet.server.dailyTask:Modify( player , 6 , 1 , furnitureInfo.id)
|
|||
|
|
skynet.server.npcTask:Modify( player , 6 , 1 )
|
|||
|
|
skynet.server.taskListEvent:Modify( player , 6 , 1)
|
|||
|
|
local houseId = player.gameData.curHouseID
|
|||
|
|
if 2 == houseId then
|
|||
|
|
skynet.server.npcTask:Modify( player , 6 , 1 )
|
|||
|
|
skynet.server.taskListEvent:Modify( player , 6 , 1 )
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--新增装修到房间
|
|||
|
|
function House:AddDecorate( player , decorateInfo , houseId , schemeId , houseFunc )
|
|||
|
|
local isSuc = false
|
|||
|
|
|
|||
|
|
--先检查玩家是否有该商品
|
|||
|
|
if not player:IsBuyGoods( dataType.GoodsType_Decorate , decorateInfo.decoId ) then
|
|||
|
|
return false
|
|||
|
|
else
|
|||
|
|
--更新装修任务
|
|||
|
|
local cfgGoods = skynet.server.gameConfig:GetPlayerCurCfg( player , "Decoration" , decorateInfo.decoId )
|
|||
|
|
if skynet.server.shop.BuyShopType_DoubleSpace == cfgGoods.shopType then
|
|||
|
|
return false
|
|||
|
|
else
|
|||
|
|
skynet.server.levelTask:Modify( player , 8 , 1 )
|
|||
|
|
skynet.server.npcTask:Modify( player , 8 , 1 )
|
|||
|
|
skynet.server.dailyTask:Modify( player , 8 , 1)
|
|||
|
|
skynet.server.taskListEvent:Modify( player , 8 , 1)
|
|||
|
|
if dataType.DecorateType_Door == cfgGoods.type then
|
|||
|
|
skynet.server.levelTask:Modify( player , 85 , 1 )
|
|||
|
|
skynet.server.taskListEvent:Modify( player , 85 , 1 )
|
|||
|
|
elseif dataType.DecorateType_Bar == cfgGoods.type then
|
|||
|
|
skynet.server.levelTask:Modify( player , 86 , 1 )
|
|||
|
|
skynet.server.taskListEvent:Modify( player , 86 , 1 )
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取当前房间当前方案
|
|||
|
|
local schemeInfo = self:GetCurSchemeForID( player , houseId , schemeId )
|
|||
|
|
if schemeInfo then
|
|||
|
|
local isExist = false
|
|||
|
|
for k, v in pairs( schemeInfo.decorate ) do
|
|||
|
|
if v.facilityType == cfgGoods.type and decorateInfo.facilityId == v.facilityId then
|
|||
|
|
v.decoId = decorateInfo.decoId
|
|||
|
|
isExist = true
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--不存在并且该户型有当前设施就新增进来
|
|||
|
|
if not isExist and skynet.server.common:IsExist( cfgGoods.type , houseFunc ) then
|
|||
|
|
decorateInfo.facilityType = cfgGoods.type
|
|||
|
|
table.insert( schemeInfo.decorate , decorateInfo )
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
log.debug(string.format("玩家 %d 家具 装修 房间ID %d 设施类型 %d 设施ID %d 装修ID %d" , player.basicInfo.userID , houseId , cfgGoods.type , decorateInfo.facilityId , decorateInfo.decoId))
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--删除装修到房间
|
|||
|
|
function House:DeleteDecorate( player , decorateInfo )
|
|||
|
|
local houseId = player.gameData.curHouseID --当前房间ID
|
|||
|
|
local schemeId = player.gameData.house[ houseId ].curSchemeId
|
|||
|
|
local isSuc = false
|
|||
|
|
|
|||
|
|
--先检查玩家是否有该商品
|
|||
|
|
if not player:IsBuyGoods( dataType.GoodsType_Decorate , decorateInfo.decoId ) then
|
|||
|
|
return false
|
|||
|
|
else
|
|||
|
|
--更新装修任务
|
|||
|
|
local cfgGoods = skynet.server.gameConfig:GetPlayerCurCfg( player , "Decoration" , decorateInfo.decoId )
|
|||
|
|
if skynet.server.shop.BuyShopType_DoubleSpace == cfgGoods.shopType then
|
|||
|
|
return false
|
|||
|
|
else
|
|||
|
|
--获取当前房间当前方案
|
|||
|
|
local schemeInfo = self:GetCurScheme( player )
|
|||
|
|
if schemeInfo then
|
|||
|
|
for k, v in pairs( schemeInfo.decorate ) do
|
|||
|
|
if v.facilityType == cfgGoods.type and decorateInfo.facilityId == v.facilityId then
|
|||
|
|
--schemeInfo.decorate[ k ] = nil
|
|||
|
|
table.remove( schemeInfo.decorate , k )
|
|||
|
|
log.debug(string.format("玩家 %d 家具 删除装修 房间ID %d 设施类型 %d 设施ID %d 装修ID %d" , player.basicInfo.userID , houseId , cfgGoods.type , decorateInfo.facilityId , decorateInfo.decoId))
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--初始化家具
|
|||
|
|
function House:InitFurniture( furnitureInfo )
|
|||
|
|
local data = {}
|
|||
|
|
data.type = furnitureInfo.type
|
|||
|
|
data.id = furnitureInfo.id
|
|||
|
|
data.nowPos = furnitureInfo.nowPos
|
|||
|
|
data.rotateType = furnitureInfo.rotateType
|
|||
|
|
data.isPutInFurniture = furnitureInfo.isPutInFurniture
|
|||
|
|
data.clickType = furnitureInfo.clickType
|
|||
|
|
data.parentFurId = furnitureInfo.parentFurId
|
|||
|
|
return data
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取拥有房子的数量
|
|||
|
|
function House:GetOwnCount( player )
|
|||
|
|
local count = 0
|
|||
|
|
for k, v in pairs(player.gameData.house ) do
|
|||
|
|
if self.Status_AlreadyBuy == v.status or self.Status_Live == v.status then
|
|||
|
|
count = count + 1
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return count
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--从当前房间移出
|
|||
|
|
function House:RemoveFurniture( player , goodsType , goodsId )
|
|||
|
|
--获取当前房间当前方案
|
|||
|
|
local schemeInfo = self:GetCurScheme( player )
|
|||
|
|
for k, v in pairs( schemeInfo.furniture ) do
|
|||
|
|
if goodsType == v.type and goodsId == v.id then
|
|||
|
|
table.remove( schemeInfo.furniture , k )
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--初始化所有装修方案
|
|||
|
|
function House:InitAllDecorateScheme( player , houseId , curHouse )
|
|||
|
|
--初始化方案数据
|
|||
|
|
local cfgScheme = skynet.server.gameConfig:GetPlayerAllCfg( player , "Scheme")
|
|||
|
|
for k, v in pairs( cfgScheme ) do
|
|||
|
|
local schemeId = v.combineID
|
|||
|
|
if houseId == v.value and curHouse and not self:IsExistScheme( player , houseId , schemeId ) then
|
|||
|
|
local status = self.SchemeStatus_NoBuy --未购买
|
|||
|
|
local moneyType , moneyCount = skynet.server.gameConfig:GetBuyMoney( player , "Scheme" , v.id )
|
|||
|
|
if dataType.MoneyType_No == moneyType and 0 == moneyCount then
|
|||
|
|
status = self.SchemeStatus_Use
|
|||
|
|
curHouse.curSchemeId = schemeId
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--将方案信息加载进去
|
|||
|
|
local decorate = self:InitDecorate( player , houseId )
|
|||
|
|
table.insert( curHouse.scheme , { id = schemeId , name = v.defaultName , status = status , furniture = {} , decorate = decorate })
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--初始化装修
|
|||
|
|
function House:InitDecorate( player , houseId )
|
|||
|
|
local goodsType = dataType.GoodsType_Decorate
|
|||
|
|
local curHouseData = skynet.server.gameConfig:GetInitHouseData( houseId )
|
|||
|
|
if not curHouseData or not curHouseData.allDecoration then
|
|||
|
|
log.debug(string.format("玩家 %d 未找到房间装修配置 房间ID %d " , player.userId , houseId ))
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
local decorate = {}
|
|||
|
|
|
|||
|
|
--初始化装修数据
|
|||
|
|
local function InitDecoData()
|
|||
|
|
for k, v in pairs( curHouseData.allDecoration ) do
|
|||
|
|
local decoId = v.decoID
|
|||
|
|
local id = v.id
|
|||
|
|
local cfgOneDecoration = skynet.server.gameConfig:GetPlayerCurCfg( player , "Decoration" , decoId )
|
|||
|
|
table.insert( decorate , { facilityType = cfgOneDecoration.type , facilityId = id , decoId = decoId })
|
|||
|
|
|
|||
|
|
--直接加到背包里,但不增加经验
|
|||
|
|
if not player:IsBuyGoods( dataType.GoodsType_Decorate , decoId ) then
|
|||
|
|
skynet.server.bag:AddGoodsNoExp( player , dataType.GoodsType_Decorate , decoId , 1 )
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
if 1 == houseId then
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 1 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 2 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 1 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Eave , facilityId = 0 , decoId = 210 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_OutDeco , facilityId = 0 , decoId = 211 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_MailBox , facilityId = 0 , decoId = 212 })
|
|||
|
|
elseif 2 == houseId then
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 1 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 2 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 1 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 2 , decoId = 25 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Door , facilityId = 1 , decoId = 26 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Bar , facilityId = 1 , decoId = 27 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Eave , facilityId = 0 , decoId = 210 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_OutDeco , facilityId = 0 , decoId = 211 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_MailBox , facilityId = 0 , decoId = 212 })
|
|||
|
|
elseif 3 == houseId then
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 1 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 2 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 3 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 4 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 5 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 1 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 2 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 3 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 4 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Bar , facilityId = 1 , decoId = 27 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Door , facilityId = 1 , decoId = 26 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Door , facilityId = 2 , decoId = 26 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Eave , facilityId = 0 , decoId = 210 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_OutDeco , facilityId = 0 , decoId = 211 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_MailBox , facilityId = 0 , decoId = 212 })
|
|||
|
|
elseif 4 == houseId then
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 1 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 2 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 1 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Eave , facilityId = 0 , decoId = 210 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_OutDeco , facilityId = 0 , decoId = 211 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_MailBox , facilityId = 0 , decoId = 212 })
|
|||
|
|
elseif 5 == houseId then
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 1 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 2 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 3 , decoId = 25 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 4 , decoId = 25 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 5 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 1 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 2 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 3 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 4 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 5 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Door , facilityId = 1 , decoId = 26 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Door , facilityId = 2 , decoId = 26 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Stair , facilityId = 1 , decoId = 163 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_HandRail , facilityId = 1 , decoId = 164 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Eave , facilityId = 0 , decoId = 210 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_OutDeco , facilityId = 0 , decoId = 211 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_MailBox , facilityId = 0 , decoId = 212 })
|
|||
|
|
elseif 7 == houseId then
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 1 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 2 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 3 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 4 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 1 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 2 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 3 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 4 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 5 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Stair , facilityId = 1 , decoId = 163 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_HandRail , facilityId = 1 , decoId = 164 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Eave , facilityId = 0 , decoId = 246 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_OutDeco , facilityId = 0 , decoId = 250 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_MailBox , facilityId = 0 , decoId = 248 })
|
|||
|
|
elseif 8 == houseId then
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 1 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 2 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 3 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 4 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 1 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 2 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 3 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 4 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 5 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 6 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 7 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Stair , facilityId = 1 , decoId = 163 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Door , facilityId = 1 , decoId = 26 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Door , facilityId = 2 , decoId = 26 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Bar , facilityId = 1 , decoId = 27 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Eave , facilityId = 0 , decoId = 245 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_OutDeco , facilityId = 0 , decoId = 251 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_MailBox , facilityId = 0 , decoId = 247 })
|
|||
|
|
elseif 9 == houseId then
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 1 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 2 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 3 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 4 , decoId = 25 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 1 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 2 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 3 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 4 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 5 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Stair , facilityId = 1 , decoId = 163 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Stair , facilityId = 2 , decoId = 163 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_HandRail , facilityId = 1 , decoId = 164 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Door , facilityId = 1 , decoId = 26 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Bar , facilityId = 1 , decoId = 27 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Eave , facilityId = 0 , decoId = 244 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_OutDeco , facilityId = 0 , decoId = 252 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_MailBox , facilityId = 0 , decoId = 249 })
|
|||
|
|
elseif 10 == houseId then
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 1 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 2 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 3 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 4 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 1 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 2 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 3 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 4 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 5 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 6 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 7 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Stair , facilityId = 1 , decoId = 163 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Stair , facilityId = 2 , decoId = 163 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_HandRail , facilityId = 1 , decoId = 164 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_HandRail , facilityId = 2 , decoId = 164 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Door , facilityId = 1 , decoId = 26 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Door , facilityId = 2 , decoId = 26 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Eave , facilityId = 0 , decoId = 210 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_OutDeco , facilityId = 0 , decoId = 211 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_MailBox , facilityId = 0 , decoId = 212 })
|
|||
|
|
elseif houseId >= 12 then --恋家置业新户型:宜居新房配置&实装 id7
|
|||
|
|
--待添加
|
|||
|
|
InitDecoData()
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--赠送装修到背包 12之前的从配置中读取装修数据
|
|||
|
|
if houseId < 12 then
|
|||
|
|
local cfgHouse = skynet.server.gameConfig:GetPlayerAllCfg( player , "House")
|
|||
|
|
for k1, v1 in pairs(cfgHouse) do
|
|||
|
|
if houseId == v1.id then
|
|||
|
|
for k2, v2 in pairs(v1.unlockDecorate) do
|
|||
|
|
if not player:IsBuyGoods( dataType.GoodsType_Decorate , v2 ) then
|
|||
|
|
skynet.server.bag:AddGoods( player , dataType.GoodsType_Decorate , v2 , 1 )
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
return decorate
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--是否解锁户型2和3
|
|||
|
|
function House:IsUnlockHouse( player , houseId )
|
|||
|
|
for k, v in pairs( player.gameData.house ) do
|
|||
|
|
if houseId == v.id and v.status > self.Status_Lock then
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取当前拥有的房子数量
|
|||
|
|
function House:GetHouseCount( player )
|
|||
|
|
local count = 0
|
|||
|
|
for k, v in pairs( player.gameData.house ) do
|
|||
|
|
if self.Status_Live == v.status or self.Status_AlreadyBuy == v.status then
|
|||
|
|
count = count + 1
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return count
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--更新数据到redis
|
|||
|
|
function House:UpdateDataToRedis( player , houseId )
|
|||
|
|
local myPartnerId = player.gameData.partner.id
|
|||
|
|
local redisKey = string.format( redisKeyUrl.GameServerHouseDetailHash , myPartnerId )
|
|||
|
|
if skynet.server.redis:exists( redisKey) then
|
|||
|
|
skynet.server.redis:hset( redisKey , "houseData_"..houseId ,
|
|||
|
|
json:encode( player.gameData.house[ houseId ]) ,
|
|||
|
|
"flowerpot" , json:encode( player.gameData.flowerpot) )
|
|||
|
|
skynet.server.redis:expire( redisKey , skynet.server.partner.HouseDetailMaxOutTime ) --设置过期时间为1小时
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--初始化房间家具
|
|||
|
|
function House:InitHouseFurniture( player , houseId )
|
|||
|
|
local schemeId = player.gameData.house[ houseId ].curSchemeId
|
|||
|
|
local curHouseData = skynet.server.gameConfig:GetInitHouseData( houseId )
|
|||
|
|
if not curHouseData then
|
|||
|
|
log.debug(string.format("玩家 %d 未找到房间配置 房间ID %d " , player.userId , houseId ))
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
local goodsType = dataType.GoodsType_Furniture
|
|||
|
|
local furnitureInfo = {}
|
|||
|
|
|
|||
|
|
--获取当前的方案
|
|||
|
|
local curScheme = nil
|
|||
|
|
for k, v in pairs( player.gameData.house[ houseId ].scheme ) do
|
|||
|
|
if schemeId == v.id then
|
|||
|
|
curScheme = v
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
if not curScheme then
|
|||
|
|
log.debug(string.format("玩家 %d 未找到方案配置 方案ID %d " , player.userId , schemeId ))
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
curScheme.furniture = {}
|
|||
|
|
for k, v in pairs( curHouseData.allPutFurniture ) do
|
|||
|
|
skynet.server.bag:AddGoodsNoExp( player , goodsType , v.furnitureInfoId , 1 )
|
|||
|
|
furnitureInfo =
|
|||
|
|
{
|
|||
|
|
type = goodsType ,
|
|||
|
|
id = v.furnitureInfoId ,
|
|||
|
|
nowPos = v.pos,
|
|||
|
|
rotateType = v.rotateType ,
|
|||
|
|
isPutInFurniture = v.isPutInFurniture ,
|
|||
|
|
clickType = v.clickType ,
|
|||
|
|
parentFurId = v.parentFurId
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
table.insert( curScheme.furniture , self:InitFurniture( furnitureInfo ))
|
|||
|
|
end
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
skynet.server.house = House
|
|||
|
|
return House
|