@@ -408,40 +408,110 @@ function describeMod(mod)
408
408
return out , orders
409
409
end
410
410
411
- function describeScalability (fileName )
411
+ -- stats placed in statDesc order, order gives order in mods, and sign gives which use a postive sign.
412
+ -- [Mod] = { { order = { 1, 2 }, sign = { 1 }, formats = { general = { "cononicalLine" }, [1] = { "formatA", "formatB", "formatC", etc }, [2] = {#2 stat formats}, }, "statA", "statB" }, { }, { }}
413
+ function describeStatOnMod (fileName )
412
414
local out = { }
413
- local stats = dat (" stats" )
414
- for stat , statDescription in pairs (statDescriptors [fileName ]) do
415
- local scalability = { }
415
+ local uniqueStatDescriptors = {}
416
+ for _ , statDescription in pairs (statDescriptors [fileName ]) do
417
+ uniqueStatDescriptors [statDescription ] = true
418
+ end
419
+ for statDescription , _ in pairs (uniqueStatDescriptors ) do
416
420
if statDescription .stats then
417
- for i , stat in ipairs (statDescription .stats ) do
418
- table.insert (scalability , stats :GetRow (" Id" , stat ).IsScalable )
419
- end
420
421
for _ , wordings in ipairs (statDescription [1 ]) do
421
- local wordingFormats = {}
422
- local inOrderScalability = { }
422
+ local formats = {}
423
+ local order = { }
424
+ local signs = { }
423
425
for _ , format in ipairs (wordings ) do
424
426
if type (format .v ) == " number" then
425
- if wordingFormats [tonumber (format .v )] then
426
- table.insert (wordingFormats [tonumber (format .v )], format .k )
427
+ if formats [tonumber (format .v )] then
428
+ table.insert (formats [tonumber (format .v )], format .k )
429
+ else
430
+ formats [tonumber (format .v )] = { format .k }
431
+ end
432
+ else
433
+ if formats .general then
434
+ table.insert (formats .general , format .k )
427
435
else
428
- wordingFormats [ tonumber ( format . v )] = { format .k }
436
+ formats . general = { format .k }
429
437
end
430
438
end
431
439
end
432
- local strippedLine = wordings .text :gsub (" [%+%-]?(%b{})" , function (num )
440
+ local strippedLine = wordings .text :gsub (" ( [%+%-]?) (%b{})" , function (sign , num )
433
441
local statNum = (num :match (" %d" ) or 0 ) + 1
434
- table.insert (inOrderScalability , { isScalable = scalability [statNum ], formats = wordingFormats [statNum ] })
442
+ if sign == " +" or num :match (" %+" ) then table.insert (signs , statNum ) end
443
+ table.insert (order , statNum )
435
444
return " #"
436
445
end )
437
- if out [strippedLine ] then -- we want to use the format with the least oddites in it. If their are less formats then that will be used instead.
438
- for j , priorScalability in ipairs (out [strippedLine ]) do
439
- if (priorScalability .formats and # priorScalability .formats or 0 ) > (wordingFormats [j ] and # wordingFormats [j ] or 0 ) then
440
- out [strippedLine ][j ] = inOrderScalability [j ]
446
+ -- find values that are set and no present on the item.
447
+ local values = { }
448
+ for i , limit in ipairs (wordings .limit ) do
449
+ local present
450
+ for _ , statNum in ipairs (order ) do
451
+ if statNum == i then
452
+ present = true
453
+ end
454
+ end
455
+ if not present then
456
+ values [i ] = { }
457
+ if limit [1 ] == " #" and limit [2 ] == " #" then
458
+ values [i ].min = - math.huge
459
+ values [i ].max = math.huge
460
+ elseif limit [1 ] == " #" then
461
+ values [i ].min = - math.huge
462
+ values [i ].max = limit [2 ]
463
+ elseif limit [2 ] == " #" then
464
+ values [i ].min = limit [1 ]
465
+ values [i ].max = math.huge
466
+ elseif limit [1 ] ~= " !" then
467
+ values [i ].min = limit [1 ]
468
+ values [i ].max = limit [2 ]
469
+ break -- won't get smaller
470
+ else
471
+ values [i ] = nil
472
+ break
473
+ end
474
+ for _ , wordings in ipairs (statDescription [1 ]) do
475
+ for j , limit in ipairs (wordings .limit ) do
476
+ if i ~= j then
477
+ if limit [1 ] == " #" and type (limit [2 ]) == " number" then
478
+ if limit [2 ] > values [i ].min and limit [2 ] < values [i ].max then
479
+ values [i ].min = limit [2 ] + 1
480
+ end
481
+ elseif type (limit [1 ]) == " number" and limit [2 ] == " #" then
482
+ if limit [1 ] > values [i ].min and limit [1 ] < values [i ].max then
483
+ values [i ].max = limit [1 ] - 1
484
+ end
485
+ elseif type (limit [1 ]) == " number" and type (limit [2 ]) == " number" then
486
+ if limit [2 ] > values [i ].min and limit [2 ] < values [i ].max then
487
+ values [i ].min = limit [2 ] + 1
488
+ end
489
+ if limit [1 ] > values [i ].min and limit [1 ] < values [i ].max then
490
+ values [i ].max = limit [1 ] - 1
491
+ end
492
+ end
493
+ end
494
+ end
495
+ end
496
+ end
497
+ end
498
+ for i = 1 , # values do
499
+ if values [i ] then
500
+ if values [i ].max == values [i ].min then
501
+ values [i ] = values [i ].min
502
+ elseif values [i ].min == - math.huge and values [i ].max ~= math.huge then
503
+ values [i ] = values [i ].max
504
+ elseif values [i ].min ~= - math.huge and values [i ].max == math.huge then
505
+ values [i ] = values [i ].min
506
+ else
507
+ values [i ] = nil
441
508
end
442
509
end
443
- else -- no present
444
- out [strippedLine ] = inOrderScalability
510
+ end
511
+ if out [strippedLine ] then
512
+ table.insert (out [strippedLine ], { order = order , signs = signs , formats = formats , values = values , unpack (statDescription .stats )})
513
+ else
514
+ out [strippedLine ] = { { order = order , signs = signs , formats = formats , values = values , unpack (statDescription .stats )} }
445
515
end
446
516
end
447
517
end
0 commit comments