Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@runox-game/game-engine

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@runox-game/game-engine - npm Package Compare versions

Comparing version 0.0.15 to 0.0.17

1

lib/commands/build-deck.command.js

@@ -42,2 +42,3 @@ "use strict";

BuildDeckCommand.prototype.execute = function (state) {
state.deck.cards = [];
state.log("Construyendo tablero", log_levels_enum_1.LogLevel.USER);

@@ -44,0 +45,0 @@ /*

@@ -24,2 +24,11 @@ import { IGameState } from '../models/game-state.model';

/**
* Invokes the necessary commands to reset the game
*
* @param currentState - current game state
* @param gameModes - different game modes
* @returns observable with the intention of being able to track the success or failure
* of the command group invocation
*/
resetGame(currentState: IGameState, gameModes?: GameModes): Observable<void>;
/**
* Invokes the necessary commands to add players to the game

@@ -26,0 +35,0 @@ *

@@ -38,2 +38,17 @@ "use strict";

/**
* Invokes the necessary commands to reset the game
*
* @param currentState - current game state
* @param gameModes - different game modes
* @returns observable with the intention of being able to track the success or failure
* of the command group invocation
*/
CommandService.prototype.resetGame = function (currentState, gameModes) {
var invoker = new commands_invoker_1.CommandsInvoker([
new build_deck_command_1.BuildDeckCommand(),
new start_game_command_1.StartGameCommand(gameModes),
]);
return invoker.invoke(currentState);
};
/**
* Invokes the necessary commands to add players to the game

@@ -40,0 +55,0 @@ *

@@ -59,6 +59,10 @@ "use strict";

state.deck.addCards([firstStackCard]);
state.log(" Barajando", log_levels_enum_1.LogLevel.USER);
state.log("Barajando", log_levels_enum_1.LogLevel.USER);
state.deck.shuffle();
firstStackCard = state.deck.takeCard();
}
state.stack.cards = [];
state.playersGroup.players.forEach(function (player) {
player.hand.cards = [];
});
state.stack.addCard(firstStackCard);

@@ -65,0 +69,0 @@ state.log(" Carta en la mesa " + firstStackCard.sprite, log_levels_enum_1.LogLevel.USER);

@@ -31,2 +31,3 @@ import { IGameState } from './models/game-state.model';

start(gameModes?: GameModes): Observable<void>;
reset(gameModes?: GameModes): Observable<void>;
join(players: IPlayer[]): Observable<void>;

@@ -33,0 +34,0 @@ remove(player: IPlayer): Observable<void>;

@@ -86,2 +86,7 @@ "use strict";

};
GameEngine.prototype.reset = function (gameModes) {
return this.commandService
.resetGame(this.state, gameModes)
.pipe(operators_1.catchError(this.handleError()));
};
GameEngine.prototype.join = function (players) {

@@ -88,0 +93,0 @@ return this.commandService

7

lib/models/game-state.model.js

@@ -70,7 +70,2 @@ "use strict";

GameState.prototype.giveCards = function (quantity, toPlayer) {
// numero de cartas disponibles entre mazo y pila
var availableCards = this.deck.cards.length + (this.stack.cards.length - 1);
while (quantity > availableCards) {
throw new Error('No se puede dar más cartas que las jugables');
}
if (quantity > this.deck.cards.length) {

@@ -88,3 +83,3 @@ this.addStackCardsToDeck();

var _this = this;
var newDeckCards = this.stack.cards.filter(function (card) { var _a; return card.id === ((_a = _this.stack.cardOnTop) === null || _a === void 0 ? void 0 : _a.id); });
var newDeckCards = this.stack.cards.filter(function (card) { var _a; return card.id !== ((_a = _this.stack.cardOnTop) === null || _a === void 0 ? void 0 : _a.id); });
this.deck.addCards(newDeckCards);

@@ -91,0 +86,0 @@ var cardOnTopTheStack = this.stack.cardOnTop;

{
"name": "@runox-game/game-engine",
"version": "0.0.15",
"version": "0.0.17",
"description": "RunoX game engine",

@@ -5,0 +5,0 @@ "main": "lib/game-engine.js",

@@ -48,2 +48,13 @@ ## Runox-Game-Engine

- reset
```[typescript]
game.reset().subscribe(
() => {},
(error: string) => {
showErrorAlert(error);
}
);
```
- join

@@ -50,0 +61,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc