1
0
Fork 0
mirror of https://codeberg.org/demostf/api.git synced 2026-06-03 18:04:08 +02:00

kills and player

This commit is contained in:
Robin Appelman 2017-04-03 17:45:56 +02:00
commit f0065d8e86
14 changed files with 861 additions and 143 deletions

109
src/Data/DemoPlayer.php Normal file
View file

@ -0,0 +1,109 @@
<?php declare(strict_types=1);
namespace Demostf\API\Data;
class DemoPlayer implements \JsonSerializable {
/** @var int */
private $id;
/** @var int */
private $userId;
/** @var string */
private $name;
/** @var string */
private $team;
/** @var string */
private $class;
/** @var string */
private $steamId;
/** @var string */
private $avatar;
/** @var int */
private $kills;
/** @var int */
private $assists;
/** @var int */
private $deaths;
public function __construct(int $id, int $userId, string $name, string $team, string $class, string $steamId, string $avatar, int $kills, int $assists, int $deaths) {
$this->id = $id;
$this->userId = $userId;
$this->name = $name;
$this->team = $team;
$this->class = $class;
$this->steamId = $steamId;
$this->avatar = $avatar;
$this->kills = $kills;
$this->assists = $assists;
$this->deaths = $deaths;
}
public function getId(): int {
return $this->id;
}
public function getUserId(): int {
return $this->userId;
}
public function getName(): string {
return $this->name;
}
public function getTeam(): string {
return $this->team;
}
public function getClass(): string {
return $this->class;
}
public function getSteamId(): string {
return $this->steamId;
}
public function getAvatar(): string {
return $this->avatar;
}
public function getKills(): int {
return $this->kills;
}
public function getAssists(): int {
return $this->assists;
}
public function getDeaths(): int {
return $this->deaths;
}
public static function fromRow($row): DemoPlayer {
return new DemoPlayer(
$row['id'],
$row['user_id'],
$row['name'],
$row['team'],
$row['class'],
$row['steamid'],
$row['avatar'],
$row['kills'],
$row['assists'],
$row['deaths']
);
}
public function jsonSerialize() {
return [
'id' => $this->getId(),
'user_id' => $this->getUserId(),
'name' => $this->getName(),
'team' => $this->getTeam(),
'class' => $this->getClass(),
'steamid' => $this->getSteamId(),
'avatar' => $this->getAvatar(),
'kills' => $this->getKills(),
'assists' => $this->getAssists(),
'deaths' => $this->getDeaths()
];
}
}

50
src/Data/Kill.php Normal file
View file

@ -0,0 +1,50 @@
<?php declare(strict_types=1);
namespace Demostf\API\Data;
class Kill {
private $id;
private $demoId;
private $attackerId;
private $assisterId;
private $victimId;
private $weapon;
public function __construct(int $id, int $demoId, int $attackerId, int $assisterId, int $victimId, string $weapon) {
$this->id = $id;
$this->demoId = $demoId;
$this->attackerId = $attackerId;
$this->assisterId = $assisterId;
$this->victimId = $victimId;
$this->weapon = $weapon;
}
public function getId(): int {
return $this->id;
}
public function getDemoId(): int {
return $this->demoId;
}
public function getAttackerId(): int {
return $this->attackerId;
}
public function getAssisterId(): int {
return $this->assisterId;
}
public function getVictimId(): int {
return $this->victimId;
}
public function getWeapon(): string {
return $this->weapon;
}
}

64
src/Data/Player.php Normal file
View file

@ -0,0 +1,64 @@
<?php declare(strict_types=1);
namespace Demostf\API\Data;
class Player {
/** @var int */
private $id;
/** @var int */
private $demoId;
/** @var int */
private $demoUserId;
/** @var int */
private $userId;
/** @var string */
private $name;
/** @var string */
private $team;
/** @var string */
private $class;
public function __construct(int $id, int $demoId, int $demoUserId, int $userId, string $name, string $team, string $class) {
$this->id = $id;
$this->demoId = $demoId;
$this->demoUserId = $demoUserId;
$this->userId = $userId;
$this->name = $name;
$this->team = $team;
$this->class = $class;
}
public function getId(): int {
return $this->id;
}
public function getDemoId(): int {
return $this->demoId;
}
public function getDemoUserId(): int {
return $this->demoUserId;
}
public function getUserId(): int {
return $this->userId;
}
public function getName(): string {
return $this->name;
}
public function getTeam(): string {
return $this->team;
}
public function getClass(): string {
return $this->class;
}
}

63
src/Data/User.php Normal file
View file

@ -0,0 +1,63 @@
<?php declare(strict_types = 1);
namespace Demostf\API\Data;
class User implements \JsonSerializable {
/** @var int */
private $id;
/** @var string */
private $steamId;
/** @var string */
private $name;
/** @var string */
private $avatar;
/** @var string */
private $token;
public function __construct(int $id, string $steamId, string $name, string $avatar, string $token) {
$this->id = $id;
$this->steamId = $steamId;
$this->name = $name;
$this->avatar = $avatar;
$this->token = $token;
}
public function getId(): int {
return $this->id;
}
public function getSteamId(): string {
return $this->steamId;
}
public function getName(): string {
return $this->name;
}
public function getAvatar(): string {
return $this->avatar;
}
public function getToken(): string {
return $this->token;
}
public function jsonSerialize() {
return [
'id' => $this->getId(),
'steamid' => $this->getSteamId(),
'name' => $this->getName(),
'avatar' => $this->getAvatar()
];
}
public static function fromRow(array $row): User {
return new User(
(int)$row['id'],
$row['steamid'],
$row['name'],
$row['avatar'],
$row['token'] ?? ''
);
}
}