├── .gitattributes ├── .gitignore ├── CSGO-Analyzer.sln ├── Common ├── Common.csproj ├── Properties │ └── AssemblyInfo.cs └── Stringify.cs ├── DemoParser-Console ├── App.config ├── DemoParser-Console.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── DemoParser-Model ├── DemoParser-Model.csproj ├── Frag.cs ├── Game.cs ├── Models │ ├── PlayerRatingData.cs │ ├── ScoreBoard.cs │ └── ScoreBoardLine.cs ├── Observers │ ├── GameObserver.cs │ ├── Observer.cs │ └── ScoreboardObserver.cs ├── Player.cs ├── Properties │ └── AssemblyInfo.cs ├── Round.cs ├── Services │ ├── IRatingService.cs │ ├── IScoreBoardService.cs │ ├── IScoreCalculatorService.cs │ ├── ISteamIdConverter.cs │ ├── RatingService.cs │ ├── ScoreBoardService.cs │ └── ScoreCalculatorService.cs └── Team.cs ├── DemoParser-UI ├── App.config ├── App.xaml ├── App.xaml.cs ├── DemoParser-UI.csproj ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings └── Resources │ └── Flags │ ├── AD.png │ ├── AE.png │ ├── AF.png │ ├── AG.png │ ├── AI.png │ ├── AL.png │ ├── AM.png │ ├── AN.png │ ├── AO.png │ ├── AQ.png │ ├── AR.png │ ├── AS.png │ ├── AT.png │ ├── AU.png │ ├── AW.png │ ├── AX.png │ ├── AZ.png │ ├── BA.png │ ├── BB.png │ ├── BD.png │ ├── BE.png │ ├── BF.png │ ├── BG.png │ ├── BH.png │ ├── BI.png │ ├── BJ.png │ ├── BL.png │ ├── BM.png │ ├── BN.png │ ├── BO.png │ ├── BR.png │ ├── BS.png │ ├── BT.png │ ├── BW.png │ ├── BY.png │ ├── BZ.png │ ├── CA.png │ ├── CC.png │ ├── CD.png │ ├── CF.png │ ├── CG.png │ ├── CH.png │ ├── CI.png │ ├── CK.png │ ├── CL.png │ ├── CM.png │ ├── CN.png │ ├── CO.png │ ├── CR.png │ ├── CU.png │ ├── CV.png │ ├── CW.png │ ├── CX.png │ ├── CY.png │ ├── CZ.png │ ├── DE.png │ ├── DJ.png │ ├── DK.png │ ├── DM.png │ ├── DO.png │ ├── DZ.png │ ├── EC.png │ ├── EE.png │ ├── EG.png │ ├── EH.png │ ├── ER.png │ ├── ES.png │ ├── ET.png │ ├── EU.png │ ├── FI.png │ ├── FJ.png │ ├── FK.png │ ├── FM.png │ ├── FO.png │ ├── FR.png │ ├── GA.png │ ├── GB.png │ ├── GD.png │ ├── GE.png │ ├── GG.png │ ├── GH.png │ ├── GI.png │ ├── GL.png │ ├── GM.png │ ├── GN.png │ ├── GQ.png │ ├── GR.png │ ├── GS.png │ ├── GT.png │ ├── GU.png │ ├── GW.png │ ├── GY.png │ ├── HK.png │ ├── HN.png │ ├── HR.png │ ├── HT.png │ ├── HU.png │ ├── IC.png │ ├── ID.png │ ├── IE.png │ ├── IL.png │ ├── IM.png │ ├── IN.png │ ├── IQ.png │ ├── IR.png │ ├── IS.png │ ├── IT.png │ ├── JE.png │ ├── JM.png │ ├── JO.png │ ├── JP.png │ ├── KE.png │ ├── KG.png │ ├── KH.png │ ├── KI.png │ ├── KM.png │ ├── KN.png │ ├── KP.png │ ├── KR.png │ ├── KW.png │ ├── KY.png │ ├── KZ.png │ ├── LA.png │ ├── LB.png │ ├── LC.png │ ├── LI.png │ ├── LK.png │ ├── LR.png │ ├── LS.png │ ├── LT.png │ ├── LU.png │ ├── LV.png │ ├── LY.png │ ├── MA.png │ ├── MC.png │ ├── MD.png │ ├── ME.png │ ├── MF.png │ ├── MG.png │ ├── MH.png │ ├── MK.png │ ├── ML.png │ ├── MM.png │ ├── MN.png │ ├── MO.png │ ├── MP.png │ ├── MQ.png │ ├── MR.png │ ├── MS.png │ ├── MT.png │ ├── MU.png │ ├── MV.png │ ├── MW.png │ ├── MX.png │ ├── MY.png │ ├── MZ.png │ ├── NA.png │ ├── NC.png │ ├── NE.png │ ├── NF.png │ ├── NG.png │ ├── NI.png │ ├── NL.png │ ├── NO.png │ ├── NP.png │ ├── NR.png │ ├── NU.png │ ├── NZ.png │ ├── OM.png │ ├── PA.png │ ├── PE.png │ ├── PF.png │ ├── PG.png │ ├── PH.png │ ├── PK.png │ ├── PL.png │ ├── PN.png │ ├── PR.png │ ├── PS.png │ ├── PT.png │ ├── PW.png │ ├── PY.png │ ├── QA.png │ ├── RO.png │ ├── RS.png │ ├── RU.png │ ├── RW.png │ ├── SA.png │ ├── SB.png │ ├── SC.png │ ├── SD.png │ ├── SE.png │ ├── SG.png │ ├── SH.png │ ├── SI.png │ ├── SK.png │ ├── SL.png │ ├── SM.png │ ├── SN.png │ ├── SO.png │ ├── SR.png │ ├── SS.png │ ├── ST.png │ ├── SV.png │ ├── SY.png │ ├── SZ.png │ ├── TC.png │ ├── TD.png │ ├── TF.png │ ├── TG.png │ ├── TH.png │ ├── TJ.png │ ├── TK.png │ ├── TL.png │ ├── TM.png │ ├── TN.png │ ├── TO.png │ ├── TR.png │ ├── TT.png │ ├── TV.png │ ├── TW.png │ ├── TZ.png │ ├── UA.png │ ├── UG.png │ ├── US.png │ ├── UY.png │ ├── UZ.png │ ├── VA.png │ ├── VC.png │ ├── VE.png │ ├── VG.png │ ├── VI.png │ ├── VN.png │ ├── VU.png │ ├── WF.png │ ├── WS.png │ ├── YE.png │ ├── YT.png │ ├── ZA.png │ ├── ZM.png │ └── ZW.png ├── DemoParser ├── DataTables │ ├── DataTableParser.cs │ ├── SendTable.cs │ ├── SendTableProperty.cs │ └── ServerClass.cs ├── DemoHeader.cs ├── DemoMessageType.cs ├── DemoParser-Core.csproj ├── DemoParser.cs ├── Entities │ ├── Equipment.cs │ ├── Player.cs │ └── Team.cs ├── Events │ ├── Events.cs │ └── EventsManager.cs ├── Helper.cs ├── Messages │ ├── gcmessages.cs │ ├── netmessages.cs │ ├── steammessages.cs │ └── usermessages.cs ├── Packets │ ├── DemoPacketParser.cs │ ├── Entity.cs │ ├── Handlers │ │ ├── CreateStringTableUserInfoHandler.cs │ │ ├── GameEventHandler.cs │ │ ├── GenericCreateStringTablesHandler.cs │ │ ├── PacketEntitiesHandler.cs │ │ ├── UpdateStringTableUserInfoHandler.cs │ │ └── UserMessageHandler.cs │ ├── IMessageParser.cs │ └── PropertyDecoder.cs ├── Properties │ └── AssemblyInfo.cs ├── Streams │ ├── BitStream │ │ ├── BitArrayStream.cs │ │ ├── BitStreamUtil.cs │ │ ├── DebugBitStream.cs │ │ ├── IBitStream.cs │ │ ├── ManagedBitStream.cs │ │ └── UnsafeBitStream.cs │ └── LimitStream.cs ├── StringTables │ └── StringTableParser.cs ├── Structs.cs └── packages.config ├── License.txt ├── PacketInspector ├── App.config ├── App.xaml ├── App.xaml.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── PacketInspector.csproj └── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── README.md └── TODO.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Dd]ebugPublic/ 12 | [Rr]elease/ 13 | [Rr]eleases/ 14 | x64/ 15 | x86/ 16 | build/ 17 | bld/ 18 | [Bb]in/ 19 | [Oo]bj/ 20 | 21 | # Roslyn cache directories 22 | *.ide/ 23 | 24 | # MSTest test Results 25 | [Tt]est[Rr]esult*/ 26 | [Bb]uild[Ll]og.* 27 | 28 | #NUNIT 29 | *.VisualState.xml 30 | TestResult.xml 31 | 32 | # Build Results of an ATL Project 33 | [Dd]ebugPS/ 34 | [Rr]eleasePS/ 35 | dlldata.c 36 | 37 | *_i.c 38 | *_p.c 39 | *_i.h 40 | *.ilk 41 | *.meta 42 | *.obj 43 | *.pch 44 | *.pdb 45 | *.pgc 46 | *.pgd 47 | *.rsp 48 | *.sbr 49 | *.tlb 50 | *.tli 51 | *.tlh 52 | *.tmp 53 | *.tmp_proj 54 | *.log 55 | *.vspscc 56 | *.vssscc 57 | .builds 58 | *.pidb 59 | *.svclog 60 | *.scc 61 | 62 | # Chutzpah Test files 63 | _Chutzpah* 64 | 65 | # Visual C++ cache files 66 | ipch/ 67 | *.aps 68 | *.ncb 69 | *.opensdf 70 | *.sdf 71 | *.cachefile 72 | 73 | # Visual Studio profiler 74 | *.psess 75 | *.vsp 76 | *.vspx 77 | 78 | # TFS 2012 Local Workspace 79 | $tf/ 80 | 81 | # Guidance Automation Toolkit 82 | *.gpState 83 | 84 | # ReSharper is a .NET coding add-in 85 | _ReSharper*/ 86 | *.[Rr]e[Ss]harper 87 | *.DotSettings.user 88 | 89 | # JustCode is a .NET coding addin-in 90 | .JustCode 91 | 92 | # TeamCity is a build add-in 93 | _TeamCity* 94 | 95 | # DotCover is a Code Coverage Tool 96 | *.dotCover 97 | 98 | # NCrunch 99 | _NCrunch_* 100 | .*crunch*.local.xml 101 | 102 | # MightyMoose 103 | *.mm.* 104 | AutoTest.Net/ 105 | 106 | # Web workbench (sass) 107 | .sass-cache/ 108 | 109 | # Installshield output folder 110 | [Ee]xpress/ 111 | 112 | # DocProject is a documentation generator add-in 113 | DocProject/buildhelp/ 114 | DocProject/Help/*.HxT 115 | DocProject/Help/*.HxC 116 | DocProject/Help/*.hhc 117 | DocProject/Help/*.hhk 118 | DocProject/Help/*.hhp 119 | DocProject/Help/Html2 120 | DocProject/Help/html 121 | 122 | # Click-Once directory 123 | publish/ 124 | 125 | # Publish Web Output 126 | *.[Pp]ublish.xml 127 | *.azurePubxml 128 | # TODO: Comment the next line if you want to checkin your web deploy settings 129 | # but database connection strings (with potential passwords) will be unencrypted 130 | *.pubxml 131 | *.publishproj 132 | 133 | # NuGet Packages 134 | *.nupkg 135 | # The packages folder can be ignored because of Package Restore 136 | **/packages/* 137 | # except build/, which is used as an MSBuild target. 138 | !**/packages/build/ 139 | # If using the old MSBuild-Integrated Package Restore, uncomment this: 140 | #!**/packages/repositories.config 141 | 142 | # Windows Azure Build Output 143 | csx/ 144 | *.build.csdef 145 | 146 | # Windows Store app package directory 147 | AppPackages/ 148 | 149 | # Others 150 | sql/ 151 | *.Cache 152 | ClientBin/ 153 | [Ss]tyle[Cc]op.* 154 | ~$* 155 | *~ 156 | *.dbmdl 157 | *.dbproj.schemaview 158 | *.pfx 159 | *.publishsettings 160 | node_modules/ 161 | 162 | # RIA/Silverlight projects 163 | Generated_Code/ 164 | 165 | # Backup & report files from converting an old project file 166 | # to a newer Visual Studio version. Backup files are not needed, 167 | # because we have git ;-) 168 | _UpgradeReport_Files/ 169 | Backup*/ 170 | UpgradeLog*.XML 171 | UpgradeLog*.htm 172 | 173 | # SQL Server files 174 | *.mdf 175 | *.ldf 176 | 177 | # Business Intelligence projects 178 | *.rdl.data 179 | *.bim.layout 180 | *.bim_*.settings 181 | 182 | # Microsoft Fakes 183 | FakesAssemblies/ 184 | 185 | # ========================= 186 | # Operating System Files 187 | # ========================= 188 | 189 | # OSX 190 | # ========================= 191 | 192 | .DS_Store 193 | .AppleDouble 194 | .LSOverride 195 | 196 | # Icon must end with two \r 197 | Icon 198 | 199 | # Thumbnails 200 | ._* 201 | 202 | # Files that might appear on external disk 203 | .Spotlight-V100 204 | .Trashes 205 | 206 | # Directories potentially created on remote AFP share 207 | .AppleDB 208 | .AppleDesktop 209 | Network Trash Folder 210 | Temporary Items 211 | .apdisk 212 | 213 | # Windows 214 | # ========================= 215 | 216 | # Windows image file caches 217 | Thumbs.db 218 | ehthumbs.db 219 | 220 | # Folder config file 221 | Desktop.ini 222 | 223 | # Recycle Bin used on file shares 224 | $RECYCLE.BIN/ 225 | 226 | # Windows Installer files 227 | *.cab 228 | *.msi 229 | *.msm 230 | *.msp 231 | -------------------------------------------------------------------------------- /CSGO-Analyzer.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2013 for Windows Desktop 4 | VisualStudioVersion = 12.0.30501.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoParser-Core", "DemoParser\DemoParser-Core.csproj", "{ACB37CB0-3D65-4A1D-9740-8F635E3E822F}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{CD0B93A7-CE91-4D0B-8D6B-671CED9FAB87}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoParser-UI", "DemoParser-UI\DemoParser-UI.csproj", "{58E55DE0-72D2-4BE5-A8BB-9EBF0A4FCF61}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoParser-Model", "DemoParser-Model\DemoParser-Model.csproj", "{2914F7C3-8329-4B3A-B170-C13044D6DE4F}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PacketInspector", "PacketInspector\PacketInspector.csproj", "{E1199FFC-F420-49A8-B22E-45A0BF556FDB}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoParser-Console", "DemoParser-Console\DemoParser-Console.csproj", "{5BB2FE69-7CB0-44B7-8B5A-D2DC1D05B748}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Any CPU = Debug|Any CPU 21 | Release|Any CPU = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {ACB37CB0-3D65-4A1D-9740-8F635E3E822F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {ACB37CB0-3D65-4A1D-9740-8F635E3E822F}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {ACB37CB0-3D65-4A1D-9740-8F635E3E822F}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {ACB37CB0-3D65-4A1D-9740-8F635E3E822F}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {CD0B93A7-CE91-4D0B-8D6B-671CED9FAB87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {CD0B93A7-CE91-4D0B-8D6B-671CED9FAB87}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {CD0B93A7-CE91-4D0B-8D6B-671CED9FAB87}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {CD0B93A7-CE91-4D0B-8D6B-671CED9FAB87}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {58E55DE0-72D2-4BE5-A8BB-9EBF0A4FCF61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {58E55DE0-72D2-4BE5-A8BB-9EBF0A4FCF61}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {58E55DE0-72D2-4BE5-A8BB-9EBF0A4FCF61}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {58E55DE0-72D2-4BE5-A8BB-9EBF0A4FCF61}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {2914F7C3-8329-4B3A-B170-C13044D6DE4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {2914F7C3-8329-4B3A-B170-C13044D6DE4F}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {2914F7C3-8329-4B3A-B170-C13044D6DE4F}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {2914F7C3-8329-4B3A-B170-C13044D6DE4F}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {E1199FFC-F420-49A8-B22E-45A0BF556FDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {E1199FFC-F420-49A8-B22E-45A0BF556FDB}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {E1199FFC-F420-49A8-B22E-45A0BF556FDB}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {E1199FFC-F420-49A8-B22E-45A0BF556FDB}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {5BB2FE69-7CB0-44B7-8B5A-D2DC1D05B748}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {5BB2FE69-7CB0-44B7-8B5A-D2DC1D05B748}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {5BB2FE69-7CB0-44B7-8B5A-D2DC1D05B748}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {5BB2FE69-7CB0-44B7-8B5A-D2DC1D05B748}.Release|Any CPU.Build.0 = Release|Any CPU 48 | EndGlobalSection 49 | GlobalSection(SolutionProperties) = preSolution 50 | HideSolutionNode = FALSE 51 | EndGlobalSection 52 | EndGlobal 53 | -------------------------------------------------------------------------------- /Common/Common.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {CD0B93A7-CE91-4D0B-8D6B-671CED9FAB87} 8 | Library 9 | Properties 10 | Common 11 | Common 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 53 | -------------------------------------------------------------------------------- /Common/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Common")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Common")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("8660cb70-f47a-44a9-bae1-4b3cd6687dd4")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Common/Stringify.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Text; 3 | 4 | namespace Common 5 | { 6 | public abstract class Stringify 7 | { 8 | public override string ToString() 9 | { 10 | PropertyInfo[] propertyInfos = this.GetType().GetProperties(); 11 | 12 | var sb = new StringBuilder(); 13 | 14 | foreach (var info in propertyInfos) 15 | { 16 | sb.AppendLine(info.Name + ": " + info.GetValue(this, null).ToString()); 17 | } 18 | 19 | return sb.ToString(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /DemoParser-Console/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /DemoParser-Console/DemoParser-Console.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {5BB2FE69-7CB0-44B7-8B5A-D2DC1D05B748} 8 | Exe 9 | Properties 10 | DemoParser_Console 11 | DemoParser-Console 12 | v4.5 13 | 512 14 | publish\ 15 | true 16 | Disk 17 | false 18 | Foreground 19 | 7 20 | Days 21 | false 22 | false 23 | true 24 | 0 25 | 1.0.0.%2a 26 | false 27 | false 28 | true 29 | 30 | 31 | AnyCPU 32 | true 33 | full 34 | false 35 | bin\Debug\ 36 | DEBUG;TRACE 37 | prompt 38 | 4 39 | 40 | 41 | AnyCPU 42 | pdbonly 43 | true 44 | bin\Release\ 45 | TRACE 46 | prompt 47 | 4 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | {cd0b93a7-ce91-4d0b-8d6b-671ced9fab87} 68 | Common 69 | 70 | 71 | {acb37cb0-3d65-4a1d-9740-8f635e3e822f} 72 | DemoParser-Core 73 | 74 | 75 | 76 | 77 | False 78 | Microsoft .NET Framework 4.5 %28x86 and x64%29 79 | true 80 | 81 | 82 | False 83 | .NET Framework 3.5 SP1 Client Profile 84 | false 85 | 86 | 87 | False 88 | .NET Framework 3.5 SP1 89 | false 90 | 91 | 92 | 93 | 100 | -------------------------------------------------------------------------------- /DemoParser-Console/Program.cs: -------------------------------------------------------------------------------- 1 | using DemoParser_Core; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace DemoParser_Console 10 | { 11 | class Program 12 | { 13 | static void Main(string[] args) 14 | { 15 | DateTime begin; 16 | DateTime end; 17 | 18 | Stream inputStream = new FileStream(args[0], FileMode.Open); 19 | 20 | Console.WriteLine("Parsing..."); 21 | 22 | begin = DateTime.Now; 23 | 24 | DemoParser parser = new DemoParser(inputStream); 25 | parser.ParseDemo(true); 26 | 27 | end = DateTime.Now; 28 | 29 | Console.WriteLine(String.Format("Started: {0}", begin.ToString("HH:mm:ss.ffffff"))); 30 | Console.WriteLine(String.Format("Finished: {0}", end.ToString("HH:mm:ss.ffffff"))); 31 | Console.WriteLine(String.Format("\nTotal: {0}", (end - begin))); 32 | 33 | Console.ReadKey(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /DemoParser-Console/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DemoParser-Console")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DemoParser-Console")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("0174a68a-3200-4c36-a0c9-7c0c85eff85b")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /DemoParser-Model/DemoParser-Model.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {2914F7C3-8329-4B3A-B170-C13044D6DE4F} 8 | Library 9 | Properties 10 | DemoParser_Model 11 | DemoParser-Model 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 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 | {cd0b93a7-ce91-4d0b-8d6b-671ced9fab87} 60 | Common 61 | 62 | 63 | {acb37cb0-3d65-4a1d-9740-8f635e3e822f} 64 | DemoParser-Core 65 | 66 | 67 | 68 | 75 | -------------------------------------------------------------------------------- /DemoParser-Model/Frag.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DemoParser_Model 8 | { 9 | public class Frag 10 | { 11 | public Player Killer { get; set; } 12 | public Player Victim { get; set; } 13 | public Player Assist { get; set; } 14 | public bool Headshot { get; set; } 15 | public bool Penetrated { get; set; } 16 | public string Weapon { get; set; } 17 | 18 | public Frag() { } 19 | 20 | public Frag(Player killer, Player victim, bool headshot, bool penetrated, string weapon) 21 | { 22 | this.Killer = killer; 23 | this.Victim = victim; 24 | this.Headshot = headshot; 25 | this.Penetrated = penetrated; 26 | this.Weapon = weapon; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /DemoParser-Model/Game.cs: -------------------------------------------------------------------------------- 1 | using Common; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace DemoParser_Model 9 | { 10 | public class Game : Stringify 11 | { 12 | public DateTime Date { get; set; } 13 | public string Map { get; set; } 14 | public float Duration { get; set; } 15 | 16 | public List Teams { get; set; } 17 | public List Players { get; set; } 18 | public List Frags { get; set; } 19 | public List Rounds { get; set; } 20 | 21 | public bool IsStarted { get; set; } 22 | 23 | public Game() 24 | { 25 | this.Teams = new List(); 26 | this.Rounds = new List(); 27 | this.Players = new List(); 28 | this.Frags = new List(); 29 | 30 | this.IsStarted = false; 31 | } 32 | 33 | public Game(DateTime date, string map, float duration) : this() 34 | { 35 | this.Date = date; 36 | this.Duration = duration; 37 | this.Map = map; 38 | } 39 | 40 | public Team GetTeam(int teamId) 41 | { 42 | return Teams.Find(t => t.Id == teamId); 43 | } 44 | 45 | public Player GetPlayer(long steamId) 46 | { 47 | return Players.Find(p => p.SteamId == steamId); 48 | } 49 | 50 | public void AddPlayer(Player player) 51 | { 52 | Player existingPlayer = GetPlayer(player.SteamId); 53 | 54 | if (existingPlayer == null) 55 | { 56 | Players.Add(player); 57 | } 58 | else 59 | { 60 | existingPlayer.Team = player.Team; 61 | } 62 | } 63 | 64 | public void AddTeam(Team team) 65 | { 66 | Team existingTeam = GetTeam(team.Id); 67 | 68 | if (existingTeam == null) 69 | Teams.Add(team); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /DemoParser-Model/Models/PlayerRatingData.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace DemoParser_Model.Models 3 | { 4 | public class PlayerRatingData 5 | { 6 | public int Kills { get; set; } 7 | public int Deaths { get; set; } 8 | 9 | public int _1K { get; set; } 10 | public int _2K { get; set; } 11 | public int _3K { get; set; } 12 | public int _4K { get; set; } 13 | public int _5K { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DemoParser-Model/Models/ScoreBoard.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DemoParser_Model.Models 8 | { 9 | public class ScoreBoard 10 | { 11 | private List lines; 12 | 13 | public ScoreBoard() 14 | { 15 | this.lines = new List(); 16 | } 17 | 18 | public void AddLine(ScoreBoardLine line) 19 | { 20 | this.lines.Add(line); 21 | } 22 | 23 | public IReadOnlyList GetLines() 24 | { 25 | return lines; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /DemoParser-Model/Models/ScoreBoardLine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DemoParser_Model.Models 8 | { 9 | public class ScoreBoardLine 10 | { 11 | public string TeamName { get; set; } 12 | public string PlayerName { get; set; } 13 | public int Kills { get; set; } 14 | public int Assist { get; set; } 15 | public int Deaths { get; set; } 16 | //public int Score { get { return (2 * Kills + Assist); } } TODO compute CSGO Score (bomb plant/defuse) 17 | public int Mvp { get; set; } 18 | public int Headshot { get; set; } 19 | public double HSR { get { return Math.Round((double)Headshot / Kills, 2); } } 20 | public double KDR { get { return Math.Round((double)Kills / Deaths, 2); } } 21 | public int KDdiff { get { return Kills - Deaths; } } 22 | public int _1K { get; set; } 23 | public int _2K { get; set; } 24 | public int _3K { get; set; } 25 | public int _4K { get; set; } 26 | public int _5K { get; set; } 27 | //public int _1vX { get; set; } 28 | public double Rating { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /DemoParser-Model/Observers/GameObserver.cs: -------------------------------------------------------------------------------- 1 | using DemoParser_Core; 2 | using DemoParser_Core.Events; 3 | using System; 4 | using System.Linq; 5 | 6 | namespace DemoParser_Model.Observers 7 | { 8 | public class GameObserver : Observer 9 | { 10 | protected Game game; 11 | 12 | public GameObserver(DemoParser demoParser) : base(demoParser) 13 | { 14 | this.game = new Game(); 15 | 16 | var eventsManager = parser.EventsManager; 17 | 18 | eventsManager.HeaderParsed += eventsManager_HeaderParsed; 19 | eventsManager.TeamParsed += eventsManager_TeamParsed; 20 | eventsManager.PlayerParsed += eventsManager_PlayerParsed; 21 | 22 | eventsManager.MatchStarted += eventsManager_MatchStarted; 23 | eventsManager.MatchEnded += eventsManager_MatchEnded; 24 | eventsManager.PlayerKilled += eventsManager_PlayerKilled; 25 | eventsManager.RoundStart += eventsManager_RoundStart; 26 | eventsManager.RoundMvp += eventsManager_RoundMvp; 27 | eventsManager.RoundEnd += eventsManager_RoundEnd; 28 | 29 | eventsManager.BombPlanted += eventsManager_BombPlanted; 30 | eventsManager.BombDefused += eventsManager_BombDefused; 31 | eventsManager.BombExploded += eventsManager_BombExploded; 32 | } 33 | 34 | protected virtual void eventsManager_BombExploded(object sender, BombEventArgs e) 35 | { 36 | 37 | } 38 | 39 | protected virtual void eventsManager_BombDefused(object sender, BombEventArgs e) 40 | { 41 | 42 | } 43 | 44 | protected virtual void eventsManager_BombPlanted(object sender, BombEventArgs e) 45 | { 46 | 47 | } 48 | 49 | protected virtual void eventsManager_PlayerParsed(object sender, PlayerParsedEventArgs e) 50 | { 51 | if (e.Player.Team != null) 52 | { 53 | Team team = game.GetTeam(e.Player.Team.Id); 54 | Player player = new Player(e.Player.Name, e.Player.SteamID, team); 55 | 56 | team.AddPlayer(player); 57 | game.AddPlayer(player); 58 | } 59 | else 60 | { 61 | Player player = new Player(e.Player.Name, e.Player.SteamID, null); 62 | game.AddPlayer(player); 63 | } 64 | } 65 | 66 | protected virtual void eventsManager_TeamParsed(object sender, TeamParsedEventArgs e) 67 | { 68 | Team team = new Team(e.Team.Name, e.Team.Flag); 69 | team.Id = e.Team.Id; 70 | 71 | game.AddTeam(team); 72 | } 73 | 74 | protected virtual void eventsManager_HeaderParsed(object sender, DemoParser_Core.Events.HeaderParsedEventArgs e) 75 | { 76 | game.Map = e.Header.MapName; 77 | game.Duration = e.Header.PlaybackTime; 78 | game.Date = DateTime.Now; 79 | } 80 | 81 | protected virtual void eventsManager_MatchStarted(object sender, MatchStartedEventArgs e) 82 | { 83 | game.IsStarted = true; 84 | 85 | game.Rounds.Clear(); 86 | game.Rounds.Add(new Round()); 87 | } 88 | 89 | protected virtual void eventsManager_MatchEnded(object sender, MatchEndedEventArgs e) 90 | { 91 | 92 | } 93 | 94 | protected virtual void eventsManager_RoundStart(object sender, RoundStartedEventArgs e) 95 | { 96 | if (game.IsStarted) 97 | { 98 | game.Rounds.Add(new Round()); 99 | } 100 | } 101 | 102 | protected virtual void eventsManager_RoundEnd(object sender, RoundEndedEventArgs e) 103 | { 104 | if (game.IsStarted) 105 | { 106 | game.Rounds.Last().Winner = game.GetTeam(e.Team.Id); 107 | game.Rounds.Last().Reason = e.Reason; 108 | //game.Rounds.Last().Duration = e. 109 | } 110 | } 111 | 112 | protected virtual void eventsManager_RoundMvp(object sender, RoundMvpEventArgs e) 113 | { 114 | if (game.IsStarted) 115 | { 116 | game.Rounds.Last().Mvp = game.GetPlayer(e.Player.SteamID); 117 | game.Rounds.Last().Reason = e.Reason; 118 | } 119 | } 120 | 121 | protected virtual void eventsManager_PlayerKilled(object sender, PlayerKilledEventArgs e) 122 | { 123 | if (game.IsStarted) 124 | { 125 | Frag frag = new Frag(); 126 | frag.Killer = game.GetPlayer(e.Killer.SteamID); 127 | frag.Victim = game.GetPlayer(e.Victim.SteamID); 128 | frag.Assist = (e.Assist != null) ? game.GetPlayer(e.Assist.SteamID) : null; 129 | frag.Headshot = e.Headshot; 130 | frag.Penetrated = (e.PenetratedObjects > 0) ? true : false; 131 | frag.Weapon = e.Weapon.OriginalString; 132 | 133 | game.Rounds.Last().Frags.Add(frag); 134 | game.GetPlayer(e.Killer.SteamID).Frags.Add(frag); 135 | game.Frags.Add(frag); 136 | } 137 | } 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /DemoParser-Model/Observers/Observer.cs: -------------------------------------------------------------------------------- 1 | using DemoParser_Core; 2 | 3 | namespace DemoParser_Model.Observers 4 | { 5 | public abstract class Observer 6 | { 7 | protected DemoParser parser; 8 | 9 | public Observer(DemoParser demoParser) 10 | { 11 | this.parser = demoParser; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DemoParser-Model/Observers/ScoreboardObserver.cs: -------------------------------------------------------------------------------- 1 | using DemoParser_Core; 2 | using DemoParser_Core.Events; 3 | using DemoParser_Model.Models; 4 | using DemoParser_Model.Services; 5 | 6 | namespace DemoParser_Model.Observers 7 | { 8 | public class ScoreboardObserver : GameObserver 9 | { 10 | private IScoreBoardService scoreBoardService = new ScoreBoardService(); 11 | 12 | public ScoreBoard scoreBoard = new ScoreBoard(); 13 | 14 | public ScoreboardObserver(DemoParser demoParser) : base(demoParser) 15 | { 16 | 17 | } 18 | 19 | protected override void eventsManager_MatchEnded(object sender, MatchEndedEventArgs e) 20 | { 21 | this.scoreBoard = scoreBoardService.GetScoreBoard(this.game); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /DemoParser-Model/Player.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DemoParser_Model 8 | { 9 | public class Player 10 | { 11 | public string Name { get; set; } 12 | public long SteamId { get; set; } // Unique 13 | public Team Team { get; set; } 14 | public List Frags { get; set; } 15 | 16 | public Player(string name, long steamId, Team team) 17 | { 18 | this.Name = name; 19 | this.SteamId = steamId; 20 | this.Team = team; 21 | this.Frags = new List(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /DemoParser-Model/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DemoParser-Model")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DemoParser-Model")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("f05d4494-842d-493e-b8a1-6e2427a1aad7")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /DemoParser-Model/Round.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DemoParser_Model 8 | { 9 | public class Round 10 | { 11 | public float Duration { get; set; } 12 | public Team Winner { get; set; } 13 | public int Reason { get; set; } 14 | public Player Mvp { get; set; } 15 | public List Frags { get; set; } 16 | 17 | public Round() 18 | { 19 | this.Frags = new List(); 20 | } 21 | 22 | public Round(float duration, Team winner, int reason, Player mvp) : this() 23 | { 24 | this.Duration = duration; 25 | this.Winner = winner; 26 | this.Reason = reason; 27 | this.Mvp = mvp; 28 | this.Frags = new List(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /DemoParser-Model/Services/IRatingService.cs: -------------------------------------------------------------------------------- 1 | using DemoParser_Model.Models; 2 | 3 | namespace DemoParser_Model.Services 4 | { 5 | public interface IRatingService 6 | { 7 | double ComputeRating(int numberOfRounds, PlayerRatingData playerData); 8 | 9 | double ComputeRating(Game game, Player player); 10 | 11 | PlayerRatingData ComputeRatingData(Game game, Player player); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DemoParser-Model/Services/IScoreBoardService.cs: -------------------------------------------------------------------------------- 1 | using DemoParser_Model.Models; 2 | 3 | namespace DemoParser_Model.Services 4 | { 5 | public interface IScoreBoardService 6 | { 7 | ScoreBoard GetScoreBoard(Game game); // OrderType : Team, KDR, Rating, ... 8 | ScoreBoardLine GetScoreBoardLine(Game game, Player player); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /DemoParser-Model/Services/IScoreCalculatorService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DemoParser_Model.Services 8 | { 9 | public interface IScoreCalculatorService 10 | { 11 | int ComputeScore(Game game, Player player); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DemoParser-Model/Services/ISteamIdConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DemoParser_Model.Services 8 | { 9 | public interface ISteamIdConverter 10 | { 11 | long ConvertSteamId(String steamId); 12 | String ConvertSteamId(long steamId); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DemoParser-Model/Services/RatingService.cs: -------------------------------------------------------------------------------- 1 | using DemoParser_Model.Models; 2 | using System; 3 | using System.Linq; 4 | 5 | namespace DemoParser_Model.Services 6 | { 7 | public class RatingService : IRatingService 8 | { 9 | public const double AVERAGE_KPR = 0.679; // (average kills per round) 10 | public const double AVERAGE_SPR = 0.317; // (average survived rounds per round) 11 | public const double AVERAGE_RMK = 1.277; // (average value calculated from rounds with multiple kills: (1K + 4*2K + 9*3K + 16*4K + 25*5K)/Rounds) 12 | 13 | public enum RatingMethod { HLTV_ORG, CSGO, BuRner }; 14 | 15 | public double ComputeRating(int numberOfRounds, PlayerRatingData playerData, RatingMethod method) 16 | { 17 | switch (method) 18 | { 19 | case RatingMethod.HLTV_ORG: return ComputeRating(numberOfRounds, playerData); 20 | case RatingMethod.CSGO: throw new NotImplementedException(); // TODO (score in csgo scoreboard) 21 | case RatingMethod.BuRner: throw new NotImplementedException(); //TODO (assists, clutch) 22 | default: throw new ArgumentException(); 23 | } 24 | } 25 | 26 | /// 27 | /// Compute rating of a player based on the rating formula by hltv.org 28 | /// 29 | /// 30 | /// 31 | /// 32 | public double ComputeRating(int numberOfRounds, PlayerRatingData playerData) 33 | { 34 | int Rounds = numberOfRounds; 35 | 36 | double KillRating = playerData.Kills / (double)Rounds / (double)AVERAGE_KPR; // Kills/Rounds/AverageKPR 37 | double SurvivalRating = (Rounds - playerData.Deaths) / (double)Rounds / (double)AVERAGE_SPR; // (Rounds-Deaths)/Rounds/AverageSPR 38 | double RoundsWithMultipleKillsRating = (playerData._1K + 4 * playerData._2K + 9 * playerData._3K + 16 * playerData._4K + 25 * playerData._5K) / (double)Rounds / (double)AVERAGE_RMK; // (1K + 4*2K + 9*3K + 16*4K + 25*5K)/Rounds/AverageRMK 39 | 40 | return Math.Round((KillRating + 0.7 * SurvivalRating + RoundsWithMultipleKillsRating) / 2.7, 3); 41 | } 42 | 43 | public double ComputeRating(Game game, Player player) 44 | { 45 | PlayerRatingData playerData = ComputeRatingData(game, player); 46 | 47 | return ComputeRating(game.Rounds.Count, playerData); 48 | } 49 | 50 | public PlayerRatingData ComputeRatingData(Game game, Player player) 51 | { 52 | PlayerRatingData data = new PlayerRatingData(); 53 | 54 | int fragByRound; 55 | 56 | foreach (Round round in game.Rounds) 57 | { 58 | fragByRound = 0; 59 | 60 | foreach (Frag frag in round.Frags) 61 | { 62 | if (frag.Killer.SteamId == player.SteamId) 63 | { 64 | data.Kills++; 65 | fragByRound++; 66 | } 67 | 68 | if (frag.Victim.SteamId == player.SteamId) 69 | { 70 | data.Deaths++; 71 | } 72 | } 73 | 74 | switch (fragByRound) 75 | { 76 | case 1: data._1K++; break; 77 | case 2: data._2K++; break; 78 | case 3: data._3K++; break; 79 | case 4: data._4K++; break; 80 | case 5: data._5K++; break; 81 | } 82 | } 83 | 84 | return data; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /DemoParser-Model/Services/ScoreBoardService.cs: -------------------------------------------------------------------------------- 1 | using DemoParser_Model.Models; 2 | 3 | namespace DemoParser_Model.Services 4 | { 5 | public class ScoreBoardService : IScoreBoardService 6 | { 7 | private IRatingService ratingService = new RatingService(); 8 | 9 | public ScoreBoard GetScoreBoard(Game game) // OrderType : Team, KDR, Rating, ... 10 | { 11 | ScoreBoard scoreBoard = new ScoreBoard(); 12 | 13 | foreach (Player player in game.Players) 14 | { 15 | if (player.Frags.Count == 0) //TODO change to IsSpectator 16 | continue; 17 | 18 | scoreBoard.AddLine(GetScoreBoardLine(game, player)); 19 | } 20 | 21 | return scoreBoard; 22 | } 23 | 24 | public ScoreBoardLine GetScoreBoardLine(Game game, Player player) 25 | { 26 | ScoreBoardLine line = new ScoreBoardLine(); 27 | 28 | line.PlayerName = player.Name; 29 | line.TeamName = (player.Team != null) ? player.Team.Name : string.Empty; 30 | 31 | foreach (Round round in game.Rounds) 32 | { 33 | foreach (Frag frag in round.Frags) 34 | { 35 | if (frag.Killer.SteamId == player.SteamId) 36 | { 37 | line.Kills++; 38 | 39 | if (frag.Headshot) 40 | { 41 | line.Headshot++; 42 | } 43 | } 44 | 45 | if (frag.Assist != null && frag.Assist.SteamId == player.SteamId) 46 | { 47 | line.Assist++; 48 | } 49 | 50 | if (frag.Victim.SteamId == player.SteamId) 51 | { 52 | line.Deaths++; 53 | } 54 | } 55 | 56 | if (round.Mvp != null && round.Mvp.SteamId == player.SteamId) 57 | { 58 | line.Mvp++; 59 | } 60 | } 61 | 62 | PlayerRatingData data = ratingService.ComputeRatingData(game, player); 63 | line._1K = data._1K; 64 | line._2K = data._2K; 65 | line._3K = data._3K; 66 | line._4K = data._4K; 67 | line._5K = data._5K; 68 | 69 | line.Rating = ratingService.ComputeRating(game.Rounds.Count, data); 70 | 71 | return line; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /DemoParser-Model/Services/ScoreCalculatorService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DemoParser_Model.Services 8 | { 9 | public class ScoreCalculatorService : IScoreCalculatorService 10 | { 11 | public int ComputeScore(Game game, Player player) 12 | { 13 | /* 14 | 2 points for a bomb plant. (Terrorist Only) 15 | 2 points if that bomb explodes. (Terrorist Only) 16 | 2 points for a kill. 17 | 1 point for an assist. 18 | 5 points for defusing a bomb. (Counter-Terrorist Only) 19 | 2 points for rescuing a hostage. (Counter-Terrorist Only) 20 | -1 point for killing a teammate. 21 | -1 point for committing suicide. 22 | */ 23 | return 0; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DemoParser-Model/Team.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DemoParser_Model 8 | { 9 | public class Team 10 | { 11 | public int Id { get; set; } 12 | 13 | public string Name { get; set; } 14 | public string Flag { get; set; } 15 | public int Score { get; set; } 16 | public int[] Scores { get; set; } 17 | public HashSet Players { get; set; } 18 | 19 | public Team() 20 | { 21 | this.Players = new HashSet(); 22 | } 23 | 24 | public Team(string name, string flag) : this() 25 | { 26 | this.Name = name; 27 | this.Flag = flag; 28 | this.Score = 0; 29 | } 30 | 31 | public void AddPlayer(Player player) 32 | { 33 | if (!Players.Contains(player)) 34 | Players.Add(player); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /DemoParser-UI/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /DemoParser-UI/App.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /DemoParser-UI/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace demoinfogo_ui 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /DemoParser-UI/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 |