Jump to content

Module:Item/Price: Difference between revisions

no edit summary
(Created page with "--★アーティファクト系の計算が合わない --★とりあえず local M = {} local localhost = nil--ローカル"true":"nil" local matdata = mw.loadData('Module:Item/Materials') local catdata = mw.loadData('Module:Item/Categories') function M.get_price(itemArgs,itemData) mw.log('--------') local itemData = itemData or {} local sell = itemArgs['sell'] or false--売り値のスイッチ local PriceType = itemArgs['PriceType'] or 'Default' local Cur...")
 
No edit summary
Line 1: Line 1:
--★アーティファクト系の計算が合わない
--★とりあえず
local M = {}
local M = {}
local localhost = nil--ローカル"true":"nil"
local localhost = nil--ローカル"true":"nil"
Line 7: Line 5:


function M.get_price(itemArgs,itemData)
function M.get_price(itemArgs,itemData)
  mw.log('--------')
  mw.log('--------')
  local itemData = itemData or {}
local itemData = itemData or {}
   local sell = itemArgs['sell'] or false--売り値のスイッチ
   local sell = itemArgs['sell'] or false--売り値のスイッチ
   local PriceType = itemArgs['PriceType'] or 'Default'
   local PriceType = itemArgs['PriceType'] or 'Default'
Line 23: Line 21:
   local rarityLv = itemArgs['rarityLv'] or itemData.quality or 0
   local rarityLv = itemArgs['rarityLv'] or itemData.quality or 0
   local qualityLv = itemArgs['qualityLv'] or 0--品質 おそらく接頭辞
   local qualityLv = itemArgs['qualityLv'] or 0--品質 おそらく接頭辞
  local charge = itemArgs['charge']--チャージ回数
   local matvalue = itemArgs['matvalue'] or matdata[itemData.defMat].value or 100
   local matvalue = itemArgs['matvalue'] or matdata[itemData.defMat].value or 100
   local cattag = itemArgs['cattag'] or catdata[itemData.category].tag or ''
   local cattag = itemArgs['cattag'] or catdata[itemData.category].tag or ''
   local value = itemData.value
   local value = itemData.value
  local price_value
   local isCopy = itemArgs['isCopy'] == 1 and true or false
   local isCopy = itemArgs['isCopy'] == 1 and true or false
   local IsReplica = itemArgs['Replica'] or false--レプリカ判定
   local IsReplica = itemArgs['Replica'] or false--レプリカ判定
   local IsUnique = itemArgs['Unique'] or rarityLv == 4 or false--ユニーク判定
   local IsUnique = itemArgs['Unique'] or rarityLv == 4 or false--ユニーク判定


  --★近距離武器が範囲に入るかちょっとわからない
local IsEquipmentOrRangedOrAmmoList = { ['sword'] = true, ['dagger'] = true, ['blunt'] = true, ['staff'] = true, ['axe'] = true, ['polearm'] = true, ['scythe'] = true, ['martial'] = true, ['shield'] = true, ['bow'] = true, ['crossbow'] = true, ['gun'] = true, ['cane'] = true, ['throw'] = true, ['head'] = true, ['torso'] = true, ['back'] = true, ['waist'] = true, ['arm'] = true, ['foot'] = true, ['ring'] = true, ['amulet'] = true, ['lightsource'] = true, ['ammo'] = true}
local IsEquipmentOrRangedOrAmmoList = { ['sword'] = true, ['dagger'] = true, ['blunt'] = true, ['staff'] = true, ['axe'] = true, ['polearm'] = true, ['scythe'] = true, ['martial'] = true, ['shield'] = true, ['bow'] = true, ['crossbow'] = true, ['gun'] = true, ['cane'] = true, ['throw'] = true, ['head'] = true, ['torso'] = true, ['back'] = true, ['waist'] = true, ['arm'] = true, ['foot'] = true, ['ring'] = true, ['amulet'] = true, ['lightsource'] = true, ['ammo'] = true}
   local IsEquipmentOrRangedOrAmmo = itemArgs['isEquipped'] or IsEquipmentOrRangedOrAmmoList[itemData.category] or false
   local IsEquipmentOrRangedOrAmmo = itemArgs['isEquipped'] or IsEquipmentOrRangedOrAmmoList[itemData.category] or false
local IsEquipmentOrRangedList = { ['sword'] = true, ['dagger'] = true, ['blunt'] = true, ['staff'] = true, ['axe'] = true, ['polearm'] = true, ['scythe'] = true, ['martial'] = true, ['shield'] = true, ['bow'] = true, ['crossbow'] = true, ['gun'] = true, ['cane'] = true, ['throw'] = true, ['head'] = true, ['torso'] = true, ['back'] = true, ['waist'] = true, ['arm'] = true, ['foot'] = true, ['ring'] = true, ['amulet'] = true, ['lightsource'] = true}
  local IsEquipmentOrRanged = itemArgs['isEquipped'] or IsEquipmentOrRangedList[itemData.category] or false


   mw.log('item_id:',item_id)
   mw.log('item_id:',item_id)
Line 73: Line 65:
   --IsFoodは多分categoriesのchildofがfoodってこと
   --IsFoodは多分categoriesのchildofがfoodってこと
   --以下の可能性がある categories 料理,食材,調味料,保存食,未加工食材 加工品
   --以下の可能性がある categories 料理,食材,調味料,保存食,未加工食材 加工品
  local price_value


   --指定idならvalueの計算を行い「GetValueここまで」まで飛ばす(Trait系)
   --指定idならvalueの計算を行い「GetValueここまで」まで飛ばす(Trait系)
   if item_id == 'gene' or item_id == 'gene_brain' then
   if item_id == 'gene' or item_id == 'gene_brain' then
    --脳細胞
     price_value = value * (100 + (itemData.owner.c_DNA.cost or 0) * 10) / 100
     price_value = value * (100 + (itemData.owner.c_DNA.cost or 0) * 10) / 100


   elseif item_id == 'book_plan' then
   elseif item_id == 'book_plan' then--計画書
    --計画書
     price_value = value * (mathf_max((source.cost[1] or 0), 3) * 17) / 100
     price_value = value * (mathf_max((source.cost[1] or 0), 3) * 17) / 100


   elseif item_id == 'mod_ranged' then
   elseif item_id == 'Mod' then
    --mod_ranged。うーんなんか違う気がする
     if item_id == 'Rune' then
     if item_id == 'rune' then
       value = value
       value = value
     end
     end
     local num = (source.value or 0) * (itemData.encLV or 0)
     local num = (source.value or 0) * (itemData.owner.encLV or 0)
     price_value = value * num / 100
     price_value = value * num / 100


   elseif item_id == 'mathammer' then
   elseif item_id == 'mathammer' then--マテリアルハンマー
    --マテリアルハンマー
     price_value = 5000 + (value or 0) * (matvalue or 0) * (matvalue or 0) / 1000
     price_value = 5000 + (value or 0) * (matvalue or 0) * (matvalue or 0) / 1000


   elseif item_id == 'figure' then
   elseif item_id == 'figure' then--彫刻
    --彫刻
     if source == nil then value = value end
     if source == nil then value = value end
     local multisize_factor = source.multisize and 2 or 1
     local multisize_factor = source.multisize and 2 or 1
Line 102: Line 91:
     price_value = (value + (source.LV or 0) * 50) * multisize_factor * quality_factor
     price_value = (value + (source.LV or 0) * 50) * multisize_factor * quality_factor


   elseif item_id == 'perfume' then
   elseif item_id == 'perfume' then--香水?当てはまらず。ポーション計算かもしれない
    --香水?当てはまらず。ポーション計算かもしれない
     price_value = (source.value or 0) * 1200 / 100
     price_value = (source.value or 0) * 1200 / 100


   elseif item_id == 'chest_gamble' then
   elseif item_id == 'chest_gamble' then--小さな宝くじ箱
    --小さな宝くじ箱
     price_value = (value or 0) + (lockLv or 0) * 50
     price_value = (value or 0) + (lockLv or 0) * 50


   elseif item_id == '1163' then
   elseif item_id == '1163' then--魔法のポーション elevalueかな?
    --魔法のポーション elevalueかな?
     price_value = (source.value or 0) * 120 / 100
     price_value = (source.value or 0) * 120 / 100


   elseif item_id == 'scroll_random' then
   elseif item_id == 'scroll_random' then--魔法の巻物
    --魔法の巻物
     if source ~= nil and (source.value or 0) ~= 0 then
     if source ~= nil and (source.value or 0) ~= 0 then
       -- MTPValueが不明なため、1と仮定
       -- MTPValueが不明なため、1と仮定
Line 127: Line 112:
     price_value = value * (100 + (itemData.owner.LV or 0) - 5) * 10 / 100
     price_value = value * (100 + (itemData.owner.LV or 0) - 5) * 10 / 100


   elseif item_id == 'book_skill' then
   elseif item_id == 'book_skill' then--技術書
    --技術書
     price_value = (value or 0)
     price_value = (value or 0)


   elseif item_id == 'rp' then
   elseif item_id == 'rp' then--ランダムレシピ
    --ランダムレシピ
     price_value = (value or 0) * (100 + (itemData.recipe.row.LV or 0) * 15) / 100
     price_value = (value or 0) * (100 + (itemData.recipe.row.LV or 0) * 15) / 100


   elseif item_id == 'monsterball' then
   elseif item_id == 'monsterball' then--モンスターボール
    --モンスターボール
     if itemData.IsLittleBall then
     if itemData.IsLittleBall then
       value = value
       value = value
Line 142: Line 124:
     price_value = value * (100 + (itemData.owner.LV or 0) * 15) / 100
     price_value = value * (100 + (itemData.owner.LV or 0) * 15) / 100
   else
   else
    --上記以外のアイテム計算
     mw.log('136 price_valuelue:',price_value)
     mw.log('142 price_valuelue:',price_value)


     if item_id == 'plat' then
     if item_id == 'plat' then
Line 157: Line 138:
       price_value = price_value * math.max(100 + rarityLv + math.min(qualityLv * 10, 200), 80) / 100
       price_value = price_value * math.max(100 + rarityLv + math.min(qualityLv * 10, 200), 80) / 100
     end
     end
     mw.log('156 price_valuelue:',price_value)
     mw.log('150 price_valuelue:',price_value)


     if IsFood then
     if IsFood then
Line 165: Line 146:
       end
       end
     end
     end
     mw.log('164 price_valuelue:',price_value)
     mw.log('156 price_valuelue:',price_value)


     local num
     local num
     mw.log('IsEquipmentOrRangedOrAmmo:',IsEquipmentOrRangedOrAmmo)
     mw.log('IsEquipmentOrRangedOrAmmo:',IsEquipmentOrRangedOrAmmo)
     if IsEquipmentOrRangedOrAmmo then-- || trait is TraitMod
     if IsEquipmentOrRangedOrAmmo then
      if sell then
        price_value = price_value * 0.3;
      end
       num = 2
       num = 2
     else
     else
Line 183: Line 161:


     --神々の武器以外?★ユニーク判定追加
     --神々の武器以外?★ユニーク判定追加
     mw.log('182 IsUnique:',IsUnique)
     mw.log('168 IsUnique:',IsUnique)
     if IsUnique == false then
     if IsUnique == false then
       if IsEquipmentOrRanged and rarityLv >= 2 then--Legendary
       if IsEquipmentOrRanged and rarityLv >= 2 then--Legendary
Line 199: Line 177:
       end
       end
     end
     end
     mw.log('198 price_valuelue:',price_value)
     mw.log('178 price_valuelue:',price_value)


     --if (trait is TraitRecipe && sell)
     --if (trait is TraitRecipe && sell)
     if encLV > 0 and not itemData.category == 'rune' then
     if encLV ~= 0 and not itemData.category == 'rune' then
       if string.find(cattag, 'enc') then
       if string.find(cattag, 'enc') then--itemData.categoryのカテゴリtagにencがあるもの
        --itemData.categoryのカテゴリtagにencがあるもの
         --コンテナ,窓,照明,装飾,鉢植え,設備,製作設備,加工設備,発電機,マウント,屋外用品,機工,特殊,ベッド,椅子,机,扉,フィギア,地球儀,楽器
         --コンテナ,窓,照明,装飾,鉢植え,設備,製作設備,加工設備,発電機,マウント,屋外用品,機工,特殊,ベッド,椅子,机,扉,フィギア,地球儀,楽器
         price_value = price_value * (0.7 + (encLV - 1) * 0.2)
         price_value = price_value * (0.7 + (encLV - 1) * 0.2)
Line 215: Line 192:
       end
       end
     end
     end
     --if (tier > 0) {num2 *= (float)(tier + 1);}
     --if (tier > 0)
   end
   end
   mw.log('216 price_valuelue:',price_value)
   mw.log('195 price_valuelue:',price_value)
   -- GetValueここまで
   -- GetValueここまで


  price_value = math.trunc(price_value)
  mw.log('219 price_valuelue:',price_value)
   price_value = price_value + (PriceAdd or 0)
   price_value = price_value + (PriceAdd or 0)


Line 252: Line 227:
     price_value = price_value * (sell and 0.01 or 50)
     price_value = price_value * (sell and 0.01 or 50)
   end
   end
  --チャージ(回数)があるもの


   if CurrencyType == 'Ecopo' then
   if CurrencyType == 'Ecopo' then
     if string.find(itemData.trait, 'Seed', 1, true) then
     price_value = price_value * 0.2
        price_value = price_value  * 2.0
    elseif string.find(itemData.trait, 'EcoMark', 1, true) then
        price_value = price_value  * 1.0
    else
      price_value = price_value * 0.2
    end
   elseif CurrencyType == 'Casino_coin' then
   elseif CurrencyType == 'Casino_coin' then
     price_value = price_value * 0.1
     price_value = price_value * 0.1
Line 270: Line 240:
     price_value = price_value * 0.005
     price_value = price_value * 0.005
   else
   else
    --Money
     if IsIdentified then
     if IsIdentified then
      --判明済みと祝福と呪い
       if blessedState == 1 then
       if blessedState == 1 then
         price_value = price_value * 1.25
         price_value = price_value * 1.25
Line 282: Line 250:
         end
         end
       end
       end
      --チャージ回数
    else
      --if (this.trait.HasCharges) { p = p * 0.05000000074505806 + p * (double)(0.5f + Mathf.Clamp(0.1f * (float)c_charges, 0f, 1.5f)); }
       if sell then
       if charge then
         price_value = 1 + 15
         local clamp_val = clamp(0.1 * charge, 0, 1.5)
      else
         price_value = price_value * 0.05 + price_value * (0.5 + clamp_val)
         price_value = 50 + 500
       end
       end
      --腐敗
      --if (IsDecayed) { p *= (flag ? 0.9f : 0.5f); }
    else
      --未判明:基本値+ランダムは省く
     end
     end
     mw.log('258 price_valuelue:',price_value)
     mw.log('258 price_valuelue:',price_value)
      
      
     --if not sell then
     --if not sell then
     --  price_value = price_value * (1 + 0.2 * (c.Evalue1406 or 0))/*観光気分*/
     --  price_value = price_value * (1 + 0.2 * (c.Evalue1406 or 0))
     --end
     --end
   end
   end


   --販売場所やスキルによる乗算は省く
   local num = 0
   --priceTypeの分岐Tourism/Shipping/PlayerShopは省く
 
  if CurrencyType ~= 'Money' and CurrencyType ~= 'Money2' then
    num = 0
  end
 
  price_value = price_value * (sell and (1 + num * 0.02) or (1 - num * 0.02))
   mw.log('283 price_valuelue:',price_value)


  --売却時の曲線補正 (curve)
   if sell then
   if sell then
     price_value = M.curve(price_value, 10000, 10000, 80)
     price_value = M.curve(price_value, 10000, 10000, 80)
   end
   end
 
    
   --最小値の保証
   if price_value < 1.0 then
   if price_value < 1.0 then
     price_value = not sell and 1 or 0
     price_value = not sell and 1 or 0
   end
   end


   --カジノコインの購入時丸めは省く
   if not sell and CurrencyType == 'Casino_coin' then
     --土地権利書による乗算 (TraitDeed)は省く
     if price_value > 100000 then
      price_value = math.ceil(price_value / 100000) * 100000
    elseif price_value > 10000 then
      price_value = math.ceil(price_value / 10000) * 10000
    elseif price_value > 1000 then
      price_value = math.ceil(price_value / 1000) * 1000
    elseif price_value > 100 then
      price_value = math.ceil(price_value / 100) * 100
    elseif price_value > 10 then
      price_value = math.ceil(price_value / 10) * 10
    end
  end
    
    
  --最大値の制限
   if price_value > 1000000000 then
   if price_value > 1000000000 then
     price_value = not sell and 1000000000 or 500000000
     price_value = not sell and 1000000000 or 500000000
Line 370: Line 348:
     rarityLv = args['rarityLv'],--レアリティレベル
     rarityLv = args['rarityLv'],--レアリティレベル
     qualityLv = args['qualityLv'],--品質レベル
     qualityLv = args['qualityLv'],--品質レベル
    charge = args['charge'],--チャージ回数
     matvalue = item_data.defMat and matdata[item_data.defMat].value,
     matvalue = item_data.defMat and matdata[item_data.defMat].value,
     cattag = (catdata[item_data.category] and catdata[item_data.category].tag) or ''
     cattag = (catdata[item_data.category] and catdata[item_data.category].tag) or ''