mirror of
https://codeberg.org/demostf/frontend.git
synced 2026-06-04 02:34:13 +02:00
This commit is contained in:
parent
f80ae5b948
commit
bdc35d0907
16 changed files with 143 additions and 27 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import {PlayerState} from "../Data/Parser";
|
||||
import {KillFeedItem} from "./KillFeed";
|
||||
import {Class, MedigunType, PlayerState, SpyState} from "../Data/Parser";
|
||||
|
||||
export interface PlayerSpecProps {
|
||||
player: PlayerState;
|
||||
|
|
@ -68,7 +67,7 @@ function filterPlayers(players: PlayerState[], team: number): PlayerState[] {
|
|||
}
|
||||
|
||||
function medics(players: PlayerState[]): PlayerState[] {
|
||||
return players.filter(player => player.playerClass === 5);
|
||||
return players.filter(player => player.playerClass === Class.Medic);
|
||||
}
|
||||
|
||||
export function PlayersSpec(props: PlayersSpecProps) {
|
||||
|
|
@ -86,7 +85,8 @@ export function PlayersSpec(props: PlayersSpecProps) {
|
|||
<For each={redMedics()}>{(player) =>
|
||||
<UberSpec
|
||||
team={teamMap[player.team]}
|
||||
chargeLevel={player.charge}
|
||||
chargeLevel={player.class_data.charge}
|
||||
medigun={player.class_data.medigun}
|
||||
isDeath={player.health < 1}
|
||||
/>
|
||||
}</For>
|
||||
|
|
@ -99,7 +99,8 @@ export function PlayersSpec(props: PlayersSpecProps) {
|
|||
<For each={blueMedics()}>{(player) =>
|
||||
<UberSpec
|
||||
team={teamMap[player.team]}
|
||||
chargeLevel={player.charge}
|
||||
chargeLevel={player.class_data.charge}
|
||||
medigun={player.class_data.medigun}
|
||||
isDeath={player.health < 1}
|
||||
/>
|
||||
}</For>
|
||||
|
|
@ -135,7 +136,15 @@ export function PlayerSpec(props: PlayerSpecProps) {
|
|||
|
||||
function getPlayerIcon(player: PlayerState) {
|
||||
if (classMap[player.playerClass]) {
|
||||
return <div class={classMap[player.playerClass] + " class-icon"}/>
|
||||
const className = classMap[player.playerClass];
|
||||
if (player.playerClass === Class.Spy && classMap[(player.class_data as SpyState).disguise_class]) {
|
||||
const disguiseClassName = classMap[(player.class_data as SpyState).disguise_class];
|
||||
return (<div class={className + " class-icon"}>
|
||||
<div class={disguiseClassName + " disguise"}/>
|
||||
</div>)
|
||||
} else {
|
||||
return <div class={className + " class-icon"}/>
|
||||
}
|
||||
} else {
|
||||
return <div class={"class-icon"}/>
|
||||
}
|
||||
|
|
@ -143,20 +152,33 @@ function getPlayerIcon(player: PlayerState) {
|
|||
|
||||
export interface UberSpecProps {
|
||||
chargeLevel: number;
|
||||
medigun: MedigunType;
|
||||
team: string;
|
||||
isDeath: boolean;
|
||||
}
|
||||
|
||||
export function UberSpec({chargeLevel, team, isDeath}: UberSpecProps) {
|
||||
const healthStatusClass = (isDeath) ? 'dead' : '';
|
||||
export function UberSpec(props: UberSpecProps) {
|
||||
const healthStatusClass = (props.isDeath) ? 'dead' : '';
|
||||
const medigunName = () => {
|
||||
switch (props.medigun) {
|
||||
case MedigunType.Kritzkrieg:
|
||||
return "Kritzkrieg";
|
||||
case MedigunType.Quickfix:
|
||||
return "Quickfix";
|
||||
case MedigunType.Vaccinator:
|
||||
return "Vaccinator";
|
||||
default:
|
||||
return "Ubercharge";
|
||||
}
|
||||
}
|
||||
return (
|
||||
<div class={`playerspec uber ${team} ${healthStatusClass}`}>
|
||||
<div class={`playerspec uber ${props.team} ${healthStatusClass}`}>
|
||||
<div class={"uber class-icon"}/>
|
||||
<div class="health-container">
|
||||
<div class="healthbar"
|
||||
style={{width: chargeLevel + '%'}}/>
|
||||
<span class="player-name">Charge</span>
|
||||
<span class="health">{Math.round(chargeLevel)}</span>
|
||||
style={{width: props.chargeLevel + '%'}}/>
|
||||
<span class="player-name">{medigunName()}</span>
|
||||
<span class="health">{Math.round(props.chargeLevel)}</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue