这应该是几年程序员可以写出的代码?

2018-01-29 09:14:12 +08:00
 huanyingch01

如下代码是是在某个类中的某个 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
9613 次点击
所在节点    程序员
87 条回复
MyDaLin
2018-01-29 09:16:29 +08:00
大家看我的网站,猜我是几年程序员?
http://www.sucaihuo.com/
aksoft
2018-01-29 09:19:24 +08:00
@MyDaLin 哈哈
jorneyr
2018-01-29 09:30:08 +08:00
有的一年当别人几年,有的几年当别人一年,因人而异,好奇的是写这个代码的人过一周后还能很快的看明白他写的是什么吗?接手的人能很快看明白写的是什么吗?
hubhub
2018-01-29 09:32:24 +08:00
这是什么语言
woscaizi
2018-01-29 09:36:23 +08:00
@MyDaLin 两年最多,php 程序员。
alen
2018-01-29 09:36:33 +08:00
这是 go 语法?
m939594960
2018-01-29 09:38:28 +08:00
@MyDaLin TP 写的,看这样子两年应该算多了
woscaizi
2018-01-29 09:40:02 +08:00
@hubhub swift 吧。其实还好,这是没有重构的代码吧。注释基本没有这点不爽。
MeteorCat
2018-01-29 09:41:00 +08:00
这写得啥? lua ? php ? java ?
frend94
2018-01-29 09:43:59 +08:00
这是 lua 吧
sheaned
2018-01-29 09:47:28 +08:00
这是 lua 吗?
Alexisused
2018-01-29 09:50:39 +08:00
内容没仔细看,首先写的挺整齐的
gemini767
2018-01-29 09:51:25 +08:00
@woscaizi Swift?什么时候 Swift 以 end 结尾了?
sumu
2018-01-29 09:54:35 +08:00
有注释,甭管几年,点个赞。有人写代码很随意:一两千行代码,0 注释这种事也是有的,N 层循环里面又有 N 个 if,也是有的,碰上这种操蛋的事,一旦接手,那就是踩雷,除了推翻彻底重构,根本没有办法
maltoze
2018-01-29 09:55:09 +08:00
看起来是 lua
v2410117
2018-01-29 09:55:43 +08:00
swift 肯定不是,lua 没接触过,php 有点像,但为啥没分号?求大神指点这是啥语言
lujiajing1126
2018-01-29 10:01:59 +08:00
Lua 吧😂是个手游?
gecco
2018-01-29 10:03:54 +08:00
语言都看不出来的人,围观吹吹水,就别乱说话带节奏啦。
torbrowserbridge
2018-01-29 10:03:55 +08:00
@v2410117 哪里看的像 php 的?因为你不熟悉 php ?
mentalidade
2018-01-29 10:05:11 +08:00
肯定是 lua 啊

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/426672

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX