如下代码是是在某个类中的某个 api,项目中各处充斥着大量这种函数
function ChangeUserPropertiesResult:execute()
local processQueue = {}
local resultData = self.mData.resultData
local allAnimationData = {}
--dump(resultData, "resultData resultData", 10, 2)
if resultData.uaitems and next(resultData.uaitems) then
for _,item in pairs(resultData.uaitems) do
local aniResult = {}
local userid = item.userId or item.userid
if item.name == Player.DIRECTION then
SingletonShareData:getPlayerWithId(userid):updateDataBonusWithName(Player.DIRECTION,{count = item.count})
--
local bd = MapDataManager:getUserPosition(userid).branchDirection or -1
MapDataManager:saveUserPosition(bd,userid,"branchDirection")
local posData = MapDataManager:getUserPosition(userid)
-- local nextPaths = PathFinder:findPathFromToEnd(posData.nowPos, item.count, 1)
-- local nextPath = nextPaths[1]
local tilePath = posData.nowPos
-- AvatarWalker:setStandAction(userid, tilePath, nextPath)
AvatarWalker:setAvatarPosition(userid,tilePath)
elseif string.find(item.name,"c_") ~= nil then
local cardid = string.sub(item.name, 3, -1)
local action = ""
if item.count > 0 then
action = "add"
elseif item.count == 0 then
action = "clear"
else
action = "remove"
end
local itemType,itemName = unpack(string.split(item.name,"_"))
local cradsData = cc.exports.SingletonShareData:getPlayerWithId(userid):getDataBonusWithName(Player.CARDS)
local isHasBaoXianKa = false
if cradsData then
for k,v in pairs(cradsData) do
if tonumber(v) == 29 then
isHasBaoXianKa = true
break
end
end
end
local isEnterHospital = cc.exports.SingletonShareData:getPlayerWithId(userid):hasStatusWithName("hospital")
if (isEnterHospital == true and isHasBaoXianKa == true) and tonumber(itemName) == 29 and item.count < 0 then
local data = {}
data.cardId = tonumber(itemName)
data.playerId = userid
local dialog = require("app.process.CardUseController").new() --// 建议位置
dialog:setInputData(data)
if data.cardId then
table.insert(processQueue, dialog)
end
--行为记录
PlayerActionRecordHelper:pushRecordData({tips_name="tips_card_other",function_name="getCardContent",data={userId=userid,resultData={cardid=data.cardId}}})
EmotionResult:getInstance():pushEmotionData({userId = userid,action = EA_USE_CARD,cardId = E_CARD_INSURANCE})
EmotionResult:getInstance():execute()
end
aniResult = {userId = userid,action=action,itemName = cardid,itemType = "card"}
if item.count > 0 then
for k = 1,item.count do
cc.exports.SingletonShareData:getPlayerWithId(userid):updateDataBonusWithName(Player.CARDS,{itemName = cardid, action = action})
end
else
cc.exports.SingletonShareData:getPlayerWithId(userid):updateDataBonusWithName(Player.CARDS,{itemName = cardid, action = action})
end
else
cc.exports.SingletonShareData:getPlayerWithId(userid):updateDataBonusWithName(
item.name,{itemCount = item.count})
if item.count > 0 then
aniResult = {userId = userid,action="add",itemName = item.name,itemType = "points"}
end
end
allAnimationData[#allAnimationData + 1] = aniResult
end
end
local diplayCtrlName = self.mExtraData and self.mExtraData.displayCtrlClass --or "UserPropertiesDisplayResult"
if diplayCtrlName then
local ctrl = require("app.processResult.displayResult."..diplayCtrlName).new()
ctrl:setInputData(allAnimationData)
ctrl:setCallBack(handler(self,self.executeProcessComplete))
table.insert(processQueue, ctrl)
end
if next(processQueue) then
local processCtrl = require("app.process.ProcessQueue").new(processQueue,function()
self:executeProcessComplete()
end)
processCtrl:handlerQueue()
else
self:executeProcessComplete()
end
end
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.