Marvel’s Strike Force – Team Builder

Sparked by a post on Reddit shortly after posting my MSFCalc for raid lane assignment, I’ve built a PowerShell based Team Builder for Marvel’s Strike Force.

The team builder will let you assign 5 heroes, based on each ‘stat’ category, will NOT let you use a hero in more than one category, shows you how many ‘positives’ there are for each hero selected, how many for each ‘stat’, and gives you the total count for the team. You are also able to save / export teams and import previously saved teams.

As noted by a user, depending on the restrictions for running scripts on your computer, you may need to run PowerShell as Admin to run the command ‘Set-ExecutionPolicy -ExecutionPolicy Bypass’ to enable scripts to run (instead of Bypass, you may need to use Unrestricted). This script itself does not need Admin rights.

MSFteambuilder 1.4

Note: As this is PowerShell, you’re free to modify and distribute as you wish, but please do give proper credit to me for this original work.

Changelog

  • V1.4 – Added Tier list rankings from Khasino. Selecting the Battletype will display the tier info for the heroes as 1=Trash, 2=Medicore, 3=Usable, 4=Demigod, 5=God
  • V1.3 – Updated with 1.4.1 Blitz infographic data from Khasino
  • V1.2 – Fixed stat calculations for columns and rows
  • V1.1 – Added stat calculations? I forget 🙂
  • V1.0 – Initial Release
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
# MSFTeamBuilder - Marvel's Strike Force Sure To Win Team Builder
#
# Created by Archimedez @ FrontRunnerTek.com
#
# Created:  2018-08-10
# Modified: 2018-08-14
# Version: 1.4
# Updated for 1.4.1 Blitz Infographic and Tier list from Khasino
# ======================================================================
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$POSHGUI_MyForm = New-Object System.Windows.Forms.Form
$POSHGUI_MyForm.Text="MSFTeamBuilder"
Try{$POSHGUI_MyForm.Icon="C:\MyIcon\MyIcon.ico"}Catch{}
$POSHGUI_MyForm.StartPosition = "CenterScreen"
$POSHGUI_MyForm.Size = New-Object System.Drawing.Size(820,350)
$POSHGUI_cmb_Hero1 = New-Object System.Windows.Forms.ComboBox
$POSHGUI_cmb_Hero1.Top="30"
$POSHGUI_cmb_Hero1.Left="10"
$POSHGUI_cmb_Hero1.Anchor="Left,Top"
$POSHGUI_cmb_Hero1.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_cmb_Hero1)
$POSHGUI_cmb_Hero1.Text=""
$POSHGUI_cmb_Hero1.Size = New-Object System.Drawing.Size(100,23)
$POSHGUI_cmb_Hero2 = New-Object System.Windows.Forms.ComboBox
$POSHGUI_cmb_Hero2.Top="30"
$POSHGUI_cmb_Hero2.Left="140"
$POSHGUI_cmb_Hero2.Anchor="Left,Top"
$POSHGUI_cmb_Hero2.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_cmb_Hero2)
$POSHGUI_cmb_Hero2.Text=""
$POSHGUI_cmb_Hero2.Size = New-Object System.Drawing.Size(100,23)
$POSHGUI_cmb_Hero3 = New-Object System.Windows.Forms.ComboBox
$POSHGUI_cmb_Hero3.Top="30"
$POSHGUI_cmb_Hero3.Left="270"
$POSHGUI_cmb_Hero3.Anchor="Left,Top"
$POSHGUI_cmb_Hero3.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_cmb_Hero3)
$POSHGUI_cmb_Hero3.Text=""
$POSHGUI_cmb_Hero3.Size = New-Object System.Drawing.Size(100,23)
$POSHGUI_cmb_Hero4 = New-Object System.Windows.Forms.ComboBox
$POSHGUI_cmb_Hero4.Top="30"
$POSHGUI_cmb_Hero4.Left="400"
$POSHGUI_cmb_Hero4.Anchor="Left,Top"
$POSHGUI_cmb_Hero4.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_cmb_Hero4)
$POSHGUI_cmb_Hero4.Text=""
$POSHGUI_cmb_Hero4.Size = New-Object System.Drawing.Size(100,23)
$POSHGUI_cmb_Hero5 = New-Object System.Windows.Forms.ComboBox
$POSHGUI_cmb_Hero5.Top="30"
$POSHGUI_cmb_Hero5.Left="540"
$POSHGUI_cmb_Hero5.Anchor="Left,Top"
$POSHGUI_cmb_Hero5.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_cmb_Hero5)
$POSHGUI_cmb_Hero5.Text=""
$POSHGUI_cmb_Hero5.Size = New-Object System.Drawing.Size(100,23)
$POSHGUI_cmb_Battletype = New-Object System.Windows.Forms.ComboBox
$POSHGUI_cmb_Battletype.Top="30"
$POSHGUI_cmb_Battletype.Left="680"
$POSHGUI_cmb_Battletype.Anchor="Left,Top"
$POSHGUI_cmb_Battletype.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_cmb_Battletype)
$POSHGUI_cmb_Battletype.Text=""
$POSHGUI_cmb_Battletype.Size = New-Object System.Drawing.Size(110,23)
$POSHGUI_Label6 = New-Object System.Windows.Forms.Label
$POSHGUI_Label6.Top="15"
$POSHGUI_Label6.Left="680"
$POSHGUI_Label6.Anchor="Left,Top"
$POSHGUI_Label6.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_Label6)
$POSHGUI_Label6.Text="Battle Type"
$POSHGUI_Label6.Size = New-Object System.Drawing.Size(120,23)
$POSHGUI_Label1 = New-Object System.Windows.Forms.Label
$POSHGUI_Label1.Top="15"
$POSHGUI_Label1.Left="540"
$POSHGUI_Label1.Anchor="Left,Top"
$POSHGUI_Label1.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_Label1)
$POSHGUI_Label1.Text="Damage with Utility"
$POSHGUI_Label1.Size = New-Object System.Drawing.Size(120,23)
$POSHGUI_Label2 = New-Object System.Windows.Forms.Label
$POSHGUI_Label2.Top="15"
$POSHGUI_Label2.Left="400"
$POSHGUI_Label2.Anchor="Left,Top"
$POSHGUI_Label2.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_Label2)
$POSHGUI_Label2.Text="Massive AOE Damage"
$POSHGUI_Label2.Size = New-Object System.Drawing.Size(120,23)
$POSHGUI_Label3 = New-Object System.Windows.Forms.Label
$POSHGUI_Label3.Top="15"
$POSHGUI_Label3.Left="270"
$POSHGUI_Label3.Anchor="Left,Top"
$POSHGUI_Label3.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_Label3)
$POSHGUI_Label3.Text="Enemy Buff Purge"
$POSHGUI_Label3.Size = New-Object System.Drawing.Size(120,23)
$POSHGUI_Label4 = New-Object System.Windows.Forms.Label
$POSHGUI_Label4.Top="15"
$POSHGUI_Label4.Left="140"
$POSHGUI_Label4.Anchor="Left,Top"
$POSHGUI_Label4.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_Label4)
$POSHGUI_Label4.Text="Early Burst Damage"
$POSHGUI_Label4.Size = New-Object System.Drawing.Size(120,23)
$POSHGUI_Label5 = New-Object System.Windows.Forms.Label
$POSHGUI_Label5.Top="15"
$POSHGUI_Label5.Left="8"
$POSHGUI_Label5.Anchor="Left,Top"
$POSHGUI_Label5.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_Label5)
$POSHGUI_Label5.Text="Team Wide Defense"
$POSHGUI_Label5.Size = New-Object System.Drawing.Size(120,23)
$POSHGUI_lbl_SureToWin = New-Object System.Windows.Forms.Label
$POSHGUI_lbl_SureToWin.Top="58"
$POSHGUI_lbl_SureToWin.Left="540"
$POSHGUI_lbl_SureToWin.Anchor="Left,Top"
$POSHGUI_lbl_SureToWin.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_lbl_SureToWin)
$POSHGUI_lbl_SureToWin.Text=""
$POSHGUI_lbl_SureToWin.Size = New-Object System.Drawing.Size(200,22)
$POSHGUI_DGV_TeamResults = New-Object System.Windows.Forms.DataGridView
$POSHGUI_DGV_TeamResults.Top="80"
$POSHGUI_DGV_TeamResults.Left="12"
$POSHGUI_DGV_TeamResults.Anchor="Left,Top"
$POSHGUI_DGV_TeamResults.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_DGV_TeamResults)
$POSHGUI_DGV_TeamResults.Text="DataGridView1"
$POSHGUI_DGV_TeamResults.Size = New-Object System.Drawing.Size(780,200)
$POSHGUI_btn_reset = New-Object System.Windows.Forms.Button
$POSHGUI_btn_reset.Top="55"
$POSHGUI_btn_reset.Left="10"
$POSHGUI_btn_reset.Anchor="Left,Top"
$POSHGUI_btn_reset.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_btn_reset)
$POSHGUI_btn_reset.Text="Reset"
$POSHGUI_btn_reset.Size = New-Object System.Drawing.Size(100,23)
$POSHGUI_btn_export = New-Object System.Windows.Forms.Button
$POSHGUI_btn_export.Top="55"
$POSHGUI_btn_export.Left="150"
$POSHGUI_btn_export.Anchor="Left,Top"
$POSHGUI_btn_export.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_btn_export)
$POSHGUI_btn_export.Text="Export Team"
$POSHGUI_btn_export.Size = New-Object System.Drawing.Size(100,23)
$POSHGUI_btn_import = New-Object System.Windows.Forms.Button
$POSHGUI_btn_import.Top="55"
$POSHGUI_btn_import.Left="300"
$POSHGUI_btn_import.Anchor="Left,Top"
$POSHGUI_btn_import.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_btn_import)
$POSHGUI_btn_import.Text="Import Team"
$POSHGUI_btn_import.Size = New-Object System.Drawing.Size(100,23)
# Add Custom Code Below - Do NOT Edit This Line!
# Rank: 5=GOD, 4=Demigod, 3=Useable, 2=Mediocre, 1=Trash
$csvData = @"
Hero,Team Wide Defense Buff,Enemy Buff Purge,Massive AOE Damage,Damage with Utility,Early Burst Damage,Campaign-RaidRank,ArenaOffense-Blitz,ArenaDefense-AI
Vision,No,Yes,Yes,Yes,No,5,5,4
Yondu,No,Yes,Yes,Yes,No,5,5,5
Black Widow,No,Yes,No,Yes,No,5,5,5
Doctor Strange,No,Yes,No,Yes,No,4,5,4
Hawkeye,No,Yes,No,Yes,No,4,4,4
Quake,No,Yes,Yes,No,No,5,5,5
Antman,No,Yes,No,No,No,3,4,3
Elektra,No,Yes,No,No,No,3,3,3
Hand Archer,No,Yes,No,No,No,3,3,2
Jessica Jones,No,Yes,No,No,No,4,4,4
Shield Operative,No,Yes,No,No,No,3,3,3
Captain America,Yes,Yes,No,No,No,4,4,4
Thanos,No,No,Yes,Yes,Yes,5,4,4
Wasp,No,No,Yes,Yes,Yes,4,4,3
Iron Man,No,No,Yes,No,Yes,5,4,4
Korath,No,No,No,Yes,Yes,4,5,4
Rocket Racoon,No,No,Yes,No,Yes,4,4,4
Starlord,No,No,No,Yes,Yes,4,4,3
Black Panther,No,No,No,Yes,No,5,4,3
Bullseye,No,No,No,No,Yes,3,3,3
Cable,No,No,No,Yes,No,4,5,3
Crossbones,No,No,Yes,No,No,4,4,4
Daredevil,No,No,No,No,Yes,4,4,3
Deadpool,No,No,No,No,Yes,5,5,4
Gamora,No,No,No,No,Yes,4,4,3
Merc Lieutenant,No,No,No,Yes,No,4,4,3
Merc Sniper,No,No,No,No,Yes,3,3,2
Mordo,No,No,No,Yes,No,4,4,3
Nobu,No,No,No,Yes,No,3,4,3
Spiderman,No,No,No,Yes,No,5,5,4
Thor,No,No,Yes,No,No,3,3,3
Winter Soldier,No,No,No,No,Yes,4,4,4
Hand Sentry,Yes,No,No,No,No,4,4,4
Kingpin,Yes,No,No,No,No,5,5,5
Luke Cage,Yes,No,No,No,No,4,3,3
Merc Riot Guard,Yes,No,No,No,No,4,4,4
Scarlet Witch,Yes,No,No,Yes,No,4,4,3
Loki,No,No,No,Yes,Yes,4,4,4
Okoye,No,No,No,Yes,Yes,4,4,3
Nick Fury,No,No,No,Yes,No,4,4,5
Ms Marvel,No,No,No,No,Yes,3,3,3
"
@

# Import Character Data
$charDataImport = $csvData | ConvertFrom-Csv

Function Load-ComboBoxes {

    # Clear comboboxes
    $POSHGUI_cmb_Hero1.Items.Clear() # Team-Wide Defense Buff
    $POSHGUI_cmb_Hero2.Items.Clear() # Early Burst Damage
    $POSHGUI_cmb_Hero3.Items.Clear() # Enemy Buff Purge
    $POSHGUI_cmb_Hero4.Items.Clear() # Massive AOE
    $POSHGUI_cmb_Hero5.Items.Clear() # Damage with Utility
    $POSHGUI_cmb_Battletype.Items.Clear()

    $POSHGUI_cmb_Hero1.Text = ""
    $POSHGUI_cmb_Hero2.Text = ""
    $POSHGUI_cmb_Hero3.Text = ""
    $POSHGUI_cmb_Hero4.Text = ""
    $POSHGUI_cmb_Hero5.Text = ""
    $POSHGUI_cmb_Battletype.Text = ""

    $POSHGUI_lbl_SureToWin.Text = ""

    [void]$POSHGUI_cmb_Battletype.Items.Add("Arena Defense / AI")
    [void]$POSHGUI_cmb_Battletype.Items.Add("Arena Offense / Blitz")
    [void]$POSHGUI_cmb_Battletype.Items.Add("Raid / Campaign")

    # Add characters to comboboxes
    ForEach ($char in $charDataImport){
       
        If ($char.'Team Wide Defense Buff' -eq 'Yes' -or $char.'Team Wide Defense Buff' -eq 'Meh'){
            [void]$POSHGUI_cmb_Hero1.items.Add($char.Hero)
        }

        If ($char.'Early Burst Damage' -eq 'Yes'){
            [void]$POSHGUI_cmb_Hero2.items.Add($char.Hero)
        }

        If ($char.'Enemy Buff Purge' -eq 'Yes'){
            [void]$POSHGUI_cmb_Hero3.items.Add($char.Hero)
        }

        If ($char.'Massive AOE Damage' -eq 'Yes'){
            [void]$POSHGUI_cmb_Hero4.items.Add($char.Hero)
        }

        If ($char.'Damage with Utility' -eq 'Yes'){
            [void]$POSHGUI_cmb_Hero5.items.Add($char.Hero)
        }

    }

}

Load-comboboxes

# Create Datatable for team building output
$Global:DToutput = New-Object System.Data.DataTable
[void]$Global:DToutput.Columns.Add("STAT")
[void]$Global:DToutput.Columns.Add("Hero 1")
[void]$Global:DToutput.Columns.Add("Hero 2")
[void]$Global:DToutput.Columns.Add("Hero 3")
[void]$Global:DToutput.Columns.Add("Hero 4")
[void]$Global:DToutput.Columns.Add("Hero 5")
[void]$Global:DToutput.Columns.Add("Sure To Win?")
$POSHGUI_DGV_TeamResults.DataSource = $Global:DToutput
$POSHGUI_DGV_TeamResults.AutoSizeColumnsMode = "AllCells"
$POSHGUI_DGV_TeamResults.ReadOnly = $true
$POSHGUI_DGV_TeamResults.AllowUserToAddRows = $false

Function Show-TeamOutput {

    # $POSHGUI_cmb_Hero1.SelectedItem = "Kingpin"

    $Hero1output = $charDataImport | Where-Object {$_.Hero -eq $POSHGUI_cmb_Hero1.SelectedItem}
    $Hero2output = $charDataImport | Where-Object {$_.Hero -eq $POSHGUI_cmb_Hero2.SelectedItem}
    $Hero3output = $charDataImport | Where-Object {$_.Hero -eq $POSHGUI_cmb_Hero3.SelectedItem}
    $Hero4output = $charDataImport | Where-Object {$_.Hero -eq $POSHGUI_cmb_Hero4.SelectedItem}
    $Hero5output = $charDataImport | Where-Object {$_.Hero -eq $POSHGUI_cmb_Hero5.SelectedItem}

    $DTteam = $Global:DToutput.Clone()    
    $row1 = $DTteam.NewRow()        
    $row1.STAT = "Team Wide Defense Buff"
    $row1.'Hero 1' = $Hero1output.'Team Wide Defense Buff'
    $row1.'Hero 2' = $Hero2output.'Team Wide Defense Buff'
    $row1.'Hero 3' = $Hero3output.'Team Wide Defense Buff'
    $row1.'Hero 4' = $Hero4output.'Team Wide Defense Buff'
    $row1.'Hero 5' = $Hero5output.'Team Wide Defense Buff'
    $row1Count = 0
    If ($Hero1output.'Team Wide Defense Buff' -eq 'Yes'){$row1Count += 1} ElseIf ($Hero1output.'Team Wide Defense Buff' -eq 'Meh'){$row1Count += 0.5}
    If ($Hero2output.'Team Wide Defense Buff' -eq 'Yes'){$row1Count += 1} ElseIf ($Hero2output.'Team Wide Defense Buff' -eq 'Meh'){$row1Count += 0.5}
    If ($Hero3output.'Team Wide Defense Buff' -eq 'Yes'){$row1Count += 1} ElseIf ($Hero3output.'Team Wide Defense Buff' -eq 'Meh'){$row1Count += 0.5}
    If ($Hero4output.'Team Wide Defense Buff' -eq 'Yes'){$row1Count += 1} ElseIf ($Hero4output.'Team Wide Defense Buff' -eq 'Meh'){$row1Count += 0.5}
    If ($Hero5output.'Team Wide Defense Buff' -eq 'Yes'){$row1Count += 1} ElseIf ($Hero5output.'Team Wide Defense Buff' -eq 'Meh'){$row1Count += 0.5}
    $row1.'Sure To Win?' =  $row1Count
    $DTteam.rows.Add($row1)

    $row2 = $DTteam.NewRow()        
    $row2.STAT = "Enemy Buff Purge"
    $row2.'Hero 1' = $Hero1output.'Enemy Buff Purge'
    $row2.'Hero 2' = $Hero2output.'Enemy Buff Purge'
    $row2.'Hero 3' = $Hero3output.'Enemy Buff Purge'
    $row2.'Hero 4' = $Hero4output.'Enemy Buff Purge'
    $row2.'Hero 5' = $Hero5output.'Enemy Buff Purge'
    $row2Count = 0
    If ($Hero1output.'Enemy Buff Purge' -eq 'Yes'){$row2Count += 1}
    If ($Hero2output.'Enemy Buff Purge' -eq 'Yes'){$row2Count += 1}
    If ($Hero3output.'Enemy Buff Purge' -eq 'Yes'){$row2Count += 1}
    If ($Hero4output.'Enemy Buff Purge' -eq 'Yes'){$row2Count += 1}
    If ($Hero5output.'Enemy Buff Purge' -eq 'Yes'){$row2Count += 1}
    $row2.'Sure To Win?' = $row2Count
    $DTteam.rows.Add($row2)

    $row3 = $DTteam.NewRow()        
    $row3.STAT = "Massive AOE Damage"
    $row3.'Hero 1' = $Hero1output.'Massive AOE Damage'
    $row3.'Hero 2' = $Hero2output.'Massive AOE Damage'
    $row3.'Hero 3' = $Hero3output.'Massive AOE Damage'
    $row3.'Hero 4' = $Hero4output.'Massive AOE Damage'
    $row3.'Hero 5' = $Hero5output.'Massive AOE Damage'
    $row3Count = 0
    If ($Hero1output.'Massive AOE Damage' -eq 'Yes'){$row3Count += 1}
    If ($Hero2output.'Massive AOE Damage' -eq 'Yes'){$row3Count += 1}
    If ($Hero3output.'Massive AOE Damage' -eq 'Yes'){$row3Count += 1}
    If ($Hero4output.'Massive AOE Damage' -eq 'Yes'){$row3Count += 1}
    If ($Hero5output.'Massive AOE Damage' -eq 'Yes'){$row3Count += 1}
    $row3.'Sure To Win?' = $row3Count
    $DTteam.rows.Add($row3)

    $row4 = $DTteam.NewRow()        
    $row4.STAT = "Damage with Utility"
    $row4.'Hero 1' = $Hero1output.'Damage with Utility'
    $row4.'Hero 2' = $Hero2output.'Damage with Utility'
    $row4.'Hero 3' = $Hero3output.'Damage with Utility'
    $row4.'Hero 4' = $Hero4output.'Damage with Utility'
    $row4.'Hero 5' = $Hero5output.'Damage with Utility'
    $row4Count = 0
    If ($Hero1output.'Damage with Utility' -eq 'Yes'){$row4Count += 1}
    If ($Hero2output.'Damage with Utility' -eq 'Yes'){$row4Count += 1}
    If ($Hero3output.'Damage with Utility' -eq 'Yes'){$row4Count += 1}
    If ($Hero4output.'Damage with Utility' -eq 'Yes'){$row4Count += 1}
    If ($Hero5output.'Damage with Utility' -eq 'Yes'){$row4Count += 1}
    $row4.'Sure To Win?' = $row4Count
    $DTteam.rows.Add($row4)

    $row5 = $DTteam.NewRow()        
    $row5.STAT = "Early Burst Damage"
    $row5.'Hero 1' = $Hero1output.'Early Burst Damage'
    $row5.'Hero 2' = $Hero2output.'Early Burst Damage'
    $row5.'Hero 3' = $Hero3output.'Early Burst Damage'
    $row5.'Hero 4' = $Hero4output.'Early Burst Damage'
    $row5.'Hero 5' = $Hero5output.'Early Burst Damage'
    $row5Count = 0
    If ($Hero1output.'Early Burst Damage' -eq 'Yes'){$row5Count += 1}
    If ($Hero2output.'Early Burst Damage' -eq 'Yes'){$row5Count += 1}
    If ($Hero3output.'Early Burst Damage' -eq 'Yes'){$row5Count += 1}
    If ($Hero4output.'Early Burst Damage' -eq 'Yes'){$row5Count += 1}
    If ($Hero5output.'Early Burst Damage' -eq 'Yes'){$row5Count += 1}
    $row5.'Sure To Win?' = $row5Count
    $DTteam.rows.Add($row5)

    $row6 = $DTteam.NewRow()        
    $row6.STAT = "Total Positives"

    $Hero1Count = 0
    $DTteam.Where{$_.'Hero 1' -eq 'Yes' }.ForEach({$Hero1Count += 1})
    $DTteam.Where{$_.'Hero 1' -eq 'Meh' }.ForEach({$Hero1Count += 0.5})
    $row6.'Hero 1' = $Hero1Count

    $Hero2Count = 0
    $DTteam.Where{$_.'Hero 2' -eq 'Yes' }.ForEach({$Hero2Count += 1})    
    $row6.'Hero 2' = $Hero2Count

    $Hero3Count = 0
    $DTteam.Where{$_.'Hero 3' -eq 'Yes' }.ForEach({$Hero3Count += 1})    
    $row6.'Hero 3' = $Hero3Count

    $Hero4Count = 0
    $DTteam.Where{$_.'Hero 4' -eq 'Yes' }.ForEach({$Hero4Count += 1})    
    $row6.'Hero 4' = $Hero4Count

    $Hero5Count = 0
    $DTteam.Where{$_.'Hero 5' -eq 'Yes' }.ForEach({$Hero5Count += 1})    
    $row6.'Hero 5' = $Hero5Count

    $totalCountPositives = [int]$row6.'Hero 1' + [int]$row6.'Hero 2' + [int]$row6.'Hero 3' + [int]$row6.'Hero 4' + [int]$row6.'Hero 5'

    $row6.'Sure To Win?' = $totalCountPositives
    $DTteam.rows.Add($row6)

    $row7 = $DTteam.NewRow()        
    $row7.STAT = "Hero Tier: 1 (Trash) to 5 (God)"
    Switch ($POSHGUI_cmb_Battletype.SelectedItem){
        # Campaign-RaidRank,ArenaOffense-Blitz,ArenaDefense-AI
        "Arena Defense / AI" {        
            $row7.'Hero 1' = $Hero1output.'ArenaDefense-AI'
            $row7.'Hero 2' = $Hero2output.'ArenaDefense-AI'
            $row7.'Hero 3' = $Hero3output.'ArenaDefense-AI'
            $row7.'Hero 4' = $Hero4output.'ArenaDefense-AI'
            $row7.'Hero 5' = $Hero5output.'ArenaDefense-AI'
        }
        "Arena Offense / Blitz" {
            $row7.'Hero 1' = $Hero1output.'ArenaOffense-Blitz'
            $row7.'Hero 2' = $Hero2output.'ArenaOffense-Blitz'
            $row7.'Hero 3' = $Hero3output.'ArenaOffense-Blitz'
            $row7.'Hero 4' = $Hero4output.'ArenaOffense-Blitz'
            $row7.'Hero 5' = $Hero5output.'ArenaOffense-Blitz'        
        }
        "Raid / Campaign" {
            $row7.'Hero 1' = $Hero1output.'Campaign-RaidRank'
            $row7.'Hero 2' = $Hero2output.'Campaign-RaidRank'
            $row7.'Hero 3' = $Hero3output.'Campaign-RaidRank'
            $row7.'Hero 4' = $Hero4output.'Campaign-RaidRank'
            $row7.'Hero 5' = $Hero5output.'Campaign-RaidRank'            
        }

    }
   
    $DTteam.rows.Add($row7)

    $POSHGUI_DGV_TeamResults.DataSource = $DTteam
}


$POSHGUI_cmb_Hero1.Add_SelectedValueChanged({

    $POSHGUI_cmb_Hero2.Items.Remove($POSHGUI_cmb_Hero1.SelectedItem)
    $POSHGUI_cmb_Hero3.Items.Remove($POSHGUI_cmb_Hero1.SelectedItem)
    $POSHGUI_cmb_Hero4.Items.Remove($POSHGUI_cmb_Hero1.SelectedItem)
    $POSHGUI_cmb_Hero5.Items.Remove($POSHGUI_cmb_Hero1.SelectedItem)

    If ($POSHGUI_cmb_Hero1.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero2.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero3.SelectedIndex -ne -1 `
            -and $POSHGUI_cmb_Hero4.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero5.SelectedIndex -ne -1 -and $POSHGUI_cmb_Battletype.SelectedIndex -ne -1){
                $POSHGUI_lbl_SureToWin.Text = "Team Is Sure To Win!!! (Probably)"
                Show-TeamOutput
    }

})
$POSHGUI_cmb_Hero2.Add_SelectedValueChanged({

    $POSHGUI_cmb_Hero1.Items.Remove($POSHGUI_cmb_Hero2.SelectedItem)
    $POSHGUI_cmb_Hero3.Items.Remove($POSHGUI_cmb_Hero2.SelectedItem)
    $POSHGUI_cmb_Hero4.Items.Remove($POSHGUI_cmb_Hero2.SelectedItem)
    $POSHGUI_cmb_Hero5.Items.Remove($POSHGUI_cmb_Hero2.SelectedItem)

    If ($POSHGUI_cmb_Hero1.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero2.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero3.SelectedIndex -ne -1 `
            -and $POSHGUI_cmb_Hero4.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero5.SelectedIndex -ne -1 -and $POSHGUI_cmb_Battletype.SelectedIndex -ne -1){
                $POSHGUI_lbl_SureToWin.Text = "Team Is Sure To Win!!! (Probably)"
                Show-TeamOutput
    }

})
$POSHGUI_cmb_Hero3.Add_SelectedValueChanged({

    $POSHGUI_cmb_Hero1.Items.Remove($POSHGUI_cmb_Hero3.SelectedItem)
    $POSHGUI_cmb_Hero2.Items.Remove($POSHGUI_cmb_Hero3.SelectedItem)
    $POSHGUI_cmb_Hero4.Items.Remove($POSHGUI_cmb_Hero3.SelectedItem)
    $POSHGUI_cmb_Hero5.Items.Remove($POSHGUI_cmb_Hero3.SelectedItem)

    If ($POSHGUI_cmb_Hero1.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero2.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero3.SelectedIndex -ne -1 `
            -and $POSHGUI_cmb_Hero4.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero5.SelectedIndex -ne -1 -and $POSHGUI_cmb_Battletype.SelectedIndex -ne -1){
                $POSHGUI_lbl_SureToWin.Text = "Team Is Sure To Win!!! (Probably)"
                Show-TeamOutput
    }

})
$POSHGUI_cmb_Hero4.Add_SelectedValueChanged({

    $POSHGUI_cmb_Hero1.Items.Remove($POSHGUI_cmb_Hero4.SelectedItem)
    $POSHGUI_cmb_Hero2.Items.Remove($POSHGUI_cmb_Hero4.SelectedItem)
    $POSHGUI_cmb_Hero3.Items.Remove($POSHGUI_cmb_Hero4.SelectedItem)
    $POSHGUI_cmb_Hero5.Items.Remove($POSHGUI_cmb_Hero4.SelectedItem)

    If ($POSHGUI_cmb_Hero1.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero2.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero3.SelectedIndex -ne -1 `
            -and $POSHGUI_cmb_Hero4.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero5.SelectedIndex -ne -1 -and $POSHGUI_cmb_Battletype.SelectedIndex -ne -1){
                $POSHGUI_lbl_SureToWin.Text = "Team Is Sure To Win!!! (Probably)"
                Show-TeamOutput
    }

})
$POSHGUI_cmb_Hero5.Add_SelectedValueChanged({

    $POSHGUI_cmb_Hero1.Items.Remove($POSHGUI_cmb_Hero5.SelectedItem)
    $POSHGUI_cmb_Hero2.Items.Remove($POSHGUI_cmb_Hero5.SelectedItem)
    $POSHGUI_cmb_Hero3.Items.Remove($POSHGUI_cmb_Hero5.SelectedItem)
    $POSHGUI_cmb_Hero4.Items.Remove($POSHGUI_cmb_Hero5.SelectedItem)

    If ($POSHGUI_cmb_Hero1.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero2.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero3.SelectedIndex -ne -1 `
            -and $POSHGUI_cmb_Hero4.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero5.SelectedIndex -ne -1 -and $POSHGUI_cmb_Battletype.SelectedIndex -ne -1){
                $POSHGUI_lbl_SureToWin.Text = "Team Is Sure To Win!!! (Probably)"
                Show-TeamOutput
    }

})
$POSHGUI_cmb_Battletype.Add_SelectedValueChanged({

   
    If ($POSHGUI_cmb_Hero1.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero2.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero3.SelectedIndex -ne -1 `
            -and $POSHGUI_cmb_Hero4.SelectedIndex -ne -1 -and $POSHGUI_cmb_Hero5.SelectedIndex -ne -1 -and $POSHGUI_cmb_Battletype.SelectedIndex -ne -1){
                $POSHGUI_lbl_SureToWin.Text = "Team Is Sure To Win!!! (Probably)"
                Show-TeamOutput
    }

})


Function Reset-All {

    Load-ComboBoxes
    $POSHGUI_DGV_TeamResults.DataSource.Clear()

}

$POSHGUI_btn_reset.Add_Click({ Reset-All })

$POSHGUI_btn_export.Add_Click({ Export-Team })

$POSHGUI_btn_import.Add_Click({ Import-Team })

Function Export-Team {
   
    $teamExportFile = Get-FileNameExport -initialDirectory $DefaultPath

    If ($teamExportFile){
        $team = [PSCustomObject] @{
            Hero1 = $POSHGUI_cmb_Hero1.SelectedItem
            Hero2 = $POSHGUI_cmb_Hero2.SelectedItem
            Hero3 = $POSHGUI_cmb_Hero3.SelectedItem
            Hero4 = $POSHGUI_cmb_Hero4.SelectedItem
            Hero5 = $POSHGUI_cmb_Hero5.SelectedItem
        }
        $team | ConvertTo-Json | Out-File $teamExportFile
    }
}

Function Import-Team {
   
    $teamImportFile = Get-FileNameImport -initialDirectory $DefaultPath

    If ($teamImportFile){
        Reset-All

        $team = Get-Content $teamImportFile | ConvertFrom-Json

        $POSHGUI_cmb_Hero1.SelectedItem = $team.Hero1
        $POSHGUI_cmb_Hero2.SelectedItem = $team.Hero2
        $POSHGUI_cmb_Hero3.SelectedItem = $team.Hero3
        $POSHGUI_cmb_Hero4.SelectedItem = $team.Hero4
        $POSHGUI_cmb_Hero5.SelectedItem = $team.Hero5

    }

}

$DefaultPath = "$env:USERPROFILE\Documents"

Function Get-FileNameExport($initialDirectory)  {
    $SaveFileDialog = New-Object System.Windows.Forms.SaveFileDialog
    $SaveFileDialog.initialDirectory = $initialDirectory
    $SaveFileDialog.filter = “JSON files (*.json)|*.json”
    $SaveFileDialog.ShowDialog() | Out-Null
    $SaveFileDialog.filename          
}
 
Function Get-FileNameImport($initialDirectory)  {
    $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
    $OpenFileDialog.initialDirectory = $initialDirectory
    $OpenFileDialog.filter = “JSON files (*.json)|*.json”
    $OpenFileDialog.ShowDialog() | Out-Null
    $OpenFileDialog.filename          
}

# Add Custom Code Above - Do NOT Edit This Line!
$null = $POSHGUI_MyForm.ShowDialog()

Marvel’s Strike Force – Raid / Lane Assignment Calculator

MSFCalc

This calculator for Marvel’s Strike Force mobile based game is for determining Raid Lane assignment for Alliance members.

There are options to assign by Strongest Team Power (STP), Total Collection Power(TCP), or Randomly.

You just plug in your player’s information, edit the lane difficulty for the desired raids (you can add and delete raids), then select your assignment scheme, and calculate the assignments. It’s just that easy!

If you have any questions, comments or suggestions, do leave them below.

The script does not require admin rights, nor does it perform any web calls.
Download below or copy/paste from the code below into a text file and save as MSFcalc.ps1.
Right-click the file and select Run With PowerShell.

The script will create two files on your desktop that contain the player data and the raid lane difficulty data. MSFPlayerData.json and MSFRaidData.json

As noted by a user, depending on the restrictions for running scripts on your computer, you may need to run PowerShell as Admin to run the command ‘Set-ExecutionPolicy -ExecutionPolicy Bypass’ to enable scripts to run (instead of Bypass, you may need to use Unrestricted). This script itself does not need Admin rights.

Note: As this is PowerShell, you’re free to modify and distribute as you wish, but please do give proper credit to me for this original work.

MSFCalc v1.5
MSFCalc v1.5
MSFCalc Example
MSFCalc Example

Changelog

  • 1.5 – Removed additional lane assignment. Fixed lane assignments where lane difficulty is 0 (unused), the lane is not used for assignment. Added ‘Support’ lanes for overflow players beyond the assigned lanes with specified difficulties.
  • 1.4 – Added an additional lane for larger raids.
  • 1.3 – Added a lane format selection to change between Letters and Numbers. This is only applicable to the Raid Lane Assignment Output and not the Raid / Lane difficulty setup so as to maintain backwards compatibility for previous versions. A=1, B=2, C=3 etc.
  • 1.2 – Reduced code for redundant calculation operations
  • 1.1 – Changed lane assignments from 1 to 9, to A through I, which reflects the beginning of the node identifiers in game
  • 1.0 – Initial Release
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
# MSFCalc - Marvel's Strike Force Raid / Lane Assignment Calculator
#
# Created by Archimedez @ FrontRunnerTek.com
#
# Created:  2018-08-07
# Modified: 2018-11-16
# Version: 1.5
# ======================================================================
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$POSHGUI_MyForm = New-Object System.Windows.Forms.Form
$POSHGUI_MyForm.Text="MSFCalc v1.5"
$POSHGUI_MyForm.StartPosition = "CenterScreen"
$POSHGUI_MyForm.Size = New-Object System.Drawing.Size(900,620)
$POSHGUI_DGV_PlayerData = New-Object System.Windows.Forms.DataGridView
$POSHGUI_DGV_PlayerData.Top="45"
$POSHGUI_DGV_PlayerData.Left="10"
$POSHGUI_DGV_PlayerData.Anchor="Left,Top"
$POSHGUI_DGV_PlayerData.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_DGV_PlayerData)
$POSHGUI_DGV_PlayerData.Text="DataGridView1"
$POSHGUI_DGV_PlayerData.Size = New-Object System.Drawing.Size(425,400)
$POSHGUI_DGV_RaidOutput = New-Object System.Windows.Forms.DataGridView
$POSHGUI_DGV_RaidOutput.Top="45"
$POSHGUI_DGV_RaidOutput.Left="450"
$POSHGUI_DGV_RaidOutput.Anchor="Left,Top"
$POSHGUI_DGV_RaidOutput.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_DGV_RaidOutput)
$POSHGUI_DGV_RaidOutput.Text="DataGridView2"
$POSHGUI_DGV_RaidOutput.Size = New-Object System.Drawing.Size(425,400)
$POSHGUI_cmb_raidSelect = New-Object System.Windows.Forms.ComboBox
$POSHGUI_cmb_raidSelect.Top="19"
$POSHGUI_cmb_raidSelect.Left="540"
$POSHGUI_cmb_raidSelect.Anchor="Left,Top"
$POSHGUI_cmb_raidSelect.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_cmb_raidSelect)
$POSHGUI_cmb_raidSelect.Text="EDIT Raids & Lanes, or Choose A Raid To Assign"
$POSHGUI_cmb_raidSelect.Size = New-Object System.Drawing.Size(334,23)
$POSHGUI_lbl_raidSelect = New-Object System.Windows.Forms.Label
$POSHGUI_lbl_raidSelect.Top="25"
$POSHGUI_lbl_raidSelect.Left="450"
$POSHGUI_lbl_raidSelect.Anchor="Left,Top"
$POSHGUI_lbl_raidSelect.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_lbl_raidSelect)
$POSHGUI_lbl_raidSelect.Text="Select Raid"
$POSHGUI_lbl_raidSelect.Size = New-Object System.Drawing.Size(100,23)
$POSHGUI_btn_calcAssignment = New-Object System.Windows.Forms.Button
$POSHGUI_btn_calcAssignment.Top="451"
$POSHGUI_btn_calcAssignment.Left="675"
$POSHGUI_btn_calcAssignment.Anchor="Left,Top"
$POSHGUI_btn_calcAssignment.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_btn_calcAssignment)
$POSHGUI_btn_calcAssignment.Text="Calculate Assignments"
$POSHGUI_btn_calcAssignment.Size = New-Object System.Drawing.Size(200,23)
$POSHGUI_lbl_AllianceCountHeader = New-Object System.Windows.Forms.Label
$POSHGUI_lbl_AllianceCountHeader.Top="25"
$POSHGUI_lbl_AllianceCountHeader.Left="10"
$POSHGUI_lbl_AllianceCountHeader.Anchor="Left,Top"
$POSHGUI_lbl_AllianceCountHeader.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_lbl_AllianceCountHeader)
$POSHGUI_lbl_AllianceCountHeader.Text="Alliance Count"
$POSHGUI_lbl_AllianceCountHeader.Size = New-Object System.Drawing.Size(80,23)
$POSHGUI_lbl_AllianceCount = New-Object System.Windows.Forms.Label
$POSHGUI_lbl_AllianceCount.Top="25"
$POSHGUI_lbl_AllianceCount.Left="110"
$POSHGUI_lbl_AllianceCount.Anchor="Left,Top"
$POSHGUI_lbl_AllianceCount.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_lbl_AllianceCount)
$POSHGUI_lbl_AllianceCount.Text="0/24"
$POSHGUI_lbl_AllianceCount.Size = New-Object System.Drawing.Size(100,23)
$POSHGUI_DGV_laneDifficulty = New-Object System.Windows.Forms.DataGridView
$POSHGUI_DGV_laneDifficulty.Top="480"
$POSHGUI_DGV_laneDifficulty.Left="10"
$POSHGUI_DGV_laneDifficulty.Anchor="Left,Top,Bottom"
$POSHGUI_DGV_laneDifficulty.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_DGV_laneDifficulty)
$POSHGUI_DGV_laneDifficulty.Text="DataGridView3"
$POSHGUI_DGV_laneDifficulty.Size = New-Object System.Drawing.Size(865,90)
$POSHGUI_lbl_laneDifficulty = New-Object System.Windows.Forms.Label
$POSHGUI_lbl_laneDifficulty.Top="460"
$POSHGUI_lbl_laneDifficulty.Left="10"
$POSHGUI_lbl_laneDifficulty.Anchor="Left,Top"
$POSHGUI_lbl_laneDifficulty.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_lbl_laneDifficulty)
$POSHGUI_lbl_laneDifficulty.Text="Define Lane Difficulty (1 = Easiest, 9 = Hardest, 0 = Lane Unused)"
$POSHGUI_lbl_laneDifficulty.Size = New-Object System.Drawing.Size(350,23)
$POSHGUI_cmb_AssignType = New-Object System.Windows.Forms.ComboBox
$POSHGUI_cmb_AssignType.Top="453"
$POSHGUI_cmb_AssignType.Left="564"
$POSHGUI_cmb_AssignType.Anchor="Left,Top"
$POSHGUI_cmb_AssignType.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_cmb_AssignType)
$POSHGUI_cmb_AssignType.Text="Select Scheme"
$POSHGUI_cmb_AssignType.Size = New-Object System.Drawing.Size(100,23)
$POSHGUI_lbl_assignType = New-Object System.Windows.Forms.Label
$POSHGUI_lbl_assignType.Top="458"
$POSHGUI_lbl_assignType.Left="449"
$POSHGUI_lbl_assignType.Anchor="Left,Top"
$POSHGUI_lbl_assignType.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_lbl_assignType)
$POSHGUI_lbl_assignType.Text="Assignment Scheme"
$POSHGUI_lbl_assignType.Size = New-Object System.Drawing.Size(150,23)
$POSHGUI_cmb_laneFormat = New-Object System.Windows.Forms.ComboBox
$POSHGUI_cmb_laneFormat.Top="19"
$POSHGUI_cmb_laneFormat.Left="335"
$POSHGUI_cmb_laneFormat.Anchor="Left,Top"
$POSHGUI_cmb_laneFormat.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_cmb_laneFormat)
$POSHGUI_cmb_laneFormat.Text="Select"
$POSHGUI_cmb_laneFormat.Size = New-Object System.Drawing.Size(100,23)
$POSHGUI_lbl_laneFormat = New-Object System.Windows.Forms.Label
$POSHGUI_lbl_laneFormat.Top="25"
$POSHGUI_lbl_laneFormat.Left="255"
$POSHGUI_lbl_laneFormat.Anchor="Left,Top"
$POSHGUI_lbl_laneFormat.Parent=""
$POSHGUI_MyForm.Controls.Add($POSHGUI_lbl_laneFormat)
$POSHGUI_lbl_laneFormat.Text="Lane Format"
$POSHGUI_lbl_laneFormat.Size = New-Object System.Drawing.Size(100,23)
# Add Custom Code Below - Do NOT Edit This Line!
CLS

# Relaunch in regular PowerShell console window if launched in ISE
If ($host.Name -like "*ISE*"){    
    Write-Warning "Launching into a regular powershell console window"
    If ($MyInvocation.MyCommand.Path) {
        $scriptpath = $MyInvocation.MyCommand.Path -replace ' ', '` '
        Invoke-Expression "start powershell {$scriptpath}"
    }
    break
}

$DefaultPath = "$env:USERPROFILE\Documents"
$savePlayerDataFile = "$env:USERPROFILE\Desktop\MSFPlayerData.json"
$saveRaidDataFile = "$env:USERPROFILE\Desktop\MSFRaidData.json"

[void]$POSHGUI_cmb_AssignType.Items.Add("STP")
[void]$POSHGUI_cmb_AssignType.Items.Add("TCP")
[void]$POSHGUI_cmb_AssignType.Items.Add("Random")

[void]$POSHGUI_cmb_laneFormat.Items.Add("Letters")
[void]$POSHGUI_cmb_laneFormat.Items.Add("Numbers")

$POSHGUI_cmb_laneFormat.Add_SelectedValueChanged({
    Lane-Assignment
})

Function Lane-Assignment {

    switch ($POSHGUI_cmb_laneFormat.SelectedItem)
    {
        'Letters' {
       
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane A' -or $_.Lane -eq 'Lane 1'}).LANE = 'Lane A'}Catch{}
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane B' -or $_.Lane -eq 'Lane 2'}).LANE = 'Lane B'}Catch{}
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane C' -or $_.Lane -eq 'Lane 3'}).LANE = 'Lane C'}Catch{}
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane D' -or $_.Lane -eq 'Lane 4'}).LANE = 'Lane D'}Catch{}
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane E' -or $_.Lane -eq 'Lane 5'}).LANE = 'Lane E'}Catch{}
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane F' -or $_.Lane -eq 'Lane 6'}).LANE = 'Lane F'}Catch{}
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane G' -or $_.Lane -eq 'Lane 7'}).LANE = 'Lane G'}Catch{}
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane H' -or $_.Lane -eq 'Lane 8'}).LANE = 'Lane H'}Catch{}
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane I' -or $_.Lane -eq 'Lane 9'}).LANE = 'Lane I'}Catch{}
       
        }
        'Numbers' {
       
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane A' -or $_.Lane -eq 'Lane 1'}).LANE = 'Lane 1'}Catch{}
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane B' -or $_.Lane -eq 'Lane 2'}).LANE = 'Lane 2'}Catch{}
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane C' -or $_.Lane -eq 'Lane 3'}).LANE = 'Lane 3'}Catch{}
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane D' -or $_.Lane -eq 'Lane 4'}).LANE = 'Lane 4'}Catch{}
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane E' -or $_.Lane -eq 'Lane 5'}).LANE = 'Lane 5'}Catch{}
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane F' -or $_.Lane -eq 'Lane 6'}).LANE = 'Lane 6'}Catch{}
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane G' -or $_.Lane -eq 'Lane 7'}).LANE = 'Lane 7'}Catch{}
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane H' -or $_.Lane -eq 'Lane 8'}).LANE = 'Lane 8'}Catch{}
            Try{($POSHGUI_DGV_RaidOutput.DataSource.Rows | Where-Object {$_.Lane -eq 'Lane I' -or $_.Lane -eq 'Lane 9'}).LANE = 'Lane 9'}Catch{}

        }

    }

}

Function Save-Data {    
        # Export the player data          
        $POSHGUI_DGV_PlayerData.DataSource | Select-Object * -ExcludeProperty ItemArray, Table, RowError, RowState, HasErrors | ConvertTo-Json | Out-File $savePlayerDataFile
        # Ensure tables are saved and validated before saving so we don't write empty files
        # Export raid / lane data
    If ($POSHGUI_cmb_raidSelect.SelectedItem -eq "EDIT Raids & Lanes, or Choose A Raid To Assign") {        
        $POSHGUI_DGV_laneDifficulty.DataSource |  Select-Object * -ExcludeProperty ItemArray, Table, RowError, RowState, HasErrors | ConvertTo-Json | Out-File $saveRaidDataFile
        $POSHGUI_cmb_raidSelect.Items.Clear()
        $POSHGUI_cmb_raidSelect.Items.Add("EDIT Raids & Lanes, or Choose A Raid To Assign")
        ForEach ($raid in $Global:DTlaneDifficulty){
            If ($raid.raid -ne $null -and $POSHGUI_cmb_raidSelect.Items -notcontains $raid.Raid){            
                [void]$POSHGUI_cmb_raidSelect.Items.Add($raid.Raid)
            }
        }
    }
}

# Create systems list datatable
[System.Data.DataTable]$Global:DTplayers = New-Object System.Data.Datatable
$Global:DTplayers.TableName = "PlayerData"
[void]$Global:DTplayers.Columns.Add("PlayerName")
[void]$Global:DTplayers.Columns.Add("STP")
[void]$Global:DTplayers.Columns.Add("TCP")
$POSHGUI_DGV_PlayerData.Font = New-Object System.Drawing.Font("Lucida Console",10,[System.Drawing.FontStyle]::Regular)
$POSHGUI_DGV_PlayerData.DataSource = $Global:DTplayers
$POSHGUI_DGV_PlayerData.AutoSizeColumnsMode = "Fill"

# Create raid assignment datatable
[System.Data.DataTable]$Global:DTraidOutput = New-Object System.Data.Datatable
[void]$Global:DTraidOutput.Columns.Add("LANE")
[void]$Global:DTraidOutput.Columns.Add("TEAM 1")
[void]$Global:DTraidOutput.Columns.Add("TEAM 2")
[void]$Global:DTraidOutput.Columns.Add("TEAM 3")
$POSHGUI_DGV_RaidOutput.Font = New-Object System.Drawing.Font("Lucida Console",10,[System.Drawing.FontStyle]::Regular)
$POSHGUI_DGV_RaidOutput.DataSource = $Global:DTraidOutput
$POSHGUI_DGV_RaidOutput.AutoSizeColumnsMode = "AllCells"
$POSHGUI_DGV_RaidOutput.AllowUserToAddRows = $false
$POSHGUI_DGV_RaidOutput.RowHeadersVisible = $false
$POSHGUI_DGV_RaidOutput.Padding = "5,5,5,5"

# Create Raid / Lane difficult settings datatable
[System.Data.DataTable]$Global:DTlaneDifficulty = New-Object System.Data.DataTable
$Global:DTlaneDifficulty.TableName = "LaneData"
[void]$Global:DTlaneDifficulty.Columns.Add("Raid")
[void]$Global:DTlaneDifficulty.Columns.Add("Lane A")
[void]$Global:DTlaneDifficulty.Columns.Add("Lane B")
[void]$Global:DTlaneDifficulty.Columns.Add("Lane C")
[void]$Global:DTlaneDifficulty.Columns.Add("Lane D")
[void]$Global:DTlaneDifficulty.Columns.Add("Lane E")
[void]$Global:DTlaneDifficulty.Columns.Add("Lane F")
[void]$Global:DTlaneDifficulty.Columns.Add("Lane G")
[void]$Global:DTlaneDifficulty.Columns.Add("Lane H")
[void]$Global:DTlaneDifficulty.Columns.Add("Lane I")
$POSHGUI_DGV_laneDifficulty.Font = New-Object System.Drawing.Font("Lucida Console",8,[System.Drawing.FontStyle]::Regular)
$POSHGUI_DGV_laneDifficulty.AutoSizeColumnsMode = "Fill"

If ($Global:DTlaneDifficulty.Rows.Count -lt 1){
   $newRow = $Global:DTlaneDifficulty.NewRow()  
   [void]$Global:DTlaneDifficulty.Rows.Add($newRow)
}

Function Get-Assignments {
    Param
    (        
        [Parameter(Mandatory=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=0)]
        $Scheme
    )
   
    Write-Host "Calculating Assignments using $Scheme"
    $tempDT = $Global:DTraidOutput.Clone()
    $playerInfo = $POSHGUI_DGV_PlayerData.DataSource

    switch ($Scheme)
    {
        'STP' { $playerInfoFixed = $playerInfo | Sort-Object  @{e={$_.STP -as [int]}} -Descending }
        'TCP' { $playerInfoFixed = $playerInfo | Sort-Object @{e={$_.TCP -as [int]}} -Descending  }
        'Random' { $playerInfoFixed = $playerInfo | Sort-Object {Get-Random} }
        Default { Write-Host "Invalid Scheme Selected"}
    }
   
    $laneInfo = $POSHGUI_DGV_laneDifficulty.DataSource

    $lane1 = [pscustomobject]@{
    Lane = "Lane A"
    Difficulty = $([int]$laneInfo.item("Lane A"))
    }
    $lane2 = [pscustomobject]@{
    Lane = "Lane B"
    Difficulty = $([int]$laneInfo.item("Lane B"))
    }
    $lane3 = [pscustomobject]@{
    Lane = "Lane C"
    Difficulty = $([int]$laneInfo.item("Lane C"))
    }
    $lane4 = [pscustomobject]@{
    Lane = "Lane D"
    Difficulty = $([int]$laneInfo.item("Lane D"))
    }
    $lane5 = [pscustomobject]@{
    Lane = "Lane E"
    Difficulty = $([int]$laneInfo.item("Lane E"))
    }
    $lane6 = [pscustomobject]@{
    Lane = "Lane F"
    Difficulty = $([int]$laneInfo.item("Lane F"))
    }
    $lane7 = [pscustomobject]@{
    Lane = "Lane G"
    Difficulty = $([int]$laneInfo.item("Lane G"))
    }
    $lane8 = [pscustomobject]@{
    Lane = "Lane H"
    Difficulty = $([int]$laneInfo.item("Lane H"))
    }
    $lane9 = [pscustomobject]@{
    Lane = "Lane I"
    Difficulty = $([int]$laneInfo.item("Lane I"))
    }

        switch ($Scheme)
    {        
        'Random' { $laneArray = @($lane1,$lane2,$lane3,$lane4,$lane5,$lane6,$lane7,$lane8,$lane9) | Where-Object {$_.Difficulty -gt 0} | Sort-Object {Get-Random} }
        Default { $laneArray = @($lane1,$lane2,$lane3,$lane4,$lane5,$lane6,$lane7,$lane8,$lane9) | Where-Object {$_.Difficulty -gt 0} | Sort-Object Difficulty -Descending }
    }

    $pCnt = 0
    $lCnt = 0

    Do {        
       
        $newRow = $tempDT.NewRow()
               
        If ($laneArray[$lCnt].Lane -ne $null){
            $newRow.LANE = $laneArray[$lCnt].Lane
        } Else {
            $newRow.LANE = "Support"
        }

        Try{$newrow.'TEAM 1' = $playerInfoFixed.playername.item($pCnt)}Catch{} ; $pCnt += 1
        Try{$newRow.'TEAM 2' = $playerInfoFixed.playername.item($pCnt)}Catch{} ; $pCnt += 1
        Try{$newRow.'TEAM 3' = $playerInfoFixed.playername.item($pCnt)}Catch{} ; $pCnt += 1
        $tempDT.Rows.Add($newRow)              

        $lCnt += 1

    } Until ($lCnt -ge (($POSHGUI_DGV_PlayerData.RowCount / 3)-1))
   

    $POSHGUI_DGV_RaidOutput.DataSource = $tempDT    
    Lane-Assignment
}

$POSHGUI_btn_calcAssignment.Enabled = $false
$POSHGUI_btn_calcAssignment.Add_Click({

    If ($POSHGUI_cmb_raidSelect.SelectedItem -eq "EDIT Raids & Lanes, or Choose A Raid To Assign" -or $POSHGUI_cmb_raidSelect.SelectedIndex -eq -1){
        # Invalid Selection
    }Else{
        Get-Assignments -Scheme $POSHGUI_cmb_AssignType.SelectedItem
        $POSHGUI_DGV_RaidOutput.ClipboardCopyMode = [System.Windows.Forms.DataGridViewClipboardCopyMode]::EnableAlwaysIncludeHeaderText    
        Write-Host "Calculations Complete"
    }
})


Function Load-Data {
  If (Test-Path -Path $savePlayerDataFile -ErrorAction SilentlyContinue) {
   
    $playerInfo  = Get-Content $savePlayerDataFile -Raw | ConvertFrom-Json
    $raidInfo = Get-Content $saveRaidDataFile -Raw | ConvertFrom-Json

    $Global:DTplayers.Rows.Clear()
    ForEach ($player in $playerInfo){
        $newRow = $Global:DTplayers.NewRow()
        $newRow.PlayerName = $player.PlayerName
        $newrow.STP = $player.STP
        $newRow.TCP = $player.TCP
        [void]$Global:DTplayers.Rows.Add($newRow)
    }

    $Global:DTlaneDifficulty.rows.Clear()
    ForEach ($raid in $raidInfo){
        If ($raid.raid -ne $null){
            $newRow = $Global:DTlaneDifficulty.NewRow()
            $newRow.Raid = $raid.Raid
            $newrow.'Lane A' = $raid.'Lane A'
            $newrow.'Lane B' = $raid.'Lane B'
            $newrow.'Lane C' = $raid.'Lane C'
            $newrow.'Lane D' = $raid.'Lane D'
            $newrow.'Lane E' = $raid.'Lane E'
            $newrow.'Lane F' = $raid.'Lane F'
            $newrow.'Lane G' = $raid.'Lane G'
            $newrow.'Lane H' = $raid.'Lane H'
            $newrow.'Lane I' = $raid.'Lane I'
            [void]$Global:DTlaneDifficulty.Rows.Add($newRow)
            [void]$POSHGUI_cmb_raidSelect.Items.Add($raid.Raid)
        }
    }

  } Else {
    $POSHGUI_DGV_laneDifficulty.DataSource = $Global:DTlaneDifficulty
  }
}

[void]$POSHGUI_cmb_raidSelect.Items.Add("EDIT Raids & Lanes, or Choose A Raid To Assign")

$POSHGUI_cmb_raidSelect.Add_SelectedValueChanged({      

    If ($POSHGUI_cmb_raidSelect.SelectedItem -eq "EDIT Raids & Lanes, or Choose A Raid To Assign") {
        $POSHGUI_DGV_laneDifficulty.AllowUserToAddRows = $true
        $POSHGUI_DGV_laneDifficulty.DataSource = $Global:DTlaneDifficulty
        $POSHGUI_DGV_laneDifficulty.ReadOnly = $false

    } Else {
        $POSHGUI_DGV_laneDifficulty.AllowUserToAddRows = $false
        $POSHGUI_DGV_laneDifficulty.ReadOnly = $true
        $tempLaneData = $Global:DTlaneDifficulty | Where-Object {$_.Raid -eq $($POSHGUI_cmb_raidSelect.SelectedItem)}    
        $tempDT = $Global:DTlaneDifficulty.Clone()

        ForEach ($cell in $tempLaneData){
            $newRow = $tempDT.NewRow()
            $newRow.Raid = $cell.Raid
            $newrow.'Lane A' = $cell.'Lane A'
            $newrow.'Lane B' = $cell.'Lane B'
            $newrow.'Lane C' = $cell.'Lane C'
            $newrow.'Lane D' = $cell.'Lane D'
            $newrow.'Lane E' = $cell.'Lane E'
            $newrow.'Lane F' = $cell.'Lane F'
            $newrow.'Lane G' = $cell.'Lane G'
            $newrow.'Lane H' = $cell.'Lane H'
            $newrow.'Lane I' = $cell.'Lane I'
        }
        [void]$tempDT.Rows.Add($newRow)
   
        $POSHGUI_DGV_laneDifficulty.DataSource = $tempDT  
    }
})

$POSHGUI_DGV_PlayerData.Add_Validated({
    Save-Data
    $playerCount = $POSHGUI_DGV_PlayerData.RowCount
    $POSHGUI_lbl_AllianceCount.Text = " $($playerCount - 1) / 24";
})
$POSHGUI_DGV_laneDifficulty.Add_Validated({Save-Data})

$POSHGUI_cmb_AssignType.Add_SelectedValueChanged({
    If ($this.SelectedIndex -ne -1){
        $POSHGUI_btn_calcAssignment.Enabled = $true
    }
})

Load-Data

# Add Custom Code Above - Do NOT Edit This Line!
$null = $POSHGUI_MyForm.ShowDialog()