From 282fe9d3116d1c4f1b4269b7ee0f0c4bc25abad3 Mon Sep 17 00:00:00 2001 From: Didictateur Date: Tue, 15 Apr 2025 16:18:22 +0200 Subject: [PATCH] all yakus without khan (and without context) --- build/test.js | 2 +- build/test_yakus.js | 2 +- src/yakus/yaku.ts | 71 +++++++++++++++++++++++++++++++++++++++++++-- tests/test_yakus.ts | 31 ++++++++++++++++---- 4 files changed, 96 insertions(+), 10 deletions(-) diff --git a/build/test.js b/build/test.js index 3d14729..095cba7 100644 --- a/build/test.js +++ b/build/test.js @@ -1 +1 @@ -(()=>{"use strict";var t={274:(t,e,i)=>{i.d(e,{F:()=>s});class s{constructor(t,e,i){this.family=t,this.value=e,this.red=i,this.imgFront=new Image,this.imgBack=new Image,this.imgGray=new Image,this.img=new Image,this.imgSrc="",this.tilt=0,this.setImgSrc()}getFamily(){return this.family}getValue(){return this.value}isEqual(t,e){return this.family===t&&this.value===e}isRed(){return this.red}compare(t){return this.family!==t.family?this.family{t.onload=null,t.onerror=null}))}preloadImg(){return t=this,e=void 0,s=function*(){const t=[{img:this.imgFront,src:"img/Regular/Front.svg"},{img:this.imgBack,src:"img/Regular/Back.svg"},{img:this.imgGray,src:"img/Regular/Gray.svg"},{img:this.img,src:this.imgSrc}];yield Promise.all(t.map((({img:t,src:e})=>this.loadImg(t,e))))},new((i=void 0)||(i=Promise))((function(n,o){function u(t){try{r(s.next(t))}catch(t){o(t)}}function l(t){try{r(s.throw(t))}catch(t){o(t)}}function r(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(u,l)}r((s=s.apply(t,e||[])).next())}));var t,e,i,s}loadImg(t,e){return new Promise(((i,s)=>{t.onload=()=>i(),t.onerror=()=>s(),t.src=e}))}setImgSrc(){if(this.imgSrc="img/Regular/",this.family<=3){const t=["","Man","Pin","Sou"];this.imgSrc+=t[this.family]+String(this.value),this.red&&(this.imgSrc+="-Dora")}else if(4===this.family){const t=["","Ton","Nan","Shaa","Pei"];this.imgSrc+=t[this.value]}else if(5===this.family){const t=["","Chun","Hatsu","Haku"];this.imgSrc+=t[this.value]}this.imgSrc+=".svg"}}},305:(t,e,i)=>{function s(t,e){return t?(console.log("%c[SUCCES] "+e,"color: green"),1):(console.log("%c[ECHEC] "+e,"color: red"),0)}i.d(e,{v:()=>s})},679:(t,e,i)=>{var s,n,o,u,l,r=i(959),m=i(305);let a=new r.U("s1s1"),h=new r.U("m1m2m3"),g=new r.U("m2m2m2 p1p1"),p=new r.U("m1m2m3 p1p2p3 s1s2s3 m9m9m9 p9p9"),c=new r.U("m2m2m2 p1p1p1"),d=0,w=0;d+=(0,m.v)(1===(null===(s=a.toGroup())||void 0===s?void 0:s.length),"s11 has 1 group"),d+=(0,m.v)(1===(null===(n=h.toGroup())||void 0===n?void 0:n.length),"m123 has 1 group"),d+=(0,m.v)(2===(null===(o=g.toGroup())||void 0===o?void 0:o.length),"m222 p11 has 2 groups"),(0,m.v)(5===(null===(u=p.toGroup())||void 0===u?void 0:u.length),"m123 p123 s123 m999 p99 has 5 groups"),d+=(0,m.v)(2===(null===(l=c.toGroup())||void 0===l?void 0:l.length),"m222 p111 has 2 groups"),w+=4,console.log("Succès: "+d.toString()+"/"+w.toString())},762:(t,e,i)=>{var s=i(305);function n(t){return t.getTiles().every((t=>t.getFamily()<4&&t.getValue()>1&&t.getValue()<9))}function o(t){return t.getTiles().every((t=>t.getFamily()>=4))}function u(t){let e=t.getTiles();return e[0].getValue()!==e[1].getValue()}function l(t){let e=t.getTiles();return e[0].getValue()===e[1].getValue()}const r={lipekou:function(t,e,i){if(e.length>0&&!r.ryanpeikou(t,e,i))return 0;let s=t.toGroup();s.sort(((t,e)=>t.compare(e)));for(let t=0;t<3;t++){let e=s[t].getTiles(),i=s[t+1].getTiles();if(e[0].isEqual(i[0].getFamily(),i[0].getValue())&&u(s[t])&&u(s[t+1]))return 1}return 0},ryanpeikou:function(t,e,i){if(e.length>0)return 0;let s=t.toGroup();if(s.filter((t=>u(t))),s.length<4)return 0;s.sort(((t,e)=>t.compare(e)));let n=s[0].getTiles()[0],o=s[1].getTiles()[0],l=s[2].getTiles()[0],r=s[3].getTiles()[0];return 0===n.compare(o)&&0===l.compare(r)?3:0},pinfu:function(t,e,i){if(e.length>0)return 0;let s=t.toGroup();return void 0!==s&&s.every((t=>{let e=t.getTiles();return u(t)||2===e.length}))?1:0},sanshokuDoujun:function(t,e,i){let s=t.toGroup(),n=[];if(n=void 0!==s?e.concat(s):e,n=n.filter((t=>u(t))),n.sort(((t,e)=>t.compare(e))),n.length<3)return 0;if(3===n.length){let t=n[0].getTiles(),i=n[1].getTiles(),s=n[2].getTiles();return t[0].getValue()===i[0].getValue()&&t[0].getValue()===s[0].getValue()&&t[0].getFamily()!==i[0].getFamily()&&t[0].getFamily()!==s[0].getFamily()&&i[0].getFamily()!==s[0].getFamily()?e.length>0?1:2:0}for(let t=0;t<4;t++){let i=[];for(let e=0;e<4;e++)e!==t&&i.push(e);let s=n[i[0]].getTiles(),o=n[i[1]].getTiles(),u=n[i[2]].getTiles();if(s[0].getValue()===o[0].getValue()&&s[0].getValue()===u[0].getValue()&&s[0].getFamily()!==o[0].getFamily()&&s[0].getFamily()!==u[0].getFamily()&&o[0].getFamily()!==u[0].getFamily())return e.length>0?1:2}return 0},ittsuu:function(t,e,i){let s=e.concat(t.toGroup());if(s=s.filter((t=>u(t))),s.sort(((t,e)=>t.compare(e))),s.length<3)return 0;if(3!==s.length){for(let t=0;t<4;t++){let i=[];for(let e=0;e<4;e++)e!==t&&i.push(e);let n=s[i[0]].getTiles(),o=s[i[1]].getTiles(),u=s[i[2]].getTiles();if(1===n[0].getValue()&&4===o[0].getValue()&&7===u[0].getValue()&&n[0].getFamily()===o[0].getFamily()&&n[0].getFamily()===u[0].getFamily())return e.length>0?1:2}return 0}{let t=s[0].getTiles(),i=s[1].getTiles(),n=s[2].getTiles();if(t[0].getFamily()===i[0].getFamily()&&i[0].getFamily()===n[0].getFamily()&&1===t[0].getValue()&&4===i[0].getValue()&&7===n[0].getValue())return e.length>0?1:2}return 0},tanyao:function(t,e,i){let s=t.toGroup();return void 0===s?0:e.every((t=>n(t)))&&s.every((t=>n(t)))?1:0},yakuhai:function(t,e,i){let s=e.concat(t.toGroup());s=s.filter((t=>l(t)&&3===t.getTiles().length));let n=0;return s.forEach((t=>{let e=t.getTiles(),s=e[0].getFamily(),o=e[0].getValue();5===s&&n++,4===s&&0===o&&n++,4===s&&o===i&&n++})),n},shousangen:function(t,e,i){let s=e.concat(t.toGroup());s=s.filter((t=>l(t)));let n=0,o=0;return s.forEach((t=>{let e=t.getTiles();5===e[0].getFamily()&&(3===e.length?n++:o++)})),2==n&&1==o?2:0},daisangen:function(t,e,i){let s=e.concat(t.toGroup());return s=s.filter((t=>l(t)&&3===t.getTiles().length&&5===t.getTiles()[0].getFamily())),3===s.length?13:0},shousuushii:function(t,e,i){let s=e.concat(t.toGroup());s=s.filter((t=>l(t)));let n=0,o=0;return s.forEach((t=>{let e=t.getTiles();4===e[0].getFamily()&&(3===e.length?n++:o++)})),3==n&&1==o?13:0},daisuushi:function(t,e,i){let s=e.concat(t.toGroup());s=s.filter((t=>l(t)));let n=0,o=0;return s.forEach((t=>{let e=t.getTiles();4===e[0].getFamily()&&(3===e.length?n++:o++)})),4==n&&0==o?13:0},chanta:function(t,e,i){let s=e.concat(t.toGroup());return s=s.filter((t=>{let e=t.getTiles(),i=e[0].getFamily(),s=e[0].getValue(),n=e[e.length-1].getValue();return i<4&&1!==s&&9!==n})),s.length>0?0:e.length>0?1:2},junchan:function(t,e,i){let s=e.concat(t.toGroup());return s=s.filter((t=>{let e=t.getTiles(),i=e[0].getFamily(),s=e[0].getValue(),n=e[e.length-1].getValue();return i>3||1!==s&&9!==n})),s.length>0?0:e.length>0?2:3},honroutou:function(t,e,i){let s=e.concat(t.toGroup());return s=s.filter((t=>{let e=t.getTiles(),i=e[0].getFamily(),s=e[1].getValue();return i<4&&1!==s&&9!==s})),s.length>0?0:2},chinroutou:function(t,e,i){return e.concat(t.toGroup()).every((t=>function(t){return t.getTiles().every((t=>t.getFamily()<4&&(1===t.getValue()||9===t.getValue())))}(t)))?13:0},tsuuiisou:function(t,e,i){let s=t.toGroup();return void 0===s?0:e.every((t=>o(t)))&&s.every((t=>o(t)))?13:0},kokushiMusou:function(t,e,i){if(e.length>0)return 0;let s=t.getTiles();if(s.some((t=>t.getFamily()<4&&t.getValue()>1&&t.getValue()<9)))return 0;let n=0;for(let t=0;t1));t++);return 1===n?13:0},chiitoitsu:function(t,e,i){if(e.length>0)return 0;let s=t.getTiles();if(14!==s.length)return 0;for(let t=0;t<14;t+=2)if(0!==s[t].compare(s[t+1])||t>0&&0===s[t].compare(s[t-1]))return 0;return 2},toitoi:function(t,e,i){let s=t.toGroup();return e.every((t=>l(t)))&&(null==s?void 0:s.every((t=>l(t))))?2:0},sanankou:function(t,e,i){let s=t.toGroup(),n=0;return null==s||s.forEach((t=>{l(t)&&3===t.getTiles().length&&n++})),3===n?2:0},suuankou:function(t,e,i){let s=t.toGroup(),n=0;return null==s||s.forEach((t=>{l(t)&&3===t.getTiles().length&&n++})),4===n?13:0},sanshokuDoukou:function(t,e,i){let s=t.toGroup(),n=[];if(n=void 0!==s?e.concat(s):e,n=n.filter((t=>l(t)&&3===t.getTiles().length)),n.sort(((t,e)=>t.compare(e))),n.length<3)return 0;if(3===n.length){let t=n[0].getTiles(),i=n[1].getTiles(),s=n[2].getTiles();return t[0].getValue()===i[0].getValue()&&t[0].getValue()===s[0].getValue()&&t[0].getFamily()!==i[0].getFamily()&&t[0].getFamily()!==s[0].getFamily()&&i[0].getFamily()!==s[0].getFamily()?e.length>0?1:2:0}for(let t=0;t<4;t++){let i=[];for(let e=0;e<4;e++)e!==t&&i.push(e);let s=n[i[0]].getTiles(),o=n[i[1]].getTiles(),u=n[i[2]].getTiles();if(s[0].getValue()===o[0].getValue()&&s[0].getValue()===u[0].getValue()&&s[0].getFamily()!==o[0].getFamily()&&s[0].getFamily()!==u[0].getFamily()&&o[0].getFamily()!==u[0].getFamily())return e.length>0?1:2}return 0},sankantsu:function(t,e,i){return 0},suukantsu:function(t,e,i){return 0},honitsu:function(t,e,i){let s=t.toGroup(),n=[];if(n=void 0!==s?e.concat(s):e,n.sort(((t,e)=>t.compare(e))),0===n.length)return 0;if(n[n.length-1].getTiles()[0].getFamily()<4)return 0;let o=n[0].getTiles()[0].getFamily();return o>3?0:n.every((t=>{let e=t.getTiles()[0].getFamily();return e>3||o===e}))?e.length>0?2:3:0},chinitsu:function(t,e,i){let s=t.getTiles(),n=s[0];return s.every((t=>t.getFamily()===n.getFamily()))&&e.every((t=>t.getTiles().every((t=>t.getFamily()===n.getFamily()))))?e.length>0?5:6:0},ryuuisou:function(t,e,i){return r.chinitsu(t,e,i),0},chuurenPoutou:function(t,e,i){return e.length>0||r.chinitsu(t,e,i),0}};var m=i(959);let a=0,h=0,g=new m.U("m1m2m3 m4m5m6 m7m8m9 m1m2m3 m5m5"),p=new m.U("m1m1m1 m4m4m4 m7m7m7 p1p1p1 p5p5"),c=new m.U("m1m1m1 p9p9p9 s1s1s1 w2w2w2 d1d1"),d=new m.U("m2m3m4 p3p3p3 p4p5p6 s4s4 s6s7s8"),w=new m.U("m1m2m3 m1m2m3 p7p8p9 p7p8p9 w3w3"),f=new m.U("m1m2m3 m1m2m3 p6p7p8 p7p8p9 w3w3"),v=new m.U("m1m2m3 p1p2p3 s1s2s3 m7m8m9 p9p9"),y=new m.U("m1m2m3 m1m2m3 p6p6 w0w0w0 w3w3w3"),F=new m.U("m1m2m3 m1m2m3 d1d1d1 d2d2d2 d3d3"),T=new m.U("m1m2m3 p6p6 d1d1d1 d2d2d2 d3d3d3"),k=new m.U("m1m2m3 w1w1w1 w2w2w2 w3w3w3 w4w4"),V=new m.U("m1m1 w1w1w1 w2w2w2 w3w3w3 w4w4w4"),S=new m.U("d1d1 w1w1w1 w2w2w2 w3w3w3 w4w4w4"),G=new m.U("m1m1 m9m9m9 p1p1p1 p9p9p9 s1s1s1"),U=new m.U("m1m9m9 p1p9 s1s9 w1w2w3w4 d1d2d3"),C=new m.U("m1m1 m2m2 m3m3 m4m4 m5m5 m6m6 m7m7"),I=new m.U("m1m1 m2m2 m3m3 m4m4 m5m5 m6m6 m6m6"),D=new m.U("m1m2m3 m4m4m4 m7m7m7 p1p1p1 p5p5"),E=new m.U("m1m1m1 p1p1p1 s1s1s1 s1s2s3 p5p5"),P=new m.U("m1m1m1 p1p1p1 s1s1 s1s2s3 p5p5p5");a+=(0,s.v)(1===r.lipekou(w,[],0),"m123 m123 p789 p789 w33 is Lipeikou"),a+=(0,s.v)(0===r.lipekou(c,[],0),"m111 p999 s111 w222 d11 is not Lipeikou"),h+=2,a+=(0,s.v)(3===r.ryanpeikou(w,[],0),"m123 m123 p789 p789 w33 is Ryanpeikou"),a+=(0,s.v)(0===r.ryanpeikou(f,[],0),"m1123 m123 p678 p789 w33 is not Ryanpeikou"),h+=2,a+=(0,s.v)(1===r.pinfu(g,[],0),"m123 m456 m789 m123 p55 is Pinfu"),a+=(0,s.v)(0===r.pinfu(p,[],0),"m111 m444 m777 p111 p55 is not Pinfu"),h+=2,a+=(0,s.v)(2===r.sanshokuDoujun(v,[],0),"m123 p123 s123 m789 p99 is Shanshokou Doujun"),a+=(0,s.v)(0===r.sanshokuDoujun(p,[],0),"m111 m444 m777 p111 p55 is not Shanshokou Doujun"),h+=2,a+=(0,s.v)(2===r.ittsuu(g,[],0),"m123 m456 m789 m123 m55 is Ittsuu"),a+=(0,s.v)(0===r.ittsuu(p,[],0),"m111 m444 m777 p111 p55 is not Ittsu"),h+=2,a+=(0,s.v)(1===r.tanyao(d,[],0),"m234 p333 p456 s44 s678 is Tanyao"),a+=(0,s.v)(0===r.tanyao(g,[],0),"m123 m456 m789 m123 p55 is not Tanyao"),h+=2,a+=(0,s.v)(1===r.yakuhai(c,[],2),"m111 p999 s111 w222 d11 West is Yakuhai"),a+=(0,s.v)(2===r.yakuhai(y,[],3),"m123 m123 p66 w000 w333 North is double Yakuhai"),a+=(0,s.v)(0===r.yakuhai(c,[],0),"m111 p999 s111 w222 d11 Est is not Yakuhai"),h+=3,a+=(0,s.v)(2===r.shousangen(F,[],0),"m123 m123 d111 d222 d33 is Shousangen"),a+=(0,s.v)(0===r.shousangen(T,[],0),"m123 p66 d111 d222 d333 is not Shousangen"),a+=(0,s.v)(0===r.shousangen(c,[],0),"m111 p999 s111 w222 d11 is not Shousangen"),h+=3,a+=(0,s.v)(13===r.daisangen(T,[],0),"m123 p66 d111 d222 d333 is Daisangen"),a+=(0,s.v)(0===r.daisangen(F,[],0),"m123 m123 d111 d222 d33 is not Daisangen"),a+=(0,s.v)(0===r.daisangen(c,[],0),"m111 p999 s111 w222 d11 is not Daisangen"),h+=3,a+=(0,s.v)(13===r.shousuushii(k,[],0),"m123 w111 w222 w333 w44 is Shousuushi"),a+=(0,s.v)(0===r.shousuushii(V,[],0),"m11 w111 w222 w333 w444 is not Shousuushi"),a+=(0,s.v)(0===r.shousuushii(c,[],0),"m111 p999 s111 w222 d11 is not Shousuushi"),h+=3,a+=(0,s.v)(13===r.daisuushi(V,[],0),"m11 w111 w222 w333 w444 is Daisuushi"),a+=(0,s.v)(0===r.daisuushi(k,[],0),"m123 w111 w222 w333 w44 is not Daisuushi"),a+=(0,s.v)(0===r.daisuushi(c,[],0),"m111 p999 s111 w222 d11 is not Daisuushi"),h+=3,a+=(0,s.v)(2===r.chanta(S,[],0),"d11 w111 w222 w333 w444 is Chanta"),a+=(0,s.v)(2===r.chanta(V,[],0),"m11 w111 w222 w333 w444 is Chanta"),a+=(0,s.v)(0===r.chanta(T,[],0),"m123 p66 d111 d222 d333 is not Chanta"),h+=3,a+=(0,s.v)(3===r.junchan(v,[],0),"m123 p123 s123 m789 p99 is Junchan"),a+=(0,s.v)(0===r.junchan(T,[],0),"m123 p66 d111 d222 d333 is not Junchan"),h+=2,a+=(0,s.v)(2===r.honroutou(G,[],0),"m11 m999 p111 p999 s111 is Honroutou"),a+=(0,s.v)(2===r.honroutou(c,[],0),"m111 p999 s111 w222 d11 is Honroutou"),a+=(0,s.v)(0===r.honroutou(T,[],0),"m123 p66 d111 d222 d333 is not Honroutou"),h+=3,a+=(0,s.v)(13===r.chinroutou(G,[],0),"m11 m999 p111 p999 s111 is Chinroutou"),a+=(0,s.v)(0===r.chinroutou(c,[],0),"m111 p999 s111 w222 d11 is not Chinroutou"),a+=(0,s.v)(0===r.chinroutou(T,[],0),"m123 p66 d111 d222 d333 is not Chinroutou"),h+=3,a+=(0,s.v)(13===r.tsuuiisou(S,[],0),"d11 w111 w222 w333 w444 is Tsuuisou"),a+=(0,s.v)(0===r.tsuuiisou(c,[],0),"m111 p999 s111 w222 d11 is not Tsuuisou"),h+=2,a+=(0,s.v)(13===r.kokushiMusou(U,[],0),"m199 p19 s19 w1234 d123 is Kokushi Musou"),a+=(0,s.v)(0===r.kokushiMusou(c,[],0),"m111 p999 s111 w222 d11 is not Kokushi Musou"),h+=2,a+=(0,s.v)(2===r.chiitoitsu(C,[],0),"m11 m22 m33 m44 m55 m66 m77 is Chiitoitsu"),a+=(0,s.v)(0===r.chiitoitsu(I,[],0),"m11 m22 m33 m44 m55 m66 m66 is not Chiitoitsu"),a+=(0,s.v)(0===r.chiitoitsu(c,[],0),"m111 p999 s111 w222 d11 is not Chiitoitsu"),h+=3,a+=(0,s.v)(2===r.toitoi(p,[],0),"m111 m444 m777 p111 p55 is Toitoi"),a+=(0,s.v)(0===r.toitoi(v,[],0),"m123 p123 s123 m789 p99 is not Toitoi"),h+=2,a+=(0,s.v)(2===r.sanankou(D,[],0),"m123 m444 m777 p111 p55 is Sanankou"),a+=(0,s.v)(0===r.sanankou(p,[],0),"m111 m444 m777 p111 p55 is not Sanankou"),a+=(0,s.v)(0===r.sanankou(v,[],0),"m123 p123 s123 m789 p99 is not Sanankou"),h+=3,a+=(0,s.v)(13===r.suuankou(p,[],0),"m111 m444 m777 p111 p55 is Sanankou"),a+=(0,s.v)(0===r.suuankou(D,[],0),"m123 m444 m777 p111 p55 is not Sanankou"),a+=(0,s.v)(0===r.suuankou(v,[],0),"m123 p123 s123 m789 p99 is not Sanankou"),h+=3,a+=(0,s.v)(2===r.sanshokuDoukou(E,[],0),"m111 p111 s111 s123 p55 is Shanshoku Doukou"),a+=(0,s.v)(0===r.sanshokuDoukou(P,[],0),"m11 p111 s111 s123 p555 is not Shanshoku Doukou"),a+=(0,s.v)(0===r.sanshokuDoukou(v,[],0),"m123 p123 s123 m789 p99 is not Shanshoku Doukou"),h+=3,a+=(0,s.v)(!1,"Sankantsu not implemented"),h+=1,a+=(0,s.v)(!1,"suukantsu not implemented"),h+=1,a+=(0,s.v)(3===r.honitsu(F,[],0),"m123 m123 d111 d222 d33 is Honitsu"),a+=(0,s.v)(0===r.honitsu(S,[],0),"d11 w111 w222 w333 w444 is not Honitsu"),a+=(0,s.v)(0===r.honitsu(g,[],0),"m123 m456 m789 m123 m55 is not Honitsu"),a+=(0,s.v)(0===r.honitsu(v,[],0),"m123 p123 s123 m789 p99 is not Honitsu"),h+=4,a+=(0,s.v)(6===r.chinitsu(g,[],0),"m123 m456 m789 m123 m55 is Chinitsu"),a+=(0,s.v)(0===r.chinitsu(F,[],0),"m123 m123 d111 d222 d33 is not Chinitsu"),a+=(0,s.v)(0===r.chinitsu(S,[],0),"d11 w111 w222 w333 w444 is not Chinitsu"),a+=(0,s.v)(0===r.chinitsu(v,[],0),"m123 p123 s123 m789 p99 is not Chinitsu"),h+=4,a+=(0,s.v)(!1,"Ryuuisou not implemented"),h+=1,a+=(0,s.v)(!1,"Chuuren Poutou not implemented"),h+=1,console.log("Succès: "+a.toString()+"/"+h.toString())},879:(t,e,i)=>{i.d(e,{Y:()=>s});class s{constructor(t,e,i){this.tiles=t,this.stolenFrom=e,this.belongsTo=i}push(t){this.tiles.push(t)}pop(){return this.tiles.pop()}getTiles(){return this.tiles}compare(t){const e=this.tiles[0].compare(t.tiles[0]);return 0!==e?e:this.tiles[1].compare(t.tiles[1])}drawGroup(t,e,i,s,n,o,u){t.save(),t.translate(525,525),t.rotate(o),t.translate(-525,-525);const l=75*n,r=90*n,m=25*n/2,a=(this.belongsTo-this.stolenFrom-1+4)%4,h=void 0===u?-1:u.getFamily(),g=void 0===u?0:u.getValue(),p=(e,i,s,o)=>{e.drawTile(t,i,s,n,!1,o,e.isEqual(h,g))},c=Math.PI/2;switch(a){case 0:p(this.tiles[0],e,i+m,c),p(this.tiles[1],e+r,i,0),p(this.tiles[2],e+r+l+s*n,i,0);break;case 1:p(this.tiles[0],e,i,0),p(this.tiles[1],e+r,i+m,-c),p(this.tiles[2],e+r+l+3*s*n,i,0);break;case 2:p(this.tiles[0],e,i,0),p(this.tiles[1],e+l+s*n,i,0),p(this.tiles[2],e+r+l+s*n,i+m,-c);break;default:console.error(`Position non prise en charge: ${a}`)}t.restore()}}},959:(t,e,i)=>{i.d(e,{U:()=>d});var s=i(274),n=i(879);const o="m",u=1,l="p",r=2,m="s",a=3,h="w",g=4,p="d",c=5;class d{constructor(t=""){this.isolate=!1,this.tiles=[],this.initializeFromString(t)}initializeFromString(t){for(let e=0;ei.getFamily()===t&&i.getValue()===e))}eject(t){if(t<0||t>=this.tiles.length)throw new Error("Invalid tile index");[this.tiles[0],this.tiles[t]]=[this.tiles[t],this.tiles[0]];const e=this.tiles.shift();return this.sort(),e}get(t){if(!(void 0===t||t<0||t>=this.tiles.length))return this.tiles[t]}sort(){this.tiles.sort(((t,e)=>t.isLessThan(e)?-1:1))}count(t,e){return this.tiles.filter((i=>i.getFamily()===t&&i.getValue()===e)).length}toGroup(t=!1){if(0===this.tiles.length)return[];const e=this.tiles.pop(),i=e.getFamily(),s=e.getValue();if(this.count(i,s)>=1&&!t){const t=this.tryFormPair(e);if(t)return t}if(this.count(i,s)>=2){const i=this.tryFormTriplet(e,t);if(i)return i}const n=this.count(i,s-1)>0,o=this.count(i,s-2)>0;if(n&&o){const i=this.tryFormSequence(e,t);if(i)return i}this.tiles.push(e),this.sort()}tryFormPair(t){const e=this.find(t.getFamily(),t.getValue()),i=this.toGroup(!0);if(this.tiles.push(e),this.sort(),void 0!==i)return this.tiles.push(t),this.sort(),i.push(new n.Y([t,e],0,0)),i}tryFormTriplet(t,e){const i=this.find(t.getFamily(),t.getValue()),s=this.find(t.getFamily(),t.getValue()),o=this.toGroup(e);if(this.tiles.push(i),this.tiles.push(s),this.sort(),void 0!==o)return o.push(new n.Y([t,i,s],0,0)),this.tiles.push(t),this.sort(),o}tryFormSequence(t,e){const i=this.find(t.getFamily(),t.getValue()-1),s=this.find(t.getFamily(),t.getValue()-2),o=this.toGroup(e);if(this.tiles.push(i),this.tiles.push(s),this.sort(),void 0!==o)return o.push(new n.Y([s,i,t],0,0)),this.tiles.push(t),this.sort(),o}drawHand(t,e,i,s,n,o=void 0,u=!1,l=0){const r=(75+s)*n,m=Math.cos(l)*r,a=Math.sin(l)*r;for(let s=0;st.preloadImg())))},new((i=void 0)||(i=Promise))((function(n,o){function u(t){try{r(s.next(t))}catch(t){o(t)}}function l(t){try{r(s.throw(t))}catch(t){o(t)}}function r(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(u,l)}r((s=s.apply(t,e||[])).next())}));var t,e,i,s}cleanup(){this.tiles.forEach((t=>t.cleanup())),this.tiles=[]}}}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var o=e[s]={exports:{}};return t[s](o,o.exports,i),o.exports}i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i(679),i(762)})(); \ No newline at end of file +(()=>{"use strict";var t={274:(t,e,i)=>{i.d(e,{F:()=>s});class s{constructor(t,e,i){this.family=t,this.value=e,this.red=i,this.imgFront=new Image,this.imgBack=new Image,this.imgGray=new Image,this.img=new Image,this.imgSrc="",this.tilt=0,this.setImgSrc()}getFamily(){return this.family}getValue(){return this.value}isEqual(t,e){return this.family===t&&this.value===e}isRed(){return this.red}compare(t){return this.family!==t.family?this.family{t.onload=null,t.onerror=null}))}preloadImg(){return t=this,e=void 0,s=function*(){const t=[{img:this.imgFront,src:"img/Regular/Front.svg"},{img:this.imgBack,src:"img/Regular/Back.svg"},{img:this.imgGray,src:"img/Regular/Gray.svg"},{img:this.img,src:this.imgSrc}];yield Promise.all(t.map((({img:t,src:e})=>this.loadImg(t,e))))},new((i=void 0)||(i=Promise))((function(n,u){function o(t){try{m(s.next(t))}catch(t){u(t)}}function l(t){try{m(s.throw(t))}catch(t){u(t)}}function m(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,l)}m((s=s.apply(t,e||[])).next())}));var t,e,i,s}loadImg(t,e){return new Promise(((i,s)=>{t.onload=()=>i(),t.onerror=()=>s(),t.src=e}))}setImgSrc(){if(this.imgSrc="img/Regular/",this.family<=3){const t=["","Man","Pin","Sou"];this.imgSrc+=t[this.family]+String(this.value),this.red&&(this.imgSrc+="-Dora")}else if(4===this.family){const t=["","Ton","Nan","Shaa","Pei"];this.imgSrc+=t[this.value]}else if(5===this.family){const t=["","Chun","Hatsu","Haku"];this.imgSrc+=t[this.value]}this.imgSrc+=".svg"}}},305:(t,e,i)=>{function s(t,e){return t?(console.log("%c[SUCCES] "+e,"color: green"),1):(console.log("%c[ECHEC] "+e,"color: red"),0)}i.d(e,{v:()=>s})},679:(t,e,i)=>{var s,n,u,o,l,m=i(959),r=i(305);let a=new m.U("s1s1"),h=new m.U("m1m2m3"),g=new m.U("m2m2m2 p1p1"),p=new m.U("m1m2m3 p1p2p3 s1s2s3 m9m9m9 p9p9"),c=new m.U("m2m2m2 p1p1p1"),d=0,f=0;d+=(0,r.v)(1===(null===(s=a.toGroup())||void 0===s?void 0:s.length),"s11 has 1 group"),d+=(0,r.v)(1===(null===(n=h.toGroup())||void 0===n?void 0:n.length),"m123 has 1 group"),d+=(0,r.v)(2===(null===(u=g.toGroup())||void 0===u?void 0:u.length),"m222 p11 has 2 groups"),(0,r.v)(5===(null===(o=p.toGroup())||void 0===o?void 0:o.length),"m123 p123 s123 m999 p99 has 5 groups"),d+=(0,r.v)(2===(null===(l=c.toGroup())||void 0===l?void 0:l.length),"m222 p111 has 2 groups"),f+=4,console.log("Succès: "+d.toString()+"/"+f.toString())},762:(t,e,i)=>{var s=i(305);function n(t){return t.getTiles().every((t=>t.getFamily()<4&&t.getValue()>1&&t.getValue()<9))}function u(t){return t.getTiles().every((t=>t.getFamily()>=4))}function o(t){let e=t.getTiles();return e[0].getValue()!==e[1].getValue()}function l(t){let e=t.getTiles();return e[0].getValue()===e[1].getValue()}const m={lipekou:function(t,e,i){if(e.length>0&&!m.ryanpeikou(t,e,i))return 0;let s=t.toGroup();s.sort(((t,e)=>t.compare(e)));for(let t=0;t<3;t++){let e=s[t].getTiles(),i=s[t+1].getTiles();if(e[0].isEqual(i[0].getFamily(),i[0].getValue())&&o(s[t])&&o(s[t+1]))return 1}return 0},ryanpeikou:function(t,e,i){if(e.length>0)return 0;let s=t.toGroup();if(s.filter((t=>o(t))),s.length<4)return 0;s.sort(((t,e)=>t.compare(e)));let n=s[0].getTiles()[0],u=s[1].getTiles()[0],l=s[2].getTiles()[0],m=s[3].getTiles()[0];return 0===n.compare(u)&&0===l.compare(m)?3:0},pinfu:function(t,e,i){if(e.length>0)return 0;let s=t.toGroup();return void 0!==s&&s.every((t=>{let e=t.getTiles();return o(t)||2===e.length}))?1:0},sanshokuDoujun:function(t,e,i){let s=t.toGroup(),n=[];if(n=void 0!==s?e.concat(s):e,n=n.filter((t=>o(t))),n.sort(((t,e)=>t.compare(e))),n.length<3)return 0;if(3===n.length){let t=n[0].getTiles(),i=n[1].getTiles(),s=n[2].getTiles();return t[0].getValue()===i[0].getValue()&&t[0].getValue()===s[0].getValue()&&t[0].getFamily()!==i[0].getFamily()&&t[0].getFamily()!==s[0].getFamily()&&i[0].getFamily()!==s[0].getFamily()?e.length>0?1:2:0}for(let t=0;t<4;t++){let i=[];for(let e=0;e<4;e++)e!==t&&i.push(e);let s=n[i[0]].getTiles(),u=n[i[1]].getTiles(),o=n[i[2]].getTiles();if(s[0].getValue()===u[0].getValue()&&s[0].getValue()===o[0].getValue()&&s[0].getFamily()!==u[0].getFamily()&&s[0].getFamily()!==o[0].getFamily()&&u[0].getFamily()!==o[0].getFamily())return e.length>0?1:2}return 0},ittsuu:function(t,e,i){let s=e.concat(t.toGroup());if(s=s.filter((t=>o(t))),s.sort(((t,e)=>t.compare(e))),s.length<3)return 0;if(3!==s.length){for(let t=0;t<4;t++){let i=[];for(let e=0;e<4;e++)e!==t&&i.push(e);let n=s[i[0]].getTiles(),u=s[i[1]].getTiles(),o=s[i[2]].getTiles();if(1===n[0].getValue()&&4===u[0].getValue()&&7===o[0].getValue()&&n[0].getFamily()===u[0].getFamily()&&n[0].getFamily()===o[0].getFamily())return e.length>0?1:2}return 0}{let t=s[0].getTiles(),i=s[1].getTiles(),n=s[2].getTiles();if(t[0].getFamily()===i[0].getFamily()&&i[0].getFamily()===n[0].getFamily()&&1===t[0].getValue()&&4===i[0].getValue()&&7===n[0].getValue())return e.length>0?1:2}return 0},tanyao:function(t,e,i){let s=t.toGroup();return void 0===s?0:e.every((t=>n(t)))&&s.every((t=>n(t)))?1:0},yakuhai:function(t,e,i){let s=e.concat(t.toGroup());s=s.filter((t=>l(t)&&3===t.getTiles().length));let n=0;return s.forEach((t=>{let e=t.getTiles(),s=e[0].getFamily(),u=e[0].getValue();5===s&&n++,4===s&&0===u&&n++,4===s&&u===i&&n++})),n},shousangen:function(t,e,i){let s=e.concat(t.toGroup());s=s.filter((t=>l(t)));let n=0,u=0;return s.forEach((t=>{let e=t.getTiles();5===e[0].getFamily()&&(3===e.length?n++:u++)})),2==n&&1==u?2:0},daisangen:function(t,e,i){let s=e.concat(t.toGroup());return s=s.filter((t=>l(t)&&3===t.getTiles().length&&5===t.getTiles()[0].getFamily())),3===s.length?13:0},shousuushii:function(t,e,i){let s=e.concat(t.toGroup());s=s.filter((t=>l(t)));let n=0,u=0;return s.forEach((t=>{let e=t.getTiles();4===e[0].getFamily()&&(3===e.length?n++:u++)})),3==n&&1==u?13:0},daisuushi:function(t,e,i){let s=e.concat(t.toGroup());s=s.filter((t=>l(t)));let n=0,u=0;return s.forEach((t=>{let e=t.getTiles();4===e[0].getFamily()&&(3===e.length?n++:u++)})),4==n&&0==u?13:0},chanta:function(t,e,i){let s=e.concat(t.toGroup());return s=s.filter((t=>{let e=t.getTiles(),i=e[0].getFamily(),s=e[0].getValue(),n=e[e.length-1].getValue();return i<4&&1!==s&&9!==n})),s.length>0?0:e.length>0?1:2},junchan:function(t,e,i){let s=e.concat(t.toGroup());return s=s.filter((t=>{let e=t.getTiles(),i=e[0].getFamily(),s=e[0].getValue(),n=e[e.length-1].getValue();return i>3||1!==s&&9!==n})),s.length>0?0:e.length>0?2:3},honroutou:function(t,e,i){let s=e.concat(t.toGroup());return s=s.filter((t=>{let e=t.getTiles(),i=e[0].getFamily(),s=e[1].getValue();return i<4&&1!==s&&9!==s})),s.length>0?0:2},chinroutou:function(t,e,i){return e.concat(t.toGroup()).every((t=>function(t){return t.getTiles().every((t=>t.getFamily()<4&&(1===t.getValue()||9===t.getValue())))}(t)))?13:0},tsuuiisou:function(t,e,i){let s=t.toGroup();return void 0===s?0:e.every((t=>u(t)))&&s.every((t=>u(t)))?13:0},kokushiMusou:function(t,e,i){if(e.length>0)return 0;let s=t.getTiles();if(s.some((t=>t.getFamily()<4&&t.getValue()>1&&t.getValue()<9)))return 0;let n=0;for(let t=0;t1));t++);return 1===n?13:0},chiitoitsu:function(t,e,i){if(e.length>0)return 0;let s=t.getTiles();if(14!==s.length)return 0;for(let t=0;t<14;t+=2)if(0!==s[t].compare(s[t+1])||t>0&&0===s[t].compare(s[t-1]))return 0;return 2},toitoi:function(t,e,i){let s=t.toGroup();return e.every((t=>l(t)))&&(null==s?void 0:s.every((t=>l(t))))?2:0},sanankou:function(t,e,i){let s=t.toGroup(),n=0;return null==s||s.forEach((t=>{l(t)&&3===t.getTiles().length&&n++})),3===n?2:0},suuankou:function(t,e,i){let s=t.toGroup(),n=0;return null==s||s.forEach((t=>{l(t)&&3===t.getTiles().length&&n++})),4===n?13:0},sanshokuDoukou:function(t,e,i){let s=t.toGroup(),n=[];if(n=void 0!==s?e.concat(s):e,n=n.filter((t=>l(t)&&3===t.getTiles().length)),n.sort(((t,e)=>t.compare(e))),n.length<3)return 0;if(3===n.length){let t=n[0].getTiles(),i=n[1].getTiles(),s=n[2].getTiles();return t[0].getValue()===i[0].getValue()&&t[0].getValue()===s[0].getValue()&&t[0].getFamily()!==i[0].getFamily()&&t[0].getFamily()!==s[0].getFamily()&&i[0].getFamily()!==s[0].getFamily()?e.length>0?1:2:0}for(let t=0;t<4;t++){let i=[];for(let e=0;e<4;e++)e!==t&&i.push(e);let s=n[i[0]].getTiles(),u=n[i[1]].getTiles(),o=n[i[2]].getTiles();if(s[0].getValue()===u[0].getValue()&&s[0].getValue()===o[0].getValue()&&s[0].getFamily()!==u[0].getFamily()&&s[0].getFamily()!==o[0].getFamily()&&u[0].getFamily()!==o[0].getFamily())return e.length>0?1:2}return 0},sankantsu:function(t,e,i){return 0},suukantsu:function(t,e,i){return 0},honitsu:function(t,e,i){let s=t.toGroup(),n=[];if(n=void 0!==s?e.concat(s):e,n.sort(((t,e)=>t.compare(e))),0===n.length)return 0;if(n[n.length-1].getTiles()[0].getFamily()<4)return 0;let u=n[0].getTiles()[0].getFamily();return u>3?0:n.every((t=>{let e=t.getTiles()[0].getFamily();return e>3||u===e}))?e.length>0?2:3:0},chinitsu:function(t,e,i){let s=t.getTiles(),n=s[0];return s.every((t=>t.getFamily()===n.getFamily()))&&e.every((t=>t.getTiles().every((t=>t.getFamily()===n.getFamily()))))?e.length>0?5:6:0},ryuuisou:function(t,e,i){if(e.length>0)return 0;let s=t.toGroup();return(null==s?void 0:s.every((t=>t.getTiles().every((t=>function(t){let e=t.getFamily(),i=t.getValue();return(5===e||3===e)&&(5===e?2===i:i%2==0||3===i)}(t))))))?13:0},chuurenPoutou:function(t,e,i){if(e.length>0||0===m.chinitsu(t,e,i))return 0;let s=t.getTiles();if(s[0].getFamily()>=4)return 0;let n=[s[0].getValue()],u=1;for(let t=1;t4)return 0}else u=1,n.push(e);else if(e===i){if(u++,u<2)n.push(e);else if(u>2)return 0}else u=1,n.push(e)}return n.toString()===[1,1,1,2,3,4,5,6,7,8,9,9,9].toString()?13:0}};var r=i(959);let a=0,h=0,g=new r.U("m1m2m3 m4m5m6 m7m8m9 m1m2m3 m5m5"),p=new r.U("m1m1m1 m4m4m4 m7m7m7 p1p1p1 p5p5"),c=new r.U("m1m1m1 p9p9p9 s1s1s1 w2w2w2 d1d1"),d=new r.U("m2m3m4 p3p3p3 p4p5p6 s4s4 s6s7s8"),f=new r.U("m1m2m3 m1m2m3 p7p8p9 p7p8p9 w3w3"),w=new r.U("m1m2m3 m1m2m3 p6p7p8 p7p8p9 w3w3"),v=new r.U("m1m2m3 p1p2p3 s1s2s3 m7m8m9 p9p9"),y=new r.U("m1m2m3 m1m2m3 p6p6 w0w0w0 w3w3w3"),F=new r.U("m1m2m3 m1m2m3 d1d1d1 d2d2d2 d3d3"),T=new r.U("m1m2m3 p6p6 d1d1d1 d2d2d2 d3d3d3"),k=new r.U("m1m2m3 w1w1w1 w2w2w2 w3w3w3 w4w4"),V=new r.U("m1m1 w1w1w1 w2w2w2 w3w3w3 w4w4w4"),S=new r.U("d1d1 w1w1w1 w2w2w2 w3w3w3 w4w4w4"),G=new r.U("m1m1 m9m9m9 p1p1p1 p9p9p9 s1s1s1"),U=new r.U("m1m9m9 p1p9 s1s9 w1w2w3w4 d1d2d3"),C=new r.U("m1m1 m2m2 m3m3 m4m4 m5m5 m6m6 m7m7"),P=new r.U("m1m1 m2m2 m3m3 m4m4 m5m5 m6m6 m6m6"),I=new r.U("m1m2m3 m4m4m4 m7m7m7 p1p1p1 p5p5"),D=new r.U("m1m1m1 p1p1p1 s1s1s1 s1s2s3 p5p5"),E=new r.U("m1m1m1 p1p1p1 s1s1 s1s2s3 p5p5p5"),M=new r.U("m1m1m1 m2m3m4 m5m6m7 m8m8 m9m9m9"),x=new r.U("s2s2s2 s8s8s8 s4s4s4 s6s6 d2d2d2"),b=new r.U("m1m1m1 m2m3m4 m5m6m7 m8m8m8 m9m9m9"),j=new r.U("m1m1m1 m2m3m4 m6m6 m5m6m7 m9m9m9");a+=(0,s.v)(1===m.lipekou(f,[],0),"m123 m123 p789 p789 w33 is Lipeikou"),a+=(0,s.v)(0===m.lipekou(c,[],0),"m111 p999 s111 w222 d11 is not Lipeikou"),h+=2,a+=(0,s.v)(3===m.ryanpeikou(f,[],0),"m123 m123 p789 p789 w33 is Ryanpeikou"),a+=(0,s.v)(0===m.ryanpeikou(w,[],0),"m1123 m123 p678 p789 w33 is not Ryanpeikou"),h+=2,a+=(0,s.v)(1===m.pinfu(g,[],0),"m123 m456 m789 m123 p55 is Pinfu"),a+=(0,s.v)(0===m.pinfu(p,[],0),"m111 m444 m777 p111 p55 is not Pinfu"),h+=2,a+=(0,s.v)(2===m.sanshokuDoujun(v,[],0),"m123 p123 s123 m789 p99 is Shanshokou Doujun"),a+=(0,s.v)(0===m.sanshokuDoujun(p,[],0),"m111 m444 m777 p111 p55 is not Shanshokou Doujun"),h+=2,a+=(0,s.v)(2===m.ittsuu(g,[],0),"m123 m456 m789 m123 m55 is Ittsuu"),a+=(0,s.v)(0===m.ittsuu(p,[],0),"m111 m444 m777 p111 p55 is not Ittsu"),h+=2,a+=(0,s.v)(1===m.tanyao(d,[],0),"m234 p333 p456 s44 s678 is Tanyao"),a+=(0,s.v)(0===m.tanyao(g,[],0),"m123 m456 m789 m123 p55 is not Tanyao"),h+=2,a+=(0,s.v)(1===m.yakuhai(c,[],2),"m111 p999 s111 w222 d11 West is Yakuhai"),a+=(0,s.v)(2===m.yakuhai(y,[],3),"m123 m123 p66 w000 w333 North is double Yakuhai"),a+=(0,s.v)(0===m.yakuhai(c,[],0),"m111 p999 s111 w222 d11 Est is not Yakuhai"),h+=3,a+=(0,s.v)(2===m.shousangen(F,[],0),"m123 m123 d111 d222 d33 is Shousangen"),a+=(0,s.v)(0===m.shousangen(T,[],0),"m123 p66 d111 d222 d333 is not Shousangen"),a+=(0,s.v)(0===m.shousangen(c,[],0),"m111 p999 s111 w222 d11 is not Shousangen"),h+=3,a+=(0,s.v)(13===m.daisangen(T,[],0),"m123 p66 d111 d222 d333 is Daisangen"),a+=(0,s.v)(0===m.daisangen(F,[],0),"m123 m123 d111 d222 d33 is not Daisangen"),a+=(0,s.v)(0===m.daisangen(c,[],0),"m111 p999 s111 w222 d11 is not Daisangen"),h+=3,a+=(0,s.v)(13===m.shousuushii(k,[],0),"m123 w111 w222 w333 w44 is Shousuushi"),a+=(0,s.v)(0===m.shousuushii(V,[],0),"m11 w111 w222 w333 w444 is not Shousuushi"),a+=(0,s.v)(0===m.shousuushii(c,[],0),"m111 p999 s111 w222 d11 is not Shousuushi"),h+=3,a+=(0,s.v)(13===m.daisuushi(V,[],0),"m11 w111 w222 w333 w444 is Daisuushi"),a+=(0,s.v)(0===m.daisuushi(k,[],0),"m123 w111 w222 w333 w44 is not Daisuushi"),a+=(0,s.v)(0===m.daisuushi(c,[],0),"m111 p999 s111 w222 d11 is not Daisuushi"),h+=3,a+=(0,s.v)(2===m.chanta(S,[],0),"d11 w111 w222 w333 w444 is Chanta"),a+=(0,s.v)(2===m.chanta(V,[],0),"m11 w111 w222 w333 w444 is Chanta"),a+=(0,s.v)(0===m.chanta(T,[],0),"m123 p66 d111 d222 d333 is not Chanta"),h+=3,a+=(0,s.v)(3===m.junchan(v,[],0),"m123 p123 s123 m789 p99 is Junchan"),a+=(0,s.v)(0===m.junchan(T,[],0),"m123 p66 d111 d222 d333 is not Junchan"),h+=2,a+=(0,s.v)(2===m.honroutou(G,[],0),"m11 m999 p111 p999 s111 is Honroutou"),a+=(0,s.v)(2===m.honroutou(c,[],0),"m111 p999 s111 w222 d11 is Honroutou"),a+=(0,s.v)(0===m.honroutou(T,[],0),"m123 p66 d111 d222 d333 is not Honroutou"),h+=3,a+=(0,s.v)(13===m.chinroutou(G,[],0),"m11 m999 p111 p999 s111 is Chinroutou"),a+=(0,s.v)(0===m.chinroutou(c,[],0),"m111 p999 s111 w222 d11 is not Chinroutou"),a+=(0,s.v)(0===m.chinroutou(T,[],0),"m123 p66 d111 d222 d333 is not Chinroutou"),h+=3,a+=(0,s.v)(13===m.tsuuiisou(S,[],0),"d11 w111 w222 w333 w444 is Tsuuisou"),a+=(0,s.v)(0===m.tsuuiisou(c,[],0),"m111 p999 s111 w222 d11 is not Tsuuisou"),h+=2,a+=(0,s.v)(13===m.kokushiMusou(U,[],0),"m199 p19 s19 w1234 d123 is Kokushi Musou"),a+=(0,s.v)(0===m.kokushiMusou(c,[],0),"m111 p999 s111 w222 d11 is not Kokushi Musou"),h+=2,a+=(0,s.v)(2===m.chiitoitsu(C,[],0),"m11 m22 m33 m44 m55 m66 m77 is Chiitoitsu"),a+=(0,s.v)(0===m.chiitoitsu(P,[],0),"m11 m22 m33 m44 m55 m66 m66 is not Chiitoitsu"),a+=(0,s.v)(0===m.chiitoitsu(c,[],0),"m111 p999 s111 w222 d11 is not Chiitoitsu"),h+=3,a+=(0,s.v)(2===m.toitoi(p,[],0),"m111 m444 m777 p111 p55 is Toitoi"),a+=(0,s.v)(0===m.toitoi(v,[],0),"m123 p123 s123 m789 p99 is not Toitoi"),h+=2,a+=(0,s.v)(2===m.sanankou(I,[],0),"m123 m444 m777 p111 p55 is Sanankou"),a+=(0,s.v)(0===m.sanankou(p,[],0),"m111 m444 m777 p111 p55 is not Sanankou"),a+=(0,s.v)(0===m.sanankou(v,[],0),"m123 p123 s123 m789 p99 is not Sanankou"),h+=3,a+=(0,s.v)(13===m.suuankou(p,[],0),"m111 m444 m777 p111 p55 is Sanankou"),a+=(0,s.v)(0===m.suuankou(I,[],0),"m123 m444 m777 p111 p55 is not Sanankou"),a+=(0,s.v)(0===m.suuankou(v,[],0),"m123 p123 s123 m789 p99 is not Sanankou"),h+=3,a+=(0,s.v)(2===m.sanshokuDoukou(D,[],0),"m111 p111 s111 s123 p55 is Shanshoku Doukou"),a+=(0,s.v)(0===m.sanshokuDoukou(E,[],0),"m11 p111 s111 s123 p555 is not Shanshoku Doukou"),a+=(0,s.v)(0===m.sanshokuDoukou(v,[],0),"m123 p123 s123 m789 p99 is not Shanshoku Doukou"),h+=3,a+=(0,s.v)(!1,"sankantsu not implemented"),h+=1,a+=(0,s.v)(!1,"suukantsu not implemented"),h+=1,a+=(0,s.v)(3===m.honitsu(F,[],0),"m123 m123 d111 d222 d33 is Honitsu"),a+=(0,s.v)(0===m.honitsu(S,[],0),"d11 w111 w222 w333 w444 is not Honitsu"),a+=(0,s.v)(0===m.honitsu(g,[],0),"m123 m456 m789 m123 m55 is not Honitsu"),a+=(0,s.v)(0===m.honitsu(v,[],0),"m123 p123 s123 m789 p99 is not Honitsu"),h+=4,a+=(0,s.v)(6===m.chinitsu(g,[],0),"m123 m456 m789 m123 m55 is Chinitsu"),a+=(0,s.v)(0===m.chinitsu(F,[],0),"m123 m123 d111 d222 d33 is not Chinitsu"),a+=(0,s.v)(0===m.chinitsu(S,[],0),"d11 w111 w222 w333 w444 is not Chinitsu"),a+=(0,s.v)(0===m.chinitsu(v,[],0),"m123 p123 s123 m789 p99 is not Chinitsu"),h+=4,a+=(0,s.v)(13===m.ryuuisou(x,[],0),"s222 s888 s444 s66 d222 is Ryuuisou"),a+=(0,s.v)(0===m.ryuuisou(g,[],0),"m123 m456 m789 m123 m55 is not Ryuuisou"),h+=2,a+=(0,s.v)(13===m.chuurenPoutou(M,[],0),"m111 m234 m567 m88 m999 is Chuuren Poutou"),a+=(0,s.v)(0===m.chuurenPoutou(b,[],0),"m111 m234 m567 m888 m999 is not Chuuren Poutou"),a+=(0,s.v)(0===m.chuurenPoutou(j,[],0),"m111 m234 m66 m567 m999 is not Chuuren Poutou"),a+=(0,s.v)(0===m.chuurenPoutou(g,[],0),"m123 m456 m789 m123 m55 is not Chuuren Poutou"),h+=4,console.log("Succès: "+a.toString()+"/"+h.toString())},879:(t,e,i)=>{i.d(e,{Y:()=>s});class s{constructor(t,e,i){this.tiles=t,this.stolenFrom=e,this.belongsTo=i}push(t){this.tiles.push(t)}pop(){return this.tiles.pop()}getTiles(){return this.tiles}compare(t){const e=this.tiles[0].compare(t.tiles[0]);return 0!==e?e:this.tiles[1].compare(t.tiles[1])}drawGroup(t,e,i,s,n,u,o){t.save(),t.translate(525,525),t.rotate(u),t.translate(-525,-525);const l=75*n,m=90*n,r=25*n/2,a=(this.belongsTo-this.stolenFrom-1+4)%4,h=void 0===o?-1:o.getFamily(),g=void 0===o?0:o.getValue(),p=(e,i,s,u)=>{e.drawTile(t,i,s,n,!1,u,e.isEqual(h,g))},c=Math.PI/2;switch(a){case 0:p(this.tiles[0],e,i+r,c),p(this.tiles[1],e+m,i,0),p(this.tiles[2],e+m+l+s*n,i,0);break;case 1:p(this.tiles[0],e,i,0),p(this.tiles[1],e+m,i+r,-c),p(this.tiles[2],e+m+l+3*s*n,i,0);break;case 2:p(this.tiles[0],e,i,0),p(this.tiles[1],e+l+s*n,i,0),p(this.tiles[2],e+m+l+s*n,i+r,-c);break;default:console.error(`Position non prise en charge: ${a}`)}t.restore()}}},959:(t,e,i)=>{i.d(e,{U:()=>d});var s=i(274),n=i(879);const u="m",o=1,l="p",m=2,r="s",a=3,h="w",g=4,p="d",c=5;class d{constructor(t=""){this.isolate=!1,this.tiles=[],this.initializeFromString(t)}initializeFromString(t){for(let e=0;ei.getFamily()===t&&i.getValue()===e))}eject(t){if(t<0||t>=this.tiles.length)throw new Error("Invalid tile index");[this.tiles[0],this.tiles[t]]=[this.tiles[t],this.tiles[0]];const e=this.tiles.shift();return this.sort(),e}get(t){if(!(void 0===t||t<0||t>=this.tiles.length))return this.tiles[t]}sort(){this.tiles.sort(((t,e)=>t.isLessThan(e)?-1:1))}count(t,e){return this.tiles.filter((i=>i.getFamily()===t&&i.getValue()===e)).length}toGroup(t=!1){if(0===this.tiles.length)return[];const e=this.tiles.pop(),i=e.getFamily(),s=e.getValue();if(this.count(i,s)>=1&&!t){const t=this.tryFormPair(e);if(t)return t}if(this.count(i,s)>=2){const i=this.tryFormTriplet(e,t);if(i)return i}const n=this.count(i,s-1)>0,u=this.count(i,s-2)>0;if(n&&u){const i=this.tryFormSequence(e,t);if(i)return i}this.tiles.push(e),this.sort()}tryFormPair(t){const e=this.find(t.getFamily(),t.getValue()),i=this.toGroup(!0);if(this.tiles.push(e),this.sort(),void 0!==i)return this.tiles.push(t),this.sort(),i.push(new n.Y([t,e],0,0)),i}tryFormTriplet(t,e){const i=this.find(t.getFamily(),t.getValue()),s=this.find(t.getFamily(),t.getValue()),u=this.toGroup(e);if(this.tiles.push(i),this.tiles.push(s),this.sort(),void 0!==u)return u.push(new n.Y([t,i,s],0,0)),this.tiles.push(t),this.sort(),u}tryFormSequence(t,e){const i=this.find(t.getFamily(),t.getValue()-1),s=this.find(t.getFamily(),t.getValue()-2),u=this.toGroup(e);if(this.tiles.push(i),this.tiles.push(s),this.sort(),void 0!==u)return u.push(new n.Y([s,i,t],0,0)),this.tiles.push(t),this.sort(),u}drawHand(t,e,i,s,n,u=void 0,o=!1,l=0){const m=(75+s)*n,r=Math.cos(l)*m,a=Math.sin(l)*m;for(let s=0;st.preloadImg())))},new((i=void 0)||(i=Promise))((function(n,u){function o(t){try{m(s.next(t))}catch(t){u(t)}}function l(t){try{m(s.throw(t))}catch(t){u(t)}}function m(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,l)}m((s=s.apply(t,e||[])).next())}));var t,e,i,s}cleanup(){this.tiles.forEach((t=>t.cleanup())),this.tiles=[]}}}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var u=e[s]={exports:{}};return t[s](u,u.exports,i),u.exports}i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i(679),i(762)})(); \ No newline at end of file diff --git a/build/test_yakus.js b/build/test_yakus.js index 6f9d7ca..c60bf66 100644 --- a/build/test_yakus.js +++ b/build/test_yakus.js @@ -1 +1 @@ -(()=>{"use strict";var t={274:(t,e,i)=>{i.d(e,{F:()=>s});class s{constructor(t,e,i){this.family=t,this.value=e,this.red=i,this.imgFront=new Image,this.imgBack=new Image,this.imgGray=new Image,this.img=new Image,this.imgSrc="",this.tilt=0,this.setImgSrc()}getFamily(){return this.family}getValue(){return this.value}isEqual(t,e){return this.family===t&&this.value===e}isRed(){return this.red}compare(t){return this.family!==t.family?this.family{t.onload=null,t.onerror=null}))}preloadImg(){return t=this,e=void 0,s=function*(){const t=[{img:this.imgFront,src:"img/Regular/Front.svg"},{img:this.imgBack,src:"img/Regular/Back.svg"},{img:this.imgGray,src:"img/Regular/Gray.svg"},{img:this.img,src:this.imgSrc}];yield Promise.all(t.map((({img:t,src:e})=>this.loadImg(t,e))))},new((i=void 0)||(i=Promise))((function(n,u){function o(t){try{r(s.next(t))}catch(t){u(t)}}function l(t){try{r(s.throw(t))}catch(t){u(t)}}function r(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,l)}r((s=s.apply(t,e||[])).next())}));var t,e,i,s}loadImg(t,e){return new Promise(((i,s)=>{t.onload=()=>i(),t.onerror=()=>s(),t.src=e}))}setImgSrc(){if(this.imgSrc="img/Regular/",this.family<=3){const t=["","Man","Pin","Sou"];this.imgSrc+=t[this.family]+String(this.value),this.red&&(this.imgSrc+="-Dora")}else if(4===this.family){const t=["","Ton","Nan","Shaa","Pei"];this.imgSrc+=t[this.value]}else if(5===this.family){const t=["","Chun","Hatsu","Haku"];this.imgSrc+=t[this.value]}this.imgSrc+=".svg"}}},305:(t,e,i)=>{function s(t,e){return t?(console.log("%c[SUCCES] "+e,"color: green"),1):(console.log("%c[ECHEC] "+e,"color: red"),0)}i.d(e,{v:()=>s})},879:(t,e,i)=>{i.d(e,{Y:()=>s});class s{constructor(t,e,i){this.tiles=t,this.stolenFrom=e,this.belongsTo=i}push(t){this.tiles.push(t)}pop(){return this.tiles.pop()}getTiles(){return this.tiles}compare(t){const e=this.tiles[0].compare(t.tiles[0]);return 0!==e?e:this.tiles[1].compare(t.tiles[1])}drawGroup(t,e,i,s,n,u,o){t.save(),t.translate(525,525),t.rotate(u),t.translate(-525,-525);const l=75*n,r=90*n,a=25*n/2,m=(this.belongsTo-this.stolenFrom-1+4)%4,h=void 0===o?-1:o.getFamily(),g=void 0===o?0:o.getValue(),p=(e,i,s,u)=>{e.drawTile(t,i,s,n,!1,u,e.isEqual(h,g))},c=Math.PI/2;switch(m){case 0:p(this.tiles[0],e,i+a,c),p(this.tiles[1],e+r,i,0),p(this.tiles[2],e+r+l+s*n,i,0);break;case 1:p(this.tiles[0],e,i,0),p(this.tiles[1],e+r,i+a,-c),p(this.tiles[2],e+r+l+3*s*n,i,0);break;case 2:p(this.tiles[0],e,i,0),p(this.tiles[1],e+l+s*n,i,0),p(this.tiles[2],e+r+l+s*n,i+a,-c);break;default:console.error(`Position non prise en charge: ${m}`)}t.restore()}}},959:(t,e,i)=>{i.d(e,{U:()=>d});var s=i(274),n=i(879);const u="m",o=1,l="p",r=2,a="s",m=3,h="w",g=4,p="d",c=5;class d{constructor(t=""){this.isolate=!1,this.tiles=[],this.initializeFromString(t)}initializeFromString(t){for(let e=0;ei.getFamily()===t&&i.getValue()===e))}eject(t){if(t<0||t>=this.tiles.length)throw new Error("Invalid tile index");[this.tiles[0],this.tiles[t]]=[this.tiles[t],this.tiles[0]];const e=this.tiles.shift();return this.sort(),e}get(t){if(!(void 0===t||t<0||t>=this.tiles.length))return this.tiles[t]}sort(){this.tiles.sort(((t,e)=>t.isLessThan(e)?-1:1))}count(t,e){return this.tiles.filter((i=>i.getFamily()===t&&i.getValue()===e)).length}toGroup(t=!1){if(0===this.tiles.length)return[];const e=this.tiles.pop(),i=e.getFamily(),s=e.getValue();if(this.count(i,s)>=1&&!t){const t=this.tryFormPair(e);if(t)return t}if(this.count(i,s)>=2){const i=this.tryFormTriplet(e,t);if(i)return i}const n=this.count(i,s-1)>0,u=this.count(i,s-2)>0;if(n&&u){const i=this.tryFormSequence(e,t);if(i)return i}this.tiles.push(e),this.sort()}tryFormPair(t){const e=this.find(t.getFamily(),t.getValue()),i=this.toGroup(!0);if(this.tiles.push(e),this.sort(),void 0!==i)return this.tiles.push(t),this.sort(),i.push(new n.Y([t,e],0,0)),i}tryFormTriplet(t,e){const i=this.find(t.getFamily(),t.getValue()),s=this.find(t.getFamily(),t.getValue()),u=this.toGroup(e);if(this.tiles.push(i),this.tiles.push(s),this.sort(),void 0!==u)return u.push(new n.Y([t,i,s],0,0)),this.tiles.push(t),this.sort(),u}tryFormSequence(t,e){const i=this.find(t.getFamily(),t.getValue()-1),s=this.find(t.getFamily(),t.getValue()-2),u=this.toGroup(e);if(this.tiles.push(i),this.tiles.push(s),this.sort(),void 0!==u)return u.push(new n.Y([s,i,t],0,0)),this.tiles.push(t),this.sort(),u}drawHand(t,e,i,s,n,u=void 0,o=!1,l=0){const r=(75+s)*n,a=Math.cos(l)*r,m=Math.sin(l)*r;for(let s=0;st.preloadImg())))},new((i=void 0)||(i=Promise))((function(n,u){function o(t){try{r(s.next(t))}catch(t){u(t)}}function l(t){try{r(s.throw(t))}catch(t){u(t)}}function r(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,l)}r((s=s.apply(t,e||[])).next())}));var t,e,i,s}cleanup(){this.tiles.forEach((t=>t.cleanup())),this.tiles=[]}}}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var u=e[s]={exports:{}};return t[s](u,u.exports,i),u.exports}i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var s=i(305);function n(t){return t.getTiles().every((t=>t.getFamily()<4&&t.getValue()>1&&t.getValue()<9))}function u(t){return t.getTiles().every((t=>t.getFamily()>=4))}function o(t){let e=t.getTiles();return e[0].getValue()!==e[1].getValue()}function l(t){let e=t.getTiles();return e[0].getValue()===e[1].getValue()}const r={lipekou:function(t,e,i){if(e.length>0&&!r.ryanpeikou(t,e,i))return 0;let s=t.toGroup();s.sort(((t,e)=>t.compare(e)));for(let t=0;t<3;t++){let e=s[t].getTiles(),i=s[t+1].getTiles();if(e[0].isEqual(i[0].getFamily(),i[0].getValue())&&o(s[t])&&o(s[t+1]))return 1}return 0},ryanpeikou:function(t,e,i){if(e.length>0)return 0;let s=t.toGroup();if(s.filter((t=>o(t))),s.length<4)return 0;s.sort(((t,e)=>t.compare(e)));let n=s[0].getTiles()[0],u=s[1].getTiles()[0],l=s[2].getTiles()[0],r=s[3].getTiles()[0];return 0===n.compare(u)&&0===l.compare(r)?3:0},pinfu:function(t,e,i){if(e.length>0)return 0;let s=t.toGroup();return void 0!==s&&s.every((t=>{let e=t.getTiles();return o(t)||2===e.length}))?1:0},sanshokuDoujun:function(t,e,i){let s=t.toGroup(),n=[];if(n=void 0!==s?e.concat(s):e,n=n.filter((t=>o(t))),n.sort(((t,e)=>t.compare(e))),n.length<3)return 0;if(3===n.length){let t=n[0].getTiles(),i=n[1].getTiles(),s=n[2].getTiles();return t[0].getValue()===i[0].getValue()&&t[0].getValue()===s[0].getValue()&&t[0].getFamily()!==i[0].getFamily()&&t[0].getFamily()!==s[0].getFamily()&&i[0].getFamily()!==s[0].getFamily()?e.length>0?1:2:0}for(let t=0;t<4;t++){let i=[];for(let e=0;e<4;e++)e!==t&&i.push(e);let s=n[i[0]].getTiles(),u=n[i[1]].getTiles(),o=n[i[2]].getTiles();if(s[0].getValue()===u[0].getValue()&&s[0].getValue()===o[0].getValue()&&s[0].getFamily()!==u[0].getFamily()&&s[0].getFamily()!==o[0].getFamily()&&u[0].getFamily()!==o[0].getFamily())return e.length>0?1:2}return 0},ittsuu:function(t,e,i){let s=e.concat(t.toGroup());if(s=s.filter((t=>o(t))),s.sort(((t,e)=>t.compare(e))),s.length<3)return 0;if(3!==s.length){for(let t=0;t<4;t++){let i=[];for(let e=0;e<4;e++)e!==t&&i.push(e);let n=s[i[0]].getTiles(),u=s[i[1]].getTiles(),o=s[i[2]].getTiles();if(1===n[0].getValue()&&4===u[0].getValue()&&7===o[0].getValue()&&n[0].getFamily()===u[0].getFamily()&&n[0].getFamily()===o[0].getFamily())return e.length>0?1:2}return 0}{let t=s[0].getTiles(),i=s[1].getTiles(),n=s[2].getTiles();if(t[0].getFamily()===i[0].getFamily()&&i[0].getFamily()===n[0].getFamily()&&1===t[0].getValue()&&4===i[0].getValue()&&7===n[0].getValue())return e.length>0?1:2}return 0},tanyao:function(t,e,i){let s=t.toGroup();return void 0===s?0:e.every((t=>n(t)))&&s.every((t=>n(t)))?1:0},yakuhai:function(t,e,i){let s=e.concat(t.toGroup());s=s.filter((t=>l(t)&&3===t.getTiles().length));let n=0;return s.forEach((t=>{let e=t.getTiles(),s=e[0].getFamily(),u=e[0].getValue();5===s&&n++,4===s&&0===u&&n++,4===s&&u===i&&n++})),n},shousangen:function(t,e,i){let s=e.concat(t.toGroup());s=s.filter((t=>l(t)));let n=0,u=0;return s.forEach((t=>{let e=t.getTiles();5===e[0].getFamily()&&(3===e.length?n++:u++)})),2==n&&1==u?2:0},daisangen:function(t,e,i){let s=e.concat(t.toGroup());return s=s.filter((t=>l(t)&&3===t.getTiles().length&&5===t.getTiles()[0].getFamily())),3===s.length?13:0},shousuushii:function(t,e,i){let s=e.concat(t.toGroup());s=s.filter((t=>l(t)));let n=0,u=0;return s.forEach((t=>{let e=t.getTiles();4===e[0].getFamily()&&(3===e.length?n++:u++)})),3==n&&1==u?13:0},daisuushi:function(t,e,i){let s=e.concat(t.toGroup());s=s.filter((t=>l(t)));let n=0,u=0;return s.forEach((t=>{let e=t.getTiles();4===e[0].getFamily()&&(3===e.length?n++:u++)})),4==n&&0==u?13:0},chanta:function(t,e,i){let s=e.concat(t.toGroup());return s=s.filter((t=>{let e=t.getTiles(),i=e[0].getFamily(),s=e[0].getValue(),n=e[e.length-1].getValue();return i<4&&1!==s&&9!==n})),s.length>0?0:e.length>0?1:2},junchan:function(t,e,i){let s=e.concat(t.toGroup());return s=s.filter((t=>{let e=t.getTiles(),i=e[0].getFamily(),s=e[0].getValue(),n=e[e.length-1].getValue();return i>3||1!==s&&9!==n})),s.length>0?0:e.length>0?2:3},honroutou:function(t,e,i){let s=e.concat(t.toGroup());return s=s.filter((t=>{let e=t.getTiles(),i=e[0].getFamily(),s=e[1].getValue();return i<4&&1!==s&&9!==s})),s.length>0?0:2},chinroutou:function(t,e,i){return e.concat(t.toGroup()).every((t=>function(t){return t.getTiles().every((t=>t.getFamily()<4&&(1===t.getValue()||9===t.getValue())))}(t)))?13:0},tsuuiisou:function(t,e,i){let s=t.toGroup();return void 0===s?0:e.every((t=>u(t)))&&s.every((t=>u(t)))?13:0},kokushiMusou:function(t,e,i){if(e.length>0)return 0;let s=t.getTiles();if(s.some((t=>t.getFamily()<4&&t.getValue()>1&&t.getValue()<9)))return 0;let n=0;for(let t=0;t1));t++);return 1===n?13:0},chiitoitsu:function(t,e,i){if(e.length>0)return 0;let s=t.getTiles();if(14!==s.length)return 0;for(let t=0;t<14;t+=2)if(0!==s[t].compare(s[t+1])||t>0&&0===s[t].compare(s[t-1]))return 0;return 2},toitoi:function(t,e,i){let s=t.toGroup();return e.every((t=>l(t)))&&(null==s?void 0:s.every((t=>l(t))))?2:0},sanankou:function(t,e,i){let s=t.toGroup(),n=0;return null==s||s.forEach((t=>{l(t)&&3===t.getTiles().length&&n++})),3===n?2:0},suuankou:function(t,e,i){let s=t.toGroup(),n=0;return null==s||s.forEach((t=>{l(t)&&3===t.getTiles().length&&n++})),4===n?13:0},sanshokuDoukou:function(t,e,i){let s=t.toGroup(),n=[];if(n=void 0!==s?e.concat(s):e,n=n.filter((t=>l(t)&&3===t.getTiles().length)),n.sort(((t,e)=>t.compare(e))),n.length<3)return 0;if(3===n.length){let t=n[0].getTiles(),i=n[1].getTiles(),s=n[2].getTiles();return t[0].getValue()===i[0].getValue()&&t[0].getValue()===s[0].getValue()&&t[0].getFamily()!==i[0].getFamily()&&t[0].getFamily()!==s[0].getFamily()&&i[0].getFamily()!==s[0].getFamily()?e.length>0?1:2:0}for(let t=0;t<4;t++){let i=[];for(let e=0;e<4;e++)e!==t&&i.push(e);let s=n[i[0]].getTiles(),u=n[i[1]].getTiles(),o=n[i[2]].getTiles();if(s[0].getValue()===u[0].getValue()&&s[0].getValue()===o[0].getValue()&&s[0].getFamily()!==u[0].getFamily()&&s[0].getFamily()!==o[0].getFamily()&&u[0].getFamily()!==o[0].getFamily())return e.length>0?1:2}return 0},sankantsu:function(t,e,i){return 0},suukantsu:function(t,e,i){return 0},honitsu:function(t,e,i){let s=t.toGroup(),n=[];if(n=void 0!==s?e.concat(s):e,n.sort(((t,e)=>t.compare(e))),0===n.length)return 0;if(n[n.length-1].getTiles()[0].getFamily()<4)return 0;let u=n[0].getTiles()[0].getFamily();return u>3?0:n.every((t=>{let e=t.getTiles()[0].getFamily();return e>3||u===e}))?e.length>0?2:3:0},chinitsu:function(t,e,i){let s=t.getTiles(),n=s[0];return s.every((t=>t.getFamily()===n.getFamily()))&&e.every((t=>t.getTiles().every((t=>t.getFamily()===n.getFamily()))))?e.length>0?5:6:0},ryuuisou:function(t,e,i){return r.chinitsu(t,e,i),0},chuurenPoutou:function(t,e,i){return e.length>0||r.chinitsu(t,e,i),0}};var a=i(959);let m=0,h=0,g=new a.U("m1m2m3 m4m5m6 m7m8m9 m1m2m3 m5m5"),p=new a.U("m1m1m1 m4m4m4 m7m7m7 p1p1p1 p5p5"),c=new a.U("m1m1m1 p9p9p9 s1s1s1 w2w2w2 d1d1"),d=new a.U("m2m3m4 p3p3p3 p4p5p6 s4s4 s6s7s8"),w=new a.U("m1m2m3 m1m2m3 p7p8p9 p7p8p9 w3w3"),f=new a.U("m1m2m3 m1m2m3 p6p7p8 p7p8p9 w3w3"),v=new a.U("m1m2m3 p1p2p3 s1s2s3 m7m8m9 p9p9"),y=new a.U("m1m2m3 m1m2m3 p6p6 w0w0w0 w3w3w3"),F=new a.U("m1m2m3 m1m2m3 d1d1d1 d2d2d2 d3d3"),T=new a.U("m1m2m3 p6p6 d1d1d1 d2d2d2 d3d3d3"),k=new a.U("m1m2m3 w1w1w1 w2w2w2 w3w3w3 w4w4"),V=new a.U("m1m1 w1w1w1 w2w2w2 w3w3w3 w4w4w4"),S=new a.U("d1d1 w1w1w1 w2w2w2 w3w3w3 w4w4w4"),G=new a.U("m1m1 m9m9m9 p1p1p1 p9p9p9 s1s1s1"),C=new a.U("m1m9m9 p1p9 s1s9 w1w2w3w4 d1d2d3"),I=new a.U("m1m1 m2m2 m3m3 m4m4 m5m5 m6m6 m7m7"),U=new a.U("m1m1 m2m2 m3m3 m4m4 m5m5 m6m6 m6m6"),D=new a.U("m1m2m3 m4m4m4 m7m7m7 p1p1p1 p5p5"),E=new a.U("m1m1m1 p1p1p1 s1s1s1 s1s2s3 p5p5"),P=new a.U("m1m1m1 p1p1p1 s1s1 s1s2s3 p5p5p5");m+=(0,s.v)(1===r.lipekou(w,[],0),"m123 m123 p789 p789 w33 is Lipeikou"),m+=(0,s.v)(0===r.lipekou(c,[],0),"m111 p999 s111 w222 d11 is not Lipeikou"),h+=2,m+=(0,s.v)(3===r.ryanpeikou(w,[],0),"m123 m123 p789 p789 w33 is Ryanpeikou"),m+=(0,s.v)(0===r.ryanpeikou(f,[],0),"m1123 m123 p678 p789 w33 is not Ryanpeikou"),h+=2,m+=(0,s.v)(1===r.pinfu(g,[],0),"m123 m456 m789 m123 p55 is Pinfu"),m+=(0,s.v)(0===r.pinfu(p,[],0),"m111 m444 m777 p111 p55 is not Pinfu"),h+=2,m+=(0,s.v)(2===r.sanshokuDoujun(v,[],0),"m123 p123 s123 m789 p99 is Shanshokou Doujun"),m+=(0,s.v)(0===r.sanshokuDoujun(p,[],0),"m111 m444 m777 p111 p55 is not Shanshokou Doujun"),h+=2,m+=(0,s.v)(2===r.ittsuu(g,[],0),"m123 m456 m789 m123 m55 is Ittsuu"),m+=(0,s.v)(0===r.ittsuu(p,[],0),"m111 m444 m777 p111 p55 is not Ittsu"),h+=2,m+=(0,s.v)(1===r.tanyao(d,[],0),"m234 p333 p456 s44 s678 is Tanyao"),m+=(0,s.v)(0===r.tanyao(g,[],0),"m123 m456 m789 m123 p55 is not Tanyao"),h+=2,m+=(0,s.v)(1===r.yakuhai(c,[],2),"m111 p999 s111 w222 d11 West is Yakuhai"),m+=(0,s.v)(2===r.yakuhai(y,[],3),"m123 m123 p66 w000 w333 North is double Yakuhai"),m+=(0,s.v)(0===r.yakuhai(c,[],0),"m111 p999 s111 w222 d11 Est is not Yakuhai"),h+=3,m+=(0,s.v)(2===r.shousangen(F,[],0),"m123 m123 d111 d222 d33 is Shousangen"),m+=(0,s.v)(0===r.shousangen(T,[],0),"m123 p66 d111 d222 d333 is not Shousangen"),m+=(0,s.v)(0===r.shousangen(c,[],0),"m111 p999 s111 w222 d11 is not Shousangen"),h+=3,m+=(0,s.v)(13===r.daisangen(T,[],0),"m123 p66 d111 d222 d333 is Daisangen"),m+=(0,s.v)(0===r.daisangen(F,[],0),"m123 m123 d111 d222 d33 is not Daisangen"),m+=(0,s.v)(0===r.daisangen(c,[],0),"m111 p999 s111 w222 d11 is not Daisangen"),h+=3,m+=(0,s.v)(13===r.shousuushii(k,[],0),"m123 w111 w222 w333 w44 is Shousuushi"),m+=(0,s.v)(0===r.shousuushii(V,[],0),"m11 w111 w222 w333 w444 is not Shousuushi"),m+=(0,s.v)(0===r.shousuushii(c,[],0),"m111 p999 s111 w222 d11 is not Shousuushi"),h+=3,m+=(0,s.v)(13===r.daisuushi(V,[],0),"m11 w111 w222 w333 w444 is Daisuushi"),m+=(0,s.v)(0===r.daisuushi(k,[],0),"m123 w111 w222 w333 w44 is not Daisuushi"),m+=(0,s.v)(0===r.daisuushi(c,[],0),"m111 p999 s111 w222 d11 is not Daisuushi"),h+=3,m+=(0,s.v)(2===r.chanta(S,[],0),"d11 w111 w222 w333 w444 is Chanta"),m+=(0,s.v)(2===r.chanta(V,[],0),"m11 w111 w222 w333 w444 is Chanta"),m+=(0,s.v)(0===r.chanta(T,[],0),"m123 p66 d111 d222 d333 is not Chanta"),h+=3,m+=(0,s.v)(3===r.junchan(v,[],0),"m123 p123 s123 m789 p99 is Junchan"),m+=(0,s.v)(0===r.junchan(T,[],0),"m123 p66 d111 d222 d333 is not Junchan"),h+=2,m+=(0,s.v)(2===r.honroutou(G,[],0),"m11 m999 p111 p999 s111 is Honroutou"),m+=(0,s.v)(2===r.honroutou(c,[],0),"m111 p999 s111 w222 d11 is Honroutou"),m+=(0,s.v)(0===r.honroutou(T,[],0),"m123 p66 d111 d222 d333 is not Honroutou"),h+=3,m+=(0,s.v)(13===r.chinroutou(G,[],0),"m11 m999 p111 p999 s111 is Chinroutou"),m+=(0,s.v)(0===r.chinroutou(c,[],0),"m111 p999 s111 w222 d11 is not Chinroutou"),m+=(0,s.v)(0===r.chinroutou(T,[],0),"m123 p66 d111 d222 d333 is not Chinroutou"),h+=3,m+=(0,s.v)(13===r.tsuuiisou(S,[],0),"d11 w111 w222 w333 w444 is Tsuuisou"),m+=(0,s.v)(0===r.tsuuiisou(c,[],0),"m111 p999 s111 w222 d11 is not Tsuuisou"),h+=2,m+=(0,s.v)(13===r.kokushiMusou(C,[],0),"m199 p19 s19 w1234 d123 is Kokushi Musou"),m+=(0,s.v)(0===r.kokushiMusou(c,[],0),"m111 p999 s111 w222 d11 is not Kokushi Musou"),h+=2,m+=(0,s.v)(2===r.chiitoitsu(I,[],0),"m11 m22 m33 m44 m55 m66 m77 is Chiitoitsu"),m+=(0,s.v)(0===r.chiitoitsu(U,[],0),"m11 m22 m33 m44 m55 m66 m66 is not Chiitoitsu"),m+=(0,s.v)(0===r.chiitoitsu(c,[],0),"m111 p999 s111 w222 d11 is not Chiitoitsu"),h+=3,m+=(0,s.v)(2===r.toitoi(p,[],0),"m111 m444 m777 p111 p55 is Toitoi"),m+=(0,s.v)(0===r.toitoi(v,[],0),"m123 p123 s123 m789 p99 is not Toitoi"),h+=2,m+=(0,s.v)(2===r.sanankou(D,[],0),"m123 m444 m777 p111 p55 is Sanankou"),m+=(0,s.v)(0===r.sanankou(p,[],0),"m111 m444 m777 p111 p55 is not Sanankou"),m+=(0,s.v)(0===r.sanankou(v,[],0),"m123 p123 s123 m789 p99 is not Sanankou"),h+=3,m+=(0,s.v)(13===r.suuankou(p,[],0),"m111 m444 m777 p111 p55 is Sanankou"),m+=(0,s.v)(0===r.suuankou(D,[],0),"m123 m444 m777 p111 p55 is not Sanankou"),m+=(0,s.v)(0===r.suuankou(v,[],0),"m123 p123 s123 m789 p99 is not Sanankou"),h+=3,m+=(0,s.v)(2===r.sanshokuDoukou(E,[],0),"m111 p111 s111 s123 p55 is Shanshoku Doukou"),m+=(0,s.v)(0===r.sanshokuDoukou(P,[],0),"m11 p111 s111 s123 p555 is not Shanshoku Doukou"),m+=(0,s.v)(0===r.sanshokuDoukou(v,[],0),"m123 p123 s123 m789 p99 is not Shanshoku Doukou"),h+=3,m+=(0,s.v)(!1,"Sankantsu not implemented"),h+=1,m+=(0,s.v)(!1,"suukantsu not implemented"),h+=1,m+=(0,s.v)(3===r.honitsu(F,[],0),"m123 m123 d111 d222 d33 is Honitsu"),m+=(0,s.v)(0===r.honitsu(S,[],0),"d11 w111 w222 w333 w444 is not Honitsu"),m+=(0,s.v)(0===r.honitsu(g,[],0),"m123 m456 m789 m123 m55 is not Honitsu"),m+=(0,s.v)(0===r.honitsu(v,[],0),"m123 p123 s123 m789 p99 is not Honitsu"),h+=4,m+=(0,s.v)(6===r.chinitsu(g,[],0),"m123 m456 m789 m123 m55 is Chinitsu"),m+=(0,s.v)(0===r.chinitsu(F,[],0),"m123 m123 d111 d222 d33 is not Chinitsu"),m+=(0,s.v)(0===r.chinitsu(S,[],0),"d11 w111 w222 w333 w444 is not Chinitsu"),m+=(0,s.v)(0===r.chinitsu(v,[],0),"m123 p123 s123 m789 p99 is not Chinitsu"),h+=4,m+=(0,s.v)(!1,"Ryuuisou not implemented"),h+=1,m+=(0,s.v)(!1,"Chuuren Poutou not implemented"),h+=1,console.log("Succès: "+m.toString()+"/"+h.toString())})(); \ No newline at end of file +(()=>{"use strict";var t={274:(t,e,i)=>{i.d(e,{F:()=>s});class s{constructor(t,e,i){this.family=t,this.value=e,this.red=i,this.imgFront=new Image,this.imgBack=new Image,this.imgGray=new Image,this.img=new Image,this.imgSrc="",this.tilt=0,this.setImgSrc()}getFamily(){return this.family}getValue(){return this.value}isEqual(t,e){return this.family===t&&this.value===e}isRed(){return this.red}compare(t){return this.family!==t.family?this.family{t.onload=null,t.onerror=null}))}preloadImg(){return t=this,e=void 0,s=function*(){const t=[{img:this.imgFront,src:"img/Regular/Front.svg"},{img:this.imgBack,src:"img/Regular/Back.svg"},{img:this.imgGray,src:"img/Regular/Gray.svg"},{img:this.img,src:this.imgSrc}];yield Promise.all(t.map((({img:t,src:e})=>this.loadImg(t,e))))},new((i=void 0)||(i=Promise))((function(n,u){function o(t){try{r(s.next(t))}catch(t){u(t)}}function l(t){try{r(s.throw(t))}catch(t){u(t)}}function r(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,l)}r((s=s.apply(t,e||[])).next())}));var t,e,i,s}loadImg(t,e){return new Promise(((i,s)=>{t.onload=()=>i(),t.onerror=()=>s(),t.src=e}))}setImgSrc(){if(this.imgSrc="img/Regular/",this.family<=3){const t=["","Man","Pin","Sou"];this.imgSrc+=t[this.family]+String(this.value),this.red&&(this.imgSrc+="-Dora")}else if(4===this.family){const t=["","Ton","Nan","Shaa","Pei"];this.imgSrc+=t[this.value]}else if(5===this.family){const t=["","Chun","Hatsu","Haku"];this.imgSrc+=t[this.value]}this.imgSrc+=".svg"}}},305:(t,e,i)=>{function s(t,e){return t?(console.log("%c[SUCCES] "+e,"color: green"),1):(console.log("%c[ECHEC] "+e,"color: red"),0)}i.d(e,{v:()=>s})},879:(t,e,i)=>{i.d(e,{Y:()=>s});class s{constructor(t,e,i){this.tiles=t,this.stolenFrom=e,this.belongsTo=i}push(t){this.tiles.push(t)}pop(){return this.tiles.pop()}getTiles(){return this.tiles}compare(t){const e=this.tiles[0].compare(t.tiles[0]);return 0!==e?e:this.tiles[1].compare(t.tiles[1])}drawGroup(t,e,i,s,n,u,o){t.save(),t.translate(525,525),t.rotate(u),t.translate(-525,-525);const l=75*n,r=90*n,m=25*n/2,a=(this.belongsTo-this.stolenFrom-1+4)%4,h=void 0===o?-1:o.getFamily(),g=void 0===o?0:o.getValue(),p=(e,i,s,u)=>{e.drawTile(t,i,s,n,!1,u,e.isEqual(h,g))},c=Math.PI/2;switch(a){case 0:p(this.tiles[0],e,i+m,c),p(this.tiles[1],e+r,i,0),p(this.tiles[2],e+r+l+s*n,i,0);break;case 1:p(this.tiles[0],e,i,0),p(this.tiles[1],e+r,i+m,-c),p(this.tiles[2],e+r+l+3*s*n,i,0);break;case 2:p(this.tiles[0],e,i,0),p(this.tiles[1],e+l+s*n,i,0),p(this.tiles[2],e+r+l+s*n,i+m,-c);break;default:console.error(`Position non prise en charge: ${a}`)}t.restore()}}},959:(t,e,i)=>{i.d(e,{U:()=>d});var s=i(274),n=i(879);const u="m",o=1,l="p",r=2,m="s",a=3,h="w",g=4,p="d",c=5;class d{constructor(t=""){this.isolate=!1,this.tiles=[],this.initializeFromString(t)}initializeFromString(t){for(let e=0;ei.getFamily()===t&&i.getValue()===e))}eject(t){if(t<0||t>=this.tiles.length)throw new Error("Invalid tile index");[this.tiles[0],this.tiles[t]]=[this.tiles[t],this.tiles[0]];const e=this.tiles.shift();return this.sort(),e}get(t){if(!(void 0===t||t<0||t>=this.tiles.length))return this.tiles[t]}sort(){this.tiles.sort(((t,e)=>t.isLessThan(e)?-1:1))}count(t,e){return this.tiles.filter((i=>i.getFamily()===t&&i.getValue()===e)).length}toGroup(t=!1){if(0===this.tiles.length)return[];const e=this.tiles.pop(),i=e.getFamily(),s=e.getValue();if(this.count(i,s)>=1&&!t){const t=this.tryFormPair(e);if(t)return t}if(this.count(i,s)>=2){const i=this.tryFormTriplet(e,t);if(i)return i}const n=this.count(i,s-1)>0,u=this.count(i,s-2)>0;if(n&&u){const i=this.tryFormSequence(e,t);if(i)return i}this.tiles.push(e),this.sort()}tryFormPair(t){const e=this.find(t.getFamily(),t.getValue()),i=this.toGroup(!0);if(this.tiles.push(e),this.sort(),void 0!==i)return this.tiles.push(t),this.sort(),i.push(new n.Y([t,e],0,0)),i}tryFormTriplet(t,e){const i=this.find(t.getFamily(),t.getValue()),s=this.find(t.getFamily(),t.getValue()),u=this.toGroup(e);if(this.tiles.push(i),this.tiles.push(s),this.sort(),void 0!==u)return u.push(new n.Y([t,i,s],0,0)),this.tiles.push(t),this.sort(),u}tryFormSequence(t,e){const i=this.find(t.getFamily(),t.getValue()-1),s=this.find(t.getFamily(),t.getValue()-2),u=this.toGroup(e);if(this.tiles.push(i),this.tiles.push(s),this.sort(),void 0!==u)return u.push(new n.Y([s,i,t],0,0)),this.tiles.push(t),this.sort(),u}drawHand(t,e,i,s,n,u=void 0,o=!1,l=0){const r=(75+s)*n,m=Math.cos(l)*r,a=Math.sin(l)*r;for(let s=0;st.preloadImg())))},new((i=void 0)||(i=Promise))((function(n,u){function o(t){try{r(s.next(t))}catch(t){u(t)}}function l(t){try{r(s.throw(t))}catch(t){u(t)}}function r(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,l)}r((s=s.apply(t,e||[])).next())}));var t,e,i,s}cleanup(){this.tiles.forEach((t=>t.cleanup())),this.tiles=[]}}}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var u=e[s]={exports:{}};return t[s](u,u.exports,i),u.exports}i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var s=i(305);function n(t){return t.getTiles().every((t=>t.getFamily()<4&&t.getValue()>1&&t.getValue()<9))}function u(t){return t.getTiles().every((t=>t.getFamily()>=4))}function o(t){let e=t.getTiles();return e[0].getValue()!==e[1].getValue()}function l(t){let e=t.getTiles();return e[0].getValue()===e[1].getValue()}const r={lipekou:function(t,e,i){if(e.length>0&&!r.ryanpeikou(t,e,i))return 0;let s=t.toGroup();s.sort(((t,e)=>t.compare(e)));for(let t=0;t<3;t++){let e=s[t].getTiles(),i=s[t+1].getTiles();if(e[0].isEqual(i[0].getFamily(),i[0].getValue())&&o(s[t])&&o(s[t+1]))return 1}return 0},ryanpeikou:function(t,e,i){if(e.length>0)return 0;let s=t.toGroup();if(s.filter((t=>o(t))),s.length<4)return 0;s.sort(((t,e)=>t.compare(e)));let n=s[0].getTiles()[0],u=s[1].getTiles()[0],l=s[2].getTiles()[0],r=s[3].getTiles()[0];return 0===n.compare(u)&&0===l.compare(r)?3:0},pinfu:function(t,e,i){if(e.length>0)return 0;let s=t.toGroup();return void 0!==s&&s.every((t=>{let e=t.getTiles();return o(t)||2===e.length}))?1:0},sanshokuDoujun:function(t,e,i){let s=t.toGroup(),n=[];if(n=void 0!==s?e.concat(s):e,n=n.filter((t=>o(t))),n.sort(((t,e)=>t.compare(e))),n.length<3)return 0;if(3===n.length){let t=n[0].getTiles(),i=n[1].getTiles(),s=n[2].getTiles();return t[0].getValue()===i[0].getValue()&&t[0].getValue()===s[0].getValue()&&t[0].getFamily()!==i[0].getFamily()&&t[0].getFamily()!==s[0].getFamily()&&i[0].getFamily()!==s[0].getFamily()?e.length>0?1:2:0}for(let t=0;t<4;t++){let i=[];for(let e=0;e<4;e++)e!==t&&i.push(e);let s=n[i[0]].getTiles(),u=n[i[1]].getTiles(),o=n[i[2]].getTiles();if(s[0].getValue()===u[0].getValue()&&s[0].getValue()===o[0].getValue()&&s[0].getFamily()!==u[0].getFamily()&&s[0].getFamily()!==o[0].getFamily()&&u[0].getFamily()!==o[0].getFamily())return e.length>0?1:2}return 0},ittsuu:function(t,e,i){let s=e.concat(t.toGroup());if(s=s.filter((t=>o(t))),s.sort(((t,e)=>t.compare(e))),s.length<3)return 0;if(3!==s.length){for(let t=0;t<4;t++){let i=[];for(let e=0;e<4;e++)e!==t&&i.push(e);let n=s[i[0]].getTiles(),u=s[i[1]].getTiles(),o=s[i[2]].getTiles();if(1===n[0].getValue()&&4===u[0].getValue()&&7===o[0].getValue()&&n[0].getFamily()===u[0].getFamily()&&n[0].getFamily()===o[0].getFamily())return e.length>0?1:2}return 0}{let t=s[0].getTiles(),i=s[1].getTiles(),n=s[2].getTiles();if(t[0].getFamily()===i[0].getFamily()&&i[0].getFamily()===n[0].getFamily()&&1===t[0].getValue()&&4===i[0].getValue()&&7===n[0].getValue())return e.length>0?1:2}return 0},tanyao:function(t,e,i){let s=t.toGroup();return void 0===s?0:e.every((t=>n(t)))&&s.every((t=>n(t)))?1:0},yakuhai:function(t,e,i){let s=e.concat(t.toGroup());s=s.filter((t=>l(t)&&3===t.getTiles().length));let n=0;return s.forEach((t=>{let e=t.getTiles(),s=e[0].getFamily(),u=e[0].getValue();5===s&&n++,4===s&&0===u&&n++,4===s&&u===i&&n++})),n},shousangen:function(t,e,i){let s=e.concat(t.toGroup());s=s.filter((t=>l(t)));let n=0,u=0;return s.forEach((t=>{let e=t.getTiles();5===e[0].getFamily()&&(3===e.length?n++:u++)})),2==n&&1==u?2:0},daisangen:function(t,e,i){let s=e.concat(t.toGroup());return s=s.filter((t=>l(t)&&3===t.getTiles().length&&5===t.getTiles()[0].getFamily())),3===s.length?13:0},shousuushii:function(t,e,i){let s=e.concat(t.toGroup());s=s.filter((t=>l(t)));let n=0,u=0;return s.forEach((t=>{let e=t.getTiles();4===e[0].getFamily()&&(3===e.length?n++:u++)})),3==n&&1==u?13:0},daisuushi:function(t,e,i){let s=e.concat(t.toGroup());s=s.filter((t=>l(t)));let n=0,u=0;return s.forEach((t=>{let e=t.getTiles();4===e[0].getFamily()&&(3===e.length?n++:u++)})),4==n&&0==u?13:0},chanta:function(t,e,i){let s=e.concat(t.toGroup());return s=s.filter((t=>{let e=t.getTiles(),i=e[0].getFamily(),s=e[0].getValue(),n=e[e.length-1].getValue();return i<4&&1!==s&&9!==n})),s.length>0?0:e.length>0?1:2},junchan:function(t,e,i){let s=e.concat(t.toGroup());return s=s.filter((t=>{let e=t.getTiles(),i=e[0].getFamily(),s=e[0].getValue(),n=e[e.length-1].getValue();return i>3||1!==s&&9!==n})),s.length>0?0:e.length>0?2:3},honroutou:function(t,e,i){let s=e.concat(t.toGroup());return s=s.filter((t=>{let e=t.getTiles(),i=e[0].getFamily(),s=e[1].getValue();return i<4&&1!==s&&9!==s})),s.length>0?0:2},chinroutou:function(t,e,i){return e.concat(t.toGroup()).every((t=>function(t){return t.getTiles().every((t=>t.getFamily()<4&&(1===t.getValue()||9===t.getValue())))}(t)))?13:0},tsuuiisou:function(t,e,i){let s=t.toGroup();return void 0===s?0:e.every((t=>u(t)))&&s.every((t=>u(t)))?13:0},kokushiMusou:function(t,e,i){if(e.length>0)return 0;let s=t.getTiles();if(s.some((t=>t.getFamily()<4&&t.getValue()>1&&t.getValue()<9)))return 0;let n=0;for(let t=0;t1));t++);return 1===n?13:0},chiitoitsu:function(t,e,i){if(e.length>0)return 0;let s=t.getTiles();if(14!==s.length)return 0;for(let t=0;t<14;t+=2)if(0!==s[t].compare(s[t+1])||t>0&&0===s[t].compare(s[t-1]))return 0;return 2},toitoi:function(t,e,i){let s=t.toGroup();return e.every((t=>l(t)))&&(null==s?void 0:s.every((t=>l(t))))?2:0},sanankou:function(t,e,i){let s=t.toGroup(),n=0;return null==s||s.forEach((t=>{l(t)&&3===t.getTiles().length&&n++})),3===n?2:0},suuankou:function(t,e,i){let s=t.toGroup(),n=0;return null==s||s.forEach((t=>{l(t)&&3===t.getTiles().length&&n++})),4===n?13:0},sanshokuDoukou:function(t,e,i){let s=t.toGroup(),n=[];if(n=void 0!==s?e.concat(s):e,n=n.filter((t=>l(t)&&3===t.getTiles().length)),n.sort(((t,e)=>t.compare(e))),n.length<3)return 0;if(3===n.length){let t=n[0].getTiles(),i=n[1].getTiles(),s=n[2].getTiles();return t[0].getValue()===i[0].getValue()&&t[0].getValue()===s[0].getValue()&&t[0].getFamily()!==i[0].getFamily()&&t[0].getFamily()!==s[0].getFamily()&&i[0].getFamily()!==s[0].getFamily()?e.length>0?1:2:0}for(let t=0;t<4;t++){let i=[];for(let e=0;e<4;e++)e!==t&&i.push(e);let s=n[i[0]].getTiles(),u=n[i[1]].getTiles(),o=n[i[2]].getTiles();if(s[0].getValue()===u[0].getValue()&&s[0].getValue()===o[0].getValue()&&s[0].getFamily()!==u[0].getFamily()&&s[0].getFamily()!==o[0].getFamily()&&u[0].getFamily()!==o[0].getFamily())return e.length>0?1:2}return 0},sankantsu:function(t,e,i){return 0},suukantsu:function(t,e,i){return 0},honitsu:function(t,e,i){let s=t.toGroup(),n=[];if(n=void 0!==s?e.concat(s):e,n.sort(((t,e)=>t.compare(e))),0===n.length)return 0;if(n[n.length-1].getTiles()[0].getFamily()<4)return 0;let u=n[0].getTiles()[0].getFamily();return u>3?0:n.every((t=>{let e=t.getTiles()[0].getFamily();return e>3||u===e}))?e.length>0?2:3:0},chinitsu:function(t,e,i){let s=t.getTiles(),n=s[0];return s.every((t=>t.getFamily()===n.getFamily()))&&e.every((t=>t.getTiles().every((t=>t.getFamily()===n.getFamily()))))?e.length>0?5:6:0},ryuuisou:function(t,e,i){if(e.length>0)return 0;let s=t.toGroup();return(null==s?void 0:s.every((t=>t.getTiles().every((t=>function(t){let e=t.getFamily(),i=t.getValue();return(5===e||3===e)&&(5===e?2===i:i%2==0||3===i)}(t))))))?13:0},chuurenPoutou:function(t,e,i){if(e.length>0||0===r.chinitsu(t,e,i))return 0;let s=t.getTiles();if(s[0].getFamily()>=4)return 0;let n=[s[0].getValue()],u=1;for(let t=1;t4)return 0}else u=1,n.push(e);else if(e===i){if(u++,u<2)n.push(e);else if(u>2)return 0}else u=1,n.push(e)}return n.toString()===[1,1,1,2,3,4,5,6,7,8,9,9,9].toString()?13:0}};var m=i(959);let a=0,h=0,g=new m.U("m1m2m3 m4m5m6 m7m8m9 m1m2m3 m5m5"),p=new m.U("m1m1m1 m4m4m4 m7m7m7 p1p1p1 p5p5"),c=new m.U("m1m1m1 p9p9p9 s1s1s1 w2w2w2 d1d1"),d=new m.U("m2m3m4 p3p3p3 p4p5p6 s4s4 s6s7s8"),f=new m.U("m1m2m3 m1m2m3 p7p8p9 p7p8p9 w3w3"),w=new m.U("m1m2m3 m1m2m3 p6p7p8 p7p8p9 w3w3"),v=new m.U("m1m2m3 p1p2p3 s1s2s3 m7m8m9 p9p9"),y=new m.U("m1m2m3 m1m2m3 p6p6 w0w0w0 w3w3w3"),F=new m.U("m1m2m3 m1m2m3 d1d1d1 d2d2d2 d3d3"),T=new m.U("m1m2m3 p6p6 d1d1d1 d2d2d2 d3d3d3"),k=new m.U("m1m2m3 w1w1w1 w2w2w2 w3w3w3 w4w4"),V=new m.U("m1m1 w1w1w1 w2w2w2 w3w3w3 w4w4w4"),S=new m.U("d1d1 w1w1w1 w2w2w2 w3w3w3 w4w4w4"),G=new m.U("m1m1 m9m9m9 p1p1p1 p9p9p9 s1s1s1"),C=new m.U("m1m9m9 p1p9 s1s9 w1w2w3w4 d1d2d3"),U=new m.U("m1m1 m2m2 m3m3 m4m4 m5m5 m6m6 m7m7"),P=new m.U("m1m1 m2m2 m3m3 m4m4 m5m5 m6m6 m6m6"),I=new m.U("m1m2m3 m4m4m4 m7m7m7 p1p1p1 p5p5"),D=new m.U("m1m1m1 p1p1p1 s1s1s1 s1s2s3 p5p5"),E=new m.U("m1m1m1 p1p1p1 s1s1 s1s2s3 p5p5p5"),M=new m.U("m1m1m1 m2m3m4 m5m6m7 m8m8 m9m9m9"),x=new m.U("s2s2s2 s8s8s8 s4s4s4 s6s6 d2d2d2"),b=new m.U("m1m1m1 m2m3m4 m5m6m7 m8m8m8 m9m9m9"),j=new m.U("m1m1m1 m2m3m4 m6m6 m5m6m7 m9m9m9");a+=(0,s.v)(1===r.lipekou(f,[],0),"m123 m123 p789 p789 w33 is Lipeikou"),a+=(0,s.v)(0===r.lipekou(c,[],0),"m111 p999 s111 w222 d11 is not Lipeikou"),h+=2,a+=(0,s.v)(3===r.ryanpeikou(f,[],0),"m123 m123 p789 p789 w33 is Ryanpeikou"),a+=(0,s.v)(0===r.ryanpeikou(w,[],0),"m1123 m123 p678 p789 w33 is not Ryanpeikou"),h+=2,a+=(0,s.v)(1===r.pinfu(g,[],0),"m123 m456 m789 m123 p55 is Pinfu"),a+=(0,s.v)(0===r.pinfu(p,[],0),"m111 m444 m777 p111 p55 is not Pinfu"),h+=2,a+=(0,s.v)(2===r.sanshokuDoujun(v,[],0),"m123 p123 s123 m789 p99 is Shanshokou Doujun"),a+=(0,s.v)(0===r.sanshokuDoujun(p,[],0),"m111 m444 m777 p111 p55 is not Shanshokou Doujun"),h+=2,a+=(0,s.v)(2===r.ittsuu(g,[],0),"m123 m456 m789 m123 m55 is Ittsuu"),a+=(0,s.v)(0===r.ittsuu(p,[],0),"m111 m444 m777 p111 p55 is not Ittsu"),h+=2,a+=(0,s.v)(1===r.tanyao(d,[],0),"m234 p333 p456 s44 s678 is Tanyao"),a+=(0,s.v)(0===r.tanyao(g,[],0),"m123 m456 m789 m123 p55 is not Tanyao"),h+=2,a+=(0,s.v)(1===r.yakuhai(c,[],2),"m111 p999 s111 w222 d11 West is Yakuhai"),a+=(0,s.v)(2===r.yakuhai(y,[],3),"m123 m123 p66 w000 w333 North is double Yakuhai"),a+=(0,s.v)(0===r.yakuhai(c,[],0),"m111 p999 s111 w222 d11 Est is not Yakuhai"),h+=3,a+=(0,s.v)(2===r.shousangen(F,[],0),"m123 m123 d111 d222 d33 is Shousangen"),a+=(0,s.v)(0===r.shousangen(T,[],0),"m123 p66 d111 d222 d333 is not Shousangen"),a+=(0,s.v)(0===r.shousangen(c,[],0),"m111 p999 s111 w222 d11 is not Shousangen"),h+=3,a+=(0,s.v)(13===r.daisangen(T,[],0),"m123 p66 d111 d222 d333 is Daisangen"),a+=(0,s.v)(0===r.daisangen(F,[],0),"m123 m123 d111 d222 d33 is not Daisangen"),a+=(0,s.v)(0===r.daisangen(c,[],0),"m111 p999 s111 w222 d11 is not Daisangen"),h+=3,a+=(0,s.v)(13===r.shousuushii(k,[],0),"m123 w111 w222 w333 w44 is Shousuushi"),a+=(0,s.v)(0===r.shousuushii(V,[],0),"m11 w111 w222 w333 w444 is not Shousuushi"),a+=(0,s.v)(0===r.shousuushii(c,[],0),"m111 p999 s111 w222 d11 is not Shousuushi"),h+=3,a+=(0,s.v)(13===r.daisuushi(V,[],0),"m11 w111 w222 w333 w444 is Daisuushi"),a+=(0,s.v)(0===r.daisuushi(k,[],0),"m123 w111 w222 w333 w44 is not Daisuushi"),a+=(0,s.v)(0===r.daisuushi(c,[],0),"m111 p999 s111 w222 d11 is not Daisuushi"),h+=3,a+=(0,s.v)(2===r.chanta(S,[],0),"d11 w111 w222 w333 w444 is Chanta"),a+=(0,s.v)(2===r.chanta(V,[],0),"m11 w111 w222 w333 w444 is Chanta"),a+=(0,s.v)(0===r.chanta(T,[],0),"m123 p66 d111 d222 d333 is not Chanta"),h+=3,a+=(0,s.v)(3===r.junchan(v,[],0),"m123 p123 s123 m789 p99 is Junchan"),a+=(0,s.v)(0===r.junchan(T,[],0),"m123 p66 d111 d222 d333 is not Junchan"),h+=2,a+=(0,s.v)(2===r.honroutou(G,[],0),"m11 m999 p111 p999 s111 is Honroutou"),a+=(0,s.v)(2===r.honroutou(c,[],0),"m111 p999 s111 w222 d11 is Honroutou"),a+=(0,s.v)(0===r.honroutou(T,[],0),"m123 p66 d111 d222 d333 is not Honroutou"),h+=3,a+=(0,s.v)(13===r.chinroutou(G,[],0),"m11 m999 p111 p999 s111 is Chinroutou"),a+=(0,s.v)(0===r.chinroutou(c,[],0),"m111 p999 s111 w222 d11 is not Chinroutou"),a+=(0,s.v)(0===r.chinroutou(T,[],0),"m123 p66 d111 d222 d333 is not Chinroutou"),h+=3,a+=(0,s.v)(13===r.tsuuiisou(S,[],0),"d11 w111 w222 w333 w444 is Tsuuisou"),a+=(0,s.v)(0===r.tsuuiisou(c,[],0),"m111 p999 s111 w222 d11 is not Tsuuisou"),h+=2,a+=(0,s.v)(13===r.kokushiMusou(C,[],0),"m199 p19 s19 w1234 d123 is Kokushi Musou"),a+=(0,s.v)(0===r.kokushiMusou(c,[],0),"m111 p999 s111 w222 d11 is not Kokushi Musou"),h+=2,a+=(0,s.v)(2===r.chiitoitsu(U,[],0),"m11 m22 m33 m44 m55 m66 m77 is Chiitoitsu"),a+=(0,s.v)(0===r.chiitoitsu(P,[],0),"m11 m22 m33 m44 m55 m66 m66 is not Chiitoitsu"),a+=(0,s.v)(0===r.chiitoitsu(c,[],0),"m111 p999 s111 w222 d11 is not Chiitoitsu"),h+=3,a+=(0,s.v)(2===r.toitoi(p,[],0),"m111 m444 m777 p111 p55 is Toitoi"),a+=(0,s.v)(0===r.toitoi(v,[],0),"m123 p123 s123 m789 p99 is not Toitoi"),h+=2,a+=(0,s.v)(2===r.sanankou(I,[],0),"m123 m444 m777 p111 p55 is Sanankou"),a+=(0,s.v)(0===r.sanankou(p,[],0),"m111 m444 m777 p111 p55 is not Sanankou"),a+=(0,s.v)(0===r.sanankou(v,[],0),"m123 p123 s123 m789 p99 is not Sanankou"),h+=3,a+=(0,s.v)(13===r.suuankou(p,[],0),"m111 m444 m777 p111 p55 is Sanankou"),a+=(0,s.v)(0===r.suuankou(I,[],0),"m123 m444 m777 p111 p55 is not Sanankou"),a+=(0,s.v)(0===r.suuankou(v,[],0),"m123 p123 s123 m789 p99 is not Sanankou"),h+=3,a+=(0,s.v)(2===r.sanshokuDoukou(D,[],0),"m111 p111 s111 s123 p55 is Shanshoku Doukou"),a+=(0,s.v)(0===r.sanshokuDoukou(E,[],0),"m11 p111 s111 s123 p555 is not Shanshoku Doukou"),a+=(0,s.v)(0===r.sanshokuDoukou(v,[],0),"m123 p123 s123 m789 p99 is not Shanshoku Doukou"),h+=3,a+=(0,s.v)(!1,"sankantsu not implemented"),h+=1,a+=(0,s.v)(!1,"suukantsu not implemented"),h+=1,a+=(0,s.v)(3===r.honitsu(F,[],0),"m123 m123 d111 d222 d33 is Honitsu"),a+=(0,s.v)(0===r.honitsu(S,[],0),"d11 w111 w222 w333 w444 is not Honitsu"),a+=(0,s.v)(0===r.honitsu(g,[],0),"m123 m456 m789 m123 m55 is not Honitsu"),a+=(0,s.v)(0===r.honitsu(v,[],0),"m123 p123 s123 m789 p99 is not Honitsu"),h+=4,a+=(0,s.v)(6===r.chinitsu(g,[],0),"m123 m456 m789 m123 m55 is Chinitsu"),a+=(0,s.v)(0===r.chinitsu(F,[],0),"m123 m123 d111 d222 d33 is not Chinitsu"),a+=(0,s.v)(0===r.chinitsu(S,[],0),"d11 w111 w222 w333 w444 is not Chinitsu"),a+=(0,s.v)(0===r.chinitsu(v,[],0),"m123 p123 s123 m789 p99 is not Chinitsu"),h+=4,a+=(0,s.v)(13===r.ryuuisou(x,[],0),"s222 s888 s444 s66 d222 is Ryuuisou"),a+=(0,s.v)(0===r.ryuuisou(g,[],0),"m123 m456 m789 m123 m55 is not Ryuuisou"),h+=2,a+=(0,s.v)(13===r.chuurenPoutou(M,[],0),"m111 m234 m567 m88 m999 is Chuuren Poutou"),a+=(0,s.v)(0===r.chuurenPoutou(b,[],0),"m111 m234 m567 m888 m999 is not Chuuren Poutou"),a+=(0,s.v)(0===r.chuurenPoutou(j,[],0),"m111 m234 m66 m567 m999 is not Chuuren Poutou"),a+=(0,s.v)(0===r.chuurenPoutou(g,[],0),"m123 m456 m789 m123 m55 is not Chuuren Poutou"),h+=4,console.log("Succès: "+a.toString()+"/"+h.toString())})(); \ No newline at end of file diff --git a/src/yakus/yaku.ts b/src/yakus/yaku.ts index ee37e2c..8c51204 100644 --- a/src/yakus/yaku.ts +++ b/src/yakus/yaku.ts @@ -1,5 +1,6 @@ import { Hand } from "../hand"; import { Group } from "../group"; +import { Tile } from "../tile" function ord(g: Group): boolean { return g.getTiles().every( @@ -35,6 +36,20 @@ function pon(g: Group): boolean { return t[0].getValue() === t[1].getValue(); } +function green(t: Tile): boolean { + let f = t.getFamily(); + let v = t.getValue(); + if (f !== 5 && f !== 3) { + return false; + } + + if (f === 5) { + return v === 2; + } + + return v % 2 === 0 || v === 3; +} + @@ -795,14 +810,22 @@ chinitsu: function( * main verte * 13/13 */ -ryuuisou: function( //TODO +ryuuisou: function( hand: Hand, groups: Array, wind: number ): number { - if (yakus.chinitsu(hand, groups, wind) === 0) { + if (groups.length > 0) { return 0; } + let h = hand.toGroup(); + if (h?.every( + g => g.getTiles().every( + t => green(t) + ) + )) { + return 13; + } return 0; }, @@ -810,7 +833,7 @@ ryuuisou: function( //TODO * neuf portes * 0/13 */ -chuurenPoutou: function( //TODO +chuurenPoutou: function( hand: Hand, groups: Array, wind: number @@ -818,6 +841,48 @@ chuurenPoutou: function( //TODO if (groups.length > 0 || yakus.chinitsu(hand, groups, wind) === 0) { return 0; } + let tiles = hand.getTiles(); + if (tiles[0].getFamily() >= 4) { + return 0; + } + + let pureHand = [tiles[0].getValue()]; + let count = 1; + for (let i = 1; i < tiles.length; i++) { + let v = tiles[i].getValue(); + let lastv = pureHand[pureHand.length - 1]; + + if (v === 1 || v === 9) { + if (v === lastv) { + count++; + if (count < 4) { + pureHand.push(v); + } else if (count > 4) { + return 0; + } + } else { + count = 1; + pureHand.push(v); + } + + } else { + if (v === lastv) { + count ++; + if (count < 2) { + pureHand.push(v); + } else if (count > 2) { + return 0; + } + } else { + count = 1; + pureHand.push(v); + } + } + } + + if (pureHand.toString() === [1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9].toString()) { + return 13; + } return 0; } diff --git a/tests/test_yakus.ts b/tests/test_yakus.ts index bdfd896..23ae5f4 100644 --- a/tests/test_yakus.ts +++ b/tests/test_yakus.ts @@ -1,6 +1,8 @@ import { assert } from "./assert" import { yakus } from "../src/yakus/yaku" import { Hand } from "../src/hand" +import { Group } from "../src/group"; +import { Tile } from "../src/tile"; let count = 0; let total = 0; @@ -25,6 +27,10 @@ let h17 = new Hand("m1m1 m2m2 m3m3 m4m4 m5m5 m6m6 m6m6"); let h18 = new Hand("m1m2m3 m4m4m4 m7m7m7 p1p1p1 p5p5"); let h19 = new Hand("m1m1m1 p1p1p1 s1s1s1 s1s2s3 p5p5"); let h20 = new Hand("m1m1m1 p1p1p1 s1s1 s1s2s3 p5p5p5"); +let h21 = new Hand("m1m1m1 m2m3m4 m5m6m7 m8m8 m9m9m9"); +let h22 = new Hand("s2s2s2 s8s8s8 s4s4s4 s6s6 d2d2d2"); +let h23 = new Hand("m1m1m1 m2m3m4 m5m6m7 m8m8m8 m9m9m9"); +let h24 = new Hand("m1m1m1 m2m3m4 m6m6 m5m6m7 m9m9m9"); // lipeikou count += assert(yakus.lipekou(h5, [], 0) === 1, "m123 m123 p789 p789 w33 is Lipeikou"); @@ -149,7 +155,18 @@ count += assert(yakus.sanshokuDoukou(h7, [], 0) === 0, "m123 p123 s123 m789 p99 total += 3; // sankantsu -count += assert(false, "Sankantsu not implemented") +// count += assert( +// yakus.sankantsu( +// new Hand(), +// [ +// new Group([new Tile(1, 1, false), new Tile(1, 1, false), new Tile(1, 1, false), new Tile(1, 1, false)], 0, 0), +// new Group([new Tile(1, 3, false), new Tile(1, 3, false), new Tile(1, 3, false), new Tile(1, 3, false)], 0, 0), +// new Group([new Tile(1, 5, false), new Tile(1, 5, false), new Tile(1, 5, false), new Tile(1, 5, false)], 0, 0), +// ], +// 0 +// ) === 2, +// " is Sankantsu"); +count += assert(false, "sankantsu not implemented"); total += 1; // suukantsu @@ -171,12 +188,16 @@ count += assert(yakus.chinitsu(h7, [], 0) === 0, "m123 p123 s123 m789 p99 is not total += 4; // ryuuisou -count += assert(false, "Ryuuisou not implemented") -total += 1; +count += assert(yakus.ryuuisou(h22, [], 0) === 13, "s222 s888 s444 s66 d222 is Ryuuisou"); +count += assert(yakus.ryuuisou(h1, [], 0) === 0, "m123 m456 m789 m123 m55 is not Ryuuisou"); +total += 2; // chuuren poutou -count += assert(false, "Chuuren Poutou not implemented") -total += 1; +count += assert(yakus.chuurenPoutou(h21, [], 0) === 13, "m111 m234 m567 m88 m999 is Chuuren Poutou"); +count += assert(yakus.chuurenPoutou(h23, [], 0) === 0, "m111 m234 m567 m888 m999 is not Chuuren Poutou"); +count += assert(yakus.chuurenPoutou(h24, [], 0) === 0, "m111 m234 m66 m567 m999 is not Chuuren Poutou"); +count += assert(yakus.chuurenPoutou(h1, [], 0) === 0, "m123 m456 m789 m123 m55 is not Chuuren Poutou"); +total += 4; // total console.log("Succès: " + count.toString() + "/" + total.toString());