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()

6 thoughts on “Marvel’s Strike Force – Raid / Lane Assignment Calculator

  1. This tool is great. We do however use numbered lanes instead of letters. Can you make it an option to choose either?

  2. Amazing work, you could add an option to import member list from a csv or similar file.
    I can also suggest you to built in few templates of actual raids.

  3. Love this tool!
    I just ran across a bug in MSFCalc. I just a had a player exceed 99,999 in STP. If I put in any value of 100,000 or greater, the player list will not sort correctly. In fact it will put him in the lowest (weakest) spot. Can you look into this?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.