♥ ♦ ♣ ♠
Thousand card game logic, written in TypeScript.
Visit https://plnkr.co/edit/o73CajJDIuEZWHp1kH0C?p=preview and observe console output
$ npm install -S 1k
;;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;
;;// called whenever game is updatedthousand.events.addListener'phaseUpdated',;// called, when any action made succesfullythousand.events.addListener'action',;