游戏王残局简化版

Artifact [689535e77e]
Login

Artifact [689535e77e]

Artifact 689535e77e2a0800513347bbae385c8a8b1056d1ee470a1b6ca785478e8c5989:


package.path = [[.\lua_lib\?.lua;]] .. package.path
package.cpath = [[.\lua_lib\?.dll;]] .. package.cpath
local 字集码互转库 = require("u8_to_a")
local u8 = 字集码互转库.u8_to_a
local f = require(u8("常用库"))
local 字段名对 = require(u8("字段名"))
local 简文件库 = require("lfs")
local 简数据库库 = require("lsqlite3")
local d = {}
do
  local TYPE_SPELL = 0x2
  local TYPE_TRAP = 0x4
  local TYPE_EFFECT = 0x20
  local TYPE_PENDULUM = 0x1000000
  local 有效果卡的类排 = {
  TYPE_SPELL
  , TYPE_TRAP
  , TYPE_EFFECT
  }
  local 无效果灵摆怪兽排 = {
    28363749 --火蛋白石头龙头领
    , 19474136 --曼陀林草龙
    , 17390179 --闪光之骑士
    , 83980492 --铜锣龙
    }
  --~ 卡对
  function d.筛有效果卡(o1_4)
    for o1 = 1, #有效果卡的类排 do
      if bit.band(有效果卡的类排[o1], o1_4.type) == 0 then
      else
        return o1_4
        end
      end
    if bit.band(TYPE_PENDULUM, o1_4.type) == 0 then
    else
      if 无效果灵摆怪兽排[o1_4.id] then
      else
        return o1_4
        end
      end
    end
  end
--~ 各文件的卡对排
function d.筛有效果卡的张数(o1_0)
  local k1_8
  --~ 卡排
  k1_8 = f.历排(o1_0, d.筛有效果卡)
  return #k1_8
  end
--~ 各文件的卡编排
function d.取卡对_一维(o1_0)
  return f.历排(o1_0, d.取卡对)
  end
--~ 卡编
function d.取卡对(o1)
  local k1_0, k2_0
  --~ 卡文对
  k1_0 = d.取卡文(o1)
  --~ 卡数据对
  k2_0 = d.取卡数据(o1)
  return f.连两对(k1_0, k2_0)
  end
--~ 卡编
function d.取卡文(o1)
  for o1_4 in 数据库:nrows("select * from texts where id = " .. o1) do
    return o1_4
    end
  end
--~ 卡编
function d.取卡数据(o1)
  for o1_4 in 数据库:nrows("select * from datas where id = " .. o1) do
    --~ if o1_4.setcode > 0xffffffff then
      --~ ffi = require("ffi")
      --~ print(bit.tohex(o1_4.setcode, 16), o1_4.setcode, o1_4.setcode == 36592129229979791, bit.tohex(bit.rshift(o1_4.setcode, 31)), bit.tohex(bit.band(o1_4.setcode, 0xf)), string.format("%x", 36592129229979791 - 36592129229979791), bit.tohex(math.fmod(36592129229979791, 0xffff + 1)), math.fmod(36592129229979791, 0xffff + 1), ffi.new("uint64_t[1]", 36592129229979791)[0], tostring(36592129229979791) == tostring(o1_4.setcode), tonumber(tostring(o1_4.setcode)) == 36592129229979791, math.modf(36592129229979791 / (0xffff + 1)), bit.tohex(bit.band(o1_4.setcode - 4, ffi.new("uint64_t[1]", 0xffff)[0])))
      --~ print(string.format("%x", 36592129229979791 - 5))
    --~ else
      --~ end
    return o1_4
    end
  end
--~ 文
function d.局筛卡编(o1)
  local k1_0
  --~ 卡编排
  k1_0 = f.历文(o1, string.gmatch, "[^\n]+")
  k1_0 = f.历排(k1_0, string.match, "Debug%.AddCard.+")
  return f.历排(k1_0, string.match, "[0-9]+")
  end
--~ 文
function d.局筛则数(o1)
  local k1
  local k1_0
  --~ 则数排
  k1_0 = f.历文(o1, string.gmatch, "[^\n]+")
  k1_0 = f.历排(k1_0, f.全筛前缀, "Debug.ReloadFieldBegin")
  --~ 则数
  k1 = string.match(k1_0[1], "[0-9]")
  return k1 or 3
  end
--~ 卡对排
function d.荐名(o1_0)
  --~ print(o1_0[1].name)
  --~ return o1_0[1]
  d.荐字段名(o1_0)
  end
--~ 卡对排
function d.荐字段名(o1_0)
  local k1, k2
  local k1_0
  --~ 字段对
  k1_0 = {}
  for o1 = 1, #o1_0 do
    --~ 字段数
    k1 = f.double_to_uint64(o1_0[o1].setcode)
    if k1 > 0xffff then
      k1 = k1 - 1
    else
      end
    --~ for o2 = 1, 11112222 do
    --~ 大字段号
      --~ k1 = f.位和(o1_0[o1].setcode, 0xffff)
      --~ k2 = 
      --~ end
    --~ 大字段号
    --~ k1 = bit.band(o1_0[o1].setcode, 0xffff)
    --~ print(o1_0[o1].setcode)
    --~ print(f.位和(o1_0[o1].setcode, 0xffff))
    --~ if k1 > 0xfff then
      --~ 字段名
      --~ k2 = 字段名对[k1]
      --~ print(k1, k2)
      --~ if k1_0[k2] then
        --~ k1_0[k2] = k1_0[k2] + 1
      --~ else
        --~ k1_0[k2] = 1
        --~ end
      --~ end
    --~ 小字段号
    --~ k1 = bit.band(o1_0[o1].setcode, 0xfff)
    --~ 字段名
    --~ k2 = 字段名对[k1]
    --~ if k1_0[k2] then
      --~ k1_0[k2] = k1_0[k2] + 1
    --~ elseif k2 == nil then
    --~ else
      --~ k1_0[k2] = 1
      --~ end
    end
  end
--~ 目对
function d.残局改名(o1_0)
  local k1_0, k2_0, k3_0, k4_0, k5_0, k6_0
  --~ 文件排
  k1_0 = f.历文(o1_0.文件目, 简文件库.dir)
  k1_0 = f.历排(k1_0, f.全筛后缀, ".lua")
  for o1 = 1, #k1_0 do
    k1_0[o1] = f.加前缀(k1_0[o1], o1_0.文件目)
    k1_0[o1] = f.读文件(k1_0[o1])
    k1_0[o1] = string.gsub(k1_0[o1], "%-%-" .. "%[(=*)%[" .. ".-" .. "%]%1%]", "")
    k1_0[o1] = string.gsub(k1_0[o1], "%-%-" .. "[^\n]*", "")
    end
  --~ 则数排
  k2_0 = f.历排(k1_0, d.局筛则数)
  --~ 各文件的卡编排
  k3_0 = f.历排(k1_0, d.局筛卡编)
  _G.数据库 = 简数据库库.open(o1_0.数据库路)
  --~ 各文件的卡对排
  k4_0 = f.历排(k3_0, d.取卡对_一维)
  --~ 有效果卡的张数排
  k5_0 = f.历排(k4_0, d.筛有效果卡的张数)
  --~ 荐名排
  k6_0 = f.历排(k4_0, d.荐名)
  --~ print(k6_0[0])
  --~ print(k5_0[2])
  end
d.目对 = {
  ["文件目"] = "../single/"
  , ["数据库路"] = [[D:\install\YGOPro\cards.cdb]]
  }
for o1_0, o2_0 in pairs(d.目对) do
  d.目对[o1_0] = f.操类(o2_0, "string", u8)
  end
d.残局改名(d.目对)