1k
♥ ♦ ♣ ♠
Thousand card game logic, written in TypeScript.
Working example
Visit https://plnkr.co/edit/o73CajJDIuEZWHp1kH0C?p=preview and observe console output
How to install?
$ npm install -S 1k
How to use?
Actions:
; ;thousand.init; ; // its a result of action, true - action succeed, false otherwise // registers player with specific nameresult = thousand.registerPlayer'adam';result = thousand.registerPlayer'pic'; // player makes a bidresult = thousand.bid'adam', 120;// player passesresult = thousand.pass'adam'; // player (adam) shares card (9♥) with opponent (alan)result = thousand.shareStock'adam', createCard'9♥', 'alan'; // player declares a bombresult = thousand.declareBomb'adam'; // player increases his bidresult = thousand.increaseBid'adam', 130; // player throws a cardresult = thousand.throwCardcreateCard'A♥', 'adam'; // get entire game state object;console.logstate;
Phases:
Available phases:
Events:
; ; // called whenever game is updatedthousand.events.addListener'phaseUpdated', ; // called, when any action made succesfullythousand.events.addListener'action', ;