From eb93dec6ba70aad67df41569d0617faac63ea6e5 Mon Sep 17 00:00:00 2001 From: Didictateur Date: Sat, 12 Apr 2025 18:44:02 +0200 Subject: [PATCH] display all tests for all yakus and fixe chinroutou --- build/test.js | 2 +- build/test_yakus.js | 2 +- src/yakus/yaku.ts | 147 ++++++++++++++++++++++++++++++++------------ tests/test_yakus.ts | 41 +++++++++++- 4 files changed, 149 insertions(+), 43 deletions(-) diff --git a/build/test.js b/build/test.js index 5c814e5..3d14729 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{l(s.next(t))}catch(t){o(t)}}function r(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(u,r)}l((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,r,l=i(959),a=i(305);let m=new l.U("s1s1"),h=new l.U("m1m2m3"),g=new l.U("m2m2m2 p1p1"),p=new l.U("m1m2m3 p1p2p3 s1s2s3 m9m9m9 p9p9"),c=new l.U("m2m2m2 p1p1p1"),d=0,w=0;d+=(0,a.v)(1===(null===(s=m.toGroup())||void 0===s?void 0:s.length),"s11 has 1 group"),d+=(0,a.v)(1===(null===(n=h.toGroup())||void 0===n?void 0:n.length),"m123 has 1 group"),d+=(0,a.v)(2===(null===(o=g.toGroup())||void 0===o?void 0:o.length),"m222 p11 has 2 groups"),(0,a.v)(5===(null===(u=p.toGroup())||void 0===u?void 0:u.length),"m123 p123 s123 m999 p99 has 5 groups"),d+=(0,a.v)(2===(null===(r=c.toGroup())||void 0===r?void 0:r.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&&(1===t.getValue()||t.getValue())}))}function u(t){return t.getTiles().every((t=>t.getFamily()>=4))}function r(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 a={lipekou:function(t,e,i){if(e.length>0&&!a.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())&&r(s[t])&&r(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=>r(t))),s.length<4)return 0;s.sort(((t,e)=>t.compare(e)));let n=s[0].getTiles()[0],o=s[1].getTiles()[0],u=s[2].getTiles()[0],l=s[3].getTiles()[0];return 0===n.compare(o)&&0===u.compare(l)?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 r(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=>r(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=>r(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){let s=t.toGroup();return void 0===s?0:e.every((t=>o(t)))&&s.every((t=>o(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){return 0},sankantsu:function(t,e,i){return 0},suukantsu:function(t,e,i){return 0},honitsu:function(t,e,i){return 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 a.chinitsu(t,e,i),0},chuurenPoutou:function(t,e,i){return e.length>0||a.chinitsu(t,e,i),0}};var m=i(959);let h=0,g=0,p=new m.U("m1m2m3 m4m5m6 m7m8m9 m1m2m3 m5m5"),c=new m.U("m1m1m1 m4m4m4 m7m7m7 p1p1p1 p5p5"),d=new m.U("m1m1m1 p9p9p9 s1s1s1 w2w2w2 d1d1"),w=new m.U("m2m3m4 p3p3p3 p4p5p6 s4s4 s6s7s8"),f=new m.U("m1m2m3 m1m2m3 p7p8p9 p7p8p9 w3w3"),v=new m.U("m1m2m3 m1m2m3 p6p7p8 p7p8p9 w3w3"),y=new m.U("m1m2m3 p1p2p3 s1s2s3 m7m8m9 p9p9"),F=new m.U("m1m2m3 m1m2m3 p6p6 w0w0w0 w3w3w3"),T=new m.U("m1m2m3 m1m2m3 d1d1d1 d2d2d2 d3d3"),k=new m.U("m1m2m3 p6p6 d1d1d1 d2d2d2 d3d3d3"),V=new m.U("m1m2m3 w1w1w1 w2w2w2 w3w3w3 w4w4"),S=new m.U("m1m1 w1w1w1 w2w2w2 w3w3w3 w4w4w4"),G=new m.U("d1d1 w1w1w1 w2w2w2 w3w3w3 w4w4w4"),U=new m.U("m1m1 m9m9m9 p1p1p1 p9p9p9 s1s1s1"),I=new m.U("m1m9m9 p1p9 s1s9 w1w2w3w4 d1d2d3"),C=new m.U("m1m1 m2m2 m3m3 m4m4 m5m5 m6m6 m7m7"),E=new m.U("m1m1 m2m2 m3m3 m4m4 m5m5 m6m6 m6m6"),P=new m.U("m1m2m3 m4m4m4 m7m7m7 p1p1p1 p5p5");new m.U("m1m2m3 m7m7m7 p1p1p1 p5p5"),h+=(0,s.v)(1===a.lipekou(f,[],0),"m123 m123 p789 p789 w33 is Lipeikou"),h+=(0,s.v)(0===a.lipekou(d,[],0),"m111 p999 s111 w222 d11 is not Lipeikou"),g+=2,h+=(0,s.v)(3===a.ryanpeikou(f,[],0),"m123 m123 p789 p789 w33 is Ryanpeikou"),h+=(0,s.v)(0===a.ryanpeikou(v,[],0),"m1123 m123 p678 p789 w33 is not Ryanpeikou"),g+=2,h+=(0,s.v)(1===a.pinfu(p,[],0),"m123 m456 m789 m123 p55 is Pinfu"),h+=(0,s.v)(0===a.pinfu(c,[],0),"m111 m444 m777 p111 p55 is not Pinfu"),g+=2,h+=(0,s.v)(2===a.sanshokuDoujun(y,[],0),"m123 p123 s123 m789 p99 is Shanshokou Doujun"),h+=(0,s.v)(0===a.sanshokuDoujun(c,[],0),"m111 m444 m777 p111 p55 is not Shanshokou Doujun"),g+=2,h+=(0,s.v)(2===a.ittsuu(p,[],0),"m123 m456 m789 m123 m55 is Ittsuu"),h+=(0,s.v)(0===a.ittsuu(c,[],0),"m111 m444 m777 p111 p55 is not Ittsu"),g+=2,h+=(0,s.v)(1===a.tanyao(w,[],0),"m234 p333 p456 s44 s678 is Tanyao"),h+=(0,s.v)(0===a.tanyao(p,[],0),"m123 m456 m789 m123 p55 is not Tanyao"),g+=2,h+=(0,s.v)(1===a.yakuhai(d,[],2),"m111 p999 s111 w222 d11 West is Yakuhai"),h+=(0,s.v)(2===a.yakuhai(F,[],3),"m123 m123 p66 w000 w333 North is double Yakuhai"),h+=(0,s.v)(0===a.yakuhai(d,[],0),"m111 p999 s111 w222 d11 Est is not Yakuhai"),g+=3,h+=(0,s.v)(2===a.shousangen(T,[],0),"m123 m123 d111 d222 d33 is Shousangen"),h+=(0,s.v)(0===a.shousangen(k,[],0),"m123 p66 d111 d222 d333 is not Shousangen"),h+=(0,s.v)(0===a.shousangen(d,[],0),"m111 p999 s111 w222 d11 is not Shousangen"),g+=3,h+=(0,s.v)(13===a.daisangen(k,[],0),"m123 p66 d111 d222 d333 is Daisangen"),h+=(0,s.v)(0===a.daisangen(T,[],0),"m123 m123 d111 d222 d33 is not Daisangen"),h+=(0,s.v)(0===a.daisangen(d,[],0),"m111 p999 s111 w222 d11 is not Daisangen"),g+=3,h+=(0,s.v)(13===a.shousuushii(V,[],0),"m123 w111 w222 w333 w44 is Shousuushi"),h+=(0,s.v)(0===a.shousuushii(S,[],0),"m11 w111 w222 w333 w444 is not Shousuushi"),h+=(0,s.v)(0===a.shousuushii(d,[],0),"m111 p999 s111 w222 d11 is not Shousuushi"),g+=3,h+=(0,s.v)(13===a.daisuushi(S,[],0),"m11 w111 w222 w333 w444 is Daisuushi"),h+=(0,s.v)(0===a.daisuushi(V,[],0),"m123 w111 w222 w333 w44 is not Daisuushi"),h+=(0,s.v)(0===a.daisuushi(d,[],0),"m111 p999 s111 w222 d11 is not Daisuushi"),g+=3,h+=(0,s.v)(2===a.chanta(G,[],0),"d11 w111 w222 w333 w444 is Chanta"),h+=(0,s.v)(2===a.chanta(S,[],0),"m11 w111 w222 w333 w444 is Chanta"),h+=(0,s.v)(0===a.chanta(k,[],0),"m123 p66 d111 d222 d333 is not Chanta"),g+=3,h+=(0,s.v)(3===a.junchan(y,[],0),"m123 p123 s123 m789 p99 is Junchan"),h+=(0,s.v)(0===a.junchan(k,[],0),"m123 p66 d111 d222 d333 is not Junchan"),g+=2,h+=(0,s.v)(2===a.honroutou(U,[],0),"m11 m999 p111 p999 s111 is Honroutou"),h+=(0,s.v)(2===a.honroutou(d,[],0),"m111 p999 s111 w222 d11 is Honroutou"),h+=(0,s.v)(0===a.honroutou(k,[],0),"m123 p66 d111 d222 d333 is not Honroutou"),g+=3,h+=(0,s.v)(13===a.chinroutou(U,[],0),"m11 m999 p111 p999 s111 is Chinroutou"),h+=(0,s.v)(0===a.chinroutou(d,[],0),"m111 p999 s111 w222 d11 is not Chinroutou"),h+=(0,s.v)(0===a.chinroutou(k,[],0),"m123 p66 d111 d222 d333 is not Chinroutou"),g+=3,h+=(0,s.v)(13===a.tsuuiisou(G,[],0),"d11 w111 w222 w333 w444 is Tsuuisou"),h+=(0,s.v)(0===a.tsuuiisou(d,[],0),"m111 p999 s111 w222 d11 is not Tsuuisou"),g+=2,h+=(0,s.v)(13===a.kokushiMusou(I,[],0),"m1m9m9 p1p9 s1s9 w1w2w3w4 d1d2d3 is Kokushi Musou"),h+=(0,s.v)(0===a.kokushiMusou(d,[],0),"m111 p999 s111 w222 d11 is not Kokushi Musou"),g+=2,h+=(0,s.v)(2===a.chiitoitsu(C,[],0),"m11 m22 m33 m44 m55 m66 m77 is Chiitoitsu"),h+=(0,s.v)(0===a.chiitoitsu(E,[],0),"m11 m22 m33 m44 m55 m66 m66 is not Chiitoitsu"),h+=(0,s.v)(0===a.chiitoitsu(d,[],0),"m111 p999 s111 w222 d11 is not Chiitoitsu"),g+=3,h+=(0,s.v)(2===a.toitoi(c,[],0),"m111 m444 m777 p111 p55 is Toitoi"),h+=(0,s.v)(0===a.toitoi(y,[],0),"m123 p123 s123 m789 p99 is not Toitoi"),g+=2,h+=(0,s.v)(2===a.sanankou(P,[],0),"m123 m444 m777 p111 p55 is Sanankou"),h+=(0,s.v)(0===a.sanankou(c,[],0),"m111 m444 m777 p111 p55 is not Sanankou"),h+=(0,s.v)(0===a.sanankou(y,[],0),"m123 p123 s123 m789 p99 is not Sanankou"),g+=3,h+=(0,s.v)(13===a.suuankou(c,[],0),"m111 m444 m777 p111 p55 is Sanankou"),h+=(0,s.v)(0===a.suuankou(P,[],0),"m123 m444 m777 p111 p55 is not Sanankou"),h+=(0,s.v)(0===a.suuankou(y,[],0),"m123 p123 s123 m789 p99 is not Sanankou"),g+=3,console.log("Succès: "+h.toString()+"/"+g.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 r=75*n,l=90*n,a=25*n/2,m=(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(m){case 0:p(this.tiles[0],e,i+a,c),p(this.tiles[1],e+l,i,0),p(this.tiles[2],e+l+r+s*n,i,0);break;case 1:p(this.tiles[0],e,i,0),p(this.tiles[1],e+l,i+a,-c),p(this.tiles[2],e+l+r+3*s*n,i,0);break;case 2:p(this.tiles[0],e,i,0),p(this.tiles[1],e+r+s*n,i,0),p(this.tiles[2],e+l+r+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 o="m",u=1,r="p",l=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,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,r=0){const l=(75+s)*n,a=Math.cos(r)*l,m=Math.sin(r)*l;for(let s=0;st.preloadImg())))},new((i=void 0)||(i=Promise))((function(n,o){function u(t){try{l(s.next(t))}catch(t){o(t)}}function r(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(u,r)}l((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,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 diff --git a/build/test_yakus.js b/build/test_yakus.js index 388afe6..6f9d7ca 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,o){function u(t){try{l(s.next(t))}catch(t){o(t)}}function r(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(u,r)}l((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,o,u){t.save(),t.translate(525,525),t.rotate(o),t.translate(-525,-525);const r=75*n,l=90*n,a=25*n/2,m=(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(m){case 0:p(this.tiles[0],e,i+a,c),p(this.tiles[1],e+l,i,0),p(this.tiles[2],e+l+r+s*n,i,0);break;case 1:p(this.tiles[0],e,i,0),p(this.tiles[1],e+l,i+a,-c),p(this.tiles[2],e+l+r+3*s*n,i,0);break;case 2:p(this.tiles[0],e,i,0),p(this.tiles[1],e+r+s*n,i,0),p(this.tiles[2],e+l+r+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 o="m",u=1,r="p",l=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,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,r=0){const l=(75+s)*n,a=Math.cos(r)*l,m=Math.sin(r)*l;for(let s=0;st.preloadImg())))},new((i=void 0)||(i=Promise))((function(n,o){function u(t){try{l(s.next(t))}catch(t){o(t)}}function r(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(u,r)}l((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);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&&(1===t.getValue()||t.getValue())}))}function u(t){return t.getTiles().every((t=>t.getFamily()>=4))}function r(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 a={lipekou:function(t,e,i){if(e.length>0&&!a.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())&&r(s[t])&&r(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=>r(t))),s.length<4)return 0;s.sort(((t,e)=>t.compare(e)));let n=s[0].getTiles()[0],o=s[1].getTiles()[0],u=s[2].getTiles()[0],l=s[3].getTiles()[0];return 0===n.compare(o)&&0===u.compare(l)?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 r(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=>r(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=>r(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){let s=t.toGroup();return void 0===s?0:e.every((t=>o(t)))&&s.every((t=>o(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){return 0},sankantsu:function(t,e,i){return 0},suukantsu:function(t,e,i){return 0},honitsu:function(t,e,i){return 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 a.chinitsu(t,e,i),0},chuurenPoutou:function(t,e,i){return e.length>0||a.chinitsu(t,e,i),0}};var m=i(959);let h=0,g=0,p=new m.U("m1m2m3 m4m5m6 m7m8m9 m1m2m3 m5m5"),c=new m.U("m1m1m1 m4m4m4 m7m7m7 p1p1p1 p5p5"),d=new m.U("m1m1m1 p9p9p9 s1s1s1 w2w2w2 d1d1"),w=new m.U("m2m3m4 p3p3p3 p4p5p6 s4s4 s6s7s8"),f=new m.U("m1m2m3 m1m2m3 p7p8p9 p7p8p9 w3w3"),v=new m.U("m1m2m3 m1m2m3 p6p7p8 p7p8p9 w3w3"),y=new m.U("m1m2m3 p1p2p3 s1s2s3 m7m8m9 p9p9"),F=new m.U("m1m2m3 m1m2m3 p6p6 w0w0w0 w3w3w3"),T=new m.U("m1m2m3 m1m2m3 d1d1d1 d2d2d2 d3d3"),k=new m.U("m1m2m3 p6p6 d1d1d1 d2d2d2 d3d3d3"),V=new m.U("m1m2m3 w1w1w1 w2w2w2 w3w3w3 w4w4"),S=new m.U("m1m1 w1w1w1 w2w2w2 w3w3w3 w4w4w4"),G=new m.U("d1d1 w1w1w1 w2w2w2 w3w3w3 w4w4w4"),I=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"),E=new m.U("m1m1 m2m2 m3m3 m4m4 m5m5 m6m6 m6m6"),P=new m.U("m1m2m3 m4m4m4 m7m7m7 p1p1p1 p5p5");new m.U("m1m2m3 m7m7m7 p1p1p1 p5p5"),h+=(0,s.v)(1===a.lipekou(f,[],0),"m123 m123 p789 p789 w33 is Lipeikou"),h+=(0,s.v)(0===a.lipekou(d,[],0),"m111 p999 s111 w222 d11 is not Lipeikou"),g+=2,h+=(0,s.v)(3===a.ryanpeikou(f,[],0),"m123 m123 p789 p789 w33 is Ryanpeikou"),h+=(0,s.v)(0===a.ryanpeikou(v,[],0),"m1123 m123 p678 p789 w33 is not Ryanpeikou"),g+=2,h+=(0,s.v)(1===a.pinfu(p,[],0),"m123 m456 m789 m123 p55 is Pinfu"),h+=(0,s.v)(0===a.pinfu(c,[],0),"m111 m444 m777 p111 p55 is not Pinfu"),g+=2,h+=(0,s.v)(2===a.sanshokuDoujun(y,[],0),"m123 p123 s123 m789 p99 is Shanshokou Doujun"),h+=(0,s.v)(0===a.sanshokuDoujun(c,[],0),"m111 m444 m777 p111 p55 is not Shanshokou Doujun"),g+=2,h+=(0,s.v)(2===a.ittsuu(p,[],0),"m123 m456 m789 m123 m55 is Ittsuu"),h+=(0,s.v)(0===a.ittsuu(c,[],0),"m111 m444 m777 p111 p55 is not Ittsu"),g+=2,h+=(0,s.v)(1===a.tanyao(w,[],0),"m234 p333 p456 s44 s678 is Tanyao"),h+=(0,s.v)(0===a.tanyao(p,[],0),"m123 m456 m789 m123 p55 is not Tanyao"),g+=2,h+=(0,s.v)(1===a.yakuhai(d,[],2),"m111 p999 s111 w222 d11 West is Yakuhai"),h+=(0,s.v)(2===a.yakuhai(F,[],3),"m123 m123 p66 w000 w333 North is double Yakuhai"),h+=(0,s.v)(0===a.yakuhai(d,[],0),"m111 p999 s111 w222 d11 Est is not Yakuhai"),g+=3,h+=(0,s.v)(2===a.shousangen(T,[],0),"m123 m123 d111 d222 d33 is Shousangen"),h+=(0,s.v)(0===a.shousangen(k,[],0),"m123 p66 d111 d222 d333 is not Shousangen"),h+=(0,s.v)(0===a.shousangen(d,[],0),"m111 p999 s111 w222 d11 is not Shousangen"),g+=3,h+=(0,s.v)(13===a.daisangen(k,[],0),"m123 p66 d111 d222 d333 is Daisangen"),h+=(0,s.v)(0===a.daisangen(T,[],0),"m123 m123 d111 d222 d33 is not Daisangen"),h+=(0,s.v)(0===a.daisangen(d,[],0),"m111 p999 s111 w222 d11 is not Daisangen"),g+=3,h+=(0,s.v)(13===a.shousuushii(V,[],0),"m123 w111 w222 w333 w44 is Shousuushi"),h+=(0,s.v)(0===a.shousuushii(S,[],0),"m11 w111 w222 w333 w444 is not Shousuushi"),h+=(0,s.v)(0===a.shousuushii(d,[],0),"m111 p999 s111 w222 d11 is not Shousuushi"),g+=3,h+=(0,s.v)(13===a.daisuushi(S,[],0),"m11 w111 w222 w333 w444 is Daisuushi"),h+=(0,s.v)(0===a.daisuushi(V,[],0),"m123 w111 w222 w333 w44 is not Daisuushi"),h+=(0,s.v)(0===a.daisuushi(d,[],0),"m111 p999 s111 w222 d11 is not Daisuushi"),g+=3,h+=(0,s.v)(2===a.chanta(G,[],0),"d11 w111 w222 w333 w444 is Chanta"),h+=(0,s.v)(2===a.chanta(S,[],0),"m11 w111 w222 w333 w444 is Chanta"),h+=(0,s.v)(0===a.chanta(k,[],0),"m123 p66 d111 d222 d333 is not Chanta"),g+=3,h+=(0,s.v)(3===a.junchan(y,[],0),"m123 p123 s123 m789 p99 is Junchan"),h+=(0,s.v)(0===a.junchan(k,[],0),"m123 p66 d111 d222 d333 is not Junchan"),g+=2,h+=(0,s.v)(2===a.honroutou(I,[],0),"m11 m999 p111 p999 s111 is Honroutou"),h+=(0,s.v)(2===a.honroutou(d,[],0),"m111 p999 s111 w222 d11 is Honroutou"),h+=(0,s.v)(0===a.honroutou(k,[],0),"m123 p66 d111 d222 d333 is not Honroutou"),g+=3,h+=(0,s.v)(13===a.chinroutou(I,[],0),"m11 m999 p111 p999 s111 is Chinroutou"),h+=(0,s.v)(0===a.chinroutou(d,[],0),"m111 p999 s111 w222 d11 is not Chinroutou"),h+=(0,s.v)(0===a.chinroutou(k,[],0),"m123 p66 d111 d222 d333 is not Chinroutou"),g+=3,h+=(0,s.v)(13===a.tsuuiisou(G,[],0),"d11 w111 w222 w333 w444 is Tsuuisou"),h+=(0,s.v)(0===a.tsuuiisou(d,[],0),"m111 p999 s111 w222 d11 is not Tsuuisou"),g+=2,h+=(0,s.v)(13===a.kokushiMusou(U,[],0),"m1m9m9 p1p9 s1s9 w1w2w3w4 d1d2d3 is Kokushi Musou"),h+=(0,s.v)(0===a.kokushiMusou(d,[],0),"m111 p999 s111 w222 d11 is not Kokushi Musou"),g+=2,h+=(0,s.v)(2===a.chiitoitsu(C,[],0),"m11 m22 m33 m44 m55 m66 m77 is Chiitoitsu"),h+=(0,s.v)(0===a.chiitoitsu(E,[],0),"m11 m22 m33 m44 m55 m66 m66 is not Chiitoitsu"),h+=(0,s.v)(0===a.chiitoitsu(d,[],0),"m111 p999 s111 w222 d11 is not Chiitoitsu"),g+=3,h+=(0,s.v)(2===a.toitoi(c,[],0),"m111 m444 m777 p111 p55 is Toitoi"),h+=(0,s.v)(0===a.toitoi(y,[],0),"m123 p123 s123 m789 p99 is not Toitoi"),g+=2,h+=(0,s.v)(2===a.sanankou(P,[],0),"m123 m444 m777 p111 p55 is Sanankou"),h+=(0,s.v)(0===a.sanankou(c,[],0),"m111 m444 m777 p111 p55 is not Sanankou"),h+=(0,s.v)(0===a.sanankou(y,[],0),"m123 p123 s123 m789 p99 is not Sanankou"),g+=3,h+=(0,s.v)(13===a.suuankou(c,[],0),"m111 m444 m777 p111 p55 is Sanankou"),h+=(0,s.v)(0===a.suuankou(P,[],0),"m123 m444 m777 p111 p55 is not Sanankou"),h+=(0,s.v)(0===a.suuankou(y,[],0),"m123 p123 s123 m789 p99 is not Sanankou"),g+=3,console.log("Succès: "+h.toString()+"/"+g.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,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 diff --git a/src/yakus/yaku.ts b/src/yakus/yaku.ts index 6e0a028..ee37e2c 100644 --- a/src/yakus/yaku.ts +++ b/src/yakus/yaku.ts @@ -11,10 +11,10 @@ function ord(g: Group): boolean { function term(g: Group): boolean { return g.getTiles().every( - t => { + t => t.getFamily() < 4 && (t.getValue() === 1 || - t.getValue() === 9)} + t.getValue() === 9) ); } @@ -488,13 +488,9 @@ chinroutou: function( groups: Array, wind: number ): number { - let h = hand.toGroup(); - if (h === undefined) { - return 0; - } + let gr = groups.concat(hand.toGroup() as NonNullable>); if ( - groups.every(g => term(g)) && - h.every(g => term(g)) + gr.every(g => term(g)) ) { return 13; } @@ -654,23 +650,70 @@ suuankou: function( return 0; }, -sanshokuDoukou: function( //TODO - /** - * triple brelan - * 2/2 - */ +/** + * triple brelan + * 2/2 + */ +sanshokuDoukou: function( hand: Hand, groups: Array, wind: number ): number { - return 0; + let h = hand.toGroup(); + let gr = []; + if (h !== undefined) { + gr = groups.concat(h); + } else { + gr = groups; + } + gr = gr.filter(g => pon(g) && g.getTiles().length === 3); + gr.sort((g1, g2) => g1.compare(g2)) + if (gr.length < 3) { // pas assez de chii + return 0; + } else if(gr.length === 3) { + let t0 = gr[0].getTiles(); + let t1 = gr[1].getTiles(); + let t2 = gr[2].getTiles(); + if ( + t0[0].getValue() === t1[0].getValue() && + t0[0].getValue() === t2[0].getValue() && + t0[0].getFamily() !== t1[0].getFamily() && + t0[0].getFamily() !== t2[0].getFamily() && + t1[0].getFamily() !== t2[0].getFamily() + ) { + return groups.length > 0 ? 1 : 2; + } + return 0; + } else {// il y a un intrus + for (let i = 0; i < 4; i++) { + let index = [] + for (let j = 0; j < 4; j++) { + if (j !== i) { + index.push(j); + } + } + let t0 = gr[index[0]].getTiles(); + let t1 = gr[index[1]].getTiles(); + let t2 = gr[index[2]].getTiles(); + if ( + t0[0].getValue() === t1[0].getValue() && + t0[0].getValue() === t2[0].getValue() && + t0[0].getFamily() !== t1[0].getFamily() && + t0[0].getFamily() !== t2[0].getFamily() && + t1[0].getFamily() !== t2[0].getFamily() + ) { + return groups.length > 0 ? 1 : 2; + } + } + return 0; + } }, +/** + * trois carrés + * 2/2 + */ sankantsu: function( //TODO - /** - * trois carrés - * 2/2 - */ hand: Hand, groups: Array, wind: number @@ -678,11 +721,11 @@ sankantsu: function( //TODO return 0; }, +/** + * quatre carrés + * 13/13 + */ suukantsu: function( //TODO - /** - * quatre carrés - * 13/13 - */ hand: Hand, groups: Array, wind: number @@ -690,23 +733,49 @@ suukantsu: function( //TODO return 0; }, -honitsu: function( //TODO - /** - * semie pure - * 2/3 - */ +/** + * semie pure + * 2/3 + */ +honitsu: function( hand: Hand, groups: Array, wind: number ): number { + let h = hand.toGroup(); + let gr = []; + if (h !== undefined) { + gr = groups.concat(h); + } else { + gr = groups; + } + gr.sort((g1, g2) => g1.compare(g2)) + if (gr.length === 0) { + return 0; + } + if (gr[gr.length - 1].getTiles()[0].getFamily() < 4) { // main pure + return 0; + } + let f = gr[0].getTiles()[0].getFamily(); + if (f > 3) { // tout honneur + return 0; + } + if (gr.every( + g => { + let ff = g.getTiles()[0].getFamily(); + return ff > 3 || f === ff + } + )) { + return groups.length > 0 ? 2 : 3; + } return 0; }, +/** + * main pure + * 5/6 + */ chinitsu: function( - /** - * main pure - * 5/6 - */ hand: Hand, groups: Array, wind: number @@ -722,11 +791,11 @@ chinitsu: function( return 0; }, +/** + * main verte + * 13/13 + */ ryuuisou: function( //TODO - /** - * main verte - * 13/13 - */ hand: Hand, groups: Array, wind: number @@ -737,11 +806,11 @@ ryuuisou: function( //TODO return 0; }, +/** + * neuf portes + * 0/13 + */ chuurenPoutou: function( //TODO - /** - * neuf portes - * 0/13 - */ hand: Hand, groups: Array, wind: number diff --git a/tests/test_yakus.ts b/tests/test_yakus.ts index df34fbf..bdfd896 100644 --- a/tests/test_yakus.ts +++ b/tests/test_yakus.ts @@ -23,7 +23,8 @@ let h15 = new Hand("m1m9m9 p1p9 s1s9 w1w2w3w4 d1d2d3"); let h16 = new Hand("m1m1 m2m2 m3m3 m4m4 m5m5 m6m6 m7m7"); let h17 = new Hand("m1m1 m2m2 m3m3 m4m4 m5m5 m6m6 m6m6"); let h18 = new Hand("m1m2m3 m4m4m4 m7m7m7 p1p1p1 p5p5"); -let h19 = new Hand("m1m2m3 m7m7m7 p1p1p1 p5p5"); +let h19 = new Hand("m1m1m1 p1p1p1 s1s1s1 s1s2s3 p5p5"); +let h20 = new Hand("m1m1m1 p1p1p1 s1s1 s1s2s3 p5p5p5"); // lipeikou count += assert(yakus.lipekou(h5, [], 0) === 1, "m123 m123 p789 p789 w33 is Lipeikou"); @@ -114,7 +115,7 @@ count += assert(yakus.tsuuiisou(h3, [], 0) === 0, "m111 p999 s111 w222 d11 is no total += 2; // kokushiMusou -count += assert(yakus.kokushiMusou(h15, [], 0) === 13, "m1m9m9 p1p9 s1s9 w1w2w3w4 d1d2d3 is Kokushi Musou"); +count += assert(yakus.kokushiMusou(h15, [], 0) === 13, "m199 p19 s19 w1234 d123 is Kokushi Musou"); count += assert(yakus.kokushiMusou(h3, [], 0) === 0, "m111 p999 s111 w222 d11 is not Kokushi Musou"); total += 2; @@ -141,5 +142,41 @@ count += assert(yakus.suuankou(h18, [], 0) === 0, "m123 m444 m777 p111 p55 is no count += assert(yakus.suuankou(h7, [], 0) === 0, "m123 p123 s123 m789 p99 is not Sanankou"); total += 3; +// sanshoku doukou +count += assert(yakus.sanshokuDoukou(h19, [], 0) === 2, "m111 p111 s111 s123 p55 is Shanshoku Doukou"); +count += assert(yakus.sanshokuDoukou(h20, [], 0) === 0, "m11 p111 s111 s123 p555 is not Shanshoku Doukou"); +count += assert(yakus.sanshokuDoukou(h7, [], 0) === 0, "m123 p123 s123 m789 p99 is not Shanshoku Doukou"); +total += 3; + +// sankantsu +count += assert(false, "Sankantsu not implemented") +total += 1; + +// suukantsu +count += assert(false, "suukantsu not implemented"); +total += 1; + +// honitsu +count += assert(yakus.honitsu(h9, [], 0) === 3, "m123 m123 d111 d222 d33 is Honitsu"); +count += assert(yakus.honitsu(h13, [], 0) === 0, "d11 w111 w222 w333 w444 is not Honitsu"); +count += assert(yakus.honitsu(h1, [], 0) === 0, "m123 m456 m789 m123 m55 is not Honitsu"); +count += assert(yakus.honitsu(h7, [], 0) === 0, "m123 p123 s123 m789 p99 is not Honitsu"); +total += 4; + +// chinitsu +count += assert(yakus.chinitsu(h1, [], 0) === 6, "m123 m456 m789 m123 m55 is Chinitsu"); +count += assert(yakus.chinitsu(h9, [], 0) === 0, "m123 m123 d111 d222 d33 is not Chinitsu"); +count += assert(yakus.chinitsu(h13, [], 0) === 0, "d11 w111 w222 w333 w444 is not Chinitsu"); +count += assert(yakus.chinitsu(h7, [], 0) === 0, "m123 p123 s123 m789 p99 is not Chinitsu"); +total += 4; + +// ryuuisou +count += assert(false, "Ryuuisou not implemented") +total += 1; + +// chuuren poutou +count += assert(false, "Chuuren Poutou not implemented") +total += 1; + // total console.log("Succès: " + count.toString() + "/" + total.toString());