游戏王残局简化版

Annotation For 残局文料/残局荐名.lua
Login

Annotation For 残局文料/残局荐名.lua

Origin for each line in 残局文料/残局荐名.lua from check-in 47f6d96028:

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