@reela/credits 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.mts +29 -0
- package/index.d.ts +29 -0
- package/index.js +236 -0
- package/index.mjs +206 -0
- package/package.json +14 -0
package/index.d.mts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
interface Pipeline {
|
|
2
|
+
tier: string;
|
|
3
|
+
type?: string;
|
|
4
|
+
cameraPosition?: number;
|
|
5
|
+
visual: string[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare function calculateAssetCredits(pipeline: Pipeline): number;
|
|
9
|
+
|
|
10
|
+
interface CalculateTaskCreditsParams {
|
|
11
|
+
durationOfShots: Array<{
|
|
12
|
+
type: string;
|
|
13
|
+
used: number;
|
|
14
|
+
}>;
|
|
15
|
+
cameraPosition?: number;
|
|
16
|
+
tier: string;
|
|
17
|
+
}
|
|
18
|
+
declare function calculateTaskCredits(params: CalculateTaskCreditsParams): number;
|
|
19
|
+
interface EstimateTaskCreditsParams {
|
|
20
|
+
duration: number;
|
|
21
|
+
visual: string[];
|
|
22
|
+
tier: string;
|
|
23
|
+
cameraPosition?: number;
|
|
24
|
+
}
|
|
25
|
+
declare function estimateTaskCredits(params: EstimateTaskCreditsParams): number;
|
|
26
|
+
|
|
27
|
+
declare function calculateAvatarCredits(): number;
|
|
28
|
+
|
|
29
|
+
export { type CalculateTaskCreditsParams, type EstimateTaskCreditsParams, calculateAssetCredits, calculateAvatarCredits, calculateTaskCredits, estimateTaskCredits };
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
interface Pipeline {
|
|
2
|
+
tier: string;
|
|
3
|
+
type?: string;
|
|
4
|
+
cameraPosition?: number;
|
|
5
|
+
visual: string[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare function calculateAssetCredits(pipeline: Pipeline): number;
|
|
9
|
+
|
|
10
|
+
interface CalculateTaskCreditsParams {
|
|
11
|
+
durationOfShots: Array<{
|
|
12
|
+
type: string;
|
|
13
|
+
used: number;
|
|
14
|
+
}>;
|
|
15
|
+
cameraPosition?: number;
|
|
16
|
+
tier: string;
|
|
17
|
+
}
|
|
18
|
+
declare function calculateTaskCredits(params: CalculateTaskCreditsParams): number;
|
|
19
|
+
interface EstimateTaskCreditsParams {
|
|
20
|
+
duration: number;
|
|
21
|
+
visual: string[];
|
|
22
|
+
tier: string;
|
|
23
|
+
cameraPosition?: number;
|
|
24
|
+
}
|
|
25
|
+
declare function estimateTaskCredits(params: EstimateTaskCreditsParams): number;
|
|
26
|
+
|
|
27
|
+
declare function calculateAvatarCredits(): number;
|
|
28
|
+
|
|
29
|
+
export { type CalculateTaskCreditsParams, type EstimateTaskCreditsParams, calculateAssetCredits, calculateAvatarCredits, calculateTaskCredits, estimateTaskCredits };
|
package/index.js
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
calculateAssetCredits: () => calculateAssetCredits,
|
|
24
|
+
calculateAvatarCredits: () => calculateAvatarCredits,
|
|
25
|
+
calculateTaskCredits: () => calculateTaskCredits,
|
|
26
|
+
estimateTaskCredits: () => estimateTaskCredits
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
|
|
30
|
+
// src/constants/shot-type.ts
|
|
31
|
+
var shotType = {
|
|
32
|
+
aiv: "AIV",
|
|
33
|
+
aivr: "AIVReference",
|
|
34
|
+
aii: "AII",
|
|
35
|
+
aiir: "AIIReference"
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/constants/tier.ts
|
|
39
|
+
var tier = {
|
|
40
|
+
lite: "lite",
|
|
41
|
+
pro: "pro",
|
|
42
|
+
max: "max",
|
|
43
|
+
photo: "photo",
|
|
44
|
+
ultra: "ultra"
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// src/constants/mode.ts
|
|
48
|
+
var mode = {
|
|
49
|
+
studio: "studio",
|
|
50
|
+
reference: "reference",
|
|
51
|
+
remix: "remix",
|
|
52
|
+
presenter: "presenter"
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// src/constants/visual.ts
|
|
56
|
+
var visual = {
|
|
57
|
+
aiv: "AIV",
|
|
58
|
+
oiv: "OIV",
|
|
59
|
+
aivr: "AIV_REFERENCE",
|
|
60
|
+
aia: "AIA",
|
|
61
|
+
aiar: "AIA_REFERENCE",
|
|
62
|
+
ovs: "OVS",
|
|
63
|
+
ova: "OVA_VISUAL",
|
|
64
|
+
webv: "WEBV"
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// src/get-key.ts
|
|
68
|
+
function getKey(pipeline) {
|
|
69
|
+
const { tier: tier2 = "default", type = "default", cameraPosition = 1, visual: visual2 = [] } = pipeline;
|
|
70
|
+
const v = Array.from(new Set(visual2));
|
|
71
|
+
v.sort();
|
|
72
|
+
return `${v.join("-")}-${type}-${tier2}-${cameraPosition}`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// src/asset-credits.ts
|
|
76
|
+
var creditsMap = {
|
|
77
|
+
[getKey({ type: shotType.aii, tier: tier.photo })]: 3,
|
|
78
|
+
[getKey({ type: shotType.aiv, tier: tier.lite })]: 25,
|
|
79
|
+
[getKey({ type: shotType.aiv, tier: tier.pro })]: 25,
|
|
80
|
+
[getKey({ type: shotType.aiv, tier: tier.max })]: 250,
|
|
81
|
+
[getKey({ type: shotType.aiv, tier: tier.ultra })]: 250,
|
|
82
|
+
[getKey({ type: shotType.aiir, tier: tier.photo })]: 5,
|
|
83
|
+
[getKey({ type: shotType.aivr, tier: tier.lite })]: 25,
|
|
84
|
+
[getKey({ type: shotType.aivr, tier: tier.pro })]: 45,
|
|
85
|
+
[getKey({ type: shotType.aivr, tier: tier.max })]: 250,
|
|
86
|
+
[getKey({ type: shotType.aivr, tier: tier.ultra })]: 250
|
|
87
|
+
};
|
|
88
|
+
var getShotType = (pipeline) => {
|
|
89
|
+
if (pipeline.type) {
|
|
90
|
+
switch (pipeline.type) {
|
|
91
|
+
case mode.reference:
|
|
92
|
+
if (pipeline.tier === "photo") {
|
|
93
|
+
return shotType.aiir;
|
|
94
|
+
}
|
|
95
|
+
return shotType.aivr;
|
|
96
|
+
case mode.studio:
|
|
97
|
+
case mode.remix:
|
|
98
|
+
case mode.presenter:
|
|
99
|
+
if (pipeline.tier === "photo") {
|
|
100
|
+
return shotType.aii;
|
|
101
|
+
}
|
|
102
|
+
return shotType.aiv;
|
|
103
|
+
default:
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (pipeline.visual && pipeline.visual.length > 0) {
|
|
108
|
+
if (pipeline.visual.includes(visual.aiv) || pipeline.visual.includes(visual.oiv)) {
|
|
109
|
+
if (pipeline.tier === "photo") {
|
|
110
|
+
return shotType.aii;
|
|
111
|
+
}
|
|
112
|
+
return shotType.aiv;
|
|
113
|
+
}
|
|
114
|
+
if (pipeline.visual.includes(visual.aivr) || pipeline.visual.includes(visual.aiar)) {
|
|
115
|
+
if (pipeline.tier === "photo") {
|
|
116
|
+
return shotType.aiir;
|
|
117
|
+
}
|
|
118
|
+
return shotType.aivr;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
throw new Error(`Invalid pipeline, get pipeline ${JSON.stringify(pipeline)}`);
|
|
122
|
+
};
|
|
123
|
+
function calculateAssetCredits(pipeline) {
|
|
124
|
+
if (typeof pipeline !== "object" || pipeline === null || Array.isArray(pipeline)) {
|
|
125
|
+
throw new Error("Pipeline must be an object");
|
|
126
|
+
}
|
|
127
|
+
const shotType2 = getShotType(pipeline);
|
|
128
|
+
const credits = creditsMap[getKey({ type: shotType2, tier: pipeline.tier })];
|
|
129
|
+
if (typeof credits === "undefined") {
|
|
130
|
+
throw new Error(`Invalid pipeline, get pipeline ${JSON.stringify(pipeline)}`);
|
|
131
|
+
}
|
|
132
|
+
return credits;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// src/task-credits.ts
|
|
136
|
+
var unitCredits = {
|
|
137
|
+
// AIV/OIV
|
|
138
|
+
[getKey({ visual: [visual.aiv], tier: tier.photo })]: 5,
|
|
139
|
+
[getKey({ visual: [visual.aiv], tier: tier.lite })]: 15,
|
|
140
|
+
[getKey({ visual: [visual.aiv], tier: tier.pro })]: 20,
|
|
141
|
+
[getKey({ visual: [visual.aiv], tier: tier.max })]: 100,
|
|
142
|
+
[getKey({ visual: [visual.aiv], tier: tier.ultra })]: 100,
|
|
143
|
+
// AIV_REFERENCE
|
|
144
|
+
[getKey({ visual: [visual.aivr], tier: tier.photo })]: 5,
|
|
145
|
+
[getKey({ visual: [visual.aivr], tier: tier.lite })]: 25,
|
|
146
|
+
[getKey({ visual: [visual.aivr], tier: tier.pro })]: 25,
|
|
147
|
+
[getKey({ visual: [visual.aivr], tier: tier.max })]: 100,
|
|
148
|
+
[getKey({ visual: [visual.aivr], tier: tier.ultra })]: 100,
|
|
149
|
+
// AIA/AIA_REFERENCE
|
|
150
|
+
[getKey({ visual: [visual.aia], tier: tier.lite })]: 5,
|
|
151
|
+
[getKey({ visual: [visual.aia], tier: tier.pro })]: 5,
|
|
152
|
+
[getKey({ visual: [visual.aia], tier: tier.max })]: 40,
|
|
153
|
+
[getKey({ visual: [visual.aia], tier: tier.ultra })]: 40,
|
|
154
|
+
// OVS/OVA
|
|
155
|
+
[getKey({ visual: [visual.ovs], tier: tier.lite })]: 3,
|
|
156
|
+
[getKey({ visual: [visual.ovs], tier: tier.pro })]: 3,
|
|
157
|
+
[getKey({ visual: [visual.ovs], tier: tier.max })]: 3,
|
|
158
|
+
[getKey({ visual: [visual.ovs], tier: tier.ultra })]: 3,
|
|
159
|
+
// WEBV
|
|
160
|
+
[getKey({ visual: [visual.webv], tier: tier.lite })]: 3,
|
|
161
|
+
[getKey({ visual: [visual.webv], tier: tier.pro })]: 3,
|
|
162
|
+
[getKey({ visual: [visual.webv], tier: tier.max })]: 3,
|
|
163
|
+
[getKey({ visual: [visual.webv], tier: tier.ultra })]: 3
|
|
164
|
+
};
|
|
165
|
+
function calculateTaskCredits(params) {
|
|
166
|
+
const { durationOfShots, cameraPosition = 1, tier: tier2 } = params;
|
|
167
|
+
if (typeof tier2 !== "string" || !tier2) {
|
|
168
|
+
throw new Error("Tier must be a non-empty string");
|
|
169
|
+
}
|
|
170
|
+
if (typeof cameraPosition !== "number") {
|
|
171
|
+
throw new Error("Camera position must be a number");
|
|
172
|
+
}
|
|
173
|
+
if (!Array.isArray(durationOfShots) || durationOfShots.length === 0) {
|
|
174
|
+
throw new Error("Duration of shots must be a non-empty array");
|
|
175
|
+
}
|
|
176
|
+
let u = 0;
|
|
177
|
+
for (const shot of durationOfShots) {
|
|
178
|
+
u += getShotCredits(shot.type, tier2, shot.used, cameraPosition);
|
|
179
|
+
}
|
|
180
|
+
if (u === 0) {
|
|
181
|
+
throw new Error(`Invalid params, get ${JSON.stringify(params)}`);
|
|
182
|
+
}
|
|
183
|
+
return u;
|
|
184
|
+
}
|
|
185
|
+
function estimateTaskCredits(params) {
|
|
186
|
+
const { duration, visual: visual2, tier: tier2, cameraPosition = 1 } = params;
|
|
187
|
+
if (typeof duration !== "number") {
|
|
188
|
+
throw new Error("Duration must be a number");
|
|
189
|
+
}
|
|
190
|
+
if (!Array.isArray(visual2) || visual2.length === 0) {
|
|
191
|
+
throw new Error("Visuals must be a non-empty array");
|
|
192
|
+
}
|
|
193
|
+
if (typeof tier2 !== "string" || !tier2) {
|
|
194
|
+
throw new Error("Tier must be a non-empty string");
|
|
195
|
+
}
|
|
196
|
+
if (typeof cameraPosition !== "number") {
|
|
197
|
+
throw new Error("Camera position must be a number");
|
|
198
|
+
}
|
|
199
|
+
const set = new Set(visual2);
|
|
200
|
+
let u = 0;
|
|
201
|
+
for (const v of set) {
|
|
202
|
+
u += getShotCredits(v, tier2, duration, cameraPosition);
|
|
203
|
+
}
|
|
204
|
+
if (u === 0) {
|
|
205
|
+
throw new Error(`Invalid params, get ${JSON.stringify(params)}`);
|
|
206
|
+
}
|
|
207
|
+
return Math.floor(u / set.size);
|
|
208
|
+
}
|
|
209
|
+
function getShotCredits(visualType, tier2, duration, cameraPosition = 1) {
|
|
210
|
+
if (visualType === visual.ova) {
|
|
211
|
+
visualType = visual.ovs;
|
|
212
|
+
}
|
|
213
|
+
if (visualType === visual.oiv) {
|
|
214
|
+
visualType = visual.aiv;
|
|
215
|
+
}
|
|
216
|
+
if (visualType === visual.aiar) {
|
|
217
|
+
visualType = visual.aia;
|
|
218
|
+
}
|
|
219
|
+
if (visualType === visual.aia) {
|
|
220
|
+
return duration * (unitCredits[getKey({ visual: [visualType], tier: tier2 })] || 0) * (Number(cameraPosition) || 1);
|
|
221
|
+
} else {
|
|
222
|
+
return duration * (unitCredits[getKey({ visual: [visualType], tier: tier2 })] || 0);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// src/avatar-credits.ts
|
|
227
|
+
function calculateAvatarCredits() {
|
|
228
|
+
return 400;
|
|
229
|
+
}
|
|
230
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
231
|
+
0 && (module.exports = {
|
|
232
|
+
calculateAssetCredits,
|
|
233
|
+
calculateAvatarCredits,
|
|
234
|
+
calculateTaskCredits,
|
|
235
|
+
estimateTaskCredits
|
|
236
|
+
});
|
package/index.mjs
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// src/constants/shot-type.ts
|
|
2
|
+
var shotType = {
|
|
3
|
+
aiv: "AIV",
|
|
4
|
+
aivr: "AIVReference",
|
|
5
|
+
aii: "AII",
|
|
6
|
+
aiir: "AIIReference"
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
// src/constants/tier.ts
|
|
10
|
+
var tier = {
|
|
11
|
+
lite: "lite",
|
|
12
|
+
pro: "pro",
|
|
13
|
+
max: "max",
|
|
14
|
+
photo: "photo",
|
|
15
|
+
ultra: "ultra"
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/constants/mode.ts
|
|
19
|
+
var mode = {
|
|
20
|
+
studio: "studio",
|
|
21
|
+
reference: "reference",
|
|
22
|
+
remix: "remix",
|
|
23
|
+
presenter: "presenter"
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// src/constants/visual.ts
|
|
27
|
+
var visual = {
|
|
28
|
+
aiv: "AIV",
|
|
29
|
+
oiv: "OIV",
|
|
30
|
+
aivr: "AIV_REFERENCE",
|
|
31
|
+
aia: "AIA",
|
|
32
|
+
aiar: "AIA_REFERENCE",
|
|
33
|
+
ovs: "OVS",
|
|
34
|
+
ova: "OVA_VISUAL",
|
|
35
|
+
webv: "WEBV"
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/get-key.ts
|
|
39
|
+
function getKey(pipeline) {
|
|
40
|
+
const { tier: tier2 = "default", type = "default", cameraPosition = 1, visual: visual2 = [] } = pipeline;
|
|
41
|
+
const v = Array.from(new Set(visual2));
|
|
42
|
+
v.sort();
|
|
43
|
+
return `${v.join("-")}-${type}-${tier2}-${cameraPosition}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/asset-credits.ts
|
|
47
|
+
var creditsMap = {
|
|
48
|
+
[getKey({ type: shotType.aii, tier: tier.photo })]: 3,
|
|
49
|
+
[getKey({ type: shotType.aiv, tier: tier.lite })]: 25,
|
|
50
|
+
[getKey({ type: shotType.aiv, tier: tier.pro })]: 25,
|
|
51
|
+
[getKey({ type: shotType.aiv, tier: tier.max })]: 250,
|
|
52
|
+
[getKey({ type: shotType.aiv, tier: tier.ultra })]: 250,
|
|
53
|
+
[getKey({ type: shotType.aiir, tier: tier.photo })]: 5,
|
|
54
|
+
[getKey({ type: shotType.aivr, tier: tier.lite })]: 25,
|
|
55
|
+
[getKey({ type: shotType.aivr, tier: tier.pro })]: 45,
|
|
56
|
+
[getKey({ type: shotType.aivr, tier: tier.max })]: 250,
|
|
57
|
+
[getKey({ type: shotType.aivr, tier: tier.ultra })]: 250
|
|
58
|
+
};
|
|
59
|
+
var getShotType = (pipeline) => {
|
|
60
|
+
if (pipeline.type) {
|
|
61
|
+
switch (pipeline.type) {
|
|
62
|
+
case mode.reference:
|
|
63
|
+
if (pipeline.tier === "photo") {
|
|
64
|
+
return shotType.aiir;
|
|
65
|
+
}
|
|
66
|
+
return shotType.aivr;
|
|
67
|
+
case mode.studio:
|
|
68
|
+
case mode.remix:
|
|
69
|
+
case mode.presenter:
|
|
70
|
+
if (pipeline.tier === "photo") {
|
|
71
|
+
return shotType.aii;
|
|
72
|
+
}
|
|
73
|
+
return shotType.aiv;
|
|
74
|
+
default:
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (pipeline.visual && pipeline.visual.length > 0) {
|
|
79
|
+
if (pipeline.visual.includes(visual.aiv) || pipeline.visual.includes(visual.oiv)) {
|
|
80
|
+
if (pipeline.tier === "photo") {
|
|
81
|
+
return shotType.aii;
|
|
82
|
+
}
|
|
83
|
+
return shotType.aiv;
|
|
84
|
+
}
|
|
85
|
+
if (pipeline.visual.includes(visual.aivr) || pipeline.visual.includes(visual.aiar)) {
|
|
86
|
+
if (pipeline.tier === "photo") {
|
|
87
|
+
return shotType.aiir;
|
|
88
|
+
}
|
|
89
|
+
return shotType.aivr;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
throw new Error(`Invalid pipeline, get pipeline ${JSON.stringify(pipeline)}`);
|
|
93
|
+
};
|
|
94
|
+
function calculateAssetCredits(pipeline) {
|
|
95
|
+
if (typeof pipeline !== "object" || pipeline === null || Array.isArray(pipeline)) {
|
|
96
|
+
throw new Error("Pipeline must be an object");
|
|
97
|
+
}
|
|
98
|
+
const shotType2 = getShotType(pipeline);
|
|
99
|
+
const credits = creditsMap[getKey({ type: shotType2, tier: pipeline.tier })];
|
|
100
|
+
if (typeof credits === "undefined") {
|
|
101
|
+
throw new Error(`Invalid pipeline, get pipeline ${JSON.stringify(pipeline)}`);
|
|
102
|
+
}
|
|
103
|
+
return credits;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/task-credits.ts
|
|
107
|
+
var unitCredits = {
|
|
108
|
+
// AIV/OIV
|
|
109
|
+
[getKey({ visual: [visual.aiv], tier: tier.photo })]: 5,
|
|
110
|
+
[getKey({ visual: [visual.aiv], tier: tier.lite })]: 15,
|
|
111
|
+
[getKey({ visual: [visual.aiv], tier: tier.pro })]: 20,
|
|
112
|
+
[getKey({ visual: [visual.aiv], tier: tier.max })]: 100,
|
|
113
|
+
[getKey({ visual: [visual.aiv], tier: tier.ultra })]: 100,
|
|
114
|
+
// AIV_REFERENCE
|
|
115
|
+
[getKey({ visual: [visual.aivr], tier: tier.photo })]: 5,
|
|
116
|
+
[getKey({ visual: [visual.aivr], tier: tier.lite })]: 25,
|
|
117
|
+
[getKey({ visual: [visual.aivr], tier: tier.pro })]: 25,
|
|
118
|
+
[getKey({ visual: [visual.aivr], tier: tier.max })]: 100,
|
|
119
|
+
[getKey({ visual: [visual.aivr], tier: tier.ultra })]: 100,
|
|
120
|
+
// AIA/AIA_REFERENCE
|
|
121
|
+
[getKey({ visual: [visual.aia], tier: tier.lite })]: 5,
|
|
122
|
+
[getKey({ visual: [visual.aia], tier: tier.pro })]: 5,
|
|
123
|
+
[getKey({ visual: [visual.aia], tier: tier.max })]: 40,
|
|
124
|
+
[getKey({ visual: [visual.aia], tier: tier.ultra })]: 40,
|
|
125
|
+
// OVS/OVA
|
|
126
|
+
[getKey({ visual: [visual.ovs], tier: tier.lite })]: 3,
|
|
127
|
+
[getKey({ visual: [visual.ovs], tier: tier.pro })]: 3,
|
|
128
|
+
[getKey({ visual: [visual.ovs], tier: tier.max })]: 3,
|
|
129
|
+
[getKey({ visual: [visual.ovs], tier: tier.ultra })]: 3,
|
|
130
|
+
// WEBV
|
|
131
|
+
[getKey({ visual: [visual.webv], tier: tier.lite })]: 3,
|
|
132
|
+
[getKey({ visual: [visual.webv], tier: tier.pro })]: 3,
|
|
133
|
+
[getKey({ visual: [visual.webv], tier: tier.max })]: 3,
|
|
134
|
+
[getKey({ visual: [visual.webv], tier: tier.ultra })]: 3
|
|
135
|
+
};
|
|
136
|
+
function calculateTaskCredits(params) {
|
|
137
|
+
const { durationOfShots, cameraPosition = 1, tier: tier2 } = params;
|
|
138
|
+
if (typeof tier2 !== "string" || !tier2) {
|
|
139
|
+
throw new Error("Tier must be a non-empty string");
|
|
140
|
+
}
|
|
141
|
+
if (typeof cameraPosition !== "number") {
|
|
142
|
+
throw new Error("Camera position must be a number");
|
|
143
|
+
}
|
|
144
|
+
if (!Array.isArray(durationOfShots) || durationOfShots.length === 0) {
|
|
145
|
+
throw new Error("Duration of shots must be a non-empty array");
|
|
146
|
+
}
|
|
147
|
+
let u = 0;
|
|
148
|
+
for (const shot of durationOfShots) {
|
|
149
|
+
u += getShotCredits(shot.type, tier2, shot.used, cameraPosition);
|
|
150
|
+
}
|
|
151
|
+
if (u === 0) {
|
|
152
|
+
throw new Error(`Invalid params, get ${JSON.stringify(params)}`);
|
|
153
|
+
}
|
|
154
|
+
return u;
|
|
155
|
+
}
|
|
156
|
+
function estimateTaskCredits(params) {
|
|
157
|
+
const { duration, visual: visual2, tier: tier2, cameraPosition = 1 } = params;
|
|
158
|
+
if (typeof duration !== "number") {
|
|
159
|
+
throw new Error("Duration must be a number");
|
|
160
|
+
}
|
|
161
|
+
if (!Array.isArray(visual2) || visual2.length === 0) {
|
|
162
|
+
throw new Error("Visuals must be a non-empty array");
|
|
163
|
+
}
|
|
164
|
+
if (typeof tier2 !== "string" || !tier2) {
|
|
165
|
+
throw new Error("Tier must be a non-empty string");
|
|
166
|
+
}
|
|
167
|
+
if (typeof cameraPosition !== "number") {
|
|
168
|
+
throw new Error("Camera position must be a number");
|
|
169
|
+
}
|
|
170
|
+
const set = new Set(visual2);
|
|
171
|
+
let u = 0;
|
|
172
|
+
for (const v of set) {
|
|
173
|
+
u += getShotCredits(v, tier2, duration, cameraPosition);
|
|
174
|
+
}
|
|
175
|
+
if (u === 0) {
|
|
176
|
+
throw new Error(`Invalid params, get ${JSON.stringify(params)}`);
|
|
177
|
+
}
|
|
178
|
+
return Math.floor(u / set.size);
|
|
179
|
+
}
|
|
180
|
+
function getShotCredits(visualType, tier2, duration, cameraPosition = 1) {
|
|
181
|
+
if (visualType === visual.ova) {
|
|
182
|
+
visualType = visual.ovs;
|
|
183
|
+
}
|
|
184
|
+
if (visualType === visual.oiv) {
|
|
185
|
+
visualType = visual.aiv;
|
|
186
|
+
}
|
|
187
|
+
if (visualType === visual.aiar) {
|
|
188
|
+
visualType = visual.aia;
|
|
189
|
+
}
|
|
190
|
+
if (visualType === visual.aia) {
|
|
191
|
+
return duration * (unitCredits[getKey({ visual: [visualType], tier: tier2 })] || 0) * (Number(cameraPosition) || 1);
|
|
192
|
+
} else {
|
|
193
|
+
return duration * (unitCredits[getKey({ visual: [visualType], tier: tier2 })] || 0);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// src/avatar-credits.ts
|
|
198
|
+
function calculateAvatarCredits() {
|
|
199
|
+
return 400;
|
|
200
|
+
}
|
|
201
|
+
export {
|
|
202
|
+
calculateAssetCredits,
|
|
203
|
+
calculateAvatarCredits,
|
|
204
|
+
calculateTaskCredits,
|
|
205
|
+
estimateTaskCredits
|
|
206
|
+
};
|
package/package.json
ADDED