zenno: lint fixes
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
import * as z from 'zod';
|
import * as z from 'zod';
|
||||||
|
|
||||||
const Scenarios = z.array(z.object({
|
const Scenarios = z.array(
|
||||||
|
z.object({
|
||||||
scenario_id: z.int32(),
|
scenario_id: z.int32(),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
export type Scenario = z.infer<typeof Scenarios>[number];
|
export type Scenario = z.infer<typeof Scenarios>[number];
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ test.for([
|
|||||||
])('level($rarity, $exp) -> $level', ({ rarity, exp, level }) => expect(support.level(rarity, exp)).toBe(level));
|
])('level($rarity, $exp) -> $level', ({ rarity, exp, level }) => expect(support.level(rarity, exp)).toBe(level));
|
||||||
|
|
||||||
describe('effects', () => {
|
describe('effects', () => {
|
||||||
|
|
||||||
describe('Bakushin R', () => {
|
describe('Bakushin R', () => {
|
||||||
test('level 1', () => {
|
test('level 1', () => {
|
||||||
const got = support.effects(bakushinR as support.SupportCard, 1);
|
const got = support.effects(bakushinR as support.SupportCard, 1);
|
||||||
@@ -251,7 +250,7 @@ describe('effects', () => {
|
|||||||
} satisfies support.UniqueEffect,
|
} satisfies support.UniqueEffect,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
describe('Bakushin SSR', () => {
|
describe('Bakushin SSR', () => {
|
||||||
test('level 1', () => {
|
test('level 1', () => {
|
||||||
@@ -407,5 +406,4 @@ describe('effects', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -37,19 +37,7 @@ export interface SupportCard {
|
|||||||
/**
|
/**
|
||||||
* Support card effects per five level increment.
|
* Support card effects per five level increment.
|
||||||
*/
|
*/
|
||||||
effects: [
|
effects: [Effect[], Effect[], Effect[], Effect[], Effect[], Effect[], Effect[], Effect[], Effect[], Effect[], Effect[]];
|
||||||
Effect[],
|
|
||||||
Effect[],
|
|
||||||
Effect[],
|
|
||||||
Effect[],
|
|
||||||
Effect[],
|
|
||||||
Effect[],
|
|
||||||
Effect[],
|
|
||||||
Effect[],
|
|
||||||
Effect[],
|
|
||||||
Effect[],
|
|
||||||
Effect[],
|
|
||||||
];
|
|
||||||
/**
|
/**
|
||||||
* Unique effect, for cards that have them.
|
* Unique effect, for cards that have them.
|
||||||
*/
|
*/
|
||||||
@@ -261,7 +249,7 @@ export function effects(card: SupportCard, level: number) {
|
|||||||
return { type: e.type, value };
|
return { type: e.type, value };
|
||||||
});
|
});
|
||||||
if (card.unique_effect != null && level >= card.unique_effect.card_level) {
|
if (card.unique_effect != null && level >= card.unique_effect.card_level) {
|
||||||
return { effects, unique: card.unique_effect }
|
return { effects, unique: card.unique_effect };
|
||||||
}
|
}
|
||||||
return { effects };
|
return { effects };
|
||||||
}
|
}
|
||||||
@@ -307,7 +295,10 @@ function singleUniqueEffects(type: EffectType, args: number[], deck: SupportCard
|
|||||||
return [{ type, value: args[0] }];
|
return [{ type, value: args[0] }];
|
||||||
|
|
||||||
case EffectType.UniqueFriendshipThreshold:
|
case EffectType.UniqueFriendshipThreshold:
|
||||||
return [{ type: args[1], value: args[2] }, { type: args[3], value: args[4] }];
|
return [
|
||||||
|
{ type: args[1], value: args[2] },
|
||||||
|
{ type: args[3], value: args[4] },
|
||||||
|
];
|
||||||
case EffectType.UniqueOffSpecialty:
|
case EffectType.UniqueOffSpecialty:
|
||||||
return [{ type: EffectType.TrainingEffectiveness, value: args[1] }];
|
return [{ type: EffectType.TrainingEffectiveness, value: args[1] }];
|
||||||
case EffectType.UniqueColorThresholdTrainingEffectiveness:
|
case EffectType.UniqueColorThresholdTrainingEffectiveness:
|
||||||
@@ -316,7 +307,7 @@ function singleUniqueEffects(type: EffectType, args: number[], deck: SupportCard
|
|||||||
}
|
}
|
||||||
return [{ type: EffectType.TrainingEffectiveness, value: args[1] }];
|
return [{ type: EffectType.TrainingEffectiveness, value: args[1] }];
|
||||||
case EffectType.UniqueFanScalingTrainingEffectiveness:
|
case EffectType.UniqueFanScalingTrainingEffectiveness:
|
||||||
return [{ type: EffectType.TrainingEffectiveness, value: args[1] }]
|
return [{ type: EffectType.TrainingEffectiveness, value: args[1] }];
|
||||||
case EffectType.UniqueColorInitialStats:
|
case EffectType.UniqueColorInitialStats:
|
||||||
return deck.flatMap((card) => {
|
return deck.flatMap((card) => {
|
||||||
switch (card.specialty) {
|
switch (card.specialty) {
|
||||||
@@ -339,7 +330,7 @@ function singleUniqueEffects(type: EffectType, args: number[], deck: SupportCard
|
|||||||
{ type: EffectType.InitialWit, value: args[1] },
|
{ type: EffectType.InitialWit, value: args[1] },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
case EffectType.UniqueRainbowStack:
|
case EffectType.UniqueRainbowStack:
|
||||||
return [{ type: args[1], value: args[0] * args[2] }];
|
return [{ type: args[1], value: args[0] * args[2] }];
|
||||||
case EffectType.UniqueLowEnergyScaling:
|
case EffectType.UniqueLowEnergyScaling:
|
||||||
|
|||||||
@@ -387,13 +387,9 @@
|
|||||||
"description": "Friendship Bonus and Specialty Priority",
|
"description": "Friendship Bonus and Specialty Priority",
|
||||||
"card_level": 25,
|
"card_level": 25,
|
||||||
"type": 1,
|
"type": 1,
|
||||||
"args": [
|
"args": [10],
|
||||||
10
|
|
||||||
],
|
|
||||||
"type2": 19,
|
"type2": 19,
|
||||||
"args2": [
|
"args2": [20],
|
||||||
20
|
|
||||||
],
|
|
||||||
"idle_mode_sub_rate": 0
|
"idle_mode_sub_rate": 0
|
||||||
},
|
},
|
||||||
"hints": [
|
"hints": [
|
||||||
|
|||||||
@@ -431,10 +431,7 @@
|
|||||||
"description": "Increases Training Effectiveness when not on preferred training. (Friendship 80+)",
|
"description": "Increases Training Effectiveness when not on preferred training. (Friendship 80+)",
|
||||||
"card_level": 30,
|
"card_level": 30,
|
||||||
"type": 102,
|
"type": 102,
|
||||||
"args": [
|
"args": [80, 20],
|
||||||
80,
|
|
||||||
20
|
|
||||||
],
|
|
||||||
"idle_mode_sub_rate": 30
|
"idle_mode_sub_rate": 30
|
||||||
},
|
},
|
||||||
"hints": [
|
"hints": [
|
||||||
|
|||||||
@@ -9,48 +9,48 @@ function gainTotalStats(gain: ism.GainInfo) {
|
|||||||
export const DEPENDENT = [
|
export const DEPENDENT = [
|
||||||
{
|
{
|
||||||
name: 'Total Stats',
|
name: 'Total Stats',
|
||||||
map: (gain: ism.GainInfo, _effects: support.Effect[]) => gainTotalStats(gain),
|
map: (gain: ism.GainInfo) => gainTotalStats(gain),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Total Stats + SP',
|
name: 'Total Stats + SP',
|
||||||
map: (gain: ism.GainInfo, _effects: support.Effect[]) => gainTotalStats(gain) + gain.skill_point,
|
map: (gain: ism.GainInfo) => gainTotalStats(gain) + gain.skill_point,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Speed',
|
name: 'Speed',
|
||||||
map: (gain: ism.GainInfo, _effects: support.Effect[]) => gain.speed.value,
|
map: (gain: ism.GainInfo) => gain.speed.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Stamina',
|
name: 'Stamina',
|
||||||
map: (gain: ism.GainInfo, _effects: support.Effect[]) => gain.stamina.value,
|
map: (gain: ism.GainInfo) => gain.stamina.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Power',
|
name: 'Power',
|
||||||
map: (gain: ism.GainInfo, _effects: support.Effect[]) => gain.power.value,
|
map: (gain: ism.GainInfo) => gain.power.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Guts',
|
name: 'Guts',
|
||||||
map: (gain: ism.GainInfo, _effects: support.Effect[]) => gain.guts.value,
|
map: (gain: ism.GainInfo) => gain.guts.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Wit',
|
name: 'Wit',
|
||||||
map: (gain: ism.GainInfo, _effects: support.Effect[]) => gain.wiz.value,
|
map: (gain: ism.GainInfo) => gain.wiz.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'SP',
|
name: 'SP',
|
||||||
map: (gain: ism.GainInfo, _effects: support.Effect[]) => gain.skill_point,
|
map: (gain: ism.GainInfo) => gain.skill_point,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Skill Hints',
|
name: 'Skill Hints',
|
||||||
map: (gain: ism.GainInfo, effects: support.Effect[]) => {
|
map: (gain: ism.GainInfo, effects: support.Effect[]) => {
|
||||||
// NOTE(zephyr): reduction starts with 1 because we want the value
|
// NOTE(zephyr): reduction starts with 1 because we want the value
|
||||||
// of each hint, not just the bonus from effects
|
// of each hint, not just the bonus from effects
|
||||||
const hintLevels = effects.reduce((l, e) => e.type === support.EffectType.HintLevels ? l + e.value : l, 1);
|
const hintLevels = effects.reduce((l, e) => (e.type === support.EffectType.HintLevels ? l + e.value : l), 1);
|
||||||
return gain.skill_tips_array.reduce((n, t) => n + Math.ceil(t.level / hintLevels), 0);
|
return gain.skill_tips_array.reduce((n, t) => n + Math.ceil(t.level / hintLevels), 0);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Skills',
|
name: 'Skills',
|
||||||
map: (gain: ism.GainInfo, _effects: support.Effect[]) => gain.skill_tips_array.length,
|
map: (gain: ism.GainInfo) => gain.skill_tips_array.length,
|
||||||
},
|
},
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
@@ -114,32 +114,45 @@ export const INDEPENDENT = [
|
|||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export type SupportCardDatum = {
|
export type SupportCardDatum = {
|
||||||
'Career': string;
|
Career: string;
|
||||||
'Scenario': string;
|
Scenario: string;
|
||||||
'Source': string;
|
Source: string;
|
||||||
'Unique Effect': string;
|
'Unique Effect': string;
|
||||||
'Idle Mode Sub Rate': number;
|
'Idle Mode Sub Rate': number;
|
||||||
'Races': number;
|
Races: number;
|
||||||
'Race Wins': number;
|
'Race Wins': number;
|
||||||
} & Record<typeof INDEPENDENT[number]['name'], number> & Record<typeof DEPENDENT[number]['name'], number>;
|
} & Record<(typeof INDEPENDENT)[number]['name'], number> &
|
||||||
|
Record<(typeof DEPENDENT)[number]['name'], number>;
|
||||||
|
|
||||||
export function supportVariables(career: ism.Career, lookupCard: (id: number) => support.SupportCard, lookupScenario: (id: number) => scenario.Scenario): SupportCardDatum[] {
|
export function supportVariables(
|
||||||
|
career: ism.Career,
|
||||||
|
lookupCard: (id: number) => support.SupportCard,
|
||||||
|
lookupScenario: (id: number) => scenario.Scenario,
|
||||||
|
): SupportCardDatum[] {
|
||||||
const deck = career.progress_log_info.support_card_gain_info_array.map((g) => lookupCard(g.support_card_id));
|
const deck = career.progress_log_info.support_card_gain_info_array.map((g) => lookupCard(g.support_card_id));
|
||||||
const scen = lookupScenario(career.end_info.chara_info.scenario_id);
|
const scen = lookupScenario(career.end_info.chara_info.scenario_id);
|
||||||
return career.progress_log_info.support_card_gain_info_array.map((g, i) => {
|
return career.progress_log_info.support_card_gain_info_array.map((g, i) => {
|
||||||
const card = deck[i];
|
const card = deck[i];
|
||||||
const level = support.level(card.rarity, career.end_info.chara_info.support_card_array[i].exp);
|
const level = support.level(card.rarity, career.end_info.chara_info.support_card_array[i].exp);
|
||||||
const { effects, unique } = support.effects(lookupCard(g.support_card_id), level);
|
const { effects, unique } = support.effects(lookupCard(g.support_card_id), level);
|
||||||
const indep = Object.fromEntries(INDEPENDENT.map((t) => [t.name, effects.find((e) => e.type === t.effect)?.value ?? 0])) as Record<typeof INDEPENDENT[number]['name'], number>;
|
const indep = Object.fromEntries(
|
||||||
const dep = Object.fromEntries(DEPENDENT.map((t) => [t.name, t.map(g.gain_info, effects)])) as Record<typeof DEPENDENT[number]['name'], number>;
|
INDEPENDENT.map((t) => [t.name, effects.find((e) => e.type === t.effect)?.value ?? 0]),
|
||||||
|
) as Record<(typeof INDEPENDENT)[number]['name'], number>;
|
||||||
|
const dep = Object.fromEntries(DEPENDENT.map((t) => [t.name, t.map(g.gain_info, effects)])) as Record<
|
||||||
|
(typeof DEPENDENT)[number]['name'],
|
||||||
|
number
|
||||||
|
>;
|
||||||
return {
|
return {
|
||||||
'Career': label(career),
|
Career: label(career),
|
||||||
'Scenario': scen.name,
|
Scenario: scen.name,
|
||||||
'Source': card.name,
|
Source: card.name,
|
||||||
'Unique Effect': unique?.description ?? 'None',
|
'Unique Effect': unique?.description ?? 'None',
|
||||||
'Idle Mode Sub Rate': unique?.idle_mode_sub_rate ?? 0,
|
'Idle Mode Sub Rate': unique?.idle_mode_sub_rate ?? 0,
|
||||||
'Races': career.progress_log_info.race_history_array.length,
|
Races: career.progress_log_info.race_history_array.length,
|
||||||
'Race Wins': career.progress_log_info.race_history_array.reduce((w, r) => r.race_history.result_rank === 1 ? w + 1 : w, 0),
|
'Race Wins': career.progress_log_info.race_history_array.reduce(
|
||||||
|
(w, r) => (r.race_history.result_rank === 1 ? w + 1 : w),
|
||||||
|
0,
|
||||||
|
),
|
||||||
...indep,
|
...indep,
|
||||||
...dep,
|
...dep,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user