Lines of
残局文料/残局改名.lua
from check-in f4c48d2eb7
that are changed by the sequence of edits moving toward
check-in 7a7894a746:
1: package.path = [[.\lua_lib\?.lua;]] .. package.path
2: package.cpath = [[.\lua_lib\?.dll;]] .. package.cpath
3: local 字集码互转库 = require("u8_to_a")
4: local u8 = 字集码互转库.u8_to_a
5: local f = require(u8("常用库"))
6: local 字段名对 = require(u8("字段名"))
7: local 简文件库 = require("lfs")
8: local 简数据库库 = require("lsqlite3")
9: local d = {}
10: do
11: local TYPE_SPELL = 0x2
12: local TYPE_TRAP = 0x4
13: local TYPE_EFFECT = 0x20
14: local TYPE_PENDULUM = 0x1000000
15: local 有效果卡的类排 = {
16: TYPE_SPELL
17: , TYPE_TRAP
18: , TYPE_EFFECT
19: }
20: local 无效果灵摆怪兽排 = {
21: 28363749 --火蛋白石头龙头领
22: , 19474136 --曼陀林草龙
23: , 17390179 --闪光之骑士
24: , 83980492 --铜锣龙
25: }
26: --~ 卡对
27: function d.筛有效果卡(o1_4)
28: for o1 = 1, #有效果卡的类排 do
29: if bit.band(有效果卡的类排[o1], o1_4.type) == 0 then
30: else
31: return o1_4
32: end
33: end
34: if bit.band(TYPE_PENDULUM, o1_4.type) == 0 then
35: else
36: if 无效果灵摆怪兽排[o1_4.id] then
37: else
38: return o1_4
39: end
40: end
41: end
42: end
43: --~ 各文件的卡对排
44: function d.筛有效果卡的张数(o1_0)
45: local k1_8
46: --~ 卡排
47: k1_8 = f.历排(o1_0, d.筛有效果卡)
48: return #k1_8
49: end
50: --~ 各文件的卡编排
51: function d.取卡对_一维(o1_0)
52: return f.历排(o1_0, d.取卡对)
53: end
54: --~ 卡编
55: function d.取卡对(o1)
56: local k1_0, k2_0
57: --~ 卡文对
58: k1_0 = d.取卡文(o1)
59: --~ 卡数据对
60: k2_0 = d.取卡数据(o1)
61: return f.连两对(k1_0, k2_0)
62: end
63: --~ 卡编
64: function d.取卡文(o1)
65: for o1_4 in 数据库:nrows("select * from texts where id = " .. o1) do
66: return o1_4
67: end
68: end
69: --~ 卡编
70: function d.取卡数据(o1)
71: for o1_4 in 数据库:nrows("select * from datas where id = " .. o1) do
72: return o1_4
73: end
74: end
75: --~ 文
76: function d.局筛卡编(o1)
77: local k1_0
78: --~ 卡编排
79: k1_0 = f.历文(o1, string.gmatch, "[^\n]+")
80: k1_0 = f.历排(k1_0, string.match, "Debug%.AddCard.+")
81: return f.历排(k1_0, string.match, "[0-9]+")
82: end
83: --~ 文
84: function d.局筛则数(o1)
85: local k1
86: local k1_0
87: --~ 则数排
88: k1_0 = f.历文(o1, string.gmatch, "[^\n]+")
89: k1_0 = f.历排(k1_0, f.全筛前缀, "Debug.ReloadFieldBegin")
90: --~ 则数
91: k1 = string.match(k1_0[1], "[0-9]")
92: return k1 or 3
93: end
94: --~ 卡对排
95: function d.荐名(o1_0)
96: --~ print(o1_0[1].name)
97: --~ return o1_0[1]
98: d.荐字段名(o1_0)
99: end
100: --~ 卡对排
101: function d.荐字段名(o1_0)
102: local k1, k2
103: local k1_0
104: --~ 字段对
105: k1_0 = {}
106: for o1 = 1, #o1_0 do
f4c48d2eb7 2024-02-05 107: --~ 大字段号
f4c48d2eb7 2024-02-05 108: k1 = bit.band(o1_0[o1].setcode, 0xffff)
f4c48d2eb7 2024-02-05 109: print(o1_0[o1].setcode)
f4c48d2eb7 2024-02-05 110: if k1 > 0xfff then
f4c48d2eb7 2024-02-05 111: --~ 字段名
f4c48d2eb7 2024-02-05 112: k2 = 字段名对[k1]
f4c48d2eb7 2024-02-05 113: print(k1, k2)
f4c48d2eb7 2024-02-05 114: if k1_0[k2] then
f4c48d2eb7 2024-02-05 115: k1_0[k2] = k1_0[k2] + 1
f4c48d2eb7 2024-02-05 116: else
f4c48d2eb7 2024-02-05 117: k1_0[k2] = 1
f4c48d2eb7 2024-02-05 118: end
f4c48d2eb7 2024-02-05 119: end
f4c48d2eb7 2024-02-05 120: --~ 小字段号
f4c48d2eb7 2024-02-05 121: k1 = bit.band(o1_0[o1].setcode, 0xfff)
f4c48d2eb7 2024-02-05 122: --~ 字段名
f4c48d2eb7 2024-02-05 123: k2 = 字段名对[k1]
f4c48d2eb7 2024-02-05 124: if k1_0[k2] then
f4c48d2eb7 2024-02-05 125: k1_0[k2] = k1_0[k2] + 1
f4c48d2eb7 2024-02-05 126: elseif k2 == nil then
f4c48d2eb7 2024-02-05 127: else
f4c48d2eb7 2024-02-05 128: k1_0[k2] = 1
f4c48d2eb7 2024-02-05 129: end
130: end
131: end
132: --~ 目对
133: function d.残局改名(o1_0)
134: local k1_0, k2_0, k3_0, k4_0, k5_0, k6_0
135: --~ 文件排
136: k1_0 = f.历文(o1_0.文件目, 简文件库.dir)
137: k1_0 = f.历排(k1_0, f.全筛后缀, ".lua")
138: for o1 = 1, #k1_0 do
139: k1_0[o1] = f.加前缀(k1_0[o1], o1_0.文件目)
140: k1_0[o1] = f.读文件(k1_0[o1])
141: k1_0[o1] = string.gsub(k1_0[o1], "%-%-" .. "%[(=*)%[" .. ".-" .. "%]%1%]", "")
142: k1_0[o1] = string.gsub(k1_0[o1], "%-%-" .. "[^\n]*", "")
143: end
144: --~ 则数排
145: k2_0 = f.历排(k1_0, d.局筛则数)
146: --~ 各文件的卡编排
147: k3_0 = f.历排(k1_0, d.局筛卡编)
148: _G.数据库 = 简数据库库.open(o1_0.数据库路)
149: --~ 各文件的卡对排
150: k4_0 = f.历排(k3_0, d.取卡对_一维)
151: --~ 有效果卡的张数排
152: k5_0 = f.历排(k4_0, d.筛有效果卡的张数)
153: --~ 荐名排
154: k6_0 = f.历排(k4_0, d.荐名)
155: --~ print(k6_0[0])
156: --~ print(k5_0[2])
157: end
158: d.目对 = {
159: ["文件目"] = "../single/"
160: , ["数据库路"] = [[D:\install\YGOPro\cards.cdb]]
161: }
162: for o1_0, o2_0 in pairs(d.目对) do
163: d.目对[o1_0] = f.操类(o2_0, "string", u8)
164: end
165: d.残局改名(d.目对)