csgo-gamestate-client
Advanced tools
Comparing version 0.1.2 to 0.2.0
@@ -210,5 +210,4 @@ import * as t from 'io-ts'; | ||
export declare type GameStateAllPlayerWeapons = t.TypeOf<typeof GameStateAllPlayerWeaponsCodec>; | ||
declare const GameStateAllPlayerCodec: t.TypeC<{ | ||
declare const GameStateAllPlayerCodec: t.IntersectionC<[t.TypeC<{ | ||
name: t.StringC; | ||
observer_slot: t.NumberC; | ||
team: t.UnionC<[t.LiteralC<"T">, t.LiteralC<"CT">]>; | ||
@@ -310,3 +309,5 @@ state: t.IntersectionC<[t.TypeC<{ | ||
forward: t.StringC; | ||
}>; | ||
}>, t.TypeC<{ | ||
observer_slot: t.NumberC; | ||
}>]>; | ||
export declare type GameStateAllPlayer = t.TypeOf<typeof GameStateAllPlayerCodec>; | ||
@@ -392,5 +393,4 @@ declare const GameStatePhaseCodec: t.UnionC<[t.LiteralC<"freezetime">, t.LiteralC<"bomb">, t.LiteralC<"live">, t.LiteralC<"over">, t.LiteralC<"defuse">, t.LiteralC<"paused">, t.LiteralC<"timeout_ct">, t.LiteralC<"timeout_t">]>; | ||
}>; | ||
allplayers: t.RecordC<t.StringC, t.TypeC<{ | ||
allplayers: t.RecordC<t.StringC, t.IntersectionC<[t.TypeC<{ | ||
name: t.StringC; | ||
observer_slot: t.NumberC; | ||
team: t.UnionC<[t.LiteralC<"T">, t.LiteralC<"CT">]>; | ||
@@ -492,3 +492,5 @@ state: t.IntersectionC<[t.TypeC<{ | ||
forward: t.StringC; | ||
}>>; | ||
}>, t.TypeC<{ | ||
observer_slot: t.NumberC; | ||
}>]>>; | ||
phase_countdowns: t.TypeC<{ | ||
@@ -495,0 +497,0 @@ phase: t.UnionC<[t.LiteralC<"freezetime">, t.LiteralC<"bomb">, t.LiteralC<"live">, t.LiteralC<"over">, t.LiteralC<"defuse">, t.LiteralC<"paused">, t.LiteralC<"timeout_ct">, t.LiteralC<"timeout_t">]>; |
@@ -147,5 +147,4 @@ "use strict"; | ||
}); | ||
const GameStateAllPlayerCodec = t.type({ | ||
const GameStateAllPlayerType = t.type({ | ||
name: t.string, | ||
observer_slot: t.number, | ||
team: GameStateTeamStringCodec, | ||
@@ -158,2 +157,6 @@ state: GameStateAllPlayerStateCodec, | ||
}); | ||
const GameStateAllPlayerPartial = t.type({ | ||
observer_slot: t.number, | ||
}); | ||
const GameStateAllPlayerCodec = t.intersection([GameStateAllPlayerType, GameStateAllPlayerPartial]); | ||
const GameStatePhaseCodec = t.union([ | ||
@@ -160,0 +163,0 @@ t.literal('freezetime'), |
export { GameState } from './gamestate'; | ||
import { GameState } from './gamestate'; | ||
export { getTeams, Teams, Team } from './teams'; | ||
export { Player } from './player'; | ||
export { Player, MatchStats, PlayerState, getActivePlayer, ActivePlayer } from './player'; | ||
export { Weapons } from './weapons'; | ||
@@ -6,0 +6,0 @@ export declare const parseGameState: (newGameState: string) => GameState; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decodeGameState = exports.parseGameState = exports.getTeams = void 0; | ||
exports.decodeGameState = exports.parseGameState = exports.getActivePlayer = exports.getTeams = void 0; | ||
const io_ts_reporters_1 = __importDefault(require("io-ts-reporters")); | ||
@@ -12,2 +12,4 @@ const gamestate_1 = require("./gamestate"); | ||
Object.defineProperty(exports, "getTeams", { enumerable: true, get: function () { return teams_1.getTeams; } }); | ||
var player_1 = require("./player"); | ||
Object.defineProperty(exports, "getActivePlayer", { enumerable: true, get: function () { return player_1.getActivePlayer; } }); | ||
const parseGameState = (newGameState) => { | ||
@@ -14,0 +16,0 @@ const parsed = JSON.parse(newGameState); |
@@ -1,5 +0,5 @@ | ||
import { GameStateAllPlayer } from "./gamestate"; | ||
import { Weapons } from "./weapons"; | ||
import { GameState, GameStateActivity, GameStateAllPlayer } from './gamestate'; | ||
import { Weapons } from './weapons'; | ||
declare type TeamString = 'CT' | 'T'; | ||
interface PlayerState { | ||
export interface PlayerState { | ||
health: number; | ||
@@ -17,3 +17,3 @@ armor: number; | ||
} | ||
interface MatchStats { | ||
export interface MatchStats { | ||
kills: number; | ||
@@ -33,4 +33,8 @@ assists: number; | ||
} | ||
export interface ActivePlayer extends Player { | ||
activity: GameStateActivity; | ||
} | ||
export declare const improvePlayer: (player: GameStateAllPlayer) => Player; | ||
export declare const getActivePlayer: (gameState: GameState) => ActivePlayer; | ||
export {}; | ||
//# sourceMappingURL=player.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.improvePlayer = void 0; | ||
exports.getActivePlayer = exports.improvePlayer = void 0; | ||
const weapons_1 = require("./weapons"); | ||
@@ -25,5 +25,14 @@ const improvePlayer = (player) => { | ||
matchStats: player.match_stats, | ||
weapons: (0, weapons_1.classifyWeapons)(player.weapons) | ||
weapons: (0, weapons_1.classifyWeapons)(player.weapons), | ||
}; | ||
}; | ||
exports.improvePlayer = improvePlayer; | ||
const getActivePlayer = (gameState) => { | ||
const player = gameState.allplayers[gameState.player.steamid]; | ||
const improvedPlayer = (0, exports.improvePlayer)(player); | ||
return { | ||
activity: gameState.player.activity, | ||
...improvedPlayer, | ||
}; | ||
}; | ||
exports.getActivePlayer = getActivePlayer; |
@@ -1,3 +0,3 @@ | ||
import { GameState, GameStateTeam, GameStateTeamString } from "./gamestate"; | ||
import { Player } from "./player"; | ||
import { GameState, GameStateTeam, GameStateTeamString } from './gamestate'; | ||
import { Player } from './player'; | ||
export interface Teams { | ||
@@ -4,0 +4,0 @@ leftPlayers: Player[]; |
{ | ||
"name": "csgo-gamestate-client", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42309
937