Files
Sun1602/Tools/ScriptChecker/rules.rb
T
2022-10-26 12:25:11 +08:00

89 lines
3.1 KiB
Ruby

# *ItemInfo.txt
class ItemInfoScript < Script
def initialize(required, name, path)
super(required, name, path)
end
def check_rule(columns)
super
code = columns[col_index('Code')].strip.to_i
type = columns[col_index('Type')].strip.to_i
level = columns[col_index('Level')].strip.to_i
sockets = columns[col_index('SocketUse')].strip.to_i
dup_num = columns[col_index('DupNum')].strip.to_i
charge_subtype = columns[col_index('ChargeSubType')].strip.to_i
# ItemCode 중복 불가
if checker.item_table.has_key?(code)
puts "[ERROR] #{@name} : Code #{code} 중복 #{checker.item_table[code]} (line #{@line_num})"
set_error
else
checker.item_table[code] = "#{@name} line #{@line_num}"
end
# 0 < ItemCode <= 65535
if code <= 0 or 65535 < code
puts "[ERROR] #{@name} : Code #{code} 범위 오류 (line #{@line_num})"
set_error
end
# 아이템 타입은 0보다 커야
if type <= 0
puts "[ERROR] #{@name} : Type #{type} 범위 오류 (line #{@line_num})"
end
# 아이템 레벨은 0보다 커야
#if level <= 0
# puts "[WARNING] #{@name} : Level #{level} 범위 오류 (line #{@line_num})"
#end
# 소켓 홀 갯수는 255 이하
if sockets < 0 or 255 < sockets
puts "[ERROR] #{@name} : SocketUse #{sockets} 범위 오류 (line #{@line_num})"
set_error
end
dup_num = columns[col_index('DupNum')].to_i
if dup_num <= 0
# 겹치기 갯수는 0보다 커야
puts "[ERROR] #{@name} : DupNum #{dup_num} 범위 오류 (line #{@line_num})"
set_error
elif dup_num > 1
# 겹치는 아이템은 유효기간을 가지지 않는다
unless charge_subtype == 0 or charge_subtype == 7
puts "[ERROR] #{@name} : ChargeSubType+DupNum #{charge_subtype}+#{dup_num} 불일치 (line #{@line_num})"
set_error
end
# 무기/방어구/목걸이/반지/장신구는 겹칠 수 없다
if type < 900 and not (type == 886 or type == 887)
puts "[ERROR] #{@name} : Type+DupNum #{charge_subtype}+#{dup_num} 불일치 (line #{@line_num})"
set_error
end
end
end
end
# Filter.txt & FilterName.txt
class FilterScript < Script
def initialize(required, name, path)
super(required, name, path)
# 컬럼 내용 중 공백 체크 건너뜀
@should_check_space = false
end
end
# AbusingOption.txt
class AbusingOptionScript < Script
def initialize(required, name, path)
super(required, name, path)
@table = {}
end
def check_rule(columns)
super
# AbuseType + AbuseSubType 조합은 중복 불가
type = columns[col_index('AbuseType')]
subtype = columns[col_index('AbuseSubType')]
if @table.has_key?([ type, subtype ])
puts "[ERROR] #{@name} : AbuseType+AbuseSubType #{type}+#{subtype} 중복 line #{@table[ [ type, subtype ] ]} (line #{@line_num})"
set_error
else
@table[ [ type, subtype ] ] = @line_num
end
end
end