-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaverageMiiPresentation.js
More file actions
49 lines (42 loc) · 1.48 KB
/
Copy pathaverageMiiPresentation.js
File metadata and controls
49 lines (42 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { MII_RENDERER_PROFILES } from "./miiRendererRouting.js";
const AVERAGE_RENDERER_PROFILE_PRIORITY = Object.freeze(["TL", "RFL", "LTD"]);
const AVERAGE_PRESENTATION_BY_PROFILE = Object.freeze({
TL: Object.freeze({
rendererProfile: "TL",
era: "CHARINFO",
console: "Mii Studio"
}),
RFL: Object.freeze({
rendererProfile: "RFL",
era: "RCD",
console: "Wii"
}),
LTD: Object.freeze({
rendererProfile: "LTD",
era: "LTD",
console: "LTD"
})
});
export function selectMostCommonMiiRendererProfile(counts) {
const source = counts instanceof Map
? counts
: new Map(Object.entries(counts && typeof counts === "object" ? counts : {}));
let selected = AVERAGE_RENDERER_PROFILE_PRIORITY[0];
let selectedCount = -1;
for (const profile of AVERAGE_RENDERER_PROFILE_PRIORITY) {
const count = Number(source.get(profile));
const normalizedCount = Number.isFinite(count) && count >= 0 ? count : 0;
if (normalizedCount > selectedCount) {
selected = profile;
selectedCount = normalizedCount;
}
}
return selected;
}
export function getAverageMiiPresentation(profile) {
const normalized = String(profile || "").trim().toUpperCase();
if (!MII_RENDERER_PROFILES.includes(normalized)) {
throw new TypeError(`Unsupported average-Mii renderer profile: ${profile}`);
}
return AVERAGE_PRESENTATION_BY_PROFILE[normalized];
}