-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathChallengesManager.lua
914 lines (767 loc) · 23.6 KB
/
ChallengesManager.lua
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
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
ChallengesManagerRes = ChallengesManagerRes or class()
function ChallengesManagerRes:init()
self:_setup()
tweak_data:add_reload_callback( self, callback( self, self, "reloaded" ) )
end
function ChallengesManagerRes:reloaded()
self:_setup()
end
function ChallengesManagerRes:reset_challenges()
self:_setup( true )
end
function ChallengesManagerRes:_setup( reset )
self._counter_map = {}
self._flag_map = {}
self._challenges_map_res = {}
self._reset_map = {}
self._session_stopped_map = {}
for category,challenges in pairs( tweak_data.challenges_res ) do
for name,challenge in pairs( challenges ) do
--if managers.dlc:has_full_game() or (not challenge.awards_achievment and challenge.in_trial) then
self._challenges_map_res[ name ] = challenge
if challenge.counter_id then
self._counter_map[ challenge.counter_id ] = self._counter_map[ challenge.counter_id ] or {}
table.insert( self._counter_map[ challenge.counter_id ], name )
end
if challenge.flag_id then
self._flag_map[ challenge.flag_id ] = self._flag_map[ challenge.flag_id ] or {}
table.insert( self._flag_map[ challenge.flag_id ], name )
end
if challenge.reset_criterias then
for _,criteria in ipairs( challenge.reset_criterias ) do
self._reset_map[ criteria ] = self._reset_map[ criteria ] or {}
table.insert( self._reset_map[ criteria ], name )
end
end
if challenge.session_stopped then
-- self._session_stopped_map[ challenge.flag_id ] = self._flag_map[ challenge.flag_id ] or {}
table.insert( self._session_stopped_map, name )
end
--end
end
end
if not Global.challenges_manager_res or reset then
Global.challenges_manager_res = {}
Global.challenges_manager_res.active = {}
Global.challenges_manager_res.completed = {}
self._global = Global.challenges_manager_res
self:check_active_challenges()
end
self._global = Global.challenges_manager_res
end
function ChallengesManagerRes:challenge( name )
return self._challenges_map_res[ name ]
end
function ChallengesManagerRes:active_challenge( name )
return self._global.active[ name ]
end
function ChallengesManagerRes:add_already_awarded_challenge( name )
local challenge = self._challenges_map_res[ name ]
if challenge and not self._global.active[ name ] then
-- if managers.experience:current_level() >= challenge.unlock_level then
if self:_check_depends_on( name ) then
local t = {}
if challenge.counter_id then
t.amount = 0
end
if challenge.flag_id then
t.flag = false
end
t.already_awarded = true
self._global.active[ name ] = t
if challenge.counter_id then
for _, sub_challenge in ipairs( managers.challenges:get_completed() ) do
if self._challenges_map_res[ sub_challenge.id ].increment_counter == challenge.counter_id then
self:add_already_awarded_challenge( sub_challenge.id )
end
end
end
end
-- end
end
end
function ChallengesManagerRes:check_active_challenges()
local added = false
local current_level = managers.experience:current_level()
for name,challenge in pairs( self._challenges_map_res ) do
if not self._global.active[ name ] and not self._global.completed[ name ] then -- If not completed or activated
-- if current_level >= challenge.unlock_level then
if self:_check_depends_on( name ) then
local t = {}
if challenge.counter_id then
t.amount = 0
end
if challenge.flag_id then
t.flag = false
end
self._global.active[ name ] = t
added = true
end
-- end
end
end
if added then
if managers.hud then
-- managers.hud:present_mid_text( { text = "NEW CHALLENGES AVAILABLE", time = 4, icon = nil, event = "stinger_levelup" } )
end
end
end
function ChallengesManagerRes:_check_depends_on( name )
if not self._challenges_map_res[ name ].depends_on then
return true
end
if self._challenges_map_res[ name ].depends_on.challenges then
for _,challenge in ipairs( self._challenges_map_res[ name ].depends_on.challenges ) do
if not self._global.completed[ challenge ] then
return false
end
end
end
if self._challenges_map_res[ name ].depends_on.equipment then
local correct_equipment = false
for _,equipment in ipairs( self._challenges_map_res[ name ].depends_on.equipment ) do
if managers.blackmarket:equipped_deployable(1) == equipment or managers.blackmarket:equipped_deployable(2) == equipment then
correct_equipment = true
end
end
if not correct_equipment then
return false
end
end
if self._challenges_map_res[ name ].depends_on.primaries then
local correct_primary = false
local current_primary = managers.blackmarket:equipped_primary()
current_primary = managers.weapon_factory:get_weapon_id_by_factory_id(current_primary.factory_id)
for _, primary in ipairs(self._challenges_map_res[ name ].depends_on.primaries) do
if primary == current_primary then
correct_primary = true
end
end
if not correct_primary then
return false
end
end
if self._challenges_map_res[ name ].depends_on.secondaries then
local correct_secondary = false
local current_secondary = managers.blackmarket:equipped_secondary()
current_secondary = managers.weapon_factory:get_weapon_id_by_factory_id(current_secondary.factory_id)
for _, secondary in ipairs(self._challenges_map_res[ name ].depends_on.secondaries) do
if secondary == current_secondary then
correct_secondary = true
end
end
if not correct_secondary then
return false
end
end
if self._challenges_map_res[ name ].depends_on.masks then
local correct_mask = false
local equipped_mask = managers.blackmarket:equipped_mask()
local current_mask = managers.blackmarket:get_real_mask_id(equipped_mask.mask_id)
for _, mask in ipairs( self._challenges_map_res[ name ].depends_on.masks ) do
if mask == current_mask then
correct_mask = true
end
end
if not correct_mask then
return false
end
end
if self._challenges_map_res[ name ].depends_on.character then
local correct_character = false
local current_character = managers.blackmarket:get_real_character()
for _, character in ipairs( self._challenges_map_res[ name ].depends_on.character ) do
if character == current_character then
correct_character = true
end
end
if not correct_character then
return false
end
end
if self._challenges_map_res[ name ].depends_on.armors then
local correct_armor = false
for _, armor in ipairs( self._challenges_map_res[ name ].depends_on.armors ) do
if managers.blackmarket:equipped_armor() == armor then
correct_armor = true
end
end
if not correct_armor then
return false
end
end
if self._challenges_map_res[ name ].depends_on.melee_weapons then
local correct_melee = false
for _, melee_weapon in ipairs( self._challenges_map_res[ name ].depends_on.melee_weapons ) do
if managers.blackmarket:equipped_melee_weapon() == melee_weapon then
correct_melee = true
end
end
if not correct_melee then
return false
end
end
if self._challenges_map_res[ name ].depends_on.grenades then
local correct_grenade = false
for _, grenade in ipairs( self._challenges_map_res[ name ].depends_on.grenades ) do
if not managers.blackmarket:equipped_grenade() == grenade then
correct_grenade = true
end
end
if not correct_grenade then
return false
end
end
return true
end
function ChallengesManagerRes:add_by_name( name )
if not self._challenges_map_res[ name ] then
Application:error( "No challenges named", name )
return
end
if self._global.active[ name ] then
self._global.active[ name ].amount = self._global.active[ name ].amount + 1
self:_check_completed( name )
end
end
function ChallengesManagerRes:count_up( counter_id )
if not self._counter_map[ counter_id ] then
-- Application:error( "No counter id named", counter_id )
return
end
local actives = clone( self._global.active )
for _,name in ipairs( self._counter_map[ counter_id ] ) do
if actives[ name ] and (not self._global.completed[ name ] or actives[ name ].already_awarded) then
self._global.active[ name ].amount = self._global.active[ name ].amount + 1
self:_check_completed( name )
end
end
end
function ChallengesManagerRes:reset_counter( counter_id )
if not self._counter_map[ counter_id ] then
-- Application:error( "No counter id named", counter_id )
return
end
local actives = clone( self._global.active )
for _,name in ipairs( self._counter_map[ counter_id ] ) do
if actives[ name ] and (not self._global.completed[ name ] or actives[ name ].already_awarded) then
self._global.active[ name ].amount = 0
end
end
end
function ChallengesManagerRes:set_flag( flag_id )
if not self._flag_map[ flag_id ] then
Application:error( "No flag id named", flag_id )
return
end
for _,name in ipairs( self._flag_map[ flag_id ] ) do
if self._global.active[ name ] and (not self._global.completed[ name ] or self._global.active[ name ].already_awarded) then
self._global.active[ name ].flag = true
self:_check_completed( name )
end
end
end
function ChallengesManagerRes:session_stopped( ... )
local actives = clone( self._global.active )
for _,name in ipairs( self._session_stopped_map ) do
if actives[ name ] and (not self._global.completed[ name ] or actives[ name ].already_awarded) then
local function_name = self._challenges_map_res[ name ].session_stopped.callback
if self[ function_name ]( self, name, ... ) then
self:_completed_challenge( name )
end
end
end
end
function ChallengesManagerRes:_check_completed( name )
local counter_ok = (not self._global.active[ name ].amount) or self._global.active[ name ].amount >= self._challenges_map_res[ name ].count
local flag_ok = self._global.active[ name ].flag == nil or self._global.active[ name ].flag
if counter_ok and flag_ok then
self:_completed_challenge( name )
end
end
function ChallengesManagerRes:_completed_challenge( name )
local already_awarded = self._global.active[ name ].already_awarded
self._global.completed[ name ] = true
self._global.active[ name ] = nil
if not already_awarded then
self._global.last_completed = name
if managers.hud then
local title = managers.localization:text( "present_challenge_completed_title" )
local text = self:get_title_text( name )
managers.hud:present_mid_text( { title = title, text = text, time = 4, icon = nil, event = "stinger_objectivecomplete", type = "challenge" } )
end
-- local cc_reward = self._challenges_map_res[ name ].cc
-- if cc_reward then
-- managers.custom_safehouse:add_coins( cc_reward, true )
-- else
-- return
-- end
-- managers.experience:add_points( self._challenges_map_res[ name ].xp, true )
if self._challenges_map_res[ name ].cc then
managers.custom_safehouse:add_coins( self._challenges_map_res[ name ].cc )
end
end
if self._challenges_map_res[ name ].increment_counter then
self:count_up( self._challenges_map_res[ name ].increment_counter )
end
--local achievement = self:get_awarded_achievment( name )
--if achievement then
-- managers.achievment:award( achievement )
--end
self:check_active_challenges()
end
function ChallengesManagerRes:reset( criteria )
if not self._reset_map[ criteria ] then
return
end
for _,name in ipairs( self._reset_map[ criteria ] ) do
if self._global.active[ name ] then
if self._global.active[ name ].amount then
self._global.active[ name ].amount = 0
end
if self._global.active[ name ].flag ~= nil then
self._global.active[ name ].flag = false
end
end
end
end
function ChallengesManagerRes:get_near_completion()
self:check_active_challenges()
local t = {}
for id, data in pairs( self._global.active ) do
if self._challenges_map_res[ id ] and not data.already_awarded then
local progress, count, amount
if data.amount then
progress = data.amount / self._challenges_map_res[ id ].count
count = self._challenges_map_res[ id ].count
amount = data.amount
else
progress = 0
count = 1
amount = 0
end
local name = self:get_title_text( id )
local description = self:get_description_text( id )
if not string.match(name, "_npc") and not string.match(name, "_crew") then
table.insert( t, { id = id, progress = progress, count = count, amount = amount, name = name, description = description } )
end
end
end
local sort_func = function( data1, data2 )
if data1.progress == data2.progress then
return data1.id < data2.id
end
return data1.progress > data2.progress
end
table.sort( t, sort_func )
return t
end
function ChallengesManagerRes:is_completed( id )
return self._global.completed[ id ]
end
function ChallengesManagerRes:get_completed()
local t = {}
for id,data in pairs( self._global.completed ) do
if self._challenges_map_res[ id ] then
local name = self:get_title_text( id )
local description = self:get_description_text( id )
table.insert( t, { id = id, name = name, description = description } )
end
end
local sort_func = function( data1, data2 )
return data1.id < data2.id
end
table.sort( t, sort_func )
return t
end
function ChallengesManagerRes:get_last_comleted_title_text()
if not self._global.last_completed or not self._challenges_map_res[ self._global.last_completed ] then
return ""
end
return self:get_title_text( self._global.last_completed )
end
function ChallengesManagerRes:get_last_comleted_description_text()
if not self._global.last_completed or not self._challenges_map_res[ self._global.last_completed ] then
return ""
end
return self:get_description_text( self._global.last_completed, true )
end
function ChallengesManagerRes:get_title_text( name )
local ch_data = self._challenges_map_res[ name ]
if ch_data.title_id and ch_data.weapName then
return managers.localization:text(ch_data.title_id, {
weapon = managers.localization:text(tweak_data.weapon[ch_data.weapName] and tweak_data.weapon[ch_data.weapName].name_id or "menu_" .. ch_data.weapName),
no = self:NumberToNumeral(ch_data.i),
eneType = managers.localization:text("ene_" .. ch_data.ene)
})
elseif ch_data.title_id then
return managers.localization:text(ch_data.title_id)
else
return name
end
end
function ChallengesManagerRes:NumberToNumeral(no)
if not no or no <= 0 then
return ""
end
local numbers = { 1, 5, 10, 50, 100, 500, 1000 }
local chars = { "I", "V", "X", "L", "C", "D", "M" }
local roman = ""
for i = #numbers, 1, -1 do
local num = numbers[i]
while no - num >= 0 and no > 0 do
roman = roman .. chars[i]
no = no - num
end
for j = 1, i - 1 do
local num2 = numbers[j]
if no - (num - num2) >= 0 and num > no and no > 0 and num - num2 ~= num2 then
roman = roman .. chars[j] .. chars[i]
no = no - (num - num2)
break
end
end
end
return roman
end
function ChallengesManagerRes:get_description_text( name )
local ch_data = self._challenges_map_res[ name ]
if ch_data.description_id then
return managers.localization:text(ch_data.description_id, {
weapon = ch_data.weapName and managers.localization:text(tweak_data.weapon[ch_data.weapName] and tweak_data.weapon[ch_data.weapName].name_id or "menu_" .. ch_data.weapName) or nil,
count = ch_data.count,
eneType = managers.localization:text("ene_" .. tostring(ch_data.ene) .. "_desc")
})
else
return name
end
end
function ChallengesManagerRes:get_awarded_achievment( name )
local achievment = self._challenges_map_res[ name ].awards_achievment
if managers.achievment:exists( achievment ) then
return achievment
end
return nil
end
function ChallengesManagerRes:check_text()
for name,_ in pairs( self._challenges_map_res ) do
print( self:get_title_text( name ) )
print( self:get_description_text( name ).."\n" )
end
end
----------------------------------------------------
function ChallengesManagerRes:amount_of_challenges()
local i = 0
for _,_ in pairs( self._challenges_map_res ) do
i = i + 1
end
return i
end
function ChallengesManagerRes:amount_of_completed_challenges()
local i = 0
for id,_ in pairs( self._global.completed ) do
if self._challenges_map_res[ id ] then
i = i + 1
end
end
return i
end
----------------------------------------------------
-- Session stopped callback functions -------------
function ChallengesManagerRes:_check_level_completed( data )
if not data.success then
return false
end
if not data.from_beginning then
return false
end
return true
end
function ChallengesManagerRes:_correct_level( level_id )
-- if not (Global.level_data and Global.level_data.level_id) then
-- return false
-- end
-- return Global.level_data.level_id == level_id
if not Global.load_level then
return
end
local current_level = managers.job:current_level_id()
if type( level_id ) == "table" then
for _, level in ipairs( level_id ) do
if level == current_level then
return true
end
end
return false
end
if level_id ~= current_level then
return false
end
return true
end
function ChallengesManagerRes:_correct_job( job_id )
if not Global.job_manager.current_job then
return
end
local current_job = managers.job:current_real_job_id()
if type( job_id ) == "table" then
for _, job in ipairs( job_id ) do
if job == current_job then
return true
end
end
return false
end
if job_id ~= current_job then
return false
end
return true
end
function ChallengesManagerRes:_correct_difficulty( difficulty )
local curr_diff = Global.game_settings.difficulty
if type( difficulty ) == "table" then
for _, diff in ipairs( difficulty ) do
if diff == curr_diff then
return true
end
end
return false
end
if difficulty ~= curr_diff then
return false
end
return true
end
function ChallengesManagerRes:never_downed( name, data )
if not self:_check_level_completed( data ) then
return
end
if data.last_session.downed.bleed_out > 0 then
return
end
return true
end
function ChallengesManagerRes:aquired_money()
local ach_name
for name,challenge in pairs( self._challenges_map_res ) do
if challenge.id == "aquired_money" and self._global.active[ name ] then
ach_name = name
break
end
end
if not ach_name then
return
end
local money = managers.money:offshore()
--log(money)
if money < self._challenges_map_res[ ach_name ].amount then
return
end
self:_completed_challenge( ach_name )
end
function ChallengesManagerRes:no_civilians_killed( name, data )
if not self:_correct_level( self._challenges_map_res[ name ].level_id ) then
return
end
if not self:_correct_difficulty( self._challenges_map_res[ name ].difficulty ) then
return
end
if not self:_check_level_completed( data ) then
return
end
if managers.statistics:session_total_civilian_kills() > 0 then
return
end
return true
end
function ChallengesManagerRes:no_kills( name, data )
if not self:_correct_level( self._challenges_map_res[ name ].level_id ) then
return
end
if not self:_correct_difficulty( self._challenges_map_res[ name ].difficulty ) then
return
end
if not self:_check_level_completed( data ) then
return
end
if managers.statistics:session_total_kills() > 0 then
return
end
if managers.statistics:started_session_from_beginning() then
return
end
return
end
function ChallengesManagerRes:never_died( name, data )
if not self:_correct_level( self._challenges_map_res[ name ].level_id ) then
return
end
if not self:_correct_difficulty( self._challenges_map_res[ name ].difficulty ) then
return
end
if not self:_check_level_completed( data ) then
return
end
if data.last_session.downed.death > 0 then
return
end
return true
end
function ChallengesManagerRes:never_bleedout( name, data )
if not self:_correct_level( self._challenges_map_res[ name ].level_id ) then
return
end
if not self:_correct_difficulty( self._challenges_map_res[ name ].difficulty ) then
return
end
if not self:_check_level_completed( data ) then
return
end
if data.last_session.downed.bleed_out > 0 then
return
end
return true
end
function ChallengesManagerRes:level_success( name, data )
if not self:_correct_level( self._challenges_map_res[ name ].level_id ) then
return
end
if not self:_check_level_completed( data ) then
return
end
if not self:_correct_difficulty( self._challenges_map_res[ name ].difficulty ) then
return
end
if not self:_check_depends_on(name) then
return false
end
return true
end
function ChallengesManagerRes:overkill_no_trade( name, data )
if not self:_correct_level( self._challenges_map_res[ name ].level_id ) then
return
end
if not self:_check_level_completed( data ) then
return
end
if not self:_correct_difficulty( self._challenges_map_res[ name ].difficulty ) then
return
end
if managers.trade._num_trades > 0 then
return
end
return true
end
function ChallengesManagerRes:job_success( name, data )
if not self:_correct_job( self._challenges_map_res[ name ].job_id ) then
return
end
if not self:_check_level_completed( data ) then
return
end
if not self:_correct_difficulty( self._challenges_map_res[ name ].difficulty ) then
return
end
if not self:_check_depends_on(name) then
return false
end
if not managers.job:on_last_stage() then
return false
end
return true
end
function ChallengesManagerRes:pro_job_success( name, data )
if not self:_correct_job( self._challenges_map_res[ name ].job_id ) then
return
end
if not self:_check_level_completed( data ) then
return
end
if not self:_correct_difficulty( self._challenges_map_res[ name ].difficulty ) then
return
end
if not self:_check_depends_on(name) then
return false
end
if not Global.game_settings.one_down then
return false
end
if not managers.job:on_last_stage() then
return false
end
return true
end
function ChallengesManagerRes:pdth_style_success( name, data )
if not self:_correct_level( self._challenges_map_res[ name ].level_id ) then
return
end
if not self:_check_level_completed( data ) then
return
end
if not self:_correct_difficulty( self._challenges_map_res[ name ].difficulty ) then
return
end
if not self:_check_depends_on(name) then
return false
end
local blank_perkdeck = false
local no_skills = false
if managers.skilltree:points() == 100 then
no_skills = true
end
local current_specialization = managers.skilltree:get_specialization_value("current_specialization")
if current_specialization == 24 or current_specialization == 25 then
blank_perkdeck = true
end
if blank_perkdeck and no_skills then
return true
else
return false
end
end
---------------------------------------------------
function ChallengesManagerRes:check_still_active_available()
local actives = clone( self._global.active )
for name,data in pairs( actives ) do
if not self._challenges_map_res[ name ] then
self._global.active[ name ] = nil
end
end
end
---------------------------------------------------
function ChallengesManagerRes:save( data )
--log("save called")
local active = {}
for i, k in pairs( self._global.active ) do
if not k.already_awarded then
active[i] = k
end
end
local state = {
active = active,
completed = self._global.completed,
last_completed = self._global.last_completed
}
data.blackmarket.ChallengesManagerRes = state
end
function ChallengesManagerRes:load( data )
--log("load called")
if data.blackmarket then
local state = data.blackmarket.ChallengesManagerRes
if state then
self._global.active = state.active
self._global.completed = state.completed
self._global.last_completed = state.last_completed
self:check_active_challenges()
self:check_still_active_available()
end
managers.network.account:challenges_loaded()
end
end
--------------------------------------- Debug -----------------------------------------
function ChallengesManagerRes:debug_set_amount( name, amount )
if not self._global.active[ name ] then
return
end
self._global.active[ name ].amount = amount
end