Dub / Boat Log Parser by Brozan (Syal)

Related: Snippet

Description: Powershell script to parse logs for upgrades/crew by dub value

1#doubloons for sinking a ship
2#Crew Contracts added to pending salvage
3#1 Ship Upgrades added to pending salvage
4
5
6$last_out_line = ''
7$folders = Get-ChildItem -Path 'C:\Program Files (x86)\Ultima Online Outlands\ClassicUO\Data\Client\JournalLogs' -Name
8foreach($item in $folders) 
9{
10    $files = 'C:\Program Files (x86)\Ultima Online Outlands\ClassicUO\Data\Client\JournalLogs\' + $item
11    foreach($file in $files)
12	{
13		foreach($line in Get-Content $file) 
14		{
15			if ($line -like "*doubloons for sinking a ship*" )
16			{
17				$out_line = $line.substring(42)
18				$out_line = $out_line -replace " doubloons for sinking a ship! They have been placed in the ship's hold."
19				#echo "$out_line"
20			}
21			if ($line -like "*ship's hold: *1*added to pending salvage*" )
22			{		
23				if ($out_line -ne $last_out_line)
24				{	
25					$boat_size = [Math]::Floor([decimal]($out_line.trim() / 2000)) + 1
26					if ($line -like "*Upgrade*" )
27					{
28						$out_drop = "Upgrade" 
29					}
30					else
31					{
32						$out_drop = "Crew_Contract"
33					}
34					$dub_value = $out_line.trim() 
35					echo "$dub_value,$boat_size,$out_drop"
36				}
37				$last_out_line = $out_line
38			}			
39        }
40    }
41}
42