-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSE.lua
More file actions
750 lines (683 loc) · 29.1 KB
/
JSE.lua
File metadata and controls
750 lines (683 loc) · 29.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
--[[
Copyright © 2025, Nalfey of Asura
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of JSE nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Nalfey BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]
_addon.name = 'JSE'
_addon.author = 'Nalfey'
_addon.version = '1.11'
_addon.commands = {'jse'}
require('chat')
require('lists')
require('logger')
require('sets')
require('tables')
require('strings')
require('pack')
-- Load tracking module for window functionality
tracking = require('tracking')
file = require('files')
slips = require('slips')
res = require('resources')
job_equipment = require('job_equipment')
currency = require('currency')
inventory = require('inventory')
zone_search = windower.ffxi.get_info().logged_in
first_pass = true
item_names = T{}
key_item_names = T{}
global_storages = T{}
-- JSE-specific storage slip ordering
local storage_slips_order = slips.storages:map(function(id)
return 'slip ' .. res.items[id].english:lower():match('^storage slip (.*)$')
end)
merged_storages_orders = inventory.storages_order + storage_slips_order + L{'key items'}
function update()
if not windower.ffxi.get_info().logged_in then
error('You have to be logged in to use this addon.')
return false
end
if zone_search == false then
notice('JSE has not detected a fully loaded inventory yet.')
return false
end
local player_name = windower.ffxi.get_player().name
local local_storage = inventory.get_local_storage()
if not local_storage then
return false
end
global_storages[player_name] = local_storage
return inventory.update()
end
function update_global_storage()
global_storages = inventory.update_global_storage()
end
windower.register_event('incoming chunk', function(id,original,modified,injected,blocked)
local seq = original:unpack('H',3)
if (next_sequence and seq == next_sequence) and zone_search then
inventory.update()
next_sequence = nil
end
if id == 0x00B then
zone_search = false
elseif id == 0x00A then
zone_search = false
elseif id == 0x01D and not zone_search then
zone_search = true
next_sequence = (seq+22)%0x10000
elseif (id == 0x1E or id == 0x1F or id == 0x20) and zone_search then
next_sequence = (seq+22)%0x10000
end
end)
windower.register_event('ipc message', function(str)
if str == 'jse update' then
inventory.update()
end
end)
handle_command = function(...)
local params = L{...}
if not params[1] or not params[2] then
log('Usage:')
log(' //jse [af|relic|empy] JOB - Check equipment and upgrade materials for a specific job')
log(' //jseall [af|relic|empy] JOB - Check equipment across all characters')
log(' //jsehelp - Display this help message')
return
end
local armor_type = params[1]:lower()
local job = params[2]:upper()
if armor_type == 'af' then
find_cards(job, 'ARTIFACT')
elseif armor_type == 'relic' then
find_cards(job, 'RELIC')
elseif armor_type == 'empy' then
find_cards(job, 'EMPYREAN')
else
log('Invalid armor type. Use: af, relic, or empy')
return
end
end
windower.register_event('unhandled command', function(command, ...)
local args = T{...}
if command:lower() == 'jsehelp' then
log('JSE Addon Commands:')
log('Artifact Commands:')
log(' //jse af JOB - Check artifact equipment and upgrade materials for a specific job')
log(' //jseall af JOB - Check artifact equipment across all characters')
log(' //jsetrack af JOB - Check artifact equipment and display in tracking window')
log('Relic Commands:')
log(' //jse relic JOB - Check relic equipment and upgrade materials for a specific job')
log(' //jsetrack relic JOB - Check relic equipment and display in tracking window')
log('Empyrean Commands:')
log(' //jse empy JOB - Check empyrean equipment and upgrade materials for a specific job')
log(' //jsetrack empy JOB - Check empyrean equipment and display in tracking window')
log('Currency Commands:')
log(' //jsecurrency - Display tracked currencies and their values')
log(' //jsecurrencydebug - Display debug information about currency values')
log('Window Commands:')
log(' //jsetrack hide - Hide the tracking window')
log(' //jsetrack show - Show the tracking window')
log(' //jsehelp - Display this help message')
return
elseif command:lower() == 'jsetrack' then
if not args[1] then
log('Usage: //jsetrack [af|relic|empy] JOB')
log(' //jsetrack [hide|show]')
return
end
if args[1]:lower() == 'hide' then
tracking.hide_window()
return
elseif args[1]:lower() == 'show' then
tracking.show_window()
return
end
if not args[2] then
log('Usage: //jsetrack [af|relic|empy] JOB')
return
end
local armor_type = args[1]:lower()
local job = args[2]:upper()
if armor_type == 'af' then
tracking.start_tracking()
find_cards(job, 'ARTIFACT')
tracking.stop_tracking()
elseif armor_type == 'relic' then
tracking.start_tracking()
find_cards(job, 'RELIC')
tracking.stop_tracking()
elseif armor_type == 'empy' then
tracking.start_tracking()
find_cards(job, 'EMPYREAN')
tracking.stop_tracking()
else
log('Invalid armor type. Use: af, relic, or empy')
return
end
elseif command:lower() == 'jsecurrency' then
-- Request an update of currency values before displaying
currency.request_update()
-- Display the currency values
currency.display_values()
return
elseif command:lower() == 'jsecurrencydebug' then
-- Request an update of currency values before displaying debug info
currency.request_update()
-- Get and display the raw packet data
local packet_data = currency.get_debug_packet()
log('Packet 0x118 Debug Information:')
log('----------------------------')
-- Display all fields in the packet
for field, value in pairs(packet_data) do
if type(value) ~= 'function' then -- Skip function fields
log(field .. ': ' .. tostring(value))
end
end
return
elseif command:lower() == 'jse' then
if not args[1] or not args[2] then
log('Usage: //jse [af|relic|empy] JOB')
return
end
local armor_type = args[1]:lower()
local job = args[2]:upper()
if armor_type == 'af' then
find_cards(job, 'ARTIFACT')
elseif armor_type == 'relic' then
find_cards(job, 'RELIC')
elseif armor_type == 'empy' then
find_cards(job, 'EMPYREAN')
else
log('Invalid armor type. Use: af, relic, or empy')
return
end
elseif command:lower() == 'jseall' then
if not args[1] or not args[2] then
log('Usage: //jseall [af|relic|empy] JOB')
return
end
local armor_type = args[1]:lower()
local job = args[2]:upper()
if armor_type == 'af' then
find_cards_all(job, 'ARTIFACT')
elseif armor_type == 'relic' then
find_cards_all(job, 'RELIC')
elseif armor_type == 'empy' then
find_cards_all(job, 'EMPYREAN')
else
log('Invalid armor type. Use: af, relic, or empy')
end
end
end)
windower.register_event('addon command', handle_command)
function find_cards(job, armor_type)
if not job_equipment[job] or not job_equipment[job][armor_type] then
log('No ' .. armor_type:lower() .. ' equipment data found for job: ' .. job)
return
end
-- Ensure we're logged in and storage is up to date
if not windower.ffxi.get_info().logged_in then
error('You have to be logged in to use this command.')
return
end
if not update() then
error('Failed to update storage information.')
return
end
-- Request an update of currency values and wait briefly for the response
currency.request_update()
coroutine.sleep(1)
local total_cards = 0
local has_upgrades = false
local card_name = 'P. ' .. job .. ' Card'
local player_name = windower.ffxi.get_player().name
log('Checking ' .. job .. ' equipment...')
-- Get fresh storage data
local local_storage = inventory.get_local_storage()
-- Only count cards for ARTIFACT equipment
local existing_cards = 0
if armor_type == 'ARTIFACT' then
for storage_name, items in pairs(local_storage) do
if storage_name ~= 'gil' and storage_name ~= 'key items' then
for item_id, quantity in pairs(items) do
local item = res.items[tonumber(item_id)]
if item and item.name == card_name then
existing_cards = existing_cards + quantity
end
end
end
end
end
-- Helper function to map material names to currency names
local function map_currency_name(material_name)
-- Handle Rem's Tales chapter name mapping
local chapter = material_name:match("^Rem's Tale Ch%.(%d+)$")
if chapter then
local mapped_name = "Rem's Tale Chapters " .. chapter .. " Stored"
return mapped_name
end
-- Handle other currency mappings
local currency_mappings = {
["Gallimaufry"] = "Gallimaufry",
["Apollyon Units"] = "Apollyon Units",
["Temenos Units"] = "Temenos Units"
}
return currency_mappings[material_name] or material_name
end
-- Helper function to get currency count
local function get_currency_count(material_name)
-- Map the material name to its currency name
local currency_name = map_currency_name(material_name)
-- Check if this is a tracked currency
if currency_name:match("^Rem's Tale Chapters %d+ Stored$") or
currency_name:match("Units$") or
currency_name == "Gallimaufry" then
local value = currency.get_value(currency_name)
return value or 0
end
-- If not a currency, check all storage locations
local count = 0
for storage_name, items in pairs(local_storage) do
if storage_name ~= 'gil' and storage_name ~= 'key items' then
for item_id, quantity in pairs(items) do
local item = res.items[tonumber(item_id)]
if item and item.name == material_name then
count = count + quantity
end
end
end
end
return count
end
-- Helper function to display materials
local function display_materials(mats)
if not mats then return end
local mat_strings = {}
for _, mat in ipairs(mats) do
local count = get_currency_count(mat.name)
local color = count >= mat.count and 200 or 167
local count_str = count >= mat.count
and tostring(count):color(200)
or tostring(count)
table.insert(mat_strings, mat.name .. ': ' .. count_str .. '/' .. tostring(mat.count):color(color))
end
if #mat_strings > 0 then
log(' Required materials: ' .. table.concat(mat_strings, ', '))
end
end
-- Check the specified armor type
for index, equip_data in ipairs(job_equipment[job][armor_type]) do
local equip_names = equip_data[1]
local cards_needed = equip_data[2]
local materials = equip_data[3]
local base_name = equip_names[1]
local found_plus4 = false
local found_plus3 = false
local found_plus2 = false
local found_plus1 = false
local found_nq = false
for storage_name, items in pairs(local_storage) do
if storage_name ~= 'gil' and storage_name ~= 'key items' then
for item_id, quantity in pairs(items) do
local item = res.items[tonumber(item_id)]
if item and item.name then
for _, name in ipairs(equip_names) do
if name then
local plus1_name = name .. ' +1'
local plus2_name = name .. ' +2'
local plus3_name = name .. ' +3'
local plus4_name = name .. ' +4'
if item.name == plus4_name then
found_plus4 = true
log(base_name:color(255) .. ': ' .. 'Already +4':color(158))
break
elseif item.name == plus3_name then
found_plus3 = true
elseif item.name == plus2_name then
found_plus2 = true
elseif item.name == plus1_name then
found_plus1 = true
elseif item.name == name then
found_nq = true
end
end
end
end
if found_plus4 then break end
end
end
if found_plus4 then break end
end
if not found_plus4 then
has_upgrades = true
if found_plus3 then
if materials and materials["+4"] then
for _, mat in ipairs(materials["+4"]) do
if mat.name:match("Units$") then
log((base_name .. ' +3'):color(255) .. ': Can upgrade to ' .. '+4':color(158))
display_materials(materials["+4"])
break
end
end
else
log((base_name .. ' +3'):color(255))
end
elseif found_plus2 then
if armor_type == 'ARTIFACT' then
local plus2_cards
if index == 1 then plus2_cards = 12
elseif index == 2 then plus2_cards = 15
elseif index == 3 then plus2_cards = 9
elseif index == 4 then plus2_cards = 12
elseif index == 5 then plus2_cards = 9 end
total_cards = total_cards + plus2_cards
log((base_name .. ' +2'):color(255) .. ': Can upgrade to ' .. '+3':color(158))
if materials and materials["+3"] then
display_materials(materials["+3"])
end
else
log((base_name .. ' +2'):color(255) .. ': Can upgrade to ' .. '+3':color(158))
if materials and materials["+3"] then
display_materials(materials["+3"])
end
end
elseif found_plus1 then
if armor_type == 'ARTIFACT' then
total_cards = total_cards + cards_needed
log((base_name .. ' +1'):color(255) .. ': Can upgrade to ' .. '+2':color(158))
if materials and materials["+2"] then
display_materials(materials["+2"])
end
else
log((base_name .. ' +1'):color(255) .. ': Can upgrade to ' .. '+2':color(158))
if materials and materials["+2"] then
display_materials(materials["+2"])
end
end
elseif found_nq then
if armor_type == 'ARTIFACT' then
total_cards = total_cards + cards_needed
log(base_name:color(255) .. ': Can upgrade to ' .. '+1':color(158))
if materials and materials["+1"] then
display_materials(materials["+1"])
end
else
log(base_name:color(255) .. ': Can upgrade to ' .. '+1':color(158))
if materials and materials["+1"] then
display_materials(materials["+1"])
end
end
else
log(base_name:color(255) .. ': Not found')
end
end
end
if armor_type == 'ARTIFACT' and total_cards > 0 then
log('Total ' .. card_name .. 's needed: ' .. tostring(total_cards):color(158))
log('You currently have: ' .. tostring(existing_cards):color(158) .. ' cards')
local remaining_cards = total_cards - existing_cards
if remaining_cards > 0 then
log('Additional cards needed: ' .. tostring(remaining_cards):color(158))
end
elseif not has_upgrades then
log('No upgrades needed')
if armor_type == 'ARTIFACT' then
log('You currently have: ' .. tostring(existing_cards):color(158) .. ' cards')
end
end
end
windower.register_event('load', function()
if windower.ffxi.get_info().logged_in then
inventory.update()
end
end)
windower.register_event('login', function()
inventory.update()
end)
function find_cards_all(job, armor_type)
if not job_equipment[job] or not job_equipment[job][armor_type] then
log('No ' .. armor_type:lower() .. ' equipment data found for job: ' .. job)
return
end
-- First, check equipment on current character
if not windower.ffxi.get_info().logged_in then
error('You have to be logged in to use this command.')
return
end
if not update() then
error('Failed to update storage information.')
return
end
-- Request an update of currency values and wait briefly for the response
currency.request_update()
coroutine.sleep(1)
local total_cards = 0
local has_upgrades = false
local card_name = 'P. ' .. job .. ' Card'
local player_name = windower.ffxi.get_player().name
log('Checking ' .. job .. ' equipment...')
-- Helper function to map material names to currency names
local function map_currency_name(material_name)
-- Handle Rem's Tales chapter name mapping
local chapter = material_name:match("^Rem's Tale Ch%.(%d+)$")
if chapter then
local mapped_name = "Rem's Tale Chapters " .. chapter .. " Stored"
return mapped_name
end
-- Handle other currency mappings
local currency_mappings = {
["Gallimaufry"] = "Gallimaufry",
["Apollyon Units"] = "Apollyon Units",
["Temenos Units"] = "Temenos Units"
}
return currency_mappings[material_name] or material_name
end
-- Helper function to get currency count
local function get_currency_count(material_name)
-- Map the material name to its currency name
local currency_name = map_currency_name(material_name)
-- Check if this is a tracked currency
if currency_name:match("^Rem's Tale Chapters %d+ Stored$") or
currency_name:match("Units$") or
currency_name == "Gallimaufry" then
local value = currency.get_value(currency_name)
return value or 0
end
-- If not a currency, check all storage locations
local count = 0
for storage_name, items in pairs(global_storages[player_name]) do
if storage_name ~= 'gil' and storage_name ~= 'key items' then
for item_id, quantity in pairs(items) do
local item = res.items[tonumber(item_id)]
if item and item.name == material_name then
count = count + quantity
end
end
end
end
return count
end
-- Helper function to display materials
local function display_materials(mats)
if not mats then return end
local mat_strings = {}
for _, mat in ipairs(mats) do
local count = get_currency_count(mat.name)
local color = count >= mat.count and 200 or 167
local count_str = count >= mat.count
and tostring(count):color(200)
or tostring(count)
table.insert(mat_strings, mat.name .. ': ' .. count_str .. '/' .. tostring(mat.count):color(color))
end
if #mat_strings > 0 then
log(' Required materials: ' .. table.concat(mat_strings, ', '))
end
end
-- Check the specified armor type for current character
for index, equip_data in ipairs(job_equipment[job][armor_type]) do
local equip_names = equip_data[1]
local cards_needed = equip_data[2]
local materials = equip_data[3]
local base_name = equip_names[1]
local found_plus4 = false
local found_plus3 = false
local found_plus2 = false
local found_plus1 = false
local found_nq = false
local storages = global_storages[player_name]
if storages then
for storage_name, items in pairs(storages) do
if storage_name ~= 'gil' and storage_name ~= 'key items' then
for item_id, quantity in pairs(items) do
local item = res.items[tonumber(item_id)]
if item and item.name then
for _, name in ipairs(equip_names) do
if name then
local plus1_name = name .. ' +1'
local plus2_name = name .. ' +2'
local plus3_name = name .. ' +3'
local plus4_name = name .. ' +4'
if item.name == plus4_name then
found_plus4 = true
log(base_name:color(255) .. ': ' .. 'Already +4':color(158))
break
elseif item.name == plus3_name then
found_plus3 = true
elseif item.name == plus2_name then
found_plus2 = true
elseif item.name == plus1_name then
found_plus1 = true
elseif item.name == name then
found_nq = true
end
end
end
end
if found_plus4 then break end
end
end
if found_plus4 then break end
end
end
if not found_plus4 then
has_upgrades = true
if found_plus3 then
if materials and materials["+4"] then
for _, mat in ipairs(materials["+4"]) do
if mat.name:match("Units$") then
log((base_name .. ' +3'):color(255) .. ': Can upgrade to ' .. '+4':color(158))
display_materials(materials["+4"])
break
end
end
else
log((base_name .. ' +3'):color(255))
end
elseif found_plus2 then
if armor_type == 'ARTIFACT' then
local plus2_cards
if index == 1 then plus2_cards = 12
elseif index == 2 then plus2_cards = 15
elseif index == 3 then plus2_cards = 9
elseif index == 4 then plus2_cards = 12
elseif index == 5 then plus2_cards = 9 end
total_cards = total_cards + plus2_cards
log((base_name .. ' +2'):color(255) .. ': Can upgrade to ' .. '+3':color(158))
if materials and materials["+3"] then
display_materials(materials["+3"])
end
else
log((base_name .. ' +2'):color(255) .. ': Can upgrade to ' .. '+3':color(158))
if materials and materials["+3"] then
display_materials(materials["+3"])
end
end
elseif found_plus1 then
if armor_type == 'ARTIFACT' then
total_cards = total_cards + cards_needed
log((base_name .. ' +1'):color(255) .. ': Can upgrade to ' .. '+2':color(158))
if materials and materials["+2"] then
display_materials(materials["+2"])
end
else
log((base_name .. ' +1'):color(255) .. ': Can upgrade to ' .. '+2':color(158))
if materials and materials["+2"] then
display_materials(materials["+2"])
end
end
elseif found_nq then
if armor_type == 'ARTIFACT' then
total_cards = total_cards + cards_needed
log(base_name:color(255) .. ': Can upgrade to ' .. '+1':color(158))
if materials and materials["+1"] then
display_materials(materials["+1"])
end
else
log(base_name:color(255) .. ': Can upgrade to ' .. '+1':color(158))
if materials and materials["+1"] then
display_materials(materials["+1"])
end
end
else
log(base_name:color(255) .. ': Not found')
end
end
end
-- Check all characters for cards only if it's ARTIFACT armor
if armor_type == 'ARTIFACT' then
update_global_storage()
local total_available_cards = 0
local cards_by_char = {}
for char_name, storage in pairs(global_storages) do
local char_cards = 0
for storage_name, items in pairs(storage) do
if storage_name ~= 'gil' and storage_name ~= 'key items' then
for item_id, quantity in pairs(items) do
local item = res.items[tonumber(item_id)]
if item and item.name == card_name then
char_cards = char_cards + quantity
end
end
end
end
if char_cards > 0 then
cards_by_char[char_name] = char_cards
total_available_cards = total_available_cards + char_cards
end
end
-- Display card results for ARTIFACT only
if total_cards > 0 then
log('Total ' .. card_name .. 's needed: ' .. tostring(total_cards):color(158))
log('Available cards by character:')
for char_name, count in pairs(cards_by_char) do
log(' ' .. char_name .. ': ' .. tostring(count):color(158))
end
log('Total available cards: ' .. tostring(total_available_cards):color(158))
local remaining_cards = total_cards - total_available_cards
if remaining_cards > 0 then
log('Additional cards needed: ' .. tostring(remaining_cards):color(158))
end
end
end
if not has_upgrades then
log('No upgrades needed')
end
end