Merge pull request #143 from OpzekerIT/dev

trycatch
This commit is contained in:
Lanta 2023-11-23 21:53:19 +01:00 committed by GitHub
commit 78e90fb6e3
3 changed files with 37 additions and 13 deletions

View file

@ -62,7 +62,12 @@ $map_map = @{
"Tiger_Main" = "Taego" "Tiger_Main" = "Taego"
} }
try {
$player_matches = get-content "$scriptroot/../data/player_matches.json" | convertfrom-json -Depth 100 $player_matches = get-content "$scriptroot/../data/player_matches.json" | convertfrom-json -Depth 100
}
catch {
Write-Output 'Unable to read file exitin'
}
$new_win_matches = $player_matches[-1].new_win_matches $new_win_matches = $player_matches[-1].new_win_matches

View file

@ -26,7 +26,13 @@ $headers = @{
'Authorization' = "$apiKey" 'Authorization' = "$apiKey"
} }
$player_matches = @() $player_matches = @()
try {
$player_data = get-content "$scriptroot/../data/player_data.json" | convertfrom-json -Depth 100 $player_data = get-content "$scriptroot/../data/player_data.json" | convertfrom-json -Depth 100
}
catch {
Write-Output 'Unable to read file exitin'
exit
}
foreach ($player in $player_data) { foreach ($player in $player_data) {
@ -66,8 +72,13 @@ foreach ($player in $player_data) {
} }
if (test-path "$scriptroot/../data/player_matches.json") { if (test-path "$scriptroot/../data/player_matches.json") {
try{$old_player_data = get-content "$scriptroot/../data/player_matches.json" | convertfrom-json -Depth 100} try {
catch {exit} $old_player_data = get-content "$scriptroot/../data/player_matches.json" | convertfrom-json -Depth 100
}
catch {
Write-Output 'Unable to read file exitin'
exit
}
$new_ids = ($player_matches.player_matches | where-object { $_.stats.winplace -eq 1 }).id $new_ids = ($player_matches.player_matches | where-object { $_.stats.winplace -eq 1 }).id
$old_ids = ($old_player_data.player_matches | where-object { $_.stats.winplace -eq 1 }).id $old_ids = ($old_player_data.player_matches | where-object { $_.stats.winplace -eq 1 }).id
$new_win_matches = ((Compare-Object -ReferenceObject $old_ids -DifferenceObject $new_ids) | Where-Object { $_.SideIndicator -eq '=>' }).InputObject | Select-Object -Unique $new_win_matches = ((Compare-Object -ReferenceObject $old_ids -DifferenceObject $new_ids) | Where-Object { $_.SideIndicator -eq '=>' }).InputObject | Select-Object -Unique

View file

@ -93,7 +93,15 @@ else {
$oldstats = @() $oldstats = @()
} }
try {
$all_player_matches = get-content "$scriptroot/../data/player_matches.json" | convertfrom-json -Depth 100 $all_player_matches = get-content "$scriptroot/../data/player_matches.json" | convertfrom-json -Depth 100
}
catch {
Write-Output 'Unable to read file exitin'
exit
}
foreach ($player in $all_player_matches) { foreach ($player in $all_player_matches) {
if ($player.psobject.properties.name -eq 'new_win_matches') { if ($player.psobject.properties.name -eq 'new_win_matches') {