miijs
Version:
The most complete and easy to use Mii library available.
3 lines (2 loc) • 14.9 kB
JavaScript
import{b as t,i as p,m as k,o as n,q as u,r as w}from"./chunk-AD7HDZ5R.js";import"./chunk-C7XDOTG6.js";import{g as i}from"./chunk-VMLSR5BU.js";i();var H=["gender"],W=e=>e.startsWith("SWITCH")?[0,1,2,3,0,1,2,3,0,1,2,3]:[0,1,2,0,1,2,0,1,2,0,1,2],I=e=>e.startsWith("SWITCH")?[0,0,0,0,1,1,1,1,2,2,2,2]:[0,0,0,1,1,1,2,2,2,3,3,3],G=["first","second","third","fourth"];function l(e,s){for(let o=0;o<e.length;o++)for(let r=0;r<e[o].length;r++)if(e[o][r]===s)return[r,o];return[-1,-1]}function B(e,s,o=t.instrGrids.threeBy){let r=e.indexOf(s);return r===-1?[-1,-1]:l(o,r)}function C(e,s){try{let o=s.split("."),r=e;for(let h of o){if(r==null)return;r=r[h]}return r}catch{return null}}function T(e,s,o){try{let r=s.split("."),h=r.pop(),c=r.reduce((d,a)=>((!d[a]||typeof d[a]!="object"||Array.isArray(d[a]))&&(d[a]={}),d[a]),e);return c[h]=o,e}catch{throw new Error(`${s} was not usable.`)}}function P(e,s){let o=s.split("."),r=e;for(let h=0;h<o.length-1;h++){if(r==null||!r.hasOwnProperty(o[h]))return;r=r[o[h]]}delete r[o[o.length-1]]}function z(e,s){if(Array.isArray(e)&&Array.isArray(s)){if(e.length!==s.length)return!1;for(let o=0;o<e.length;o++)if(e[o]!==s[o])return!1;return!0}return e===s}function D(e,s){return w.hasOwnProperty(e)?w[e]:typeof s=="boolean"?!1:0}var g=e=>!Array.isArray(e)||e.some(s=>!Number.isFinite(Number(s))||Number(s)<0)?"closest available option":e.length===3&&e[0]!==void 0?`on page ${e[0]+1}, ${e[1]+1} from the left, ${e[2]+1} from the top`:e.length===2?`${e[0]+1} from the left, ${e[1]+1} from the top`:e.length===1?`${e[0]+1} from the top`:"",b=e=>{let s=e.length===3&&e[2]===1,o=g(s?[e[0],e[1]]:e);return s?`${o}, in the expanded colors menu`:o},$=(e,s=G)=>{if(!Array.isArray(e)||e.some(o=>typeof o!="string"&&(!Number.isFinite(Number(o))||Number(o)<0)))return"closest available option";if(e.length===2){let o=typeof e[1]=="string"?e[1]:s[e[1]];return o?o==="first"||o==="top"?`${e[0]+1} from the left`:`${e[0]+1} from the left, on the ${o} row`:g(e)}return g(e)},M=e=>e===n.WIIU?["top","middle","bottom"]:["first","second"];function f(e,s,o){for(var r=0;r<e.length;r++){var h=l(e,r);if(h[0]===s&&h[1]===o)return r}return null}function S(e,s,o,r){for(var h=0;h<e.length;h++)if(e[h]===o&&s[h]===r)return h;return null}function y(e,s,o){switch(u.hasOwnProperty(o)&&(o=u[o]),o){case"face.color":switch(s){case n.WII:return e.face.color>2?[e.face.color-3,1]:[e.face.color,0];case n.DS:case n["3DS"]:return[e.face.color];case n.WIIU:return[[0,1,0,1,0,1][e.face.color],[0,0,1,1,2,2][e.face.color]];case n.SWITCH:case n.SWITCH2:var r=t.switch.faceColors[e.face.color];return r>4?[r-5,1]:[r,0]}case"face.type":return[W(s)[e.face.type],I(s)[e.face.type]];case"face.makeup":return[W(s)[e.face.makeup],I(s)[e.face.makeup]];case"face.feature":return[W(s)[e.face.feature],I(s)[e.face.feature]];case"hair.type":switch(s){case n.DS:case n.WII:var h=l(t.pages.hair.wii,e.hair.type),c=l(t.instrGrids.threeBy,h[0]);return[h[1],c[0],c[1]];case n["3DS"]:case n.WIIU:var h=l(t.pages.hair["3ds"],e.hair.type),c=l(t.instrGrids.threeBy,h[0]);return[h[1],c[0],c[1]];case n.SWITCH:case n.SWITCH2:return[l(t.grids.hairs,e.hair.type)[0],l(t.grids.hairs,e.hair.type)[1]]}case"hair.color":if(s.endsWith("DS"))return[e.hair.color];var d=s.startsWith("SWITCH")?t.grids.colors:s==="WII"?t.instrGrids.fourBy:t.instrGrids.twoBy,a=l(d,e.hair.color);return s.startsWith("SWITCH")?[a[0],a[1],1]:[a[0],a[1]];case"eyes.type":if(s.startsWith("SWITCH"))return[l(t.grids.eyes,e.eyes.type)[0],l(t.grids.eyes,e.eyes.type)[1]];var h=l(t.pages.eyes,e.eyes.type),c=l(t.instrGrids.threeBy,h[0]);return[h[1],c[0],c[1]];case"eyes.color":if(s.endsWith("DS"))return[e.eyes.color];var d=s.startsWith("SWITCH")?t.grids.colors:s==="WII"?t.instrGrids.threeBy:t.instrGrids.twoBy,a=l(d,e.eyes.color);return s.startsWith("SWITCH")?[a[0],a[1],1]:[a[0],a[1]];case"eyebrows.type":if(s.startsWith("SWITCH"))return[l(t.grids.eyebrows,e.eyebrows.type)[0],l(t.grids.eyebrows,e.eyebrows.type)[1]];var h=l(t.pages.eyebrows,e.eyebrows.type),c=l(t.instrGrids.threeBy,h[0]);return[h[1],c[0],c[1]];case"eyebrows.color":if(s.endsWith("DS"))return[e.eyebrows.color];var d=s.startsWith("SWITCH")?t.grids.colors:s==="WII"?t.instrGrids.fourBy:t.instrGrids.twoBy,a=l(d,e.eyebrows.color);return s.startsWith("SWITCH")?[a[0],a[1],1]:[a[0],a[1]];case"nose.type":switch(s){case n.DS:case n.WII:return B(t.pages.noses[0],e.nose.type);case n["3DS"]:case n.WIIU:var h=l(t.pages.noses,e.nose.type),c=l(t.instrGrids.threeBy,h[0]);return[h[1],c[0],c[1]];case n.SWITCH:case n.SWITCH2:return[l(t.grids.noses,e.nose.type)[0],l(t.grids.noses,e.nose.type)[1]]}case"mouth.type":if(s.startsWith("SWITCH"))return[l(t.grids.mouths,e.mouth.type)[0],l(t.grids.mouths,e.mouth.type)[1]];var h=l(t.pages.mouths,e.mouth.type),c=l(t.instrGrids.threeBy,h[0]);return[h[1],c[0],c[1]];case"mouth.color":if(s.endsWith(n.DS)||s===n.WII)return s===n.WII?[e.mouth.color]:[e.mouth.color];var d=s.startsWith("SWITCH")?t.grids.colors:t.instrGrids.twoBy,a=l(d,e.mouth.color);return s.startsWith("SWITCH")?[a[0],a[1],1]:[a[0],a[1]];case"beard.mustache.type":var a=l(s.startsWith("SWITCH")?t.instrGrids.threeBy:t.instrGrids.twoBy,e.beard.mustache.type);return[a[0],a[1]];case"beard.type":var a=l(s.startsWith("SWITCH")?t.instrGrids.threeBy:t.instrGrids.twoBy,e.beard.type);return[a[0],a[1]];case"beard.color":if(s.endsWith("DS"))return[e.beard.color];var d=s.startsWith("SWITCH")?t.grids.colors:s==="WII"?t.instrGrids.fourBy:t.instrGrids.twoBy,a=l(d,e.beard.color);return s.startsWith("SWITCH")?[a[0],a[1],1]:[a[0],a[1]];case"glasses.type":var a=l(s.startsWith("SWITCH")?t.grids.glasses:t.instrGrids.threeBy,e.glasses.type);return[a[0],a[1]];case"glasses.color":if(s.endsWith("DS"))return[e.glasses.color];var d=s.startsWith("SWITCH")?t.grids.colors:s==="WII"?t.instrGrids.threeBy:t.instrGrids.twoBy,a=l(d,e.glasses.color);return s.startsWith("SWITCH")?[a[0],a[1],1]:[a[0],a[1]]}return null}function E(e,s,o,r){switch(u.hasOwnProperty(o)&&(o=u[o]),o){case"face.color":switch(s){case n.WII:e.face.color=r[1]===1?r[0]+3:r[0];break;case n.DS:case n["3DS"]:e.face.color=r[0];break;case n.WIIU:e.face.color=r[1]*2+r[0];break;case n.SWITCH:case n.SWITCH2:var h=r[1]===1?r[0]+5:r[0];e.face.color=t.switch.faceColors.indexOf(h);break}break;case"face.type":e.face.type=S(W(s),I(s),r[0],r[1]);break;case"face.makeup":e.face.makeup=S(W(s),I(s),r[0],r[1]);break;case"face.feature":e.face.feature=S(W(s),I(s),r[0],r[1]);break;case"hair.type":switch(s){case n.DS:case n.WII:var c=f(t.instrGrids.threeBy,r[1],r[2]);e.hair.type=f(t.pages.hair.wii,c,r[0]);break;case n["3DS"]:case n.WIIU:var c=f(t.instrGrids.threeBy,r[1],r[2]);e.hair.type=f(t.pages.hair["3ds"],c,r[0]);break;case n.SWITCH:case n.SWITCH2:e.hair.type=f(t.grids.hairs,r[0],r[1]);break}break;case"hair.color":if(s.endsWith("DS"))e.hair.color=r[0];else if(s.startsWith("SWITCH"))e.hair.color=f(t.grids.colors,r[0],r[1]);else{var d=s==="WII"?t.instrGrids.fourBy:t.instrGrids.twoBy;e.hair.color=f(d,r[0],r[1])}break;case"eyes.type":if(s.startsWith("SWITCH"))e.eyes.type=f(t.grids.eyes,r[0],r[1]);else{var c=f(t.instrGrids.threeBy,r[1],r[2]);e.eyes.type=f(t.pages.eyes,c,r[0])}break;case"eyes.color":if(s.endsWith("DS"))e.eyes.color=r[0];else if(s.startsWith("SWITCH"))e.eyes.color=f(t.grids.colors,r[0],r[1]);else{var d=s==="WII"?t.instrGrids.threeBy:t.instrGrids.twoBy;e.eyes.color=f(d,r[0],r[1])}break;case"eyebrows.type":if(s.startsWith("SWITCH"))e.eyebrows.type=f(t.grids.eyebrows,r[0],r[1]);else{var c=f(t.instrGrids.threeBy,r[1],r[2]);e.eyebrows.type=f(t.pages.eyebrows,c,r[0])}break;case"eyebrows.color":if(s.endsWith("DS"))e.eyebrows.color=r[0];else if(s.startsWith("SWITCH"))e.eyebrows.color=f(t.grids.colors,r[0],r[1]);else{var d=s==="WII"?t.instrGrids.fourBy:t.instrGrids.twoBy;e.eyebrows.color=f(d,r[0],r[1])}break;case"nose.type":switch(s){case n.DS:case n.WII:var c=f(t.instrGrids.threeBy,r[0],r[1]);e.nose.type=c===null?null:t.pages.noses[0][c];break;case n["3DS"]:case n.WIIU:var c=f(t.instrGrids.threeBy,r[1],r[2]);e.nose.type=f(t.pages.noses,c,r[0]);break;case n.SWITCH:case n.SWITCH2:e.nose.type=f(t.grids.noses,r[0],r[1]);break}break;case"mouth.type":if(s.startsWith("SWITCH"))e.mouth.type=f(t.grids.mouths,r[0],r[1]);else{var c=f(t.instrGrids.threeBy,r[1],r[2]);e.mouth.type=f(t.pages.mouths,c,r[0])}break;case"mouth.color":s.endsWith("DS")||s==="WII"?e.mouth.color=r[0]:s.startsWith("SWITCH")?e.mouth.color=f(t.grids.colors,r[0],r[1]):e.mouth.color=f(t.instrGrids.twoBy,r[0],r[1]);break;case"beard.mustache.type":var d=s.startsWith("SWITCH")?t.instrGrids.threeBy:t.instrGrids.twoBy;e.beard.mustache.type=f(d,r[0],r[1]);break;case"beard.type":var d=s.startsWith("SWITCH")?t.instrGrids.threeBy:t.instrGrids.twoBy;e.beard.type=f(d,r[0],r[1]);break;case"beard.color":if(s.endsWith("DS"))e.beard.color=r[0];else if(s.startsWith("SWITCH"))e.beard.color=f(t.grids.colors,r[0],r[1]);else{var d=s==="WII"?t.instrGrids.fourBy:t.instrGrids.twoBy;e.beard.color=f(d,r[0],r[1])}break;case"glasses.type":var d=s.startsWith("SWITCH")?t.grids.glasses:t.instrGrids.threeBy;e.glasses.type=f(d,r[0],r[1]);break;case"glasses.color":if(s.endsWith("DS"))e.glasses.color=r[0];else if(s.startsWith("SWITCH"))e.glasses.color=f(t.grids.colors,r[0],r[1]);else{var d=s==="WII"?t.instrGrids.threeBy:t.instrGrids.twoBy;e.glasses.color=f(d,r[0],r[1])}break}return e}function q(e,s){return{meta:{name:`Set the name to "${e.meta.name}".`,creatorName:`The name of this Mii's creator was set to "${e.meta.creatorName!=null?e.meta.creatorName:""}".`},general:{gender:`Set the ${s==="SWITCH2"?"style":"gender"} to "${e.general.gender==0?"Male":"Female"}".`,birthMonth:`Set the birth month to ${e.general.birthMonth!=null?e.general.birthMonth:0}.`,birthday:`Set the birthday to ${e.general.birthday!=null?e.general.birthday:0}.`,favoriteColor:`Set the favorite color to ${t.favoriteColors[e.general.favoriteColor].toLowerCase()}.`,height:`Set the height to ${Math.round(e.general.height/127*100)}%.`,weight:`Set the weight to ${Math.round(e.general.weight/127*100)}%.`},face:{color:`Set the face/skin color to the one ${$(y(e,s,"face.color"),M(s))}.`,type:`Set the face type to the one ${$(y(e,s,"face.type"))}.`,makeup:`Set the makeup to the one ${$(y(e,s,"face.makeup"))}.`,feature:`Set the facial features/wrinkles to the one ${$(y(e,s,"face.feature"))}.`},hair:{type:`Set the hair style to the one ${g(y(e,s,"hair.type"))}.`,flipped:e.hair.flipped?`Press the ${s==="SWITCH2"?"Y ":""}button to flip the hair.`:"",color:`Set the hair color to the one ${b(y(e,s,"hair.color"))}.`},eyes:{type:`Set the eyes to the one ${g(y(e,s,"eyes.type"))}.`,color:`Set the eye color to the one ${b(y(e,s,"eyes.color"))}.`,size:`Make the eyes ${e.eyes.size<4?`${4-e.eyes.size} smaller`:`${e.eyes.size-4} larger`}.`,squash:`${e.eyes.squash<3?"S":"Uns"}quash the eyes ${e.eyes.squash<3?3-e.eyes.squash:e.eyes.squash-3} ${s.startsWith("SWITCH")?`to the ${e.eyes.squash<3?"left":"right"}`:"times"}.`,rotation:`Rotate the outer edge of the eyes all the way down, then rotate it ${e.eyes.rotation} ticks back up.`,distanceApart:`Move the eyes ${e.eyes.distanceApart<2?`${2-e.eyes.distanceApart} closer`:`${e.eyes.distanceApart-2} further apart`}.`,yPosition:`Move the eyes ${e.eyes.yPosition<12?`${12-e.eyes.yPosition} ticks up.`:`${e.eyes.yPosition-12} ticks down.`}`},eyebrows:{type:`Set the eyebrows to the one ${g(y(e,s,"eyebrows.type"))}.`,color:`Set the eyebrows color to the one ${b(y(e,s,"eyebrows.color"))}.`,size:`Make the eyebrows ${e.eyebrows.size<4?`${4-e.eyebrows.size} smaller`:`${e.eyebrows.size-4} larger`}.`,squash:`${e.eyebrows.squash<3?"S":"Uns"}quash the eyebrows ${e.eyebrows.squash<3?3-e.eyebrows.squash:e.eyebrows.squash-3} ${s.startsWith("SWITCH")?`to the ${e.eyebrows.squash<3?"left":"right"}`:"times"}.`,rotation:`Rotate the outer edge of the eyebrows ${e.eyebrows.rotation<6?6-e.eyebrows.rotation:e.eyebrows.rotation-6} ticks ${e.eyebrows.rotation<6?"down":"up"}.`,distanceApart:`Move the eyebrows ${e.eyebrows.distanceApart<2?`${2-e.eyebrows.distanceApart} closer`:`${e.eyebrows.distanceApart-2} further apart`}.`,yPosition:`Move the eyebrows ${e.eyebrows.yPosition<7?`${7-e.eyebrows.yPosition} ticks up.`:`${e.eyebrows.yPosition-7} ticks down.`}`},nose:{type:`Set the nose to the one ${g(y(e,s,"nose.type"))}.`,size:`Make the nose ${e.nose.size<4?`${4-e.nose.size} smaller`:`${e.nose.size-4} larger.`}`,yPosition:`Move the nose ${e.nose.yPosition<9?`${9-e.nose.yPosition} ticks up.`:`${e.nose.yPosition-9} ticks down.`}`},mouth:{type:`Set the mouth to the one ${g(y(e,s,"mouth.type"))}.`,color:`Set the mouth color to the one ${b(y(e,s,"mouth.color"))}.`,size:`Make the mouth ${e.mouth.size<4?`${4-e.mouth.size} smaller`:`${e.mouth.size-4} larger.`}`,squash:`${e.mouth.squash<3?"S":"Uns"}quash the mouth ${e.mouth.squash<3?3-e.mouth.squash:e.mouth.squash-3} ${s==="SWITCH"?`to the ${e.mouth.squash<3?"left":"right"}`:"times"}.`,yPosition:`Move the mouth ${e.mouth.yPosition<13?`${13-e.mouth.yPosition} ticks up.`:`${e.mouth.yPosition-13} ticks down.`}`},beard:{mustache:{type:`Set the mustache type to the one ${g(y(e,s,"beard.mustache.type"))}.`,size:`Make the mustache ${e.beard.mustache.size<4?`${4-e.beard.mustache.size} smaller`:`${e.beard.mustache.size-4} larger.`}`,yPosition:`Move the mustache ${e.beard.mustache.yPosition<10?`${10-e.beard.mustache.yPosition} ticks up.`:`${e.beard.mustache.yPosition-10} ticks down.`}`},type:`Set the beard type to the one ${g(y(e,s,"beard.type"))}.`,color:`Set the beard color to the one ${b(y(e,s,"beard.color"))}.`},glasses:{type:`Set the glasses type to the one ${g(y(e,s,"glasses.type"))}.`,color:`Set the glasses color to the one ${b(y(e,s,"glasses.color"))}.`,size:`Make the glasses ${e.glasses.size<4?`${4-e.glasses.size} smaller`:`${e.glasses.size-4} larger.`}`,yPosition:`Move the glasses ${e.glasses.yPosition<10?`${10-e.glasses.yPosition} ticks up.`:`${e.glasses.yPosition-10} ticks down.`}`},mole:{on:`Turn the mole ${e.mole.on?"on":"off"}.`,size:`Make the mole ${e.mole.size<4?`${4-e.mole.size} smaller`:`${e.mole.size-4} larger.`}`,xPosition:`Move the mole ${e.mole.xPosition<2?`${2-e.mole.xPosition} ticks to the left.`:`${e.mole.xPosition-2} ticks to the right.`}`,yPosition:`Move the mole ${e.mole.yPosition<20?`${20-e.mole.yPosition} ticks up.`:`${e.mole.yPosition-20} ticks down.`}`}}}function A(e,s="SWITCH"){if(s=s.toUpperCase().replaceAll(" ",""),!n.hasOwnProperty(s))throw new Error(`${s} is not a valid type, expected one of ${Object.keys(n).join(", ")}.`);if(e=p(e),e&&typeof e.then=="function")return e.then(r=>A(r,s));s!=="SWITCH"&&(e=k(e,s)),Object.keys(u).forEach(r=>{C(e,u[r])==null&&(w.hasOwnProperty(r)?T(e,u[r],w[r]):T(e,u[r],0))});var o=q(e,s);return Object.keys(u).forEach(r=>{let h=C(e,u[r]),c=D(r,h);(h==null||z(h,c)&&!H.includes(r))&&P(o,u[r])}),o}export{y as getAs,A as makeInstructions,E as setAs};
//# sourceMappingURL=miiInstructions-FJNU7F24.js.map