Runox-Game-Engine
Example
const game = new GameEngine();
Methods of GameEngine
- start
game.start().subscribe(
() => {},
(error: string) => {
// handle error
}
);
Also, you can use different game modes passing a GameModes object as parameter (by default all game modes are deactivated)
const gameModes: GameModes = {
randomTakeDeckCard: false,
cumulativePlusTwo: false,
dedicatePlusFour: false,
crazyCommands: false,
};
game.start(gameModes).subscribe(
() => {},
(error: string) => {
// handle error
}
);
game.start().subscribe(
() => {},
(error: string) => {
// handle error
}
);
- reset
game.reset().subscribe(
() => {},
(error: string) => {
showErrorAlert(error);
}
);
- reset
game.reset().subscribe(
() => {},
(error: string) => {
showErrorAlert(error);
}
);
- join
game.join([user]).subscribe();
- remove
game.remove(user).subscribe();
- playCard
game.playCard(game.playerTurn?.id, card).subscribe();
- takeCard
game.takeCard();
- takeCardToRandomPlayer
game.takeCardToRandomPlayer();
- uno
game.uno(user.id);
- switchHands
game.switchHands(player1, player2);
- overrideInternalState
game.overrideInternalState(_data);
- logs
LogLevel.ALL LogLevel.USER LogLevel.BEFORE_COMMAND LogLevel.AFTER_COMMAND LogLevel.BEFORE_VALIDATION LogLevel.AFTER_VALIDATION
game.logs(LogLevel.USER).subscribe((log: ILog) => {
console.log(log);
});
- onSpecialCardPlayed Special for play special sound
game.onSpecialCardPlayed().subscribe((card: ICard) => {
console.log(card);
});
- onCardPlayed
game.onCardPlayed().subscribe((card: ICard) => {
console.log(card);
});
- onStateChanged
game.onStateChanged().subscribe((state: IGameState) => {
console.log(state);
});