490477db61 2024-02-03 1: package.path = [[.\lua_lib\?.lua;]] .. package.path
490477db61 2024-02-03 2: package.cpath = [[.\lua_lib\?.dll;]] .. package.cpath
490477db61 2024-02-03 3: local 字集码互转库 = require("u8_to_a")
490477db61 2024-02-03 4: local u8 = 字集码互转库.u8_to_a
490477db61 2024-02-03 5: local f = require(u8("常用库"))
f4c48d2eb7 2024-02-05 6: local 字段名对 = require(u8("字段名"))
13cd0daf30 2024-02-03 7: local 简文件库 = require("lfs")
a8787a258d 2024-02-03 8: local 简数据库库 = require("lsqlite3")
eda1d2cdc8 2024-02-04 9: local d = {}
023be319b7 2024-02-03 10: do
023be319b7 2024-02-03 11: local TYPE_SPELL = 0x2
023be319b7 2024-02-03 12: local TYPE_TRAP = 0x4
023be319b7 2024-02-03 13: local TYPE_EFFECT = 0x20
65d8c2fcdd 2024-02-03 14: local TYPE_PENDULUM = 0x1000000
65d8c2fcdd 2024-02-03 15: local 有效果卡的类排 = {
023be319b7 2024-02-03 16: TYPE_SPELL
023be319b7 2024-02-03 17: , TYPE_TRAP
023be319b7 2024-02-03 18: , TYPE_EFFECT
023be319b7 2024-02-03 19: }
023be319b7 2024-02-03 20: local 无效果灵摆怪兽排 = {
023be319b7 2024-02-03 21: 28363749 --火蛋白石头龙头领
023be319b7 2024-02-03 22: , 19474136 --曼陀林草龙
023be319b7 2024-02-03 23: , 17390179 --闪光之骑士
023be319b7 2024-02-03 24: , 83980492 --铜锣龙
023be319b7 2024-02-03 25: }
023be319b7 2024-02-03 26: --~ 卡对
f38085debc 2024-02-04 27: function d.筛有效果卡(o1_4)
33a6341d1d 2024-02-04 28: for o1 = 1, #有效果卡的类排 do
f38085debc 2024-02-04 29: if bit.band(有效果卡的类排[o1], o1_4.type) == 0 then
33a6341d1d 2024-02-04 30: else
f38085debc 2024-02-04 31: return o1_4
33a6341d1d 2024-02-04 32: end
33a6341d1d 2024-02-04 33: end
f38085debc 2024-02-04 34: if bit.band(TYPE_PENDULUM, o1_4.type) == 0 then
33a6341d1d 2024-02-04 35: else
f38085debc 2024-02-04 36: if 无效果灵摆怪兽排[o1_4.id] then
33a6341d1d 2024-02-04 37: else
f38085debc 2024-02-04 38: return o1_4
33a6341d1d 2024-02-04 39: end
33a6341d1d 2024-02-04 40: end
33a6341d1d 2024-02-04 41: end
33a6341d1d 2024-02-04 42: end
3d6f1a35a9 2024-02-04 43: --~ 各文件的卡对排
33a6341d1d 2024-02-04 44: function d.筛有效果卡的张数(o1_0)
33a6341d1d 2024-02-04 45: local k1_8
33a6341d1d 2024-02-04 46: --~ 卡排
33a6341d1d 2024-02-04 47: k1_8 = f.历排(o1_0, d.筛有效果卡)
33a6341d1d 2024-02-04 48: return #k1_8
33a6341d1d 2024-02-04 49: end
3d6f1a35a9 2024-02-04 50: --~ 各文件的卡编排
3d6f1a35a9 2024-02-04 51: function d.取卡对_一维(o1_0)
3d6f1a35a9 2024-02-04 52: return f.历排(o1_0, d.取卡对)
33a6341d1d 2024-02-04 53: end
33a6341d1d 2024-02-04 54: --~ 卡编
33a6341d1d 2024-02-04 55: function d.取卡对(o1)
f4c48d2eb7 2024-02-05 56: local k1_0, k2_0
f4c48d2eb7 2024-02-05 57: --~ 卡文对
f4c48d2eb7 2024-02-05 58: k1_0 = d.取卡文(o1)
f4c48d2eb7 2024-02-05 59: --~ 卡数据对
f4c48d2eb7 2024-02-05 60: k2_0 = d.取卡数据(o1)
f4c48d2eb7 2024-02-05 61: return f.连两对(k1_0, k2_0)
f4c48d2eb7 2024-02-05 62: end
f4c48d2eb7 2024-02-05 63: --~ 卡编
f4c48d2eb7 2024-02-05 64: function d.取卡文(o1)
f4c48d2eb7 2024-02-05 65: for o1_4 in 数据库:nrows("select * from texts where id = " .. o1) do
f4c48d2eb7 2024-02-05 66: return o1_4
f4c48d2eb7 2024-02-05 67: end
f4c48d2eb7 2024-02-05 68: end
f4c48d2eb7 2024-02-05 69: --~ 卡编
f4c48d2eb7 2024-02-05 70: function d.取卡数据(o1)
33a6341d1d 2024-02-04 71: for o1_4 in 数据库:nrows("select * from datas where id = " .. o1) do
6bd570d52a 2024-02-05 72: --~ if o1_4.setcode > 0xffffffff then
6bd570d52a 2024-02-05 73: --~ ffi = require("ffi")
6bd570d52a 2024-02-05 74: --~ 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])))
6bd570d52a 2024-02-05 75: --~ print(string.format("%x", 36592129229979791 - 5))
6bd570d52a 2024-02-05 76: --~ else
6bd570d52a 2024-02-05 77: --~ end
33a6341d1d 2024-02-04 78: return o1_4
33033c8d3d 2024-02-04 79: end
33033c8d3d 2024-02-04 80: end
33033c8d3d 2024-02-04 81: --~ 文
33033c8d3d 2024-02-04 82: function d.局筛卡编(o1)
33033c8d3d 2024-02-04 83: local k1_0
33033c8d3d 2024-02-04 84: --~ 卡编排
33033c8d3d 2024-02-04 85: k1_0 = f.历文(o1, string.gmatch, "[^\n]+")
f4c48d2eb7 2024-02-05 86: k1_0 = f.历排(k1_0, string.match, "Debug%.AddCard.+")
33033c8d3d 2024-02-04 87: return f.历排(k1_0, string.match, "[0-9]+")
eda1d2cdc8 2024-02-04 88: end
eda1d2cdc8 2024-02-04 89: --~ 文
eda1d2cdc8 2024-02-04 90: function d.局筛则数(o1)
eda1d2cdc8 2024-02-04 91: local k1
d75e496659 2024-02-04 92: local k1_0
eda1d2cdc8 2024-02-04 93: --~ 则数排
d75e496659 2024-02-04 94: k1_0 = f.历文(o1, string.gmatch, "[^\n]+")
d75e496659 2024-02-04 95: k1_0 = f.历排(k1_0, f.全筛前缀, "Debug.ReloadFieldBegin")
eda1d2cdc8 2024-02-04 96: --~ 则数
d75e496659 2024-02-04 97: k1 = string.match(k1_0[1], "[0-9]")
65d8c2fcdd 2024-02-03 98: return k1 or 3
f4c48d2eb7 2024-02-05 99: end
f4c48d2eb7 2024-02-05 100: --~ 卡对排
f4c48d2eb7 2024-02-05 101: function d.荐名(o1_0)
f4c48d2eb7 2024-02-05 102: --~ print(o1_0[1].name)
f4c48d2eb7 2024-02-05 103: --~ return o1_0[1]
f4c48d2eb7 2024-02-05 104: d.荐字段名(o1_0)
f4c48d2eb7 2024-02-05 105: end
f4c48d2eb7 2024-02-05 106: --~ 卡对排
f4c48d2eb7 2024-02-05 107: function d.荐字段名(o1_0)
91958121fe 2024-02-05 108: local k1, k2, k3, k4
f4c48d2eb7 2024-02-05 109: local k1_0
f4c48d2eb7 2024-02-05 110: --~ 字段对
f4c48d2eb7 2024-02-05 111: k1_0 = {}
f4c48d2eb7 2024-02-05 112: for o1 = 1, #o1_0 do
6bd570d52a 2024-02-05 113: --~ 字段数
91958121fe 2024-02-05 114: k1 = f.to_uint64(o1_0[o1].setcode)
91958121fe 2024-02-05 115: if k1 > 0xffffFFFFffff then
6bd570d52a 2024-02-05 116: k1 = k1 - 1
91958121fe 2024-02-05 117: elseif k1 < 1 then
6bd570d52a 2024-02-05 118: else
91958121fe 2024-02-05 119: for o2 = 1, 11112222 do
91958121fe 2024-02-05 120: if k1 < 1 then
91958121fe 2024-02-05 121: --~ f.历对(k1_0, print)
91958121fe 2024-02-05 122: --~ print(3)
91958121fe 2024-02-05 123: break
91958121fe 2024-02-05 124: --~ return
91958121fe 2024-02-05 125: else
91958121fe 2024-02-05 126: --~ 大字段号
91958121fe 2024-02-05 127: k2 = f.位和(k1, 0xffff)
91958121fe 2024-02-05 128: k1 = f.位右移(k1, f.乘法(4, 4))
91958121fe 2024-02-05 129: --~ print(k1, k2)
91958121fe 2024-02-05 130: --~ 字段名
91958121fe 2024-02-05 131: k3 = 字段名对[tonumber(k2)]
91958121fe 2024-02-05 132: --~ print(k3)
91958121fe 2024-02-05 133: if k3 then
91958121fe 2024-02-05 134: if k1_0[k3] then
91958121fe 2024-02-05 135: k1_0[k3] = f.加法(k1_0[k3], 1)
91958121fe 2024-02-05 136: else
91958121fe 2024-02-05 137: k1_0[k3] = 1
91958121fe 2024-02-05 138: end
91958121fe 2024-02-05 139: --~ 小字段号
91958121fe 2024-02-05 140: k4 = f.位和(k1, 0xfff)
91958121fe 2024-02-05 141: k3 = 字段名对[tonumber(k4)]
91958121fe 2024-02-05 142: if k3 then
91958121fe 2024-02-05 143: if k1_0[k3] then
91958121fe 2024-02-05 144: k1_0[k3] = f.加法(k1_0[k3], 1)
91958121fe 2024-02-05 145: else
91958121fe 2024-02-05 146: k1_0[k3] = 1
91958121fe 2024-02-05 147: end
91958121fe 2024-02-05 148: else
91958121fe 2024-02-05 149: end
91958121fe 2024-02-05 150: else
91958121fe 2024-02-05 151: end
91958121fe 2024-02-05 152: end
91958121fe 2024-02-05 153: end
6bd570d52a 2024-02-05 154: end
91958121fe 2024-02-05 155: --~ print(string.format("%x", k1))
91958121fe 2024-02-05 156: --~ for o2 = 1, 6 do
91958121fe 2024-02-05 157: --~ print(k1)
91958121fe 2024-02-05 158: --~ if k1 < 1 then
91958121fe 2024-02-05 159: --~ f.历对(k1_0, print)
91958121fe 2024-02-05 160: --~ print(23)
91958121fe 2024-02-05 161: --~ return
91958121fe 2024-02-05 162: --~ else
91958121fe 2024-02-05 163: --~ 大字段号
91958121fe 2024-02-05 164: --~ k2 = f.位和(k1, 0xffff)
91958121fe 2024-02-05 165: --~ k1 = f.位右移(k1, f.乘法(4, 4))
91958121fe 2024-02-05 166: --~ 字段名
91958121fe 2024-02-05 167: --~ k3 = 字段名对[k2]
91958121fe 2024-02-05 168: --~ if k3 then
91958121fe 2024-02-05 169: --~ if k1_0[k3] then
91958121fe 2024-02-05 170: --~ k1_0[k3] = f.加法(k1_0[k3], 1)
91958121fe 2024-02-05 171: --~ else
91958121fe 2024-02-05 172: --~ k1_0[k3] = 1
91958121fe 2024-02-05 173: --~ end
91958121fe 2024-02-05 174: --~ 小字段号
91958121fe 2024-02-05 175: --~ k4 = f.位和(k1, 0xfff)
91958121fe 2024-02-05 176: --~ k3 = 字段名对[k4]
91958121fe 2024-02-05 177: --~ if k3 then
91958121fe 2024-02-05 178: --~ if k1_0[k3] then
91958121fe 2024-02-05 179: --~ k1_0[k3] = f.加法(k1_0[k3], 1)
91958121fe 2024-02-05 180: --~ else
91958121fe 2024-02-05 181: --~ k1_0[k3] = 1
91958121fe 2024-02-05 182: --~ end
91958121fe 2024-02-05 183: --~ else
91958121fe 2024-02-05 184: --~ end
91958121fe 2024-02-05 185: --~ else
91958121fe 2024-02-05 186: --~ end
91958121fe 2024-02-05 187: --~ end
91958121fe 2024-02-05 188:
91958121fe 2024-02-05 189: --~ print(k1, k2)
7a7894a746 2024-02-05 190: --~ k2 =
7a7894a746 2024-02-05 191: --~ end
7a7894a746 2024-02-05 192: --~ 大字段号
7a7894a746 2024-02-05 193: --~ k1 = bit.band(o1_0[o1].setcode, 0xffff)
7a7894a746 2024-02-05 194: --~ print(o1_0[o1].setcode)
7a7894a746 2024-02-05 195: --~ print(f.位和(o1_0[o1].setcode, 0xffff))
7a7894a746 2024-02-05 196: --~ if k1 > 0xfff then
7a7894a746 2024-02-05 197: --~ 字段名
7a7894a746 2024-02-05 198: --~ k2 = 字段名对[k1]
7a7894a746 2024-02-05 199: --~ print(k1, k2)
7a7894a746 2024-02-05 200: --~ if k1_0[k2] then
7a7894a746 2024-02-05 201: --~ k1_0[k2] = k1_0[k2] + 1
7a7894a746 2024-02-05 202: --~ else
7a7894a746 2024-02-05 203: --~ k1_0[k2] = 1
7a7894a746 2024-02-05 204: --~ end
7a7894a746 2024-02-05 205: --~ end
7a7894a746 2024-02-05 206: --~ 小字段号
7a7894a746 2024-02-05 207: --~ k1 = bit.band(o1_0[o1].setcode, 0xfff)
7a7894a746 2024-02-05 208: --~ 字段名
7a7894a746 2024-02-05 209: --~ k2 = 字段名对[k1]
7a7894a746 2024-02-05 210: --~ if k1_0[k2] then
7a7894a746 2024-02-05 211: --~ k1_0[k2] = k1_0[k2] + 1
7a7894a746 2024-02-05 212: --~ elseif k2 == nil then
7a7894a746 2024-02-05 213: --~ else
7a7894a746 2024-02-05 214: --~ k1_0[k2] = 1
7a7894a746 2024-02-05 215: --~ end
7a7894a746 2024-02-05 216: end
91958121fe 2024-02-05 217: f.历对(k1_0, print)
987280ca92 2024-02-04 218: end
65d8c2fcdd 2024-02-03 219: --~ 目对
987280ca92 2024-02-04 220: function d.残局改名(o1_0)
987280ca92 2024-02-04 221: local k1_0, k2_0, k3_0, k4_0, k5_0, k6_0
65d8c2fcdd 2024-02-03 222: --~ 文件排
987280ca92 2024-02-04 223: k1_0 = f.历文(o1_0.文件目, 简文件库.dir)
987280ca92 2024-02-04 224: k1_0 = f.历排(k1_0, f.全筛后缀, ".lua")
987280ca92 2024-02-04 225: for o1 = 1, #k1_0 do
987280ca92 2024-02-04 226: k1_0[o1] = f.加前缀(k1_0[o1], o1_0.文件目)
987280ca92 2024-02-04 227: k1_0[o1] = f.读文件(k1_0[o1])
987280ca92 2024-02-04 228: k1_0[o1] = string.gsub(k1_0[o1], "%-%-" .. "%[(=*)%[" .. ".-" .. "%]%1%]", "")
987280ca92 2024-02-04 229: k1_0[o1] = string.gsub(k1_0[o1], "%-%-" .. "[^\n]*", "")
65d8c2fcdd 2024-02-03 230: end
65d8c2fcdd 2024-02-03 231: --~ 则数排
987280ca92 2024-02-04 232: k2_0 = f.历排(k1_0, d.局筛则数)
65d8c2fcdd 2024-02-03 233: --~ 各文件的卡编排
987280ca92 2024-02-04 234: k3_0 = f.历排(k1_0, d.局筛卡编)
987280ca92 2024-02-04 235: _G.数据库 = 简数据库库.open(o1_0.数据库路)
65d8c2fcdd 2024-02-03 236: --~ 各文件的卡对排
987280ca92 2024-02-04 237: k4_0 = f.历排(k3_0, d.取卡对_一维)
65d8c2fcdd 2024-02-03 238: --~ 有效果卡的张数排
987280ca92 2024-02-04 239: k5_0 = f.历排(k4_0, d.筛有效果卡的张数)
f4c48d2eb7 2024-02-05 240: --~ 荐名排
f4c48d2eb7 2024-02-05 241: k6_0 = f.历排(k4_0, d.荐名)
f4c48d2eb7 2024-02-05 242: --~ print(k6_0[0])
987280ca92 2024-02-04 243: --~ print(k5_0[2])
65d8c2fcdd 2024-02-03 244: end
eda1d2cdc8 2024-02-04 245: d.目对 = {
13cd0daf30 2024-02-03 246: ["文件目"] = "../single/"
13cd0daf30 2024-02-03 247: , ["数据库路"] = [[D:\install\YGOPro\cards.cdb]]
9cdbbb717e 2024-02-03 248: }
eda1d2cdc8 2024-02-04 249: for o1_0, o2_0 in pairs(d.目对) do
eda1d2cdc8 2024-02-04 250: d.目对[o1_0] = f.操类(o2_0, "string", u8)
13cd0daf30 2024-02-03 251: end
eda1d2cdc8 2024-02-04 252: d.残局改名(d.目对)