volleyballsimtypes 0.0.427 → 0.0.429
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/dist/cjs/src/api/index.d.ts +7 -0
- package/dist/cjs/src/data/init-models.js +6 -0
- package/dist/cjs/src/data/models/index.d.ts +1 -0
- package/dist/cjs/src/data/models/index.js +1 -0
- package/dist/cjs/src/data/models/lineup-preset.d.ts +29 -0
- package/dist/cjs/src/data/models/lineup-preset.js +71 -0
- package/dist/cjs/src/data/transformers/index.d.ts +1 -0
- package/dist/cjs/src/data/transformers/index.js +1 -0
- package/dist/cjs/src/data/transformers/lineup-preset.d.ts +4 -0
- package/dist/cjs/src/data/transformers/lineup-preset.js +13 -0
- package/dist/cjs/src/data/transformers/lineup-preset.test.d.ts +1 -0
- package/dist/cjs/src/data/transformers/lineup-preset.test.js +25 -0
- package/dist/cjs/src/data/transformers/tactics.d.ts +3 -1
- package/dist/cjs/src/data/transformers/tactics.js +38 -0
- package/dist/cjs/src/data/transformers/tactics.test.d.ts +1 -0
- package/dist/cjs/src/data/transformers/tactics.test.js +66 -0
- package/dist/cjs/src/service/event/reception.d.ts +3 -2
- package/dist/cjs/src/service/event/reception.js +3 -0
- package/dist/cjs/src/service/event/schemas/reception.z.js +1 -1
- package/dist/cjs/src/service/event/schemas/reception.z.test.d.ts +1 -0
- package/dist/cjs/src/service/event/schemas/reception.z.test.js +29 -0
- package/dist/cjs/src/service/player/improvement.d.ts +1 -0
- package/dist/cjs/src/service/player/improvement.js +33 -6
- package/dist/cjs/src/service/player/improvement.test.js +45 -14
- package/dist/cjs/src/service/team/schemas/designated-sub.z.test.js +19 -0
- package/dist/esm/src/api/index.d.ts +7 -0
- package/dist/esm/src/data/init-models.js +7 -1
- package/dist/esm/src/data/models/index.d.ts +1 -0
- package/dist/esm/src/data/models/index.js +1 -0
- package/dist/esm/src/data/models/lineup-preset.d.ts +29 -0
- package/dist/esm/src/data/models/lineup-preset.js +67 -0
- package/dist/esm/src/data/transformers/index.d.ts +1 -0
- package/dist/esm/src/data/transformers/index.js +1 -0
- package/dist/esm/src/data/transformers/lineup-preset.d.ts +4 -0
- package/dist/esm/src/data/transformers/lineup-preset.js +11 -0
- package/dist/esm/src/data/transformers/lineup-preset.test.d.ts +1 -0
- package/dist/esm/src/data/transformers/lineup-preset.test.js +23 -0
- package/dist/esm/src/data/transformers/tactics.d.ts +3 -1
- package/dist/esm/src/data/transformers/tactics.js +38 -1
- package/dist/esm/src/data/transformers/tactics.test.d.ts +1 -0
- package/dist/esm/src/data/transformers/tactics.test.js +64 -0
- package/dist/esm/src/service/event/reception.d.ts +3 -2
- package/dist/esm/src/service/event/reception.js +3 -0
- package/dist/esm/src/service/event/schemas/reception.z.js +1 -1
- package/dist/esm/src/service/event/schemas/reception.z.test.d.ts +1 -0
- package/dist/esm/src/service/event/schemas/reception.z.test.js +27 -0
- package/dist/esm/src/service/player/improvement.d.ts +1 -0
- package/dist/esm/src/service/player/improvement.js +32 -6
- package/dist/esm/src/service/player/improvement.test.js +46 -15
- package/dist/esm/src/service/team/schemas/designated-sub.z.test.js +19 -0
- package/package.json +1 -1
|
@@ -114,6 +114,13 @@ export interface Tactics {
|
|
|
114
114
|
designatedSetters: string[];
|
|
115
115
|
offensivePreferences: ApiOffensivePreference[];
|
|
116
116
|
}
|
|
117
|
+
export interface ApiLineupPreset {
|
|
118
|
+
presetId: string;
|
|
119
|
+
name: string;
|
|
120
|
+
isActive: boolean;
|
|
121
|
+
orderIndex: number;
|
|
122
|
+
config: Tactics;
|
|
123
|
+
}
|
|
117
124
|
export type Team = Omit<DataProps<_Team>, 'roster' | '_rating' | 'rating' | 'tactics'> & {
|
|
118
125
|
roster: Player[];
|
|
119
126
|
rating: {
|
|
@@ -7,6 +7,7 @@ function initModels(sequelize) {
|
|
|
7
7
|
const Scout = models_1.ScoutModel.initModel(sequelize);
|
|
8
8
|
const CurrencyTransaction = models_1.CurrencyTransactionModel.initModel(sequelize);
|
|
9
9
|
const Tactics = models_1.TacticsModel.initModel(sequelize);
|
|
10
|
+
const LineupPreset = models_1.LineupPresetModel.initModel(sequelize);
|
|
10
11
|
const AuthUser = models_1.AuthUserModel.initModel(sequelize);
|
|
11
12
|
const UserCurrency = models_1.UserCurrencyModel.initModel(sequelize);
|
|
12
13
|
const UserPlayerProgress = models_1.UserPlayerProgressModel.initModel(sequelize);
|
|
@@ -199,6 +200,10 @@ function initModels(sequelize) {
|
|
|
199
200
|
Team.hasOne(Scout, { as: 'Scout', foreignKey: 'team_id' });
|
|
200
201
|
Scout.belongsTo(Team, { as: 'team', foreignKey: 'team_id' });
|
|
201
202
|
Team.hasOne(Tactics, { as: 'tactics', foreignKey: 'team_id' });
|
|
203
|
+
// Lineup presets are loaded only by the management API; deliberately NOT in Team.defaultScope so the
|
|
204
|
+
// simulator's team loads are unchanged (it reads the active config from the mirrored Tactics row).
|
|
205
|
+
Team.hasMany(LineupPreset, { as: 'lineupPresets', foreignKey: 'team_id' });
|
|
206
|
+
LineupPreset.belongsTo(Team, { as: 'team', foreignKey: 'team_id' });
|
|
202
207
|
Team.belongsTo(Country, { as: 'country', foreignKey: 'country_id' });
|
|
203
208
|
Team.belongsToMany(Competition, {
|
|
204
209
|
as: 'Competitions',
|
|
@@ -270,6 +275,7 @@ function initModels(sequelize) {
|
|
|
270
275
|
Team,
|
|
271
276
|
TeamReplacement,
|
|
272
277
|
Tactics,
|
|
278
|
+
LineupPreset,
|
|
273
279
|
UserTeam,
|
|
274
280
|
UserCurrency,
|
|
275
281
|
UserPlayerProgress,
|
|
@@ -33,6 +33,7 @@ export * from './scout';
|
|
|
33
33
|
export * from './team';
|
|
34
34
|
export * from './team-replacement';
|
|
35
35
|
export * from './tactics';
|
|
36
|
+
export * from './lineup-preset';
|
|
36
37
|
export * from './user-currency';
|
|
37
38
|
export * from './user-player-progress';
|
|
38
39
|
export * from './gacha-pity';
|
|
@@ -49,6 +49,7 @@ __exportStar(require("./scout"), exports);
|
|
|
49
49
|
__exportStar(require("./team"), exports);
|
|
50
50
|
__exportStar(require("./team-replacement"), exports);
|
|
51
51
|
__exportStar(require("./tactics"), exports);
|
|
52
|
+
__exportStar(require("./lineup-preset"), exports);
|
|
52
53
|
__exportStar(require("./user-currency"), exports);
|
|
53
54
|
__exportStar(require("./user-player-progress"), exports);
|
|
54
55
|
__exportStar(require("./gacha-pity"), exports);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as Sequelize from 'sequelize';
|
|
2
|
+
import { Model, Optional } from 'sequelize';
|
|
3
|
+
import { TeamId, TeamModel } from '.';
|
|
4
|
+
import type { Tactics as ApiTactics } from '../../api';
|
|
5
|
+
export interface LineupPresetAttributes {
|
|
6
|
+
preset_id: string;
|
|
7
|
+
team_id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
is_active: boolean;
|
|
10
|
+
order_index: number;
|
|
11
|
+
config: ApiTactics;
|
|
12
|
+
}
|
|
13
|
+
export type LineupPresetPk = 'preset_id';
|
|
14
|
+
export type LineupPresetId = LineupPresetModel[LineupPresetPk];
|
|
15
|
+
export type LineupPresetOptionalAttributes = 'preset_id' | 'is_active';
|
|
16
|
+
export type LineupPresetCreationAttributes = Optional<LineupPresetAttributes, LineupPresetOptionalAttributes>;
|
|
17
|
+
export declare class LineupPresetModel extends Model<LineupPresetAttributes, LineupPresetCreationAttributes> implements LineupPresetAttributes {
|
|
18
|
+
preset_id: string;
|
|
19
|
+
team_id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
is_active: boolean;
|
|
22
|
+
order_index: number;
|
|
23
|
+
config: ApiTactics;
|
|
24
|
+
team: TeamModel;
|
|
25
|
+
getTeam: Sequelize.BelongsToGetAssociationMixin<TeamModel>;
|
|
26
|
+
setTeam: Sequelize.BelongsToSetAssociationMixin<TeamModel, TeamId>;
|
|
27
|
+
createTeam: Sequelize.BelongsToCreateAssociationMixin<TeamModel>;
|
|
28
|
+
static initModel(sequelize: Sequelize.Sequelize): typeof LineupPresetModel;
|
|
29
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LineupPresetModel = void 0;
|
|
4
|
+
const sequelize_1 = require("sequelize");
|
|
5
|
+
class LineupPresetModel extends sequelize_1.Model {
|
|
6
|
+
static initModel(sequelize) {
|
|
7
|
+
return LineupPresetModel.init({
|
|
8
|
+
preset_id: {
|
|
9
|
+
type: sequelize_1.DataTypes.UUID,
|
|
10
|
+
allowNull: false,
|
|
11
|
+
primaryKey: true,
|
|
12
|
+
defaultValue: sequelize_1.DataTypes.UUIDV4
|
|
13
|
+
},
|
|
14
|
+
team_id: {
|
|
15
|
+
type: sequelize_1.DataTypes.UUID,
|
|
16
|
+
allowNull: false,
|
|
17
|
+
references: {
|
|
18
|
+
model: 'Team',
|
|
19
|
+
key: 'team_id'
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
name: {
|
|
23
|
+
type: sequelize_1.DataTypes.STRING,
|
|
24
|
+
allowNull: false
|
|
25
|
+
},
|
|
26
|
+
is_active: {
|
|
27
|
+
type: sequelize_1.DataTypes.BOOLEAN,
|
|
28
|
+
allowNull: false,
|
|
29
|
+
defaultValue: false
|
|
30
|
+
},
|
|
31
|
+
order_index: {
|
|
32
|
+
type: sequelize_1.DataTypes.INTEGER,
|
|
33
|
+
allowNull: false
|
|
34
|
+
},
|
|
35
|
+
config: {
|
|
36
|
+
type: sequelize_1.DataTypes.JSONB,
|
|
37
|
+
allowNull: false
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
sequelize,
|
|
41
|
+
tableName: 'LineupPreset',
|
|
42
|
+
schema: 'public',
|
|
43
|
+
timestamps: false,
|
|
44
|
+
indexes: [
|
|
45
|
+
{
|
|
46
|
+
name: 'LineupPreset_pk',
|
|
47
|
+
unique: true,
|
|
48
|
+
fields: [
|
|
49
|
+
{ name: 'preset_id' }
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'LineupPreset_team_id_idx',
|
|
54
|
+
fields: [
|
|
55
|
+
{ name: 'team_id' }
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
// At most one active preset per team.
|
|
60
|
+
name: 'LineupPreset_one_active_per_team',
|
|
61
|
+
unique: true,
|
|
62
|
+
fields: [
|
|
63
|
+
{ name: 'team_id' }
|
|
64
|
+
],
|
|
65
|
+
where: { is_active: true }
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.LineupPresetModel = LineupPresetModel;
|
|
@@ -42,4 +42,5 @@ __exportStar(require("./national"), exports);
|
|
|
42
42
|
__exportStar(require("./national-match"), exports);
|
|
43
43
|
__exportStar(require("./team"), exports);
|
|
44
44
|
__exportStar(require("./tactics"), exports);
|
|
45
|
+
__exportStar(require("./lineup-preset"), exports);
|
|
45
46
|
__exportStar(require("./vper"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformToLineupPreset = transformToObject;
|
|
4
|
+
// `config` is already stored as the API Tactics DTO, so a preset row maps to its API shape with no hydration.
|
|
5
|
+
function transformToObject(model) {
|
|
6
|
+
return {
|
|
7
|
+
presetId: model.preset_id,
|
|
8
|
+
name: model.name,
|
|
9
|
+
isActive: model.is_active,
|
|
10
|
+
orderIndex: model.order_index,
|
|
11
|
+
config: model.config
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const globals_1 = require("@jest/globals");
|
|
4
|
+
const lineup_preset_1 = require("./lineup-preset");
|
|
5
|
+
(0, globals_1.describe)('transformToLineupPreset()', () => {
|
|
6
|
+
(0, globals_1.it)('maps preset columns to the API shape and passes config through by reference', () => {
|
|
7
|
+
const config = { lineup: { bench: [] }, substitutionBand: 'TIRED' };
|
|
8
|
+
const preset = (0, lineup_preset_1.transformToLineupPreset)({
|
|
9
|
+
preset_id: 'p1',
|
|
10
|
+
team_id: 't1',
|
|
11
|
+
name: 'Starters',
|
|
12
|
+
is_active: true,
|
|
13
|
+
order_index: 2,
|
|
14
|
+
config
|
|
15
|
+
});
|
|
16
|
+
(0, globals_1.expect)(preset).toEqual({
|
|
17
|
+
presetId: 'p1',
|
|
18
|
+
name: 'Starters',
|
|
19
|
+
isActive: true,
|
|
20
|
+
orderIndex: 2,
|
|
21
|
+
config
|
|
22
|
+
});
|
|
23
|
+
(0, globals_1.expect)(preset.config).toBe(config);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { TacticsAttributes, TacticsModel } from '../models';
|
|
2
2
|
import { Player, Tactics } from '../../service';
|
|
3
|
+
import type { Tactics as ApiTactics } from '../../api';
|
|
3
4
|
declare function transformToAttributes(tactics: Tactics, teamId: string): TacticsAttributes;
|
|
4
5
|
declare function transformToObject(model: TacticsModel, roster: Player[]): Tactics;
|
|
5
|
-
|
|
6
|
+
declare function tacticsColumnsToApiDto(model: TacticsModel): ApiTactics;
|
|
7
|
+
export { transformToObject as transformToTactics, transformToAttributes as transformFromTactics, tacticsColumnsToApiDto };
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformToTactics = transformToObject;
|
|
4
4
|
exports.transformFromTactics = transformToAttributes;
|
|
5
|
+
exports.tacticsColumnsToApiDto = tacticsColumnsToApiDto;
|
|
5
6
|
const service_1 = require("../../service");
|
|
6
7
|
// Back-compat: new rows persist `mode`; rows written before the mode change persist `isPinchServer` (+ a
|
|
7
8
|
// 'NEVER' fatigueBand for the old "never fatigue-sub" state). Derive the mode so existing data keeps working
|
|
@@ -137,3 +138,40 @@ function transformToObject(model, roster) {
|
|
|
137
138
|
}))
|
|
138
139
|
});
|
|
139
140
|
}
|
|
141
|
+
// Serialize a Tactics ROW (db columns) straight to the API Tactics DTO (player references stay as ids; no
|
|
142
|
+
// roster needed). Used to seed a lineup preset's `config` from the existing single tactics row (backfill) and
|
|
143
|
+
// to keep the active preset and the mirrored Tactics row in the same shape. Applies the same legacy fixups as
|
|
144
|
+
// the service transformer: resolve the designated-sub `mode` and drop a legacy 'NEVER' fatigueBand.
|
|
145
|
+
function tacticsColumnsToApiDto(model) {
|
|
146
|
+
return {
|
|
147
|
+
lineup: model.lineup,
|
|
148
|
+
substitutionTolerance: model.substitution_tolerance,
|
|
149
|
+
liberoReplacements: model.libero_replacements,
|
|
150
|
+
pinchServerSubs: model.pinch_server_subs,
|
|
151
|
+
receiveRotationOffset: model.receive_rotation_offset,
|
|
152
|
+
substitutionBand: model.substitution_band,
|
|
153
|
+
secondLibero: model.second_libero,
|
|
154
|
+
liberoSub: model.libero_sub,
|
|
155
|
+
liberoReplacementSets: model.libero_replacement_sets,
|
|
156
|
+
designatedSubs: (model.designated_subs ?? []).map(d => ({
|
|
157
|
+
starterId: d.starterId,
|
|
158
|
+
benchId: d.benchId,
|
|
159
|
+
mode: subModeFromAttributes(d),
|
|
160
|
+
fatigueBand: d.fatigueBand === 'NEVER' ? undefined : d.fatigueBand,
|
|
161
|
+
benchFatigueBand: d.benchFatigueBand,
|
|
162
|
+
conditions: d.conditions,
|
|
163
|
+
conditionLogic: d.conditionLogic,
|
|
164
|
+
sets: d.sets?.map(s => ({
|
|
165
|
+
mode: s.mode,
|
|
166
|
+
benchId: s.benchId,
|
|
167
|
+
fatigueBand: s.fatigueBand,
|
|
168
|
+
benchFatigueBand: s.benchFatigueBand,
|
|
169
|
+
conditions: s.conditions,
|
|
170
|
+
conditionLogic: s.conditionLogic
|
|
171
|
+
}))
|
|
172
|
+
})),
|
|
173
|
+
rotationSystem: model.rotation_system,
|
|
174
|
+
designatedSetters: model.designated_setters,
|
|
175
|
+
offensivePreferences: model.offensive_preferences
|
|
176
|
+
};
|
|
177
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const globals_1 = require("@jest/globals");
|
|
4
|
+
const tactics_1 = require("./tactics");
|
|
5
|
+
const service_1 = require("../../service");
|
|
6
|
+
// Minimal TacticsModel-shaped object; cast through unknown since the transformer only reads columns.
|
|
7
|
+
function makeTactics(designatedSubs) {
|
|
8
|
+
return {
|
|
9
|
+
team_id: 'team-1',
|
|
10
|
+
substitution_tolerance: 10,
|
|
11
|
+
lineup: {
|
|
12
|
+
[service_1.CourtPosition.LEFT_FRONT]: 'lf',
|
|
13
|
+
[service_1.CourtPosition.MIDDLE_FRONT]: 'mf',
|
|
14
|
+
[service_1.CourtPosition.RIGHT_FRONT]: 'rf',
|
|
15
|
+
[service_1.CourtPosition.LEFT_BACK]: 'lb',
|
|
16
|
+
[service_1.CourtPosition.MIDDLE_BACK]: 'mb',
|
|
17
|
+
[service_1.CourtPosition.RIGHT_BACK]: 'rb',
|
|
18
|
+
bench: ['b1', 'b2']
|
|
19
|
+
},
|
|
20
|
+
libero_replacements: ['lf'],
|
|
21
|
+
pinch_server_subs: { starter1: 'server1' },
|
|
22
|
+
receive_rotation_offset: true,
|
|
23
|
+
designated_subs: designatedSubs,
|
|
24
|
+
substitution_band: service_1.EnergyBand.TIRED,
|
|
25
|
+
second_libero: undefined,
|
|
26
|
+
libero_sub: undefined,
|
|
27
|
+
libero_replacement_sets: undefined,
|
|
28
|
+
rotation_system: '5-1',
|
|
29
|
+
designated_setters: ['lf'],
|
|
30
|
+
offensive_preferences: [{ rotation: 1, order: ['lf', 'rf'] }]
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
(0, globals_1.describe)('tacticsColumnsToApiDto()', () => {
|
|
34
|
+
(0, globals_1.it)('passes scalar/array columns through to the API DTO shape', () => {
|
|
35
|
+
const dto = (0, tactics_1.tacticsColumnsToApiDto)(makeTactics([]));
|
|
36
|
+
(0, globals_1.expect)(dto.substitutionTolerance).toBe(10);
|
|
37
|
+
(0, globals_1.expect)(dto.receiveRotationOffset).toBe(true);
|
|
38
|
+
(0, globals_1.expect)(dto.substitutionBand).toBe(service_1.EnergyBand.TIRED);
|
|
39
|
+
(0, globals_1.expect)(dto.rotationSystem).toBe('5-1');
|
|
40
|
+
(0, globals_1.expect)(dto.liberoReplacements).toEqual(['lf']);
|
|
41
|
+
(0, globals_1.expect)(dto.pinchServerSubs).toEqual({ starter1: 'server1' });
|
|
42
|
+
(0, globals_1.expect)(dto.lineup.bench).toEqual(['b1', 'b2']);
|
|
43
|
+
(0, globals_1.expect)(dto.offensivePreferences).toEqual([{ rotation: 1, order: ['lf', 'rf'] }]);
|
|
44
|
+
});
|
|
45
|
+
(0, globals_1.it)("resolves a legacy isPinchServer entry to mode 'PINCH'", () => {
|
|
46
|
+
const dto = (0, tactics_1.tacticsColumnsToApiDto)(makeTactics([
|
|
47
|
+
{ starterId: 's1', benchId: 'b1', isPinchServer: true, conditions: [{ type: 'ASAP' }] }
|
|
48
|
+
]));
|
|
49
|
+
(0, globals_1.expect)(dto.designatedSubs[0].mode).toBe('PINCH');
|
|
50
|
+
});
|
|
51
|
+
(0, globals_1.it)("resolves a legacy 'NEVER' fatigueBand to mode NEVER and drops the band", () => {
|
|
52
|
+
const dto = (0, tactics_1.tacticsColumnsToApiDto)(makeTactics([
|
|
53
|
+
{ starterId: 's1', fatigueBand: 'NEVER' }
|
|
54
|
+
]));
|
|
55
|
+
(0, globals_1.expect)(dto.designatedSubs[0].mode).toBe('NEVER');
|
|
56
|
+
(0, globals_1.expect)(dto.designatedSubs[0].fatigueBand).toBeUndefined();
|
|
57
|
+
});
|
|
58
|
+
(0, globals_1.it)('passes a fatigue entry with its own bands through unchanged', () => {
|
|
59
|
+
const dto = (0, tactics_1.tacticsColumnsToApiDto)(makeTactics([
|
|
60
|
+
{ starterId: 's1', benchId: 'b1', mode: 'FATIGUE', fatigueBand: service_1.EnergyBand.WORN, benchFatigueBand: service_1.EnergyBand.TIRED }
|
|
61
|
+
]));
|
|
62
|
+
(0, globals_1.expect)(dto.designatedSubs[0].mode).toBe('FATIGUE');
|
|
63
|
+
(0, globals_1.expect)(dto.designatedSubs[0].fatigueBand).toBe(service_1.EnergyBand.WORN);
|
|
64
|
+
(0, globals_1.expect)(dto.designatedSubs[0].benchFatigueBand).toBe(service_1.EnergyBand.TIRED);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -3,9 +3,10 @@ export declare enum ReceptionTypeEnum {
|
|
|
3
3
|
DIG = 0,
|
|
4
4
|
OVERHAND = 1,
|
|
5
5
|
ONE_HAND = 2,
|
|
6
|
-
OTHER_BODY_PART = 3
|
|
6
|
+
OTHER_BODY_PART = 3,
|
|
7
|
+
NO_TOUCH = 4
|
|
7
8
|
}
|
|
8
|
-
export type ReceptionType = ReceptionTypeEnum.DIG | ReceptionTypeEnum.OVERHAND | ReceptionTypeEnum.ONE_HAND | ReceptionTypeEnum.OTHER_BODY_PART;
|
|
9
|
+
export type ReceptionType = ReceptionTypeEnum.DIG | ReceptionTypeEnum.OVERHAND | ReceptionTypeEnum.ONE_HAND | ReceptionTypeEnum.OTHER_BODY_PART | ReceptionTypeEnum.NO_TOUCH;
|
|
9
10
|
export declare enum ReceptionFailureEnum {
|
|
10
11
|
NO_FAILURE = 0,
|
|
11
12
|
FAULT = 1,
|
|
@@ -10,6 +10,9 @@ var ReceptionTypeEnum;
|
|
|
10
10
|
ReceptionTypeEnum[ReceptionTypeEnum["OVERHAND"] = 1] = "OVERHAND";
|
|
11
11
|
ReceptionTypeEnum[ReceptionTypeEnum["ONE_HAND"] = 2] = "ONE_HAND";
|
|
12
12
|
ReceptionTypeEnum[ReceptionTypeEnum["OTHER_BODY_PART"] = 3] = "OTHER_BODY_PART";
|
|
13
|
+
// The ball was never touched: a serve so good (vs the receiver's reflex) it drops untouched for a
|
|
14
|
+
// clean ace. Booked as the server's ace only, with no reception attempt/error charged to the passer.
|
|
15
|
+
ReceptionTypeEnum[ReceptionTypeEnum["NO_TOUCH"] = 4] = "NO_TOUCH";
|
|
13
16
|
})(ReceptionTypeEnum || (exports.ReceptionTypeEnum = ReceptionTypeEnum = {}));
|
|
14
17
|
var ReceptionFailureEnum;
|
|
15
18
|
(function (ReceptionFailureEnum) {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ReceptionInputSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const player_1 = require("../../player");
|
|
6
|
-
const receptionTypeValues = [0, 1, 2, 3];
|
|
6
|
+
const receptionTypeValues = [0, 1, 2, 3, 4];
|
|
7
7
|
const receptionFailureValues = [0, 1, 2, 3, 4];
|
|
8
8
|
const courtTargetValues = Array.from({ length: 13 }, (_, i) => i);
|
|
9
9
|
exports.ReceptionInputSchema = zod_1.z.object({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const globals_1 = require("@jest/globals");
|
|
4
|
+
const reception_z_1 = require("./reception.z");
|
|
5
|
+
const base = {
|
|
6
|
+
playerId: '11111111-1111-4111-8111-111111111111',
|
|
7
|
+
score: 10,
|
|
8
|
+
target: 5,
|
|
9
|
+
activeTraits: [],
|
|
10
|
+
failure: 2,
|
|
11
|
+
type: 0
|
|
12
|
+
};
|
|
13
|
+
(0, globals_1.describe)('ReceptionInputSchema', () => {
|
|
14
|
+
(0, globals_1.it)('accepts every reception type 0-4 (incl. NO_TOUCH = 4)', () => {
|
|
15
|
+
for (const type of [0, 1, 2, 3, 4]) {
|
|
16
|
+
(0, globals_1.expect)(reception_z_1.ReceptionInputSchema.safeParse({ ...base, type }).success).toBe(true);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
(0, globals_1.it)('rejects an out-of-range reception type', () => {
|
|
20
|
+
(0, globals_1.expect)(reception_z_1.ReceptionInputSchema.safeParse({ ...base, type: 5 }).success).toBe(false);
|
|
21
|
+
(0, globals_1.expect)(reception_z_1.ReceptionInputSchema.safeParse({ ...base, type: -1 }).success).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
(0, globals_1.it)('rejects an out-of-range reception failure', () => {
|
|
24
|
+
(0, globals_1.expect)(reception_z_1.ReceptionInputSchema.safeParse({ ...base, failure: 5 }).success).toBe(false);
|
|
25
|
+
});
|
|
26
|
+
(0, globals_1.it)('rejects an out-of-range court target', () => {
|
|
27
|
+
(0, globals_1.expect)(reception_z_1.ReceptionInputSchema.safeParse({ ...base, target: 13 }).success).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -4,6 +4,7 @@ import { DeclineProfile } from './decline';
|
|
|
4
4
|
export type TrainingFocus = Stats;
|
|
5
5
|
export declare function getStatCap(rarity: Rarity): number;
|
|
6
6
|
export declare function getRarityMultiplier(rarity: Rarity): number;
|
|
7
|
+
export declare function getImprovementFloor(rarity: Rarity): number;
|
|
7
8
|
export declare function getImprovementThreshold(statTotal: number, rarity: Rarity): number;
|
|
8
9
|
export declare function getCoachMultiplier(rarity: Rarity): number;
|
|
9
10
|
export declare function matchExperience(pointsPlayed: number): number;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getStatCap = getStatCap;
|
|
4
4
|
exports.getRarityMultiplier = getRarityMultiplier;
|
|
5
|
+
exports.getImprovementFloor = getImprovementFloor;
|
|
5
6
|
exports.getImprovementThreshold = getImprovementThreshold;
|
|
6
7
|
exports.getCoachMultiplier = getCoachMultiplier;
|
|
7
8
|
exports.matchExperience = matchExperience;
|
|
@@ -12,9 +13,26 @@ const rarity_1 = require("./rarity");
|
|
|
12
13
|
const performance_stats_1 = require("./performance-stats");
|
|
13
14
|
const stats_1 = require("./stats");
|
|
14
15
|
const decline_1 = require("./decline");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// ── Improvement threshold curve (normalize-to-band) ───────────────────────────
|
|
17
|
+
// The exp a player needs to gain +1 stat. Every rarity improves on ONE shared curve, but measured against
|
|
18
|
+
// ITS OWN range: a freshly generated player sits at the floor (improves the fastest) and the stat cap is the
|
|
19
|
+
// ceiling (improves the slowest). `frac` is the player's position from floor to ceiling, so the same relative
|
|
20
|
+
// progress costs the same for every rarity -- rarer players are no longer penalised for their higher skill
|
|
21
|
+
// floor (which is what the old rarity-multiplier divisor failed to offset). Threshold runs from CURVE_BASE at
|
|
22
|
+
// the floor to CURVE_BASE + CURVE_SCALAR at the cap; CURVE_EXPONENT keeps players fast through most of the
|
|
23
|
+
// band and slows them sharply only near the cap.
|
|
24
|
+
const CURVE_BASE = 180;
|
|
25
|
+
const CURVE_SCALAR = 800;
|
|
26
|
+
const CURVE_EXPONENT = 2;
|
|
27
|
+
// Per-rarity floor of the curve: the mean generated core-6 total (attack + serve + block + reception +
|
|
28
|
+
// setting + stamina) for that rarity, measured from PlayerGenerator. The ceiling is 6 * cap.
|
|
29
|
+
const IMPROVEMENT_FLOOR = {
|
|
30
|
+
[rarity_1.RarityEnum.COMMON]: 180,
|
|
31
|
+
[rarity_1.RarityEnum.RARE]: 296,
|
|
32
|
+
[rarity_1.RarityEnum.LEGENDARY]: 346,
|
|
33
|
+
[rarity_1.RarityEnum.MYTHIC]: 432,
|
|
34
|
+
[rarity_1.RarityEnum.SPECIAL]: 501
|
|
35
|
+
};
|
|
18
36
|
const statCaps = stat_config_1.statCapsJSON;
|
|
19
37
|
function getStatCap(rarity) {
|
|
20
38
|
const entry = statCaps.find(e => e.rarity === rarity);
|
|
@@ -22,16 +40,25 @@ function getStatCap(rarity) {
|
|
|
22
40
|
throw new Error(`UNKNOWN_RARITY: ${rarity}`);
|
|
23
41
|
return entry.cap;
|
|
24
42
|
}
|
|
43
|
+
// Retained for config/reference. No longer used by the improvement curve -- superseded by IMPROVEMENT_FLOOR,
|
|
44
|
+
// which is the per-rarity adjustment now.
|
|
25
45
|
function getRarityMultiplier(rarity) {
|
|
26
46
|
const entry = statCaps.find(e => e.rarity === rarity);
|
|
27
47
|
if (entry == null)
|
|
28
48
|
throw new Error(`UNKNOWN_RARITY: ${rarity}`);
|
|
29
49
|
return entry.rarityMultiplier;
|
|
30
50
|
}
|
|
51
|
+
function getImprovementFloor(rarity) {
|
|
52
|
+
const floor = IMPROVEMENT_FLOOR[rarity];
|
|
53
|
+
if (floor == null)
|
|
54
|
+
throw new Error(`UNKNOWN_RARITY: ${rarity}`);
|
|
55
|
+
return floor;
|
|
56
|
+
}
|
|
31
57
|
function getImprovementThreshold(statTotal, rarity) {
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
58
|
+
const floor = getImprovementFloor(rarity);
|
|
59
|
+
const span = 6 * getStatCap(rarity) - floor;
|
|
60
|
+
const frac = span <= 0 ? 1 : Math.max(0, Math.min(1, (statTotal - floor) / span));
|
|
61
|
+
return Math.round(CURVE_BASE + CURVE_SCALAR * Math.pow(frac, CURVE_EXPONENT));
|
|
35
62
|
}
|
|
36
63
|
const COACH_MULTIPLIERS = {
|
|
37
64
|
[rarity_1.RarityEnum.COMMON]: 2.0,
|
|
@@ -37,24 +37,55 @@ const decline_1 = require("./decline");
|
|
|
37
37
|
});
|
|
38
38
|
// ─── getImprovementThreshold ──────────────────────────────────────────────────
|
|
39
39
|
(0, globals_1.describe)('getImprovementThreshold()', () => {
|
|
40
|
-
(0, globals_1.it)('at
|
|
41
|
-
//
|
|
42
|
-
(0, globals_1.expect)((0, improvement_1.getImprovementThreshold)(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
(0, globals_1.it)('at or below the floor the threshold is CURVE_BASE (180) — the fastest pace', () => {
|
|
41
|
+
// A freshly generated player sits ~at the floor → frac 0 → threshold = 180 for every rarity.
|
|
42
|
+
(0, globals_1.expect)((0, improvement_1.getImprovementThreshold)((0, improvement_1.getImprovementFloor)(rarity_1.RarityEnum.COMMON), rarity_1.RarityEnum.COMMON)).toBe(180);
|
|
43
|
+
(0, globals_1.expect)((0, improvement_1.getImprovementThreshold)(0, rarity_1.RarityEnum.SPECIAL)).toBe(180);
|
|
44
|
+
});
|
|
45
|
+
(0, globals_1.it)('at the ceiling (6 × cap) the threshold is CURVE_BASE + CURVE_SCALAR (980) — the slowest pace', () => {
|
|
46
|
+
(0, globals_1.expect)((0, improvement_1.getImprovementThreshold)(6 * (0, improvement_1.getStatCap)(rarity_1.RarityEnum.COMMON), rarity_1.RarityEnum.COMMON)).toBe(980);
|
|
47
|
+
(0, globals_1.expect)((0, improvement_1.getImprovementThreshold)(6 * (0, improvement_1.getStatCap)(rarity_1.RarityEnum.SPECIAL), rarity_1.RarityEnum.SPECIAL)).toBe(980);
|
|
48
|
+
});
|
|
49
|
+
(0, globals_1.it)('threshold increases as statTotal climbs from the floor toward the cap', () => {
|
|
50
|
+
const floor = (0, improvement_1.getImprovementFloor)(rarity_1.RarityEnum.COMMON);
|
|
51
|
+
const low = (0, improvement_1.getImprovementThreshold)(floor + 10, rarity_1.RarityEnum.COMMON);
|
|
52
|
+
const high = (0, improvement_1.getImprovementThreshold)(floor + 120, rarity_1.RarityEnum.COMMON);
|
|
49
53
|
(0, globals_1.expect)(high).toBeGreaterThan(low);
|
|
50
54
|
});
|
|
51
|
-
(0, globals_1.it)('
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
+
(0, globals_1.it)('is equivalent across rarities at the same position within their band', () => {
|
|
56
|
+
// Halfway from floor to ceiling must cost the same for every rarity — the whole point of the rework.
|
|
57
|
+
const midThreshold = (rarity) => {
|
|
58
|
+
const floor = (0, improvement_1.getImprovementFloor)(rarity);
|
|
59
|
+
const mid = floor + (6 * (0, improvement_1.getStatCap)(rarity) - floor) / 2;
|
|
60
|
+
return (0, improvement_1.getImprovementThreshold)(mid, rarity);
|
|
61
|
+
};
|
|
62
|
+
const common = midThreshold(rarity_1.RarityEnum.COMMON);
|
|
63
|
+
(0, globals_1.expect)(midThreshold(rarity_1.RarityEnum.RARE)).toBe(common);
|
|
64
|
+
(0, globals_1.expect)(midThreshold(rarity_1.RarityEnum.LEGENDARY)).toBe(common);
|
|
65
|
+
(0, globals_1.expect)(midThreshold(rarity_1.RarityEnum.SPECIAL)).toBe(common);
|
|
55
66
|
});
|
|
56
67
|
(0, globals_1.it)('returns an integer (Math.round applied)', () => {
|
|
57
|
-
(0, globals_1.expect)(Number.isInteger((0, improvement_1.getImprovementThreshold)(
|
|
68
|
+
(0, globals_1.expect)(Number.isInteger((0, improvement_1.getImprovementThreshold)(200, rarity_1.RarityEnum.RARE))).toBe(true);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
// ─── getImprovementFloor ──────────────────────────────────────────────────────
|
|
72
|
+
(0, globals_1.describe)('getImprovementFloor()', () => {
|
|
73
|
+
globals_1.it.each([
|
|
74
|
+
[rarity_1.RarityEnum.COMMON, 180],
|
|
75
|
+
[rarity_1.RarityEnum.RARE, 296],
|
|
76
|
+
[rarity_1.RarityEnum.LEGENDARY, 346],
|
|
77
|
+
[rarity_1.RarityEnum.MYTHIC, 432],
|
|
78
|
+
[rarity_1.RarityEnum.SPECIAL, 501]
|
|
79
|
+
])('%s → floor %i', (rarity, expected) => {
|
|
80
|
+
(0, globals_1.expect)((0, improvement_1.getImprovementFloor)(rarity)).toBe(expected);
|
|
81
|
+
});
|
|
82
|
+
(0, globals_1.it)('throws UNKNOWN_RARITY for an unrecognised rarity string', () => {
|
|
83
|
+
(0, globals_1.expect)(() => (0, improvement_1.getImprovementFloor)('DIVINE')).toThrow('UNKNOWN_RARITY');
|
|
84
|
+
});
|
|
85
|
+
(0, globals_1.it)('every floor is below its rarity ceiling (6 × cap)', () => {
|
|
86
|
+
for (const rarity of [rarity_1.RarityEnum.COMMON, rarity_1.RarityEnum.RARE, rarity_1.RarityEnum.LEGENDARY, rarity_1.RarityEnum.MYTHIC, rarity_1.RarityEnum.SPECIAL]) {
|
|
87
|
+
(0, globals_1.expect)((0, improvement_1.getImprovementFloor)(rarity)).toBeLessThan(6 * (0, improvement_1.getStatCap)(rarity));
|
|
88
|
+
}
|
|
58
89
|
});
|
|
59
90
|
});
|
|
60
91
|
// ─── getCoachMultiplier ───────────────────────────────────────────────────────
|
|
@@ -73,6 +73,25 @@ const test_helpers_1 = require("../../test-helpers");
|
|
|
73
73
|
});
|
|
74
74
|
(0, globals_1.expect)(res.success).toBe(true);
|
|
75
75
|
});
|
|
76
|
+
(0, globals_1.it)("accepts a fatigue-mode entry with the substitute's own benchFatigueBand", () => {
|
|
77
|
+
const res = designated_sub_z_1.DesignatedSubSchema.safeParse({
|
|
78
|
+
starter,
|
|
79
|
+
bench,
|
|
80
|
+
mode: 'FATIGUE',
|
|
81
|
+
fatigueBand: energy_band_1.EnergyBand.WORN,
|
|
82
|
+
benchFatigueBand: energy_band_1.EnergyBand.TIRED
|
|
83
|
+
});
|
|
84
|
+
(0, globals_1.expect)(res.success).toBe(true);
|
|
85
|
+
});
|
|
86
|
+
(0, globals_1.it)('rejects benchFatigueBand = NEVER (only the team default band may be NEVER)', () => {
|
|
87
|
+
const res = designated_sub_z_1.DesignatedSubSchema.safeParse({
|
|
88
|
+
starter,
|
|
89
|
+
bench,
|
|
90
|
+
mode: 'FATIGUE',
|
|
91
|
+
benchFatigueBand: 'NEVER'
|
|
92
|
+
});
|
|
93
|
+
(0, globals_1.expect)(res.success).toBe(false);
|
|
94
|
+
});
|
|
76
95
|
(0, globals_1.it)('accepts a fatigue-mode entry with no bench (falls back to closest sub)', () => {
|
|
77
96
|
const res = designated_sub_z_1.DesignatedSubSchema.safeParse({
|
|
78
97
|
starter,
|
|
@@ -114,6 +114,13 @@ export interface Tactics {
|
|
|
114
114
|
designatedSetters: string[];
|
|
115
115
|
offensivePreferences: ApiOffensivePreference[];
|
|
116
116
|
}
|
|
117
|
+
export interface ApiLineupPreset {
|
|
118
|
+
presetId: string;
|
|
119
|
+
name: string;
|
|
120
|
+
isActive: boolean;
|
|
121
|
+
orderIndex: number;
|
|
122
|
+
config: Tactics;
|
|
123
|
+
}
|
|
117
124
|
export type Team = Omit<DataProps<_Team>, 'roster' | '_rating' | 'rating' | 'tactics'> & {
|
|
118
125
|
roster: Player[];
|
|
119
126
|
rating: {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { AuthIdentityModel, AuthSessionModel, AuthUserModel, BoxScoreModel, CoachModel, ScoutModel, BoxScoreTotalsModel, CompetitionChampionModel, CurrencyTransactionModel, GachaPityModel, GachaPullHistoryModel, WishlistModel, UserSettingsModel, CompetitionMatchModel, CompetitionMVPModel, CompetitionModel, CompetitionStandingsMatchModel, CompetitionStandingsModel, CompetitionTeamsModel, CountryModel, DivisionModel, DivisionSeasonModel, IterationModel, LeagueModel, MatchModel, MatchRatingModel, MatchResultModel, MatchSetModel, PerformanceStatsModel, PlayerModel, PlayerImprovementLogModel, PlayerTeamModel, RetiredPlayerModel, PromotionMatchModel, RegionQualifierModel, NationalCountryModel, RallyModel, TacticsModel, TeamModel, TeamReplacementModel, UserCurrencyModel, UserPlayerProgressModel, UserPullGrantModel, UserTeamModel, VPERModel, NotificationModel, AppConfigModel, LegacyTeamFlagModel } from './models';
|
|
1
|
+
import { AuthIdentityModel, AuthSessionModel, AuthUserModel, BoxScoreModel, CoachModel, ScoutModel, BoxScoreTotalsModel, CompetitionChampionModel, CurrencyTransactionModel, GachaPityModel, GachaPullHistoryModel, WishlistModel, UserSettingsModel, CompetitionMatchModel, CompetitionMVPModel, CompetitionModel, CompetitionStandingsMatchModel, CompetitionStandingsModel, CompetitionTeamsModel, CountryModel, DivisionModel, DivisionSeasonModel, IterationModel, LeagueModel, MatchModel, MatchRatingModel, MatchResultModel, MatchSetModel, PerformanceStatsModel, PlayerModel, PlayerImprovementLogModel, PlayerTeamModel, RetiredPlayerModel, PromotionMatchModel, RegionQualifierModel, NationalCountryModel, RallyModel, TacticsModel, LineupPresetModel, TeamModel, TeamReplacementModel, UserCurrencyModel, UserPlayerProgressModel, UserPullGrantModel, UserTeamModel, VPERModel, NotificationModel, AppConfigModel, LegacyTeamFlagModel } from './models';
|
|
2
2
|
export function initModels(sequelize) {
|
|
3
3
|
const Coach = CoachModel.initModel(sequelize);
|
|
4
4
|
const Scout = ScoutModel.initModel(sequelize);
|
|
5
5
|
const CurrencyTransaction = CurrencyTransactionModel.initModel(sequelize);
|
|
6
6
|
const Tactics = TacticsModel.initModel(sequelize);
|
|
7
|
+
const LineupPreset = LineupPresetModel.initModel(sequelize);
|
|
7
8
|
const AuthUser = AuthUserModel.initModel(sequelize);
|
|
8
9
|
const UserCurrency = UserCurrencyModel.initModel(sequelize);
|
|
9
10
|
const UserPlayerProgress = UserPlayerProgressModel.initModel(sequelize);
|
|
@@ -196,6 +197,10 @@ export function initModels(sequelize) {
|
|
|
196
197
|
Team.hasOne(Scout, { as: 'Scout', foreignKey: 'team_id' });
|
|
197
198
|
Scout.belongsTo(Team, { as: 'team', foreignKey: 'team_id' });
|
|
198
199
|
Team.hasOne(Tactics, { as: 'tactics', foreignKey: 'team_id' });
|
|
200
|
+
// Lineup presets are loaded only by the management API; deliberately NOT in Team.defaultScope so the
|
|
201
|
+
// simulator's team loads are unchanged (it reads the active config from the mirrored Tactics row).
|
|
202
|
+
Team.hasMany(LineupPreset, { as: 'lineupPresets', foreignKey: 'team_id' });
|
|
203
|
+
LineupPreset.belongsTo(Team, { as: 'team', foreignKey: 'team_id' });
|
|
199
204
|
Team.belongsTo(Country, { as: 'country', foreignKey: 'country_id' });
|
|
200
205
|
Team.belongsToMany(Competition, {
|
|
201
206
|
as: 'Competitions',
|
|
@@ -267,6 +272,7 @@ export function initModels(sequelize) {
|
|
|
267
272
|
Team,
|
|
268
273
|
TeamReplacement,
|
|
269
274
|
Tactics,
|
|
275
|
+
LineupPreset,
|
|
270
276
|
UserTeam,
|
|
271
277
|
UserCurrency,
|
|
272
278
|
UserPlayerProgress,
|
|
@@ -33,6 +33,7 @@ export * from './scout';
|
|
|
33
33
|
export * from './team';
|
|
34
34
|
export * from './team-replacement';
|
|
35
35
|
export * from './tactics';
|
|
36
|
+
export * from './lineup-preset';
|
|
36
37
|
export * from './user-currency';
|
|
37
38
|
export * from './user-player-progress';
|
|
38
39
|
export * from './gacha-pity';
|
|
@@ -33,6 +33,7 @@ export * from './scout';
|
|
|
33
33
|
export * from './team';
|
|
34
34
|
export * from './team-replacement';
|
|
35
35
|
export * from './tactics';
|
|
36
|
+
export * from './lineup-preset';
|
|
36
37
|
export * from './user-currency';
|
|
37
38
|
export * from './user-player-progress';
|
|
38
39
|
export * from './gacha-pity';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as Sequelize from 'sequelize';
|
|
2
|
+
import { Model, Optional } from 'sequelize';
|
|
3
|
+
import { TeamId, TeamModel } from '.';
|
|
4
|
+
import type { Tactics as ApiTactics } from '../../api';
|
|
5
|
+
export interface LineupPresetAttributes {
|
|
6
|
+
preset_id: string;
|
|
7
|
+
team_id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
is_active: boolean;
|
|
10
|
+
order_index: number;
|
|
11
|
+
config: ApiTactics;
|
|
12
|
+
}
|
|
13
|
+
export type LineupPresetPk = 'preset_id';
|
|
14
|
+
export type LineupPresetId = LineupPresetModel[LineupPresetPk];
|
|
15
|
+
export type LineupPresetOptionalAttributes = 'preset_id' | 'is_active';
|
|
16
|
+
export type LineupPresetCreationAttributes = Optional<LineupPresetAttributes, LineupPresetOptionalAttributes>;
|
|
17
|
+
export declare class LineupPresetModel extends Model<LineupPresetAttributes, LineupPresetCreationAttributes> implements LineupPresetAttributes {
|
|
18
|
+
preset_id: string;
|
|
19
|
+
team_id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
is_active: boolean;
|
|
22
|
+
order_index: number;
|
|
23
|
+
config: ApiTactics;
|
|
24
|
+
team: TeamModel;
|
|
25
|
+
getTeam: Sequelize.BelongsToGetAssociationMixin<TeamModel>;
|
|
26
|
+
setTeam: Sequelize.BelongsToSetAssociationMixin<TeamModel, TeamId>;
|
|
27
|
+
createTeam: Sequelize.BelongsToCreateAssociationMixin<TeamModel>;
|
|
28
|
+
static initModel(sequelize: Sequelize.Sequelize): typeof LineupPresetModel;
|
|
29
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { DataTypes, Model } from 'sequelize';
|
|
2
|
+
export class LineupPresetModel extends Model {
|
|
3
|
+
static initModel(sequelize) {
|
|
4
|
+
return LineupPresetModel.init({
|
|
5
|
+
preset_id: {
|
|
6
|
+
type: DataTypes.UUID,
|
|
7
|
+
allowNull: false,
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
defaultValue: DataTypes.UUIDV4
|
|
10
|
+
},
|
|
11
|
+
team_id: {
|
|
12
|
+
type: DataTypes.UUID,
|
|
13
|
+
allowNull: false,
|
|
14
|
+
references: {
|
|
15
|
+
model: 'Team',
|
|
16
|
+
key: 'team_id'
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
name: {
|
|
20
|
+
type: DataTypes.STRING,
|
|
21
|
+
allowNull: false
|
|
22
|
+
},
|
|
23
|
+
is_active: {
|
|
24
|
+
type: DataTypes.BOOLEAN,
|
|
25
|
+
allowNull: false,
|
|
26
|
+
defaultValue: false
|
|
27
|
+
},
|
|
28
|
+
order_index: {
|
|
29
|
+
type: DataTypes.INTEGER,
|
|
30
|
+
allowNull: false
|
|
31
|
+
},
|
|
32
|
+
config: {
|
|
33
|
+
type: DataTypes.JSONB,
|
|
34
|
+
allowNull: false
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
sequelize,
|
|
38
|
+
tableName: 'LineupPreset',
|
|
39
|
+
schema: 'public',
|
|
40
|
+
timestamps: false,
|
|
41
|
+
indexes: [
|
|
42
|
+
{
|
|
43
|
+
name: 'LineupPreset_pk',
|
|
44
|
+
unique: true,
|
|
45
|
+
fields: [
|
|
46
|
+
{ name: 'preset_id' }
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'LineupPreset_team_id_idx',
|
|
51
|
+
fields: [
|
|
52
|
+
{ name: 'team_id' }
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
// At most one active preset per team.
|
|
57
|
+
name: 'LineupPreset_one_active_per_team',
|
|
58
|
+
unique: true,
|
|
59
|
+
fields: [
|
|
60
|
+
{ name: 'team_id' }
|
|
61
|
+
],
|
|
62
|
+
where: { is_active: true }
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// `config` is already stored as the API Tactics DTO, so a preset row maps to its API shape with no hydration.
|
|
2
|
+
function transformToObject(model) {
|
|
3
|
+
return {
|
|
4
|
+
presetId: model.preset_id,
|
|
5
|
+
name: model.name,
|
|
6
|
+
isActive: model.is_active,
|
|
7
|
+
orderIndex: model.order_index,
|
|
8
|
+
config: model.config
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export { transformToObject as transformToLineupPreset };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, it, expect } from '@jest/globals';
|
|
2
|
+
import { transformToLineupPreset } from './lineup-preset';
|
|
3
|
+
describe('transformToLineupPreset()', () => {
|
|
4
|
+
it('maps preset columns to the API shape and passes config through by reference', () => {
|
|
5
|
+
const config = { lineup: { bench: [] }, substitutionBand: 'TIRED' };
|
|
6
|
+
const preset = transformToLineupPreset({
|
|
7
|
+
preset_id: 'p1',
|
|
8
|
+
team_id: 't1',
|
|
9
|
+
name: 'Starters',
|
|
10
|
+
is_active: true,
|
|
11
|
+
order_index: 2,
|
|
12
|
+
config
|
|
13
|
+
});
|
|
14
|
+
expect(preset).toEqual({
|
|
15
|
+
presetId: 'p1',
|
|
16
|
+
name: 'Starters',
|
|
17
|
+
isActive: true,
|
|
18
|
+
orderIndex: 2,
|
|
19
|
+
config
|
|
20
|
+
});
|
|
21
|
+
expect(preset.config).toBe(config);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { TacticsAttributes, TacticsModel } from '../models';
|
|
2
2
|
import { Player, Tactics } from '../../service';
|
|
3
|
+
import type { Tactics as ApiTactics } from '../../api';
|
|
3
4
|
declare function transformToAttributes(tactics: Tactics, teamId: string): TacticsAttributes;
|
|
4
5
|
declare function transformToObject(model: TacticsModel, roster: Player[]): Tactics;
|
|
5
|
-
|
|
6
|
+
declare function tacticsColumnsToApiDto(model: TacticsModel): ApiTactics;
|
|
7
|
+
export { transformToObject as transformToTactics, transformToAttributes as transformFromTactics, tacticsColumnsToApiDto };
|
|
@@ -133,4 +133,41 @@ function transformToObject(model, roster) {
|
|
|
133
133
|
}))
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
// Serialize a Tactics ROW (db columns) straight to the API Tactics DTO (player references stay as ids; no
|
|
137
|
+
// roster needed). Used to seed a lineup preset's `config` from the existing single tactics row (backfill) and
|
|
138
|
+
// to keep the active preset and the mirrored Tactics row in the same shape. Applies the same legacy fixups as
|
|
139
|
+
// the service transformer: resolve the designated-sub `mode` and drop a legacy 'NEVER' fatigueBand.
|
|
140
|
+
function tacticsColumnsToApiDto(model) {
|
|
141
|
+
return {
|
|
142
|
+
lineup: model.lineup,
|
|
143
|
+
substitutionTolerance: model.substitution_tolerance,
|
|
144
|
+
liberoReplacements: model.libero_replacements,
|
|
145
|
+
pinchServerSubs: model.pinch_server_subs,
|
|
146
|
+
receiveRotationOffset: model.receive_rotation_offset,
|
|
147
|
+
substitutionBand: model.substitution_band,
|
|
148
|
+
secondLibero: model.second_libero,
|
|
149
|
+
liberoSub: model.libero_sub,
|
|
150
|
+
liberoReplacementSets: model.libero_replacement_sets,
|
|
151
|
+
designatedSubs: (model.designated_subs ?? []).map(d => ({
|
|
152
|
+
starterId: d.starterId,
|
|
153
|
+
benchId: d.benchId,
|
|
154
|
+
mode: subModeFromAttributes(d),
|
|
155
|
+
fatigueBand: d.fatigueBand === 'NEVER' ? undefined : d.fatigueBand,
|
|
156
|
+
benchFatigueBand: d.benchFatigueBand,
|
|
157
|
+
conditions: d.conditions,
|
|
158
|
+
conditionLogic: d.conditionLogic,
|
|
159
|
+
sets: d.sets?.map(s => ({
|
|
160
|
+
mode: s.mode,
|
|
161
|
+
benchId: s.benchId,
|
|
162
|
+
fatigueBand: s.fatigueBand,
|
|
163
|
+
benchFatigueBand: s.benchFatigueBand,
|
|
164
|
+
conditions: s.conditions,
|
|
165
|
+
conditionLogic: s.conditionLogic
|
|
166
|
+
}))
|
|
167
|
+
})),
|
|
168
|
+
rotationSystem: model.rotation_system,
|
|
169
|
+
designatedSetters: model.designated_setters,
|
|
170
|
+
offensivePreferences: model.offensive_preferences
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
export { transformToObject as transformToTactics, transformToAttributes as transformFromTactics, tacticsColumnsToApiDto };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, it, expect } from '@jest/globals';
|
|
2
|
+
import { tacticsColumnsToApiDto } from './tactics';
|
|
3
|
+
import { CourtPosition, EnergyBand } from '../../service';
|
|
4
|
+
// Minimal TacticsModel-shaped object; cast through unknown since the transformer only reads columns.
|
|
5
|
+
function makeTactics(designatedSubs) {
|
|
6
|
+
return {
|
|
7
|
+
team_id: 'team-1',
|
|
8
|
+
substitution_tolerance: 10,
|
|
9
|
+
lineup: {
|
|
10
|
+
[CourtPosition.LEFT_FRONT]: 'lf',
|
|
11
|
+
[CourtPosition.MIDDLE_FRONT]: 'mf',
|
|
12
|
+
[CourtPosition.RIGHT_FRONT]: 'rf',
|
|
13
|
+
[CourtPosition.LEFT_BACK]: 'lb',
|
|
14
|
+
[CourtPosition.MIDDLE_BACK]: 'mb',
|
|
15
|
+
[CourtPosition.RIGHT_BACK]: 'rb',
|
|
16
|
+
bench: ['b1', 'b2']
|
|
17
|
+
},
|
|
18
|
+
libero_replacements: ['lf'],
|
|
19
|
+
pinch_server_subs: { starter1: 'server1' },
|
|
20
|
+
receive_rotation_offset: true,
|
|
21
|
+
designated_subs: designatedSubs,
|
|
22
|
+
substitution_band: EnergyBand.TIRED,
|
|
23
|
+
second_libero: undefined,
|
|
24
|
+
libero_sub: undefined,
|
|
25
|
+
libero_replacement_sets: undefined,
|
|
26
|
+
rotation_system: '5-1',
|
|
27
|
+
designated_setters: ['lf'],
|
|
28
|
+
offensive_preferences: [{ rotation: 1, order: ['lf', 'rf'] }]
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
describe('tacticsColumnsToApiDto()', () => {
|
|
32
|
+
it('passes scalar/array columns through to the API DTO shape', () => {
|
|
33
|
+
const dto = tacticsColumnsToApiDto(makeTactics([]));
|
|
34
|
+
expect(dto.substitutionTolerance).toBe(10);
|
|
35
|
+
expect(dto.receiveRotationOffset).toBe(true);
|
|
36
|
+
expect(dto.substitutionBand).toBe(EnergyBand.TIRED);
|
|
37
|
+
expect(dto.rotationSystem).toBe('5-1');
|
|
38
|
+
expect(dto.liberoReplacements).toEqual(['lf']);
|
|
39
|
+
expect(dto.pinchServerSubs).toEqual({ starter1: 'server1' });
|
|
40
|
+
expect(dto.lineup.bench).toEqual(['b1', 'b2']);
|
|
41
|
+
expect(dto.offensivePreferences).toEqual([{ rotation: 1, order: ['lf', 'rf'] }]);
|
|
42
|
+
});
|
|
43
|
+
it("resolves a legacy isPinchServer entry to mode 'PINCH'", () => {
|
|
44
|
+
const dto = tacticsColumnsToApiDto(makeTactics([
|
|
45
|
+
{ starterId: 's1', benchId: 'b1', isPinchServer: true, conditions: [{ type: 'ASAP' }] }
|
|
46
|
+
]));
|
|
47
|
+
expect(dto.designatedSubs[0].mode).toBe('PINCH');
|
|
48
|
+
});
|
|
49
|
+
it("resolves a legacy 'NEVER' fatigueBand to mode NEVER and drops the band", () => {
|
|
50
|
+
const dto = tacticsColumnsToApiDto(makeTactics([
|
|
51
|
+
{ starterId: 's1', fatigueBand: 'NEVER' }
|
|
52
|
+
]));
|
|
53
|
+
expect(dto.designatedSubs[0].mode).toBe('NEVER');
|
|
54
|
+
expect(dto.designatedSubs[0].fatigueBand).toBeUndefined();
|
|
55
|
+
});
|
|
56
|
+
it('passes a fatigue entry with its own bands through unchanged', () => {
|
|
57
|
+
const dto = tacticsColumnsToApiDto(makeTactics([
|
|
58
|
+
{ starterId: 's1', benchId: 'b1', mode: 'FATIGUE', fatigueBand: EnergyBand.WORN, benchFatigueBand: EnergyBand.TIRED }
|
|
59
|
+
]));
|
|
60
|
+
expect(dto.designatedSubs[0].mode).toBe('FATIGUE');
|
|
61
|
+
expect(dto.designatedSubs[0].fatigueBand).toBe(EnergyBand.WORN);
|
|
62
|
+
expect(dto.designatedSubs[0].benchFatigueBand).toBe(EnergyBand.TIRED);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -3,9 +3,10 @@ export declare enum ReceptionTypeEnum {
|
|
|
3
3
|
DIG = 0,
|
|
4
4
|
OVERHAND = 1,
|
|
5
5
|
ONE_HAND = 2,
|
|
6
|
-
OTHER_BODY_PART = 3
|
|
6
|
+
OTHER_BODY_PART = 3,
|
|
7
|
+
NO_TOUCH = 4
|
|
7
8
|
}
|
|
8
|
-
export type ReceptionType = ReceptionTypeEnum.DIG | ReceptionTypeEnum.OVERHAND | ReceptionTypeEnum.ONE_HAND | ReceptionTypeEnum.OTHER_BODY_PART;
|
|
9
|
+
export type ReceptionType = ReceptionTypeEnum.DIG | ReceptionTypeEnum.OVERHAND | ReceptionTypeEnum.ONE_HAND | ReceptionTypeEnum.OTHER_BODY_PART | ReceptionTypeEnum.NO_TOUCH;
|
|
9
10
|
export declare enum ReceptionFailureEnum {
|
|
10
11
|
NO_FAILURE = 0,
|
|
11
12
|
FAULT = 1,
|
|
@@ -7,6 +7,9 @@ export var ReceptionTypeEnum;
|
|
|
7
7
|
ReceptionTypeEnum[ReceptionTypeEnum["OVERHAND"] = 1] = "OVERHAND";
|
|
8
8
|
ReceptionTypeEnum[ReceptionTypeEnum["ONE_HAND"] = 2] = "ONE_HAND";
|
|
9
9
|
ReceptionTypeEnum[ReceptionTypeEnum["OTHER_BODY_PART"] = 3] = "OTHER_BODY_PART";
|
|
10
|
+
// The ball was never touched: a serve so good (vs the receiver's reflex) it drops untouched for a
|
|
11
|
+
// clean ace. Booked as the server's ace only, with no reception attempt/error charged to the passer.
|
|
12
|
+
ReceptionTypeEnum[ReceptionTypeEnum["NO_TOUCH"] = 4] = "NO_TOUCH";
|
|
10
13
|
})(ReceptionTypeEnum || (ReceptionTypeEnum = {}));
|
|
11
14
|
export var ReceptionFailureEnum;
|
|
12
15
|
(function (ReceptionFailureEnum) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { TraitEnum } from '../../player';
|
|
3
|
-
const receptionTypeValues = [0, 1, 2, 3];
|
|
3
|
+
const receptionTypeValues = [0, 1, 2, 3, 4];
|
|
4
4
|
const receptionFailureValues = [0, 1, 2, 3, 4];
|
|
5
5
|
const courtTargetValues = Array.from({ length: 13 }, (_, i) => i);
|
|
6
6
|
export const ReceptionInputSchema = z.object({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, it, expect } from '@jest/globals';
|
|
2
|
+
import { ReceptionInputSchema } from './reception.z';
|
|
3
|
+
const base = {
|
|
4
|
+
playerId: '11111111-1111-4111-8111-111111111111',
|
|
5
|
+
score: 10,
|
|
6
|
+
target: 5,
|
|
7
|
+
activeTraits: [],
|
|
8
|
+
failure: 2,
|
|
9
|
+
type: 0
|
|
10
|
+
};
|
|
11
|
+
describe('ReceptionInputSchema', () => {
|
|
12
|
+
it('accepts every reception type 0-4 (incl. NO_TOUCH = 4)', () => {
|
|
13
|
+
for (const type of [0, 1, 2, 3, 4]) {
|
|
14
|
+
expect(ReceptionInputSchema.safeParse({ ...base, type }).success).toBe(true);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
it('rejects an out-of-range reception type', () => {
|
|
18
|
+
expect(ReceptionInputSchema.safeParse({ ...base, type: 5 }).success).toBe(false);
|
|
19
|
+
expect(ReceptionInputSchema.safeParse({ ...base, type: -1 }).success).toBe(false);
|
|
20
|
+
});
|
|
21
|
+
it('rejects an out-of-range reception failure', () => {
|
|
22
|
+
expect(ReceptionInputSchema.safeParse({ ...base, failure: 5 }).success).toBe(false);
|
|
23
|
+
});
|
|
24
|
+
it('rejects an out-of-range court target', () => {
|
|
25
|
+
expect(ReceptionInputSchema.safeParse({ ...base, target: 13 }).success).toBe(false);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -4,6 +4,7 @@ import { DeclineProfile } from './decline';
|
|
|
4
4
|
export type TrainingFocus = Stats;
|
|
5
5
|
export declare function getStatCap(rarity: Rarity): number;
|
|
6
6
|
export declare function getRarityMultiplier(rarity: Rarity): number;
|
|
7
|
+
export declare function getImprovementFloor(rarity: Rarity): number;
|
|
7
8
|
export declare function getImprovementThreshold(statTotal: number, rarity: Rarity): number;
|
|
8
9
|
export declare function getCoachMultiplier(rarity: Rarity): number;
|
|
9
10
|
export declare function matchExperience(pointsPlayed: number): number;
|
|
@@ -3,9 +3,26 @@ import { RarityEnum } from './rarity';
|
|
|
3
3
|
import { performanceStatKeys } from './performance-stats';
|
|
4
4
|
import { getMultipliers } from './stats';
|
|
5
5
|
import { youthMultiplier } from './decline';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
// ── Improvement threshold curve (normalize-to-band) ───────────────────────────
|
|
7
|
+
// The exp a player needs to gain +1 stat. Every rarity improves on ONE shared curve, but measured against
|
|
8
|
+
// ITS OWN range: a freshly generated player sits at the floor (improves the fastest) and the stat cap is the
|
|
9
|
+
// ceiling (improves the slowest). `frac` is the player's position from floor to ceiling, so the same relative
|
|
10
|
+
// progress costs the same for every rarity -- rarer players are no longer penalised for their higher skill
|
|
11
|
+
// floor (which is what the old rarity-multiplier divisor failed to offset). Threshold runs from CURVE_BASE at
|
|
12
|
+
// the floor to CURVE_BASE + CURVE_SCALAR at the cap; CURVE_EXPONENT keeps players fast through most of the
|
|
13
|
+
// band and slows them sharply only near the cap.
|
|
14
|
+
const CURVE_BASE = 180;
|
|
15
|
+
const CURVE_SCALAR = 800;
|
|
16
|
+
const CURVE_EXPONENT = 2;
|
|
17
|
+
// Per-rarity floor of the curve: the mean generated core-6 total (attack + serve + block + reception +
|
|
18
|
+
// setting + stamina) for that rarity, measured from PlayerGenerator. The ceiling is 6 * cap.
|
|
19
|
+
const IMPROVEMENT_FLOOR = {
|
|
20
|
+
[RarityEnum.COMMON]: 180,
|
|
21
|
+
[RarityEnum.RARE]: 296,
|
|
22
|
+
[RarityEnum.LEGENDARY]: 346,
|
|
23
|
+
[RarityEnum.MYTHIC]: 432,
|
|
24
|
+
[RarityEnum.SPECIAL]: 501
|
|
25
|
+
};
|
|
9
26
|
const statCaps = statCapsJSON;
|
|
10
27
|
export function getStatCap(rarity) {
|
|
11
28
|
const entry = statCaps.find(e => e.rarity === rarity);
|
|
@@ -13,16 +30,25 @@ export function getStatCap(rarity) {
|
|
|
13
30
|
throw new Error(`UNKNOWN_RARITY: ${rarity}`);
|
|
14
31
|
return entry.cap;
|
|
15
32
|
}
|
|
33
|
+
// Retained for config/reference. No longer used by the improvement curve -- superseded by IMPROVEMENT_FLOOR,
|
|
34
|
+
// which is the per-rarity adjustment now.
|
|
16
35
|
export function getRarityMultiplier(rarity) {
|
|
17
36
|
const entry = statCaps.find(e => e.rarity === rarity);
|
|
18
37
|
if (entry == null)
|
|
19
38
|
throw new Error(`UNKNOWN_RARITY: ${rarity}`);
|
|
20
39
|
return entry.rarityMultiplier;
|
|
21
40
|
}
|
|
41
|
+
export function getImprovementFloor(rarity) {
|
|
42
|
+
const floor = IMPROVEMENT_FLOOR[rarity];
|
|
43
|
+
if (floor == null)
|
|
44
|
+
throw new Error(`UNKNOWN_RARITY: ${rarity}`);
|
|
45
|
+
return floor;
|
|
46
|
+
}
|
|
22
47
|
export function getImprovementThreshold(statTotal, rarity) {
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
48
|
+
const floor = getImprovementFloor(rarity);
|
|
49
|
+
const span = 6 * getStatCap(rarity) - floor;
|
|
50
|
+
const frac = span <= 0 ? 1 : Math.max(0, Math.min(1, (statTotal - floor) / span));
|
|
51
|
+
return Math.round(CURVE_BASE + CURVE_SCALAR * Math.pow(frac, CURVE_EXPONENT));
|
|
26
52
|
}
|
|
27
53
|
const COACH_MULTIPLIERS = {
|
|
28
54
|
[RarityEnum.COMMON]: 2.0,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect } from '@jest/globals';
|
|
2
2
|
import { RarityEnum } from './rarity';
|
|
3
|
-
import { getStatCap, getRarityMultiplier, getImprovementThreshold, getCoachMultiplier, selectImprovableStat, matchExperience, experienceGained } from './improvement';
|
|
3
|
+
import { getStatCap, getRarityMultiplier, getImprovementFloor, getImprovementThreshold, getCoachMultiplier, selectImprovableStat, matchExperience, experienceGained } from './improvement';
|
|
4
4
|
import { StatsEnum } from './stats';
|
|
5
5
|
import { DeclineProfileEnum } from './decline';
|
|
6
6
|
// ─── getStatCap ───────────────────────────────────────────────────────────────
|
|
@@ -35,24 +35,55 @@ describe('getRarityMultiplier()', () => {
|
|
|
35
35
|
});
|
|
36
36
|
// ─── getImprovementThreshold ──────────────────────────────────────────────────
|
|
37
37
|
describe('getImprovementThreshold()', () => {
|
|
38
|
-
it('at
|
|
39
|
-
//
|
|
40
|
-
expect(getImprovementThreshold(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
it('at or below the floor the threshold is CURVE_BASE (180) — the fastest pace', () => {
|
|
39
|
+
// A freshly generated player sits ~at the floor → frac 0 → threshold = 180 for every rarity.
|
|
40
|
+
expect(getImprovementThreshold(getImprovementFloor(RarityEnum.COMMON), RarityEnum.COMMON)).toBe(180);
|
|
41
|
+
expect(getImprovementThreshold(0, RarityEnum.SPECIAL)).toBe(180);
|
|
42
|
+
});
|
|
43
|
+
it('at the ceiling (6 × cap) the threshold is CURVE_BASE + CURVE_SCALAR (980) — the slowest pace', () => {
|
|
44
|
+
expect(getImprovementThreshold(6 * getStatCap(RarityEnum.COMMON), RarityEnum.COMMON)).toBe(980);
|
|
45
|
+
expect(getImprovementThreshold(6 * getStatCap(RarityEnum.SPECIAL), RarityEnum.SPECIAL)).toBe(980);
|
|
46
|
+
});
|
|
47
|
+
it('threshold increases as statTotal climbs from the floor toward the cap', () => {
|
|
48
|
+
const floor = getImprovementFloor(RarityEnum.COMMON);
|
|
49
|
+
const low = getImprovementThreshold(floor + 10, RarityEnum.COMMON);
|
|
50
|
+
const high = getImprovementThreshold(floor + 120, RarityEnum.COMMON);
|
|
47
51
|
expect(high).toBeGreaterThan(low);
|
|
48
52
|
});
|
|
49
|
-
it('
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
+
it('is equivalent across rarities at the same position within their band', () => {
|
|
54
|
+
// Halfway from floor to ceiling must cost the same for every rarity — the whole point of the rework.
|
|
55
|
+
const midThreshold = (rarity) => {
|
|
56
|
+
const floor = getImprovementFloor(rarity);
|
|
57
|
+
const mid = floor + (6 * getStatCap(rarity) - floor) / 2;
|
|
58
|
+
return getImprovementThreshold(mid, rarity);
|
|
59
|
+
};
|
|
60
|
+
const common = midThreshold(RarityEnum.COMMON);
|
|
61
|
+
expect(midThreshold(RarityEnum.RARE)).toBe(common);
|
|
62
|
+
expect(midThreshold(RarityEnum.LEGENDARY)).toBe(common);
|
|
63
|
+
expect(midThreshold(RarityEnum.SPECIAL)).toBe(common);
|
|
53
64
|
});
|
|
54
65
|
it('returns an integer (Math.round applied)', () => {
|
|
55
|
-
expect(Number.isInteger(getImprovementThreshold(
|
|
66
|
+
expect(Number.isInteger(getImprovementThreshold(200, RarityEnum.RARE))).toBe(true);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
// ─── getImprovementFloor ──────────────────────────────────────────────────────
|
|
70
|
+
describe('getImprovementFloor()', () => {
|
|
71
|
+
it.each([
|
|
72
|
+
[RarityEnum.COMMON, 180],
|
|
73
|
+
[RarityEnum.RARE, 296],
|
|
74
|
+
[RarityEnum.LEGENDARY, 346],
|
|
75
|
+
[RarityEnum.MYTHIC, 432],
|
|
76
|
+
[RarityEnum.SPECIAL, 501]
|
|
77
|
+
])('%s → floor %i', (rarity, expected) => {
|
|
78
|
+
expect(getImprovementFloor(rarity)).toBe(expected);
|
|
79
|
+
});
|
|
80
|
+
it('throws UNKNOWN_RARITY for an unrecognised rarity string', () => {
|
|
81
|
+
expect(() => getImprovementFloor('DIVINE')).toThrow('UNKNOWN_RARITY');
|
|
82
|
+
});
|
|
83
|
+
it('every floor is below its rarity ceiling (6 × cap)', () => {
|
|
84
|
+
for (const rarity of [RarityEnum.COMMON, RarityEnum.RARE, RarityEnum.LEGENDARY, RarityEnum.MYTHIC, RarityEnum.SPECIAL]) {
|
|
85
|
+
expect(getImprovementFloor(rarity)).toBeLessThan(6 * getStatCap(rarity));
|
|
86
|
+
}
|
|
56
87
|
});
|
|
57
88
|
});
|
|
58
89
|
// ─── getCoachMultiplier ───────────────────────────────────────────────────────
|
|
@@ -71,6 +71,25 @@ describe('DesignatedSubSchema', () => {
|
|
|
71
71
|
});
|
|
72
72
|
expect(res.success).toBe(true);
|
|
73
73
|
});
|
|
74
|
+
it("accepts a fatigue-mode entry with the substitute's own benchFatigueBand", () => {
|
|
75
|
+
const res = DesignatedSubSchema.safeParse({
|
|
76
|
+
starter,
|
|
77
|
+
bench,
|
|
78
|
+
mode: 'FATIGUE',
|
|
79
|
+
fatigueBand: EnergyBand.WORN,
|
|
80
|
+
benchFatigueBand: EnergyBand.TIRED
|
|
81
|
+
});
|
|
82
|
+
expect(res.success).toBe(true);
|
|
83
|
+
});
|
|
84
|
+
it('rejects benchFatigueBand = NEVER (only the team default band may be NEVER)', () => {
|
|
85
|
+
const res = DesignatedSubSchema.safeParse({
|
|
86
|
+
starter,
|
|
87
|
+
bench,
|
|
88
|
+
mode: 'FATIGUE',
|
|
89
|
+
benchFatigueBand: 'NEVER'
|
|
90
|
+
});
|
|
91
|
+
expect(res.success).toBe(false);
|
|
92
|
+
});
|
|
74
93
|
it('accepts a fatigue-mode entry with no bench (falls back to closest sub)', () => {
|
|
75
94
|
const res = DesignatedSubSchema.safeParse({
|
|
76
95
|
starter,
|