$ npm install uno-engine
const Game = ;
; // maximum 10 players with unique names; // you can add your own rules (see ); // initialize the game
After starting a new game, the first card will be randomly chosen, hands of 7 dealt, and a player will be randomly chosen to go first.
; // player whose turn it is; // array of `Card` objects; // get player by name; // get the exact card in the player's hand
;; // current card in-play; // get the index of the card color: 0 to 3// (WILD and WILD DRAW FOUR will not have this property set)Colors; // get the name of the color: RED, BLUE, GREEN, or YELLOW// Card value; // get the index of the card value: 0 to 14Values; // get the name of the card:// 0-9, SKIP, REVERSE, DRAW_TWO, WILD, or WILD_DRAW_TWO// Get card from value/color strings;;;// Set WILD or WD4 color; // get args from player input; // get exact WILD/WD4 in player's handcard.color = Colors; // set color of WILD/WD4 in hand// Get Card from args function;
trycatch egame.draw; // draw a card for the current playertrycatch e// Yelling UNO!game.uno; // game.currentPlayer is yelling UNO!game.uno"Player 1"; // Other than current player yells UNO// - If the yelling player is the current player,// and they have 2 or less cards, he is just marked as "yelled"// - If the yelling player has more than 2 cards,// the game searches for someone with 1 card that did not yell "UNO!",// and make him draw 2 cards. If there's no one,// the yelling player draws instead.
Check all the official game rules.