-
Notifications
You must be signed in to change notification settings - Fork 183
/
post_game_progress_screens.js
2749 lines (2305 loc) · 90.6 KB
/
post_game_progress_screens.js
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
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ----------------------------------------------------------------------------
// Battle pass level progress bar
// ----------------------------------------------------------------------------
function AnimateBattlePassLevelsAction( panel, eventId, bpPointsStart, bpPointsPerLevel, bpPointsAdd )
{
this.panel = panel;
this.eventId = eventId;
this.bpPointsStart = bpPointsStart;
this.bpPointsPerLevel = bpPointsPerLevel;
this.bpPointsAdd = bpPointsAdd;
this.seq = new RunSequentialActions();
var battlePointsStart = this.bpPointsStart;
var battleLevelStart = Math.floor( battlePointsStart / this.bpPointsPerLevel );
var battlePointsAtLevelStart = battleLevelStart * this.bpPointsPerLevel;
var bpLevelStart = battlePointsStart - battlePointsAtLevelStart;
var bpLevelNext = this.bpPointsPerLevel;
panel.SetDialogVariableInt( 'current_level_bp', bpLevelStart );
panel.SetDialogVariableInt( 'bp_to_next_level', bpLevelNext );
panel.FindChildInLayoutFile( 'BattlePassLevelShield' ).SetEventLevel( this.eventId, battleLevelStart );
var progressBar = panel.FindChildInLayoutFile( "BattleLevelProgress" );
progressBar.max = bpLevelNext;
progressBar.lowervalue = bpLevelStart;
progressBar.uppervalue = bpLevelStart;
var bpEarned = 0;
var bpLevel = bpLevelStart;
var battleLevel = battleLevelStart;
var bpRemaining = this.bpPointsAdd;
var bpEarnedOnRow = 0;
while ( bpRemaining > 0 )
{
var bpToAnimate = 0;
var bpToNextLevel = 0;
bpToNextLevel = bpLevelNext - bpLevel;
bpToAnimate = Math.min( bpRemaining, bpToNextLevel );
if ( bpToAnimate > 0 )
{
this.seq.actions.push( new SkippableAction( new AnimateBattlePointsIncreaseAction( panel, bpToAnimate, bpEarnedOnRow, bpEarned, bpLevel ) ) );
bpEarned += bpToAnimate;
bpLevel += bpToAnimate;
bpEarnedOnRow += bpToAnimate;
bpRemaining -= bpToAnimate;
}
bpToNextLevel = bpLevelNext - bpLevel;
if ( bpToNextLevel != 0 )
continue;
battleLevel = battleLevel + 1;
bpLevel = 0;
this.seq.actions.push( new AddClassAction( panel, 'LeveledUpStart' ) );
( function ( me, battleLevelInternal ) {
me.seq.actions.push( new RunFunctionAction( function () {
var levelShield = panel.FindChildInLayoutFile( 'BattlePassLevelShield' );
levelShield.AddClass( 'LeveledUp' );
levelShield.SetEventLevel( me.eventId, battleLevelInternal );
} ) );
} )( this, battleLevel );
this.seq.actions.push( new RemoveClassAction( panel, 'LeveledUpStart' ) );
this.seq.actions.push( new AddClassAction( panel, 'LeveledUpEnd' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( 1.0 ) ) );
( function ( me, battleLevelInternal ) {
me.seq.actions.push( new RunFunctionAction( function () {
var levelShield = panel.FindChildInLayoutFile( 'BattlePassLevelShield' );
levelShield.RemoveClass( 'LeveledUp' );
} ) );
} )( this, battleLevel );
this.seq.actions.push( new RemoveClassAction( panel, 'LeveledUpEnd' ) );
( function ( me, bpLevelInternal, bpLevelNextInternal ) {
me.seq.actions.push( new RunFunctionAction( function () {
progressBar.lowervalue = 0;
progressBar.uppervalue = 0;
panel.SetDialogVariableInt( 'current_level_bp', bpLevelInternal );
panel.SetDialogVariableInt( 'bp_to_next_level', bpLevelNextInternal );
panel.FindChildInLayoutFile( "BattleLevelProgress" ).max = bpLevelNextInternal;
panel.FindChildInLayoutFile( "BattleLevelProgress" ).value = bpLevelInternal;
} ) );
} )( this, bpLevel, bpLevelNext );
}
}
AnimateBattlePassLevelsAction.prototype = new BaseAction();
AnimateBattlePassLevelsAction.prototype.start = function () {
return this.seq.start();
}
AnimateBattlePassLevelsAction.prototype.update = function () {
return this.seq.update();
}
AnimateBattlePassLevelsAction.prototype.finish = function () {
this.seq.finish();
}
// ----------------------------------------------------------------------------
//
// Cavern Crawl Screen
//
// ----------------------------------------------------------------------------
function AnimateCavernCrawlScreenAction( data )
{
this.data = data;
}
AnimateCavernCrawlScreenAction.prototype = new BaseAction();
AnimateCavernCrawlScreenAction.prototype.start = function ()
{
var heroID = this.data.hero_id;
var eventID = this.data.cavern_crawl_progress.event_id;
var mapVariant = this.data.cavern_crawl_progress.map_variant;
var turboMode = this.data.cavern_crawl_progress.turbo_mode;
var mapProgress = this.data.cavern_crawl_progress.map_progress;
// Create the screen and do a bunch of initial setup
var panel = StartNewScreen( 'CavernCrawlProgressScreen' );
panel.BLoadLayoutSnippet( "CavernCrawlProgress" );
// Setup the sequence of actions to animate the screen
this.seq = new RunSequentialActions();
this.eventHandler = null;
( function (me)
{
me.seq.actions.push( new RunFunctionAction( function ()
{
var hHandler = (function (me2)
{
return function ()
{
if ( !me2.disabled_update )
{
me2.disabled_update = true;
me2.cavern_panel.DisableUpdateDisplay(true);
}
};
}(me));
me.eventHandler = $.RegisterForUnhandledEvent("PostGameProgressSkippingAhead", hHandler);
}));
})(this);
this.seq.actions.push( new AddScreenLinkAction( panel, 'CavernsProgress', '#DOTACavernCrawl_Title_TI2020' ) );
this.seq.actions.push( new AddClassAction( panel, 'ShowScreen' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( 1.0 ) ) );
var cavernCrawlPanel = panel.FindChildInLayoutFile('CavernCrawl');
this.seq.actions.push( new AddClassAction( panel, 'ShowCavernCrawlProgress' ) );
this.seq.actions.push( new RunFunctionAction( function ()
{
cavernCrawlPanel.ClearMapResults();
if ( mapProgress )
{
for ( var i = 0; i < mapProgress.length; ++i )
{
var result = mapProgress[i]
cavernCrawlPanel.AddMapResult( result.path_id_completed, result.room_id_claimed );
}
}
cavernCrawlPanel.ShowPostGameProgress( eventID, 0, mapVariant, heroID, turboMode );
} ) );
this.seq.actions.push( new WaitForEventAction( cavernCrawlPanel, 'DOTACavernCrawlPostGameProgressComplete' ) );
this.seq.actions.push( new StopSkippingAheadAction() );
this.seq.start();
this.cavern_panel = panel.FindChildInLayoutFile( "CavernCrawl" );
}
AnimateCavernCrawlScreenAction.prototype.update = function ()
{
return this.seq.update();
}
AnimateCavernCrawlScreenAction.prototype.finish = function ()
{
if ( this.eventHandler != null )
{
$.UnregisterForUnhandledEvent("PostGameProgressSkippingAhead", this.eventHandler);
this.eventHandler = null;
}
if ( this.disabled_update )
{
this.cavern_panel.DisableUpdateDisplay(false);
this.disabled_update = false;
}
this.seq.finish();
}
// ----------------------------------------------------------------------------
//
// Battle Points
//
// ----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Animates battle points within a single level
//-----------------------------------------------------------------------------
function GetBPIncreaseAnimationDuration( bpAmount )
{
return RemapValClamped( bpAmount, 0, 500, 0.2, 0.6 );
}
// Action to animate a battle pass bp increase
function AnimateBattlePointsIncreaseAction( panel, bpAmount, bpValueStart, bpEarnedStart, bpLevelStart )
{
this.panel = panel;
this.bpAmount = bpAmount;
this.bpValueStart = bpValueStart;
this.bpEarnedStart = bpEarnedStart;
this.bpLevelStart = bpLevelStart;
}
AnimateBattlePointsIncreaseAction.prototype = new BaseAction();
AnimateBattlePointsIncreaseAction.prototype.start = function ()
{
this.seq = new RunParallelActions();
var duration = GetBPIncreaseAnimationDuration( this.bpAmount );
var levelProgressBar = this.panel.FindChildInLayoutFile( 'BattleLevelProgress' );
var minLevelBP = Math.min( this.bpLevelStart, levelProgressBar.max );
var maxLevelBP = Math.min( this.bpLevelStart + this.bpAmount, levelProgressBar.max );
this.seq.actions.push( new AnimateDialogVariableIntAction( this.panel, 'current_level_bp', minLevelBP, maxLevelBP, duration ) );
this.seq.actions.push( new AnimateProgressBarWithMiddleAction( levelProgressBar, minLevelBP, maxLevelBP, duration ) );
this.seq.actions.push( new PlaySoundForDurationAction( "XP.Count", duration ) );
this.seq.start();
}
AnimateBattlePointsIncreaseAction.prototype.update = function ()
{
return this.seq.update();
}
AnimateBattlePointsIncreaseAction.prototype.finish = function ()
{
this.seq.finish();
}
//-----------------------------------------------------------------------------
// Adds points to totals bar
//-----------------------------------------------------------------------------
function UpdateSubpanelTotalPoints( panel, ownerPanel, bpAmount, bpStartingSubTotal, displayOnly )
{
panel.SetDialogVariableInt( 'xp_circle_points', bpAmount );
panel.AddClass( 'ShowTotals' );
if ( !displayOnly )
{
ownerPanel.SetDialogVariableInt( 'total_points_gained', bpStartingSubTotal + bpAmount );
}
}
//-----------------------------------------------------------------------------
// Subpanel animation timings
//-----------------------------------------------------------------------------
var g_DelayAfterStart = 0.05;
var g_SubElementDelay = 0.05;
//-----------------------------------------------------------------------------
// Animates wagering subpanel
//-----------------------------------------------------------------------------
// Action to animate a battle pass bp increase
function AnimateWageringSubpanelAction( panel, ownerPanel, wagering_data, startingPoints )
{
this.panel = panel;
this.ownerPanel = ownerPanel;
this.startingPoints = startingPoints;
panel.AddClass( 'Visible' );
var panelXPCircle = panel.FindChildInLayoutFile( "XPCircleContainer" );
panelXPCircle.BLoadLayoutSnippet( 'BattlePassXPCircle' );
panel.SetDialogVariableInt( 'wager_amount', wagering_data.wager_amount );
panel.SetDialogVariableInt( 'wager_conversion_ratio', wagering_data.conversion_ratio );
panel.SetDialogVariableInt( 'wager_token_bonus_pct', wagering_data.wager_token_bonus_pct );
panel.SetDialogVariableInt( 'wager_streak_bonus_pct', wagering_data.wager_streak_bonus_pct );
this.total_points = wagering_data.wager_amount * wagering_data.conversion_ratio * ( 100 + wagering_data.wager_streak_bonus_pct + wagering_data.wager_token_bonus_pct ) / 100;
}
AnimateWageringSubpanelAction.prototype = new BaseAction();
AnimateWageringSubpanelAction.prototype.start = function ()
{
this.seq = new RunSequentialActions();
this.seq.actions.push( new AddClassAction( this.panel, 'BecomeVisible' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_DelayAfterStart ) ) );
this.seq.actions.push( new AddClassAction( this.panel, 'ShowWager' ) );
this.seq.actions.push( new AddClassAction( this.panel, 'ShowTeamWagerBonus' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
var panel = this.panel;
var ownerPanel = this.ownerPanel;
var total_points = this.total_points;
var startingPoints = this.startingPoints;
this.seq.actions.push( new RunFunctionAction( function ()
{
UpdateSubpanelTotalPoints( panel, ownerPanel, total_points, startingPoints, false );
} ) );
this.seq.start();
}
AnimateWageringSubpanelAction.prototype.update = function ()
{
return this.seq.update();
}
AnimateWageringSubpanelAction.prototype.finish = function ()
{
this.seq.finish();
}
//-----------------------------------------------------------------------------
// Animates tipping subpanel
//-----------------------------------------------------------------------------
// Action to animate a battle pass bp increase
function AnimateTippingSubpanelAction( panel, ownerPanel, tips, startingPoints )
{
this.panel = panel;
this.ownerPanel = ownerPanel;
this.startingPoints = startingPoints;
panel.AddClass( 'Visible' );
var panelXPCircle = panel.FindChildInLayoutFile( "XPCircleContainer" );
panelXPCircle.BLoadLayoutSnippet( 'BattlePassXPCircle' );
var totalTipCount = 0;
this.panelCount = 0;
this.total_points = 0;
var tipContainer = panel.FindChildInLayoutFile( "TipContainer" );
var tipContainer2 = panel.FindChildInLayoutFile( "TipContainer2" );
var tipParent = tipContainer;
for ( var i = 0; i < tips.length; ++i )
{
if ( i == 4 )
{
tipParent = tipContainer2;
panel.AddClass( "TwoTipColumns" );
}
var tipperPanel = $.CreatePanel( 'Panel', tipParent, 'Tipper' + i );
tipperPanel.BLoadLayoutSnippet( 'BattlePassTip' );
var avatarPanel = tipperPanel.FindChildInLayoutFile( "Avatar" );
avatarPanel.SetAccountID( tips[i].account_id );
tipperPanel.SetDialogVariableInt( 'tip_points', tips[i].amount );
tipperPanel.AddClass( 'TipCount' + tips[i].count );
totalTipCount += tips[i].count;
this.panelCount = this.panelCount + 1;
this.total_points += tips[i].count * tips[i].amount
}
panel.SetDialogVariableInt( 'total_tip_count', totalTipCount );
}
AnimateTippingSubpanelAction.prototype = new BaseAction();
AnimateTippingSubpanelAction.prototype.start = function ()
{
this.seq = new RunSequentialActions();
this.seq.actions.push( new AddClassAction( this.panel, 'BecomeVisible' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_DelayAfterStart ) ) );
this.seq.actions.push( new AddClassAction( this.panel, 'ShowTotalTips' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
for ( var i = 0; i < this.panelCount; ++i )
{
var tipperPanel = this.panel.FindChildInLayoutFile( 'Tipper' + i );
this.seq.actions.push( new AddClassAction( tipperPanel, 'ShowTip' ) );
}
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
var panel = this.panel;
var ownerPanel = this.ownerPanel;
var total_points = this.total_points;
var startingPoints = this.startingPoints;
this.seq.actions.push( new RunFunctionAction( function ()
{
UpdateSubpanelTotalPoints( panel, ownerPanel, total_points, startingPoints, false );
} ) );
this.seq.start();
}
AnimateTippingSubpanelAction.prototype.update = function ()
{
return this.seq.update();
}
AnimateTippingSubpanelAction.prototype.finish = function ()
{
this.seq.finish();
}
//-----------------------------------------------------------------------------
// Animates actions granted subpanel
//-----------------------------------------------------------------------------
// Action to animate a battle pass bp increase
function AnimateActionsGrantedSubpanelAction( panel, ownerPanel, actions_granted, startingPoints )
{
this.panel = panel;
this.ownerPanel = ownerPanel;
this.startingPoints = startingPoints;
panel.AddClass( 'Visible' );
var panelXPCircle = panel.FindChildInLayoutFile( "XPCircleContainer" );
panelXPCircle.BLoadLayoutSnippet( 'BattlePassXPCircle' );
this.panelCount = 0;
this.total_points = 0;
var actionContainer = panel.FindChildInLayoutFile( "ActionContainer" );
for ( var i = 0; i < actions_granted.length; ++i )
{
var actionPanel = $.CreatePanel( 'Panel', actionContainer, 'Action' + i );
actionPanel.BLoadLayoutSnippet( 'BattlePassAction' );
if ( actions_granted[i].action_image != null )
{
var imagePanel = actionPanel.FindChildInLayoutFile( "ConsumableImage" );
imagePanel.SetImage( actions_granted[i].action_image );
}
actionPanel.SetDialogVariableInt( 'action_points', actions_granted[i].bp_amount );
actionPanel.SetDialogVariableInt( 'action_quantity', actions_granted[i].quantity );
this.panelCount = this.panelCount + 1;
this.total_points += actions_granted[i].quantity * actions_granted[i].bp_amount
}
}
AnimateActionsGrantedSubpanelAction.prototype = new BaseAction();
AnimateActionsGrantedSubpanelAction.prototype.start = function ()
{
this.seq = new RunSequentialActions();
this.seq.actions.push( new AddClassAction( this.panel, 'BecomeVisible' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_DelayAfterStart ) ) );
this.seq.actions.push( new AddClassAction( this.panel, 'ShowTotalActions' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
for ( var i = 0; i < this.panelCount; ++i )
{
var actionPanel = this.panel.FindChildInLayoutFile( 'Action' + i );
this.seq.actions.push( new AddClassAction( actionPanel, 'ShowAction' ) );
}
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
var panel = this.panel;
var ownerPanel = this.ownerPanel;
var total_points = this.total_points;
var startingPoints = this.startingPoints;
this.seq.actions.push( new RunFunctionAction( function ()
{
UpdateSubpanelTotalPoints( panel, ownerPanel, total_points, startingPoints, false );
} ) );
this.seq.start();
}
AnimateActionsGrantedSubpanelAction.prototype.update = function ()
{
return this.seq.update();
}
AnimateActionsGrantedSubpanelAction.prototype.finish = function ()
{
this.seq.finish();
}
//-----------------------------------------------------------------------------
// Animates cavern crawl subpanel
//-----------------------------------------------------------------------------
// Action to animate a battle pass bp increase
function AnimateCavernCrawlSubpanelAction( panel, ownerPanel, cavern_data, startingPoints )
{
this.panel = panel;
this.ownerPanel = ownerPanel;
this.startingPoints = startingPoints;
panel.AddClass( 'Visible' );
var panelXPCircle = panel.FindChildInLayoutFile( "XPCircleContainer" );
panelXPCircle.BLoadLayoutSnippet( 'BattlePassXPCircle' );
panel.FindChildInLayoutFile( "CavernCrawlHero" ).heroid = cavern_data.hero_id;
this.total_points = cavern_data.bp_amount;
}
AnimateCavernCrawlSubpanelAction.prototype = new BaseAction();
AnimateCavernCrawlSubpanelAction.prototype.start = function ()
{
this.seq = new RunSequentialActions();
this.seq.actions.push( new AddClassAction( this.panel, 'BecomeVisible' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_DelayAfterStart ) ) );
this.seq.actions.push( new AddClassAction( this.panel, 'ShowMap' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
this.seq.actions.push( new AddClassAction( this.panel, 'ShowCompleted' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
var panel = this.panel;
var ownerPanel = this.ownerPanel;
var total_points = this.total_points;
var startingPoints = this.startingPoints;
this.seq.actions.push( new RunFunctionAction( function ()
{
UpdateSubpanelTotalPoints( panel, ownerPanel, total_points, startingPoints, false );
} ) );
this.seq.start();
}
AnimateCavernCrawlSubpanelAction.prototype.update = function ()
{
return this.seq.update();
}
AnimateCavernCrawlSubpanelAction.prototype.finish = function ()
{
this.seq.finish();
}
//-----------------------------------------------------------------------------
// Event game bp progress
//-----------------------------------------------------------------------------
function AnimateEventGameTI9SubpanelAction( panel, ownerPanel, event_game_ti9, startingPoints ) {
var kWinPointsBase = 300;
this.panel = panel;
this.ownerPanel = ownerPanel;
this.startingPoints = startingPoints;
this.total_points = event_game_ti9.bp_amount;
this.show_win = ( event_game_ti9.win_points > 0 );
this.show_loss = ( event_game_ti9.loss_points > 0 );
this.show_daily_bonus = ( event_game_ti9.win_points > kWinPointsBase );
this.show_treasure = ( event_game_ti9.treasure_points > 0 );
panel.AddClass( 'Visible' );
if ( this.show_win )
{
panel.AddClass( "EventGame_HasWin" );
}
if ( this.show_loss )
{
panel.AddClass( "EventGame_HasLoss" );
}
if ( this.show_daily_bonus )
{
panel.AddClass( "EventGame_HasDailyBonus" );
}
if ( this.show_treasure )
{
panel.AddClass( "EventGame_HasTreasure" );
}
var panelXPCircle = panel.FindChildInLayoutFile( "XPCircleContainer" );
panelXPCircle.BLoadLayoutSnippet( 'BattlePassXPCircle' );
panel.SetDialogVariableInt( "win_points", event_game_ti9.win_points > kWinPointsBase ? kWinPointsBase : event_game_ti9.win_points );
panel.SetDialogVariableInt( "bonus_points", event_game_ti9.win_points - kWinPointsBase );
panel.SetDialogVariableInt( "loss_points", event_game_ti9.loss_points );
panel.SetDialogVariableInt( "treasure_points", event_game_ti9.treasure_points );
var progressMax = event_game_ti9.weekly_cap_total;
var progressEnd = progressMax - event_game_ti9.weekly_cap_remaining;
var progressStart = progressEnd - event_game_ti9.bp_amount;
panel.SetDialogVariableInt( "weekly_progress", progressEnd );
panel.SetDialogVariableInt( "weekly_complete_limit", progressMax );
var progressBar = panel.FindChildInLayoutFile( "EventGameWeeklyProgress" );
progressBar.max = progressMax;
progressBar.lowervalue = progressStart;
progressBar.uppervalue = progressEnd;
}
AnimateEventGameTI9SubpanelAction.prototype = new BaseAction();
AnimateEventGameTI9SubpanelAction.prototype.start = function () {
this.seq = new RunSequentialActions();
this.seq.actions.push( new AddClassAction( this.panel, 'BecomeVisible' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_DelayAfterStart ) ) );
if ( this.show_win )
{
this.seq.actions.push( new AddClassAction( this.panel, 'EventGame_ShowWin' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
if ( this.show_daily_bonus )
{
this.seq.actions.push( new AddClassAction( this.panel, 'EventGame_ShowDailyBonus' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
}
}
if ( this.show_loss )
{
this.seq.actions.push( new AddClassAction( this.panel, 'EventGame_ShowLoss' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
}
if ( this.show_treasure )
{
this.seq.actions.push( new AddClassAction( this.panel, 'EventGame_ShowTreasure' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
}
this.seq.actions.push( new AddClassAction( this.panel, 'EventGame_ShowWeeklyProgress' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
var panel = this.panel;
var ownerPanel = this.ownerPanel;
var total_points = this.total_points;
var startingPoints = this.startingPoints;
this.seq.actions.push( new RunFunctionAction( function () {
UpdateSubpanelTotalPoints( panel, ownerPanel, total_points, startingPoints, false );
} ) );
this.seq.start();
}
AnimateEventGameTI9SubpanelAction.prototype.update = function () {
return this.seq.update();
}
AnimateEventGameTI9SubpanelAction.prototype.finish = function () {
this.seq.finish();
}
//-----------------------------------------------------------------------------
// Event game bp progress
//-----------------------------------------------------------------------------
function AnimateEventGameTI10SubpanelAction(panel, ownerPanel, event_game_ti10, startingPoints)
{
this.panel = panel;
this.ownerPanel = ownerPanel;
this.startingPoints = startingPoints;
this.total_points = event_game_ti10.bp_amount;
this.premium_starting_points = event_game_ti10.premium_start;
this.premium_progress = event_game_ti10.bonus_premium_amount;
this.show_weekly_progress = (event_game_ti10.bp_amount > 0 );
this.show_premium_weekly_progress = (event_game_ti10.bonus_premium_amount > 0);
panel.AddClass( 'Visible' );
var panelXPCircle = panel.FindChildInLayoutFile( "XPCircleContainer" );
panelXPCircle.BLoadLayoutSnippet( 'BattlePassXPCircle' );
panel.SetDialogVariableInt("win_points", event_game_ti10.bp_amount);
var nPremiumPoints = event_game_ti10.premium_amount;
var nExtraPremiumPoints = 0;
if (event_game_ti10.bonus_premium_amount > 0)
{
nExtraPremiumPoints = event_game_ti10.premium_amount - event_game_ti10.bonus_premium_amount;
nPremiumPoints = event_game_ti10.bonus_premium_amount;
}
panel.SetDialogVariableInt("premium_points", nPremiumPoints );
panel.SetDialogVariableInt("extra_premium_points", nExtraPremiumPoints );
panel.SetHasClass('HasExtraPremiumPoints', nExtraPremiumPoints > 0 );
panel.SetHasClass('HasBonusPremiumPoints', event_game_ti10.bonus_premium_amount > 0);
var progressMax = event_game_ti10.bp_max;
var progressStart = event_game_ti10.bp_start;
var progressEnd = this.total_points + event_game_ti10.bp_start;
panel.SetDialogVariableInt( "weekly_progress", this.total_points );
panel.SetDialogVariableInt( "weekly_start_value", progressStart );
panel.SetDialogVariableInt( "weekly_complete_limit", progressMax );
var progressBar = panel.FindChildInLayoutFile( "EventGameWeeklyProgress" );
progressBar.max = Math.max( progressMax, 1 );
progressBar.lowervalue = progressStart;
progressBar.uppervalue = progressEnd;
panel.SetDialogVariableInt("weekly_premium_progress", event_game_ti10.bonus_premium_amount );
panel.SetDialogVariableInt("weekly_premium_start_value", event_game_ti10.premium_start );
panel.SetDialogVariableInt("weekly_premium_complete_limit", event_game_ti10.premium_max);
var progressBar = panel.FindChildInLayoutFile("EventGameWeeklyPremiumProgress");
progressBar.max = Math.max( event_game_ti10.premium_max, 1 );
progressBar.lowervalue = event_game_ti10.premium_start;
progressBar.uppervalue = progressBar.lowervalue;
}
AnimateEventGameTI10SubpanelAction.prototype = new BaseAction();
AnimateEventGameTI10SubpanelAction.prototype.start = function ()
{
this.seq = new RunSequentialActions();
this.seq.actions.push( new AddClassAction( this.panel, 'BecomeVisible' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_DelayAfterStart ) ) );
if ( this.show_premium_weekly_progress )
{
this.seq.actions.push(new AddClassAction(this.panel, 'EventGame_ShowWeeklyPremiumProgress'));
this.seq.actions.push(new SkippableAction(new WaitAction(g_SubElementDelay)));
}
if (this.show_weekly_progress)
{
this.seq.actions.push(new AddClassAction(this.panel, 'EventGame_ShowWeeklyProgress'));
this.seq.actions.push(new SkippableAction(new WaitAction(g_SubElementDelay)));
}
var panel = this.panel;
var ownerPanel = this.ownerPanel;
var total_points = this.total_points;
var startingPoints = this.startingPoints;
this.seq.actions.push(new RunFunctionAction(function ()
{
UpdateSubpanelTotalPoints( panel, ownerPanel, total_points, startingPoints, false );
} ) );
if (this.show_premium_weekly_progress)
{
this.seq.actions.push(new SkippableAction(new WaitAction(0.2)));
this.seq.actions.push(new AddClassAction(this.panel, 'EventGame_ShowWeeklyPremiumBonus'));
(function (me) {
me.seq.actions.push(new RunFunctionAction(function () {
var progressBar = me.panel.FindChildInLayoutFile("EventGameWeeklyPremiumProgress");
progressBar.uppervalue = me.premium_starting_points + me.premium_progress;
}));
})(this);
}
this.seq.start();
}
AnimateEventGameTI10SubpanelAction.prototype.update = function () {
return this.seq.update();
}
AnimateEventGameTI10SubpanelAction.prototype.finish = function () {
this.seq.finish();
}
//-----------------------------------------------------------------------------
// Animates daily challenge subpanel
//-----------------------------------------------------------------------------
// Action to animate a battle pass bp increase
function AnimateDailyChallengeSubpanelAction( panel, ownerPanel, daily_challenge, startingPoints )
{
this.panel = panel;
this.ownerPanel = ownerPanel;
this.startingPoints = startingPoints;
panel.AddClass( 'Visible' );
var panelXPCircle = panel.FindChildInLayoutFile( "XPCircleContainer" );
panelXPCircle.BLoadLayoutSnippet( 'BattlePassXPCircle' );
panel.FindChildInLayoutFile( "DailyChallengeHeroMovie" ).heroid = daily_challenge.hero_id;
this.total_points = daily_challenge.bp_amount;
}
AnimateDailyChallengeSubpanelAction.prototype = new BaseAction();
AnimateDailyChallengeSubpanelAction.prototype.start = function ()
{
this.seq = new RunSequentialActions();
this.seq.actions.push( new AddClassAction( this.panel, 'BecomeVisible' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_DelayAfterStart ) ) );
this.seq.actions.push( new AddClassAction( this.panel, 'ShowHero' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
this.seq.actions.push( new AddClassAction( this.panel, 'ShowCompleted' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
var panel = this.panel;
var ownerPanel = this.ownerPanel;
var total_points = this.total_points;
var startingPoints = this.startingPoints;
this.seq.actions.push( new RunFunctionAction( function ()
{
UpdateSubpanelTotalPoints( panel, ownerPanel, total_points, startingPoints, false );
} ) );
this.seq.start();
}
AnimateDailyChallengeSubpanelAction.prototype.update = function ()
{
return this.seq.update();
}
AnimateDailyChallengeSubpanelAction.prototype.finish = function ()
{
this.seq.finish();
}
//-----------------------------------------------------------------------------
// Animates weekly challenge subpanel
//-----------------------------------------------------------------------------
// Action to animate a battle pass bp increase
function AnimateWeeklyChallengeSubpanelAction( panel, ownerPanel, weekly_challenge, startingPoints )
{
this.panel = panel;
this.ownerPanel = ownerPanel;
this.startingPoints = startingPoints;
panel.AddClass( 'Visible' );
var panelXPCircle = panel.FindChildInLayoutFile( "XPCircleContainer" );
panelXPCircle.BLoadLayoutSnippet( 'BattlePassXPCircle' );
panelXPCircle.SetDialogVariableInt( 'points', 1000 ); // Not sure why this is necesssary, we used to do this?
panel.SetDialogVariable( 'weekly_challenge_description', weekly_challenge.challenge_description );
panel.SetDialogVariableInt( 'weekly_progress', weekly_challenge.progress );
panel.SetDialogVariableInt( 'weekly_complete_limit', weekly_challenge.complete_limit );
panel.SetDialogVariableInt( 'weekly_increment', weekly_challenge.end_progress - weekly_challenge.progress );
var progressBar = panel.FindChildInLayoutFile( "WeeklyChallengeProgress" );
progressBar.max = weekly_challenge.complete_limit;
progressBar.lowervalue = weekly_challenge.progress;
progressBar.uppervalue = weekly_challenge.end_progress;
this.points_for_display = weekly_challenge.bp_amount;
this.total_points = 0;
if ( weekly_challenge.end_progress == weekly_challenge.complete_limit )
{
this.total_points = weekly_challenge.bp_amount;
}
else
{
panel.AddClass( "HideXPCircle" );
}
}
AnimateWeeklyChallengeSubpanelAction.prototype = new BaseAction();
AnimateWeeklyChallengeSubpanelAction.prototype.start = function ()
{
this.seq = new RunSequentialActions();
this.seq.actions.push( new AddClassAction( this.panel, 'BecomeVisible' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_DelayAfterStart ) ) );
this.seq.actions.push( new AddClassAction( this.panel, 'ShowChallenge' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
if ( this.total_points != 0 )
{
this.seq.actions.push( new AddClassAction( this.panel, 'ShowCompleted' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
}
var panel = this.panel;
var ownerPanel = this.ownerPanel;
var total_points = this.points_for_display;
var displayOnly = ( this.total_points == 0 );
var startingPoints = this.startingPoints;
this.seq.actions.push( new RunFunctionAction( function ()
{
UpdateSubpanelTotalPoints( panel, ownerPanel, total_points, startingPoints, displayOnly );
} ) );
this.seq.start();
}
AnimateWeeklyChallengeSubpanelAction.prototype.update = function ()
{
return this.seq.update();
}
AnimateWeeklyChallengeSubpanelAction.prototype.finish = function ()
{
this.seq.finish();
}
//-----------------------------------------------------------------------------
// Animates Guild subpanel
//-----------------------------------------------------------------------------
// Action to animate a battle pass bp increase
function AnimateGuildSubpanelAction( panel, ownerPanel, guild_progress, startingPoints, event_id )
{
this.panel = panel;
this.ownerPanel = ownerPanel;
this.startingPoints = startingPoints;
this.total_points = 0;
this.guild_progress = guild_progress;
panel.AddClass( 'Visible' );
if ( guild_progress.guild_contracts != null && guild_progress.guild_contracts.length > 0 )
{
var contractsList = panel.FindChildInLayoutFile( "GuildContractList" );
for ( var i = 0; i < guild_progress.guild_contracts.length; ++i )
{
var guildContract = guild_progress.guild_contracts[i];
var contractPanel = $.CreatePanel( 'Panel', contractsList, '' );
contractPanel.BLoadLayoutSnippet( 'BattlePassGuildContract' );
var contract = contractPanel.FindChildInLayoutFile( 'GuildContract' );
contract.SetContract( event_id, guildContract.challenge_instance_id, guildContract.challenge_parameter, guildContract.completed );
contractPanel.SetHasClass( "ContractCompleted", guildContract.completed );
if (guildContract.completed )
this.total_points += guildContract.battle_point_reward;
}
panel.AddClass( "HasGuildContracts" );
}
if ( guild_progress.guild_challenge != null )
{
var guildChallenge = guild_progress.guild_challenge;
var challengeImage = panel.FindChildInLayoutFile( "GuildChallengeImage" );
challengeImage.SetImage( guildChallenge.challenge_image );
panel.SetDialogVariableInt( "challenge_start_value", guildChallenge.challenge_start_value );
panel.SetDialogVariableInt( "challenge_max_value", guildChallenge.challenge_max_value );
panel.SetDialogVariableInt( "challenge_progress", guildChallenge.challenge_progress );
var challengeProgressBar = panel.FindChildInLayoutFile( "GuildChallengeProgressBar" );
challengeProgressBar.min = 0;
challengeProgressBar.max = guildChallenge.challenge_max_value;
challengeProgressBar.lowervalue = guildChallenge.challenge_start_value;
challengeProgressBar.uppervalue = guildChallenge.challenge_start_value + guildChallenge.challenge_progress;
panel.AddClass( "HasGuildChallenge" );
}
var panelXPCircle = panel.FindChildInLayoutFile( "XPCircleContainer" );
panelXPCircle.BLoadLayoutSnippet( 'BattlePassXPCircle' );
}
AnimateGuildSubpanelAction.prototype = new BaseAction();
AnimateGuildSubpanelAction.prototype.start = function ()
{
this.seq = new RunSequentialActions();
this.seq.actions.push( new AddClassAction( this.panel, 'BecomeVisible' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_DelayAfterStart ) ) );
var contractsList = this.panel.FindChildInLayoutFile( "GuildContractList" );
if ( contractsList.GetChildCount() > 0 )
{
this.seq.actions.push( new AddClassAction( this.panel, "ShowGuildContracts" ) );
for ( var i = 0; i < contractsList.GetChildCount(); ++i )
{
var contractPanel = contractsList.GetChild( i );
this.seq.actions.push( new RunFunctionAction( ( function ( contract )
{
return function () { contract.AddClass( "ShowGuildContract" ) };
} )( contractPanel ) ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
}
}
if ( this.guild_progress.guild_challenge != null )
{
this.seq.actions.push( new AddClassAction( this.panel, 'ShowGuildChallenge' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
}
if ( this.total_points != 0 )
{
this.seq.actions.push( new AddClassAction( this.panel, 'ShowCompleted' ) );
this.seq.actions.push( new SkippableAction( new WaitAction( g_SubElementDelay ) ) );
}