[ create a new paste ] login | about

Link: http://codepad.org/UH9rKn4r    [ raw code | fork ]

Lua, pasted on Apr 7:
-- 狙いたいグッドコンディションがあれば他を買わずコイン節約
if priorityCondition1 ~= "" or priorityCondition2 ~= "" then

-- 既にグッドコンディションが付与されているかを判定
local hasCondition1 = false
local hasCondition2 = false
for i = 1, #g_status[STATUS.CONDITION] do
if priorityCondition1 ~= "" and g_status[STATUS.CONDITION][i].name == priorityCondition1 then
hasCondition1 = true
end
if priorityCondition2 ~= "" and g_status[STATUS.CONDITION][i].name == priorityCondition2 then
hasCondition2 = true
end
end

-- 購入リストに対象のアイテムがあればその名前を保持
local priorityItem1 = nil
local priorityItem2 = nil
for i = 1, #itemScoreTable do
if itemScoreTable[i].itemInfo.param == priorityCondition1
and (itemScoreTable[i].score == nil or itemScoreTable[i].score >= 100)
and not hasCondition1 then
priorityItem1 = itemScoreTable[i].itemInfo.name
end
if itemScoreTable[i].itemInfo.param == priorityCondition2
and (itemScoreTable[i].score == nil or itemScoreTable[i].score >= 100)
and not hasCondition2 then
priorityItem2 = itemScoreTable[i].itemInfo.name
end
end

-- 購入リストの対象アイテム以外のスコアを下げコイン節約
if (not hasCondition1 and priorityItem1 ~= nil) or
(not hasCondition2 and priorityItem2 ~= nil) then
for i = 1, #itemScoreTable do
if (priorityItem1 ~= nil and itemScoreTable[i].itemInfo.name ~= priorityItem1)
or (priorityItem2 ~= nil and itemScoreTable[i].itemInfo.name ~= priorityItem2) then
itemScoreTable[i].score = 0
end
end

-- 評価点があるものがあれば購入
for i = 1, #itemScoreTable do
if itemScoreTable[i].score ~= nil and itemScoreTable[i].score > 0 then
return itemScoreTable[i], true
end
end
end

end 


Create a new paste based on this one


Comments: