mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 18:04:08 +02:00
no longer store weapon name per kill
This commit is contained in:
parent
00b547028f
commit
89687f6a76
8 changed files with 12 additions and 28 deletions
|
|
@ -10,15 +10,13 @@ class Kill {
|
|||
private int $attackerId;
|
||||
private int $assisterId;
|
||||
private int $victimId;
|
||||
private string $weapon;
|
||||
|
||||
public function __construct(int $id, int $demoId, int $attackerId, int $assisterId, int $victimId, string $weapon) {
|
||||
public function __construct(int $id, int $demoId, int $attackerId, int $assisterId, int $victimId) {
|
||||
$this->id = $id;
|
||||
$this->demoId = $demoId;
|
||||
$this->attackerId = $attackerId;
|
||||
$this->assisterId = $assisterId;
|
||||
$this->victimId = $victimId;
|
||||
$this->weapon = $weapon;
|
||||
}
|
||||
|
||||
public function getId(): int {
|
||||
|
|
@ -40,8 +38,4 @@ class Kill {
|
|||
public function getVictimId(): int {
|
||||
return $this->victimId;
|
||||
}
|
||||
|
||||
public function getWeapon(): string {
|
||||
return $this->weapon;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,11 @@ class ParsedKill {
|
|||
private int $attackerDemoId;
|
||||
private int $assisterDemoId;
|
||||
private int $victimDemoId;
|
||||
private string $weapon;
|
||||
|
||||
public function __construct(int $attackerDemoId, int $assisterDemoId, int $victimDemoId, string $weapon) {
|
||||
public function __construct(int $attackerDemoId, int $assisterDemoId, int $victimDemoId) {
|
||||
$this->attackerDemoId = $attackerDemoId;
|
||||
$this->assisterDemoId = $assisterDemoId;
|
||||
$this->victimDemoId = $victimDemoId;
|
||||
$this->weapon = $weapon;
|
||||
}
|
||||
|
||||
public function getAttackerDemoId(): int {
|
||||
|
|
@ -28,8 +26,4 @@ class ParsedKill {
|
|||
public function getVictimDemoId(): int {
|
||||
return $this->victimDemoId;
|
||||
}
|
||||
|
||||
public function getWeapon(): string {
|
||||
return $this->weapon;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,8 +88,7 @@ class DemoSaver {
|
|||
$demoId,
|
||||
$userMap[$kill->getAttackerDemoId()] ?? 0,
|
||||
$userMap[$kill->getAssisterDemoId()] ?? 0,
|
||||
$userMap[$kill->getVictimDemoId()] ?? 0,
|
||||
$kill->getWeapon()
|
||||
$userMap[$kill->getVictimDemoId()] ?? 0
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,8 +93,7 @@ class Parser {
|
|||
});
|
||||
/** @var ParsedKill[] $kills */
|
||||
$kills = array_map(function (array $death) {
|
||||
return new ParsedKill($death['killer'] ?? 0, $death['assister'] ?? 0, $death['victim'] ?? 0,
|
||||
$death['weapon']);
|
||||
return new ParsedKill($death['killer'] ?? 0, $death['assister'] ?? 0, $death['victim'] ?? 0);
|
||||
}, $deaths);
|
||||
$activityMap = [];
|
||||
foreach ($kills as $kill) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ class KillProvider extends BaseProvider {
|
|||
'attacker_id' => $query->createNamedParameter($kill->getAttackerId()),
|
||||
'assister_id' => $query->createNamedParameter($kill->getAssisterId()),
|
||||
'victim_id' => $query->createNamedParameter($kill->getVictimId()),
|
||||
'weapon' => $query->createNamedParameter($kill->getWeapon()),
|
||||
'created_at' => 'now()',
|
||||
'updated_at' => 'now()',
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -66,9 +66,9 @@ class DemoSaverTest extends TestCase {
|
|||
new ParsedPlayer('user2', 2, '2345678', 'blue', 'soldier'),
|
||||
],
|
||||
[
|
||||
new ParsedKill(1, 0, 2, 'pan'),
|
||||
new ParsedKill(1, 2, 2, 'pan'),
|
||||
new ParsedKill(2, 0, 1, 'pan'),
|
||||
new ParsedKill(1, 0, 2),
|
||||
new ParsedKill(1, 2, 2),
|
||||
new ParsedKill(2, 0, 1),
|
||||
]
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ class ParserTest extends TestCase {
|
|||
$this->assertEquals((int) $expectedKills[0]['killer'], $result->getKills()[0]->getAttackerDemoId());
|
||||
$this->assertEquals((int) $expectedKills[0]['assister'], $result->getKills()[0]->getAssisterDemoId());
|
||||
$this->assertEquals((int) $expectedKills[0]['victim'], $result->getKills()[0]->getVictimDemoId());
|
||||
$this->assertEquals($expectedKills[0]['weapon'], $result->getKills()[0]->getWeapon());
|
||||
}
|
||||
|
||||
public function testFailedParse() {
|
||||
|
|
|
|||
|
|
@ -129,9 +129,9 @@ class DemoProviderTest extends TestCase {
|
|||
$player3 = $this->addPlayer($id, 103, $user3->getId(), 'blue', 'engineer');
|
||||
$player4 = $this->addPlayer($id, 104, $user4->getId(), 'blue', 'spy');
|
||||
|
||||
$this->addKill($id, $user1->getId(), 0, $user3->getId(), 'pan');
|
||||
$this->addKill($id, $user1->getId(), $user2->getId(), $user3->getId(), 'pan');
|
||||
$this->addKill($id, $user4->getId(), 0, $user1->getId(), 'pan');
|
||||
$this->addKill($id, $user1->getId(), 0, $user3->getId());
|
||||
$this->addKill($id, $user1->getId(), $user2->getId(), $user3->getId());
|
||||
$this->addKill($id, $user4->getId(), 0, $user1->getId());
|
||||
|
||||
$retrieved = $this->provider->get($id, true);
|
||||
$this->assertInstanceOf(Demo::class, $retrieved);
|
||||
|
|
@ -155,8 +155,8 @@ class DemoProviderTest extends TestCase {
|
|||
return $this->playerProvider->store($player);
|
||||
}
|
||||
|
||||
private function addKill(int $demoId, int $attackerId, int $assisterId, int $victimId, string $weapon): int {
|
||||
$kill = new Kill(0, $demoId, $attackerId, $assisterId, $victimId, $weapon);
|
||||
private function addKill(int $demoId, int $attackerId, int $assisterId, int $victimId): int {
|
||||
$kill = new Kill(0, $demoId, $attackerId, $assisterId, $victimId);
|
||||
|
||||
return $this->killProvider->store($kill);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue