UNPKG

miijs

Version:

The most complete and easy to use Mii library available.

3 lines (2 loc) 4 kB
import{a as k,c as f,i as v}from"./chunk-AD7HDZ5R.js";import"./chunk-C7XDOTG6.js";import{g as D}from"./chunk-VMLSR5BU.js";D();function w(a,s){return a?.perms?.[s]??!0}async function O(a,s=-1){a.fields&&(a=await a.toJSON()),a=await v(a);var l=Math.min(Math.max(a.eyes.yPosition+2,0),18);let r=a.eyebrows.yPosition+2;r>15?r=15:r<0&&(r=0);var t=Math.min(Math.max(a.mouth.yPosition-2,0),18),h=a.eyes.yPosition-l,d=a.eyebrows.yPosition-r,m=a.mouth.yPosition-t;a.stages=[];for(var e=0;e<6;e++)a.stages.push(structuredClone(a)),a.stages[e].eyes.yPosition=Math.floor(h*e/5)+l,a.stages[e].eyebrows.yPosition=Math.floor(d*e/5)+r,a.stages[e].mouth.yPosition=Math.floor(m*e/5)+t,a.stages[e].nose.size=Math.floor(a.nose.size*e/5),e<4&&(a.stages[e].face.type=9,a.stages[e].eyebrows.color=7),(e<5||s!=-1)&&(a.stages[e].beard.type=0,a.stages[e].beard.mustache.type=0,a.stages[e].face.feature=0,a.stages[e].face.makeup=0,a.stages[e].glasses.type=0,a.stages[e].hair.flipped=!1),a.stages[e].general.height=Math.floor(a.stages[e].general.height/5*e),delete a.stages[e].stages;var y=-1;if(s<0||s>9){var g=[],p=[],u=!1;for(let o=3;o>=1&&!u;o--)for(let n=a.general.gender===0?0:4;n<=(a.general.gender===0?3:9);n++)f.hairStyleGroups[n][o].includes(a.hair.type)&&(g.push(n),p.push(o),u=!0);if(g.length>0){let o=Math.floor(Math.random()*g.length);s=g[o],y=p[o]}else s=f.hairStyleGroupMappings[a.hair.type][a.general.gender],y=-2}let M=0;for(let o=0;o<4&&!(o==3&&y!=-1);o++){let n=f.hairStyleGroups[s][M],c=n[Math.floor(Math.random()*n.length)];switch(o){case 0:a.stages[0].hair.type=c;break;case 1:a.stages[1].hair.type=c,a.stages[2].hair.type=c;break;case 2:a.stages[3].hair.type=c,a.stages[4].hair.type=c;break;case 3:a.stages[5].hair.type=c;break}(o===0||Math.floor(Math.random()*(a.stages[0].general.gender===0?3:4))!==0)&&(M=Math.min(M+1,y<0?3:y))}return a.stages}async function z(a,s,l){let r,t;if(a.fields?r=await a.toJSON():r=a,s.fields?t=await s.toJSON():t=s,r=await v(r),t=await v(t),r.general.gender!==0){let C=structuredClone(r);r=structuredClone(t),t=structuredClone(C)}for(var h=[],d=0;d<8;d++)h.push(Math.floor(Math.random()*2));var m=h[0]===1?t:r,e=structuredClone(m);e.meta.type=r.meta?.type==="Special"||t.meta?.type==="Special"?"Special":"Default",e.perms||(e.perms={}),e.perms.sharing=w(r,"sharing")&&w(t,"sharing"),e.perms.copying=w(r,"copying")&&w(t,"copying");var y=new Date;e.general.birthday=y.getDate(),e.general.birthMonth=y.getMonth()+1,e.meta.creatorName=l?.hasOwnProperty("creatorName")?l.creatorName:"";var g=l?.hasOwnProperty("gender")?l.gender:Math.floor(Math.random()*2);e.general.gender=g,e.meta.name=l?.hasOwnProperty("name")?l.name:f.names[e.general.gender][Math.floor(Math.random()*f.names[e.general.gender].length)];var p=r.general.gender===g?r:t;let u=k.switch.faceColors[r.face.color],M=k.switch.faceColors[t.face.color];var o=f.skinColorMixing[Math.min(u,M)][Math.max(u,M)].filter(C=>C!==-1);e.face.color=o[Math.floor(Math.random()*o.length)];var n=f.hairStyleGroupMappings[p.hair.type][g];e.hair.color=h[2]===0?r.hair.color:t.hair.color,e.eyebrows.color=e.hair.color,e.face.type=p.face.type,e.eyes.type=h[3]===0?r.eyes.type:t.eyes.type,e.eyes.color=h[4]===0?r.eyes.color:t.eyes.color,e.eyebrows.type=p.eyebrows.type,e.nose.type=h[5]===0?r.nose.type:t.nose.type,e.mouth.type=h[6]===0?r.mouth.type:t.mouth.type,e.mouth.color=h[7]===0?r.mouth.color:t.mouth.color,e.mole.on=Math.floor(Math.random()*2)===0?r.mole.on:t.mole.on;var c=Math.floor(Math.random()*2)===0?r:t,b=(c.general.height>>3)*1.4;b*=1.4*1.4,b*=1.4*1.4,e.general.height=Math.round(Math.min(Math.max(b,0),127));var N=Math.floor(Math.random()*2)===0?r:t;let P=Math.trunc((N.general.weight+1)/4)+48;for(var i=0;i<5;i++)P+=(P-64)*.2;return e.general.weight=Math.round(Math.min(Math.max(P,0),127)),e.general.favoriteColor=l?.favoriteColor?l.favoriteColor:(e.general.gender==0?[2,3,5,6]:[0,1,7,8])[Math.floor(Math.random()*4)],await O(e,n)}export{O as kidomatic,z as makeMiiChild}; //# sourceMappingURL=miiBabies-EVBBWW7R.js.map