Riichi/build/test.js
2025-04-15 20:37:24 +02:00

1 line
No EOL
22 KiB
JavaScript

(()=>{"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.family?-1:1:this.value!==t.value?this.value<t.value?-1:1:0}isLessThan(t){return this.family<t.family||this.family===t.family&&this.value<=t.value}setTilt(){this.tilt=.04*(1-2*Math.random())}drawTile(t,e,i,s,n=!1,u=0,o=!1,l=!0){const r=75*s,m=100*s,a=r/2,h=m/2;t.save(),t.translate(e+a,i+h),t.rotate(u+(l?this.tilt:0));const g=-.92*r/2,p=-.92*m/2;if(t.drawImage(this.imgGray,g,p,r,m),n)t.drawImage(this.imgBack,-a,-h,r,m);else{t.drawImage(this.imgFront,-a,-h,r,m);const e=.9,i=r*e,n=m*e,u=-68*s/2,l=-90*s/2;t.drawImage(this.img,u,l,i,n),o&&t.drawImage(this.imgGray,-a,-h,r,m)}t.restore()}cleanup(){[this.imgFront,this.imgBack,this.imgGray,this.img].forEach((t=>{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})},679:(t,e,i)=>{var s,n,u,o,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,f=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===(u=g.toGroup())||void 0===u?void 0:u.length),"m222 p11 has 2 groups"),(0,m.v)(5===(null===(o=p.toGroup())||void 0===o?void 0:o.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"),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 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;t<s.length-1&&(s[t].isEqual(s[t+1].getFamily(),s[t+1].getValue())&&n++,!(n>1));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;t<s.length;t++){let e=s[t].getValue(),i=n[n.length-1];if(1===e||9===e)if(e===i){if(u++,u<4)n.push(e);else if(u>4)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"),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"),P=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"),x=new m.U("m1m1m1 m2m3m4 m5m6m7 m8m8 m9m9m9"),M=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(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(P,[],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(P,[],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(M,[],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(x,[],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())},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:()=>f});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.tiles=t.map((t=>new s.F(t.getFamily(),t.getValue(),t.isRed()))),this.sort()}sort(){this.tiles.sort(((t,e)=>t.isLessThan(e)?-1:1))}find(t,e){const i=this.findTileIndex(t,e);if(-1!==i){[this.tiles[i],this.tiles[0]]=[this.tiles[0],this.tiles[i]];const t=this.tiles.shift();return this.sort(),t}}findTileIndex(t,e){return this.tiles.findIndex((i=>i.getFamily()===t&&i.getValue()===e))}count(t,e){return this.tiles.filter((i=>i.getFamily()===t&&i.getValue()===e)).length}findGroups(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}if(i<=3){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.findGroups(!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.findGroups(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.findGroups(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}}class f{constructor(t=""){this.isolate=!1,this.tiles=[],this.initializeFromString(t)}initializeFromString(t){for(let e=0;e<t.length-1;e++){const i=t.substring(e,e+2),s=i[0],n=Number(i[1]);this.isValidTileCode(s,n)&&this.addTileFromCode(s,n)}}isValidTileCode(t,e){return t===u||t===l||t===m||t===h||t===p}addTileFromCode(t,e){const i={[u]:o,[l]:r,[m]:a,[h]:g,[p]:c}[t];void 0!==i&&this.tiles.push(new s.F(i,e,!1))}getTiles(){return this.tiles}length(){return this.tiles.length}push(t){this.tiles.push(t)}pop(){return this.tiles.pop()}find(t,e){const i=this.findTileIndex(t,e);if(-1!==i){[this.tiles[i],this.tiles[0]]=[this.tiles[0],this.tiles[i]];const t=this.tiles.shift();return this.sort(),t}}findTileIndex(t,e){return this.tiles.findIndex((i=>i.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){return new d(this.tiles).findGroups(t)}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;s<this.tiles.length;s++){const r=s===this.tiles.length-1&&this.isolate?10:0;let h=e+s*m+r*n*Math.cos(l),g=i+s*a+r*n*Math.sin(l);s===u&&(h+=25*n*Math.sin(l),g-=25*n*Math.cos(l)),this.tiles[s].drawTile(t,h,g,n,o,l)}}preload(){return t=this,e=void 0,s=function*(){yield Promise.all(this.tiles.map((t=>t.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),i(679),i(762)})();