Skip to content

Commit

Permalink
feat: tests, blinded event, threw events
Browse files Browse the repository at this point in the history
  • Loading branch information
hjbdev committed Oct 4, 2023
1 parent c6da073 commit 8b93cdb
Show file tree
Hide file tree
Showing 32 changed files with 578 additions and 119 deletions.
18 changes: 0 additions & 18 deletions src/CS2/Models/AllChat.php

This file was deleted.

28 changes: 15 additions & 13 deletions src/CS2/Models/Attack.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,47 @@

class Attack extends Model
{
public const PATTERN = '/"(?P<attackerName>.*)[<](?P<attackerId>\d+)[>][<](?P<attackerSteamId>.*)[>][<](?P<attackerTeam>CT|TERRORIST|Unassigned|Spectator)[>]" \[(?P<attackerX>[\-]?[0-9]+) (?P<attackerY>[\-]?[0-9]+) (?P<attackerZ>[\-]?[0-9]+)\] attacked "(?P<victimName>.*)[<](?P<victimId>\d+)[>][<](?P<victimSteamId>.*)[>][<](?P<victimTeam>CT|TERRORIST|Unassigned|Spectator)[>]" \[(?P<victimX>[\-]?[0-9]+) (?P<victimY>[\-]?[0-9]+) (?P<victimZ>[\-]?[0-9]+)\] with "(?P<attackerWeapon>[a-zA-Z0-9_]+)" \(damage "(?P<attackerDamage>[0-9]+)"\) \(damage_armor "(?P<attackerDamageArmor>[0-9]+)"\) \(health "(?P<victimHealth>[0-9]+)"\) \(armor "(?P<victimArmor>[0-9]+)"\) \(hitgroup "(?P<victimHitGroup>.*)"\)/';

public string $type = 'Attack';

public string $attackerName;

public string $attackerUserId;
public string $attackerId;

public string $attackerSteamId;

public string $attackerTeam;

public string $attackerPosX;
public int $attackerX;

public string $attackerPosY;
public int $attackerY;

public string $attackerPosZ;
public int $attackerZ;

public string $attackerWeapon;

public string $attackerDamage;
public int $attackerDamage;

public string $attackerDamageArmor;
public int $attackerDamageArmor;

public string $attackerHitGroup;
public string $victimHitGroup;

public string $victimName;

public string $victimUserId;
public string $victimId;

public string $victimSteamId;

public string $victimTeam;

public string $victimPosX;
public int $victimX;

public string $victimPosY;
public int $victimY;

public string $victimPosZ;
public int $victimZ;

public string $victimHealth;
public int $victimHealth;

public string $victimArmor;
public int $victimArmor;
}
32 changes: 32 additions & 0 deletions src/CS2/Models/Blinded.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace CSLog\CS2\Models;

use CSLog\Model;

class Blinded extends Model
{
public const PATTERN = '/"(?P<victimName>.+)[<](?P<victimId>\d+)[>][<](?P<victimSteamId>.*)[>][<](?P<victimTeam>CT|TERRORIST|Unassigned|Spectator)[>]" blinded for (?<time>[0-9.]+) by "(?P<throwerName>.+)[<](?P<throwerUserId>\d+)[>][<](?P<throwerSteamId>.*)[>][<](?P<throwerTeam>CT|TERRORIST|Unassigned|Spectator)[>]" from flashbang entindex (?<entindex>[0-9]+)/';

public string $type = 'Blinded';

public string $victimId;

public string $victimName;

public string $victimTeam;

public string $victimSteamId;

public string $throwerUserId;

public string $throwerName;

public string $throwerTeam;

public string $throwerSteamId;

public float $time;

public int $entindex;
}
2 changes: 2 additions & 0 deletions src/CS2/Models/BombDefusing.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class BombDefusing extends Model
{
public const PATTERN = '/"(?P<userName>.+)[<](?P<userId>\d+)[>][<](?P<steamId>.*)[>][<](?P<userTeam>CT|TERRORIST|Unassigned|Spectator)[>]" triggered "(Begin_Bomb_Defuse_With_Kit|Begin_Bomb_Defuse_Without_Kit)"/';

public string $type = 'BombDefusing';

public string $userId;
Expand Down
4 changes: 4 additions & 0 deletions src/CS2/Models/BombPlanting.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class BombPlanting extends Model
{
public const PATTERN = '/"(?P<userName>.+)[<](?P<userId>\d+)[>][<](?P<steamId>.*)[>][<](?P<userTeam>CT|TERRORIST|Unassigned|Spectator)[>]" triggered "Planted_The_Bomb" at bombsite (?P<bombsite>A|B)/';

public string $type = 'BombPlanting';

public string $userId;
Expand All @@ -15,4 +17,6 @@ class BombPlanting extends Model
public string $userTeam;

public string $steamId;

public string $bombsite;
}
2 changes: 2 additions & 0 deletions src/CS2/Models/ChangeMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class ChangeMap extends Model
{
public const PATTERN = '/(Started map|Loading map) "(?P<maps>.*)"/';

public string $type = 'ChangeMap';

public string $maps;
Expand Down
2 changes: 2 additions & 0 deletions src/CS2/Models/ChangeName.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class ChangeName extends Model
{
public const PATTERN = '/"(?P<userName>.+)[<](?P<userId>\d+)[>][<](?P<steamId>.*)[>][<](?P<userTeam>CT|TERRORIST|Unassigned|Spectator)[>]" changed name to "(?P<newName>.*)"/';

public string $type = 'ChangeName';

public string $userId;
Expand Down
2 changes: 2 additions & 0 deletions src/CS2/Models/Connected.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class Connected extends Model
{
public const PATTERN = '/"(?P<userName>.+)[<](?P<userId>\d+)[>][<](?P<steamId>.*)[>][<][>]" connected, address "(?P<address>.*)"/';

public string $type = 'Connected';

public string $userId;
Expand Down
2 changes: 2 additions & 0 deletions src/CS2/Models/Disconnected.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class Disconnected extends Model
{
public const PATTERN = '/"(?P<userName>.+)[<](?P<userId>\d+)[>][<](?P<steamId>.*)[>][<](?P<userTeam>CT|TERRORIST|Unassigned|Spectator)[>]" disconnected \(reason "(?P<reason>[A-Z_]*)"\)/';

public string $type = 'Disconnected';

public string $userId;
Expand Down
2 changes: 2 additions & 0 deletions src/CS2/Models/EnteredTheGame.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class EnteredTheGame extends Model
{
public const PATTERN = '/"(?P<userName>.+)[<](?P<userId>\d+)[>][<](?P<steamId>.*)[>][<][>]" entered the game/';

public string $type = 'EnteredTheGame';

public string $userId;
Expand Down
10 changes: 10 additions & 0 deletions src/CS2/Models/GotTheBomb.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,15 @@

class GotTheBomb extends Model
{
public const PATTERN = '/"(?P<userName>.+)[<](?P<userId>\d+)[>][<](?P<steamId>.*)[>][<](?P<team>CT|TERRORIST|Unassigned|Spectator)[>]" triggered \"Got\_The\_Bomb\"/';

public string $type = 'GotTheBomb';

public string $userName;

public string $userId;

public string $steamId;

public string $team;
}
2 changes: 2 additions & 0 deletions src/CS2/Models/JoinTeam.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class JoinTeam extends Model
{
public const PATTERN = '/"(?P<userName>.+)[<](?P<userId>\d+)[>][<](?P<steamId>.*)[>][<](?P<userTeam>CT|TERRORIST|Unassigned|Spectator)[>]" joined team "(?P<joinTeam>CT|TERRORIST|Unassigned|Spectator)"/';

public string $type = 'JoinTeam';

public string $userId;
Expand Down
28 changes: 15 additions & 13 deletions src/CS2/Models/Kill.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,37 @@

class Kill extends Model
{
public const PATTERN = '/"(?P<killerName>.+)[<](?P<killerId>\d+)[>][<](?P<killerSteamId>.*)[>][<](?P<killerTeam>CT|TERRORIST|Unassigned|Spectator)[>]" \[(?P<killerX>[\-]?[0-9]+) (?P<killerY>[\-]?[0-9]+) (?P<killerZ>[\-]?[0-9]+)\] killed "(?P<killedName>.+)[<](?P<killedId>\d+)[>][<](?P<killedSteamId>.*)[>][<](?P<killedTeam>CT|TERRORIST|Unassigned|Spectator)[>]" \[(?P<killedX>[\-]?[0-9]+) (?P<killedY>[\-]?[0-9]+) (?P<killedZ>[\-]?[0-9]+)\] with "(?P<weapon>[a-zA-Z0-9_]+)"(?P<headshot>.*)/';

public string $type = 'Kill';

public string $userId;
public string $killerId;

public string $userName;
public string $killerName;

public string $userTeam;
public string $killerTeam;

public string $steamId;
public string $killerSteamId;

public string $killerX;
public int $killerX;

public string $killerY;
public int $killerY;

public string $killerZ;
public int $killerZ;

public string $killedUserId;
public string $killedId;

public string $killedUserName;
public string $killedName;

public string $killedUserTeam;
public string $killedTeam;

public string $killedSteamId;

public string $killedX;
public int $killedX;

public string $killedY;
public int $killedY;

public string $killedZ;
public int $killedZ;

public string $weapon;

Expand Down
16 changes: 9 additions & 7 deletions src/CS2/Models/KillAssist.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@

class KillAssist extends Model
{
public const PATTERN = '/"(?P<assisterName>.+)[<](?P<assisterId>\d+)[>][<](?P<assisterSteamId>.*)[>][<](?P<assisterTeam>CT|TERRORIST|Unassigned|Spectator)[>]" assisted killing "(?P<killedName>.+)[<](?P<killedId>\d+)[>][<](?P<killedSteamId>.*)[>][<](?P<killedTeam>CT|TERRORIST|Unassigned|Spectator)[>]"/';

public string $type = 'KillAssist';

public string $userId;
public string $assisterId;

public string $userName;
public string $assisterName;

public string $userTeam;
public string $assisterTeam;

public string $steamId;
public string $assisterSteamId;

public string $killedUserId;
public string $killedId;

public string $killedUserName;
public string $killedName;

public string $killedUserTeam;
public string $killedTeam;

public string $killedSteamId;
}
12 changes: 12 additions & 0 deletions src/CS2/Models/MatchEnd.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,17 @@

class MatchEnd extends Model
{
public const PATTERN = '/(Game Over: competitive) (?P<mapGroup>[a-z_0-9]*+) (?P<map>[a-z_0-9]*+) score (?P<scoreA>[0-9]{1,2}):(?P<scoreB>[0-9]{1,2}) after (?P<duration>[0-9]{1,4}) min/';

public string $type = 'MatchEnd';

public string $mapGroup;

public string $map;

public int $scoreA;

public int $scoreB;

public int $duration;
}
4 changes: 4 additions & 0 deletions src/CS2/Models/MatchStart.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@

class MatchStart extends Model
{
public const PATTERN = '/World triggered "Match_Start" on "(?P<map>[a-z_0-9]*+)"/';

public string $type = 'MatchStart';

public string $map;
}
2 changes: 2 additions & 0 deletions src/CS2/Models/MatchStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class MatchStatus extends Model
{
public const PATTERN = '/MatchStatus: Score: (?P<scoreA>[0-9]{1,2}):(?P<scoreB>[0-9]{1,2}) on map "(?P<map>[a-z_0-9]*)" RoundsPlayed: (?P<roundsPlayed>[0-9]{1,2})/';

public string $type = 'MatchStatus';

public int $scoreA;
Expand Down
2 changes: 2 additions & 0 deletions src/CS2/Models/Purchased.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class Purchased extends Model
{
public const PATTERN = '/"(?P<userName>.+)[<](?P<userId>\d+)[>][<](?P<steamId>.*)[>][<](?P<userTeam>CT|TERRORIST|Unassigned|Spectator)[>]" purchased "(?P<object>.*)"/';

public string $type = 'Purchased';

public string $userId;
Expand Down
2 changes: 2 additions & 0 deletions src/CS2/Models/RoundEnd.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@

class RoundEnd extends Model
{
public const PATTERN = '/World triggered "Round_End"/';

public string $type = 'RoundEnd';
}
2 changes: 2 additions & 0 deletions src/CS2/Models/RoundRestart.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@

class RoundRestart extends Model
{
public const PATTERN = '!World triggered "Restart_Round_\((\d+)_(second|seconds)\)"!';

public string $type = 'RoundRestart';
}
6 changes: 4 additions & 2 deletions src/CS2/Models/RoundScored.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class RoundScored extends Model
{
public const PATTERN = '/Team "(?P<team>.*)" triggered "SFUI_Notice_(?P<teamWin>Terrorists_Win|CTs_Win|Target_Bombed|Target_Saved|Bomb_Defused)/';

public const TARGET_BOMBED = 'target_bombed';

public const NORMAL = 'normal';
Expand All @@ -29,11 +31,11 @@ public function __construct($data = [])
switch ($this->teamWin) {
case 'Target_Bombed':
$this->winType = self::TARGET_BOMBED;
$this->teamWin = 'T';
$this->teamWin = 'TERRORIST';
break;
case 'Terrorists_Win':
$this->winType = self::NORMAL;
$this->teamWin = 'T';
$this->teamWin = 'TERRORIST';
break;
case 'Target_Saved':
$this->winType = self::SAVED;
Expand Down
2 changes: 2 additions & 0 deletions src/CS2/Models/RoundStart.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class RoundStart extends Model
{
public const PATTERN = '/World triggered "Round_Start"/';

public string $type = 'RoundStart';

public int $time;
Expand Down
2 changes: 2 additions & 0 deletions src/CS2/Models/Say.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class Say extends Model
{
public const PATTERN = '/"(?P<userName>.+)[<](?P<userId>\d+)[>][<](?P<steamId>.*)[>][<](?P<userTeam>CT|TERRORIST|Unassigned|Spectator)[>]" say "(?P<text>.*)"/';

public string $type = 'Say';

public string $userId;
Expand Down
Loading

0 comments on commit 8b93cdb

Please sign in to comment.