Gitea Auto Deploy / Deploy-Container (push) Failing after 46s
- Updated metadata interfaces in `metaData.ts` for improved readability. - Refactored `mics.ts` types to enhance structure and maintainability. - Added `Invasion` type to `mocDetail.ts` and `peakDetail.ts` for new functionality. - Simplified modal configuration in `modelConfig.ts`. - Cleaned up monster detail interfaces in `monsterDetail.ts`. - Enhanced battle configuration types in `pfDetail.ts` to include `Invasion`. - Updated JSON schemas in `srtools.zod.ts` to use `nullish` for optional fields. - Introduced new skills-lock.json for skill management. - Added global type declarations for CSS and SCSS modules in `global.d.ts`.
35 lines
1000 B
TypeScript
35 lines
1000 B
TypeScript
export function randomPartition(sum: number, parts: number): number[] {
|
|
if (!Number.isFinite(sum) || !Number.isInteger(parts) || parts <= 0) {
|
|
return [];
|
|
}
|
|
if (sum < parts) {
|
|
return Array.from({ length: parts }, () => 0);
|
|
}
|
|
|
|
const raw = Array.from({ length: parts }, () => Math.random());
|
|
const total = raw.reduce((a, b) => a + b, 0);
|
|
const result = raw.map(r => Math.floor((r / total) * (sum - parts)) + 1);
|
|
let diff = sum - result.reduce((a, b) => a + b, 0);
|
|
while (diff !== 0) {
|
|
for (let i = 0; i < result.length && diff !== 0; i++) {
|
|
if (diff > 0) {
|
|
result[i]++;
|
|
diff--;
|
|
} else if (result[i] > 1) {
|
|
result[i]--;
|
|
diff++;
|
|
}
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
export function randomStep(x: number): number {
|
|
let total = 0;
|
|
for (let i = 0; i < x; i++) {
|
|
total += Math.floor(Math.random() * 3);
|
|
}
|
|
return total;
|
|
}
|