local skynet = require "skynet" local oo = require "Class" local log = require "Log" local pb = require "pb" local dataType = require "DataType" local errorInfo = require "ErrorInfo" local SuitIllustration = oo.class() function SuitIllustration:Init() end --图鉴展示 function SuitIllustration:Show( player , c2sData , s2cData ) c2sData.data = assert(pb.decode("C2SIllustrationShow", c2sData.data )) local data = {} s2cData.cmd = pb.enum("MsgType","CMD_S2C_IllustrationShow") s2cData.data = assert(pb.encode("S2CIllustrationShow", data)) end --新增植物图鉴 function SuitIllustration:Add( player , suitType , goodsType , goodsId ) if not player.gameData.suitIllustration[ suitType ] then player.gameData.suitIllustration[ suitType ] = {} player.gameData.suitIllustration[ suitType ].furniture = {} --家具 player.gameData.suitIllustration[ suitType ].decorate = {} --装修 end --player.gameData.suitIllustration --不存在就插入图鉴 if not self:IsExistGoods( player , suitType , goodsType , goodsId ) then if dataType.GoodsType_Furniture == goodsType then table.insert( player.gameData.suitIllustration[ suitType ].furniture , goodsId ) elseif dataType.GoodsType_Decorate == goodsType then table.insert( player.gameData.suitIllustration[ suitType ].decorate , goodsId ) end local data = {} data.type = IllustrationType data.item = { type = goodsType , id = goodsId } skynet.server.gameServer:SendMsgToUser( player.userId , "CMD_C2S_IllustrationUpdate" , data ) log.info(string.format("玩家 %d 图鉴 新增图鉴 图鉴类型 %d 商品类型 %d 商品ID %d" , player.userId , IllustrationType , goodsType , goodsId )) --检查是否完成图鉴,完成了就通知客户端 if not self:IsGainAward( player , IllustrationType , goodsId ) and self:IsAchieve( player , IllustrationType , goodsId ) then skynet.server.msgTips:Add( player , 18) end end end --是否存在图鉴商品 function SuitIllustration:IsExistGoods( player ,suitType , goodsType , goodsId ) local goodsInfo = {} if dataType.GoodsType_Furniture == goodsType then goodsInfo = player.gameData.suitIllustration[ suitType ].furniture elseif dataType.GoodsType_Decorate == goodsType then goodsInfo = player.gameData.suitIllustration[ suitType ].decorate end for k, v in pairs( goodsInfo ) do if goodsId == v then return true end end return false end skynet.server.suitIllustration = SuitIllustration return SuitIllustration