more scores
This commit is contained in:
parent
a486f73046
commit
10f022c849
|
@ -65,13 +65,18 @@ export default function PlayerInfo({playerId}: { playerId: Guid }) {
|
|||
<table>
|
||||
<tbody>
|
||||
<ScoreRow name="controls" value={lastJsonMessage.controls}/>
|
||||
<ScoreRow name="kills" value={lastJsonMessage.scores.kills}/>
|
||||
<ScoreRow name="deaths" value={lastJsonMessage.scores.deaths}/>
|
||||
<ScoreRow name="walls" value={lastJsonMessage.scores.wallsDestroyed}/>
|
||||
<ScoreRow name="explosive bullets" value={lastJsonMessage.tank?.explosiveBullets}/>
|
||||
<ScoreRow name="position" value={lastJsonMessage.tank?.position}/>
|
||||
<ScoreRow name="orientation" value={lastJsonMessage.tank?.orientation}/>
|
||||
<ScoreRow name="moving" value={lastJsonMessage.tank?.moving}/>
|
||||
|
||||
<ScoreRow name="kills" value={lastJsonMessage.scores.kills}/>
|
||||
<ScoreRow name="deaths" value={lastJsonMessage.scores.deaths}/>
|
||||
|
||||
<ScoreRow name="walls destroyed" value={lastJsonMessage.scores.wallsDestroyed}/>
|
||||
<ScoreRow name="bullets fired" value={lastJsonMessage.scores.shotsFired}/>
|
||||
|
||||
<ScoreRow name="score" value={lastJsonMessage.scores.overallScore}/>
|
||||
</tbody>
|
||||
</table>
|
||||
</Column>;
|
||||
|
|
|
@ -47,6 +47,16 @@ export default function Scoreboard({}: {}) {
|
|||
field: 'walls',
|
||||
visualize: p => p.scores.wallsDestroyed.toString(),
|
||||
sorter: (a, b) => numberSorter(a.scores.wallsDestroyed, b.scores.wallsDestroyed)
|
||||
},
|
||||
{
|
||||
field: 'bullets',
|
||||
visualize: p => p.scores.shotsFired.toString(),
|
||||
sorter: (a, b) => numberSorter(a.scores.shotsFired, b.scores.shotsFired)
|
||||
},
|
||||
{
|
||||
field: 'score',
|
||||
visualize: p => p.scores.overallScore.toString(),
|
||||
sorter: (a, b) => numberSorter(a.scores.overallScore, b.scores.overallScore)
|
||||
}
|
||||
]}/>
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {Guid} from './Guid.ts';
|
||||
|
||||
export function makeApiUrl(path: string, protocol: 'http' | 'ws' = 'http') {
|
||||
return new URL(`${protocol}://${window.location.hostname}${path}`);
|
||||
return new URL(`${protocol}://${window.location.hostname}${path}`);
|
||||
}
|
||||
|
||||
export type ServerResponse<T> = {
|
||||
|
@ -16,6 +16,8 @@ export type Scores = {
|
|||
readonly kills: number;
|
||||
readonly deaths: number;
|
||||
readonly wallsDestroyed: number;
|
||||
readonly shotsFired: number;
|
||||
readonly overallScore: number;
|
||||
};
|
||||
|
||||
export type Player = {
|
||||
|
|
|
@ -30,6 +30,7 @@ internal sealed class ShootFromTanks(
|
|||
if (explosive)
|
||||
tank.ExplosiveBullets--;
|
||||
|
||||
tank.Owner.Scores.ShotsFired++;
|
||||
entityManager.SpawnBullet(tank.Owner, tank.Position, tank.Orientation / 16d, explosive);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,4 +19,8 @@ internal sealed record class Scores
|
|||
}
|
||||
|
||||
public int WallsDestroyed { get; set; }
|
||||
|
||||
public int ShotsFired { get; set; }
|
||||
|
||||
public int OverallScore => Math.Max(0, 10000 * Kills - 1000 * Deaths + 10 * ShotsFired + 10 * WallsDestroyed);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue