diff --git a/src/services/vehicleCopier.ts b/src/services/vehicleCopier.ts index 1527b99..605b6bd 100644 --- a/src/services/vehicleCopier.ts +++ b/src/services/vehicleCopier.ts @@ -18,10 +18,12 @@ export const enum CopyOptions AllVehiclesOnTrain, PrecedingVehiclesOnTrain, FollowingVehiclesOnTrain, + SpecificVehiclesOnTrain, AllVehiclesOnAllTrains, PrecedingVehiclesOnAllTrains, FollowingVehiclesOnAllTrains, - SameVehicleOnAllTrains + SameVehicleOnAllTrains, + SpecificVehiclesOnAllTrains } /** @@ -31,10 +33,12 @@ export const copyOptions = [ "All vehicles on this train", "Preceding vehicles on this train", "Following vehicles on this train", + "Specific vehicles on this train", "All vehicles on all trains", "Preceding vehicles on all trains", "Following vehicles on all trains", - "Same vehicle number on all trains" + "Same vehicle number on all trains", + "Specific vehicles on all trains" ]; @@ -62,7 +66,7 @@ export const enum CopyFilter * Gets the targeted vehicles based on the selected copy option, in the following * format; [[ car id, amount of following cars (inclusive) ], ...]. */ -export function getTargets(copyOption: CopyOptions, ride: [ParkRide, number] | null, train: [RideTrain, number] | null, vehicle: [RideVehicle, number] | null): [number, number | null][] +export function getTargets(copyOption: CopyOptions, ride: [ParkRide, number] | null, train: [RideTrain, number] | null, vehicle: [RideVehicle, number] | null, amount: number, sequence: number): [number, number | null, number][] { if (ride && train && vehicle) { @@ -70,34 +74,43 @@ export function getTargets(copyOption: CopyOptions, ride: [ParkRide, number] | n { case CopyOptions.AllVehiclesOnTrain: { - return [[ train[0]._carId, null ]]; + return [[ train[0]._carId, null, 1 ]]; } case CopyOptions.PrecedingVehiclesOnTrain: { - return [[ train[0]._carId, vehicle[1] + 1 ]]; + return [[ train[0]._carId, vehicle[1] + 1, 1 ]]; } case CopyOptions.FollowingVehiclesOnTrain: { - return [[ vehicle[0]._id, null ]]; + return [[ vehicle[0]._id, null, 1 ]]; + } + case CopyOptions.SpecificVehiclesOnTrain: + { + return [[ vehicle[0]._id, amount, sequence ]]; } case CopyOptions.AllVehiclesOnAllTrains: { - return getTargetsOnAllTrains(ride, t => [ t._carId, null ]); + return getTargetsOnAllTrains(ride, t => [ t._carId, null, 1 ]); } case CopyOptions.PrecedingVehiclesOnAllTrains: { const amountOfVehicles = (vehicle[1] + 1); - return getTargetsOnAllTrains(ride, t => [ t._carId, amountOfVehicles ]); + return getTargetsOnAllTrains(ride, t => [ t._carId, amountOfVehicles, 1 ]); } case CopyOptions.FollowingVehiclesOnAllTrains: { const index = vehicle[1]; - return getTargetsOnAllTrains(ride, t => [ t._at(index)._id, null ]); + return getTargetsOnAllTrains(ride, t => [ t._at(index)._id, null, 1 ]); } case CopyOptions.SameVehicleOnAllTrains: { const index = vehicle[1]; - return getTargetsOnAllTrains(ride, t => [ t._at(index)._id, 1 ]); + return getTargetsOnAllTrains(ride, t => [ t._at(index)._id, 1, 1 ]); + } + case CopyOptions.SpecificVehiclesOnAllTrains: + { + const index = vehicle[1]; + return getTargetsOnAllTrains(ride, t => [ t._at(index)._id, amount, sequence ]); } } } @@ -157,7 +170,7 @@ export function getVehicleSettings(source: RideVehicle, filters: CopyFilter): Ve /** * Applies the set of vehicle settings to the specified targets. */ -export function applyToTargets(settings: VehicleSettings, targets: [number, number | null][]): void +export function applyToTargets(settings: VehicleSettings, targets: [number, number | null, number][]): void { execute({ settings, targets }); } @@ -237,7 +250,7 @@ function applyVehicleSettings(car: Car, settings: VehicleSettings): void /** * Finds the matching targets on all trains of the specified ride. */ -function getTargetsOnAllTrains(ride: [ParkRide, number], callback: (train: RideTrain) => [number, number | null]): [number, number | null][] +function getTargetsOnAllTrains(ride: [ParkRide, number], callback: (train: RideTrain) => [number, number | null, number]): [number, number | null, number][] { return ride[0]._trains().map(callback); } diff --git a/src/services/vehicleEditor.ts b/src/services/vehicleEditor.ts index 0240fae..c7eec2d 100644 --- a/src/services/vehicleEditor.ts +++ b/src/services/vehicleEditor.ts @@ -292,7 +292,6 @@ function updateVehicleSetting(args: UpdateVehicleSettingArgs): void return; } } - forEachVehicle(targets, callback); } diff --git a/src/services/vehicleSpan.ts b/src/services/vehicleSpan.ts index 6703190..e4733fb 100644 --- a/src/services/vehicleSpan.ts +++ b/src/services/vehicleSpan.ts @@ -3,13 +3,15 @@ import { isNull } from "../utilities/type"; import { invoke, refreshVehicle } from "./events"; /** - * A tuple for targeting a span of entities. The first tuple value specifies a car id - * and the second tuple value specifies to how many vehicles the change should be applied. + * A tuple for targeting a span of entities. The first tuple value specifies a car id, + * the second tuple value specifies to how many vehicles and the third tuple + * specifies every number of vehicles to which the change should be applied * - * For example: `[33, 2]` applies the paste to the vehicle with id 33, and the first - * one after. A `null` applies the paste from the first vehicle to the end of the train. + * For example: `[33, 10, 4]` applies the paste from the vehicle with id 33 to ten + * vehicles, every fourth vehicle. A `null` in the second tuple applies the paste + * from the first vehicle to the end of the train. */ -export type VehicleSpan = [number, number | null]; +export type VehicleSpan = [number, number | null, number]; /** @@ -21,6 +23,7 @@ export function forEachVehicle(vehicles: VehicleSpan[], action: (car: Car, index { const span = vehicles[s]; const maximum = span[1]; + const sequence = span[2]; let currentId = span[0]; let count = 0; @@ -29,10 +32,11 @@ export function forEachVehicle(vehicles: VehicleSpan[], action: (car: Car, index const car = getCarById(currentId); if (!car) break; - - action(car, count); + if (count % sequence === 0) + { + action(car, count); + } invoke(refreshVehicle, currentId); - const nextId = car.nextCarOnTrain; if (isNull(nextId)) break; diff --git a/src/ui/mainWindow.ts b/src/ui/mainWindow.ts index a086db2..6e24d31 100644 --- a/src/ui/mainWindow.ts +++ b/src/ui/mainWindow.ts @@ -1,4 +1,4 @@ -import { button, checkbox, CheckboxParams, colourPicker, compute, dropdown, dropdownSpinner, DropdownSpinnerParams, FlexiblePosition, groupbox, horizontal, label, SpinnerParams, toggle, twoway, vertical, viewport, WidgetCreator, window } from "openrct2-flexui"; +import { button, checkbox, CheckboxParams, colourPicker, compute, dropdown, dropdownSpinner, DropdownSpinnerParams, FlexiblePosition, groupbox, horizontal, label, spinner, SpinnerParams, toggle, twoway, vertical, viewport, WidgetCreator, window } from "openrct2-flexui"; import { isDevelopment, pluginVersion } from "../environment"; import { RideType } from "../objects/rideType"; import { RideVehicleVariant, VehicleVisibility } from "../objects/rideVehicleVariant"; @@ -55,7 +55,7 @@ model._selectedRide.subscribe(r => const mainWindow = window({ title, width: { value: 515, min: 515, max: 560 }, - height: 415, + height: 430, spacing: 5, onOpen: () => model._open(), onClose: () => @@ -244,14 +244,62 @@ const mainWindow = window({ "All vehicles on this train", "Preceding vehicles on this train", "Following vehicles on this train", + "Specific vehicles on this train", "All vehicles on all trains", "Preceding vehicles on all trains", "Following vehicles on all trains", - "Same vehicle number on all trains" + "Same vehicle number on all trains", + "Specific vehicles on all trains" ], tooltip: applyOptionsTip, selectedIndex: model._copyTargetOption, - onChange: idx => model._copyTargetOption.set(idx) + onChange: idx => + { + model._setSequence(idx); + model._copyTargetOption.set(idx); + } + }), + horizontal({ + padding: { top: -4, right: 1 }, + content: [ + label({ + text: "Apply to every # vehicle(s):", + tooltip: "Applies settings to every selected number of vehicles", + width: 180, + visibility: model._isSequenceVisible + }), + spinner({ + tooltip: "Applies settings to every selected number of vehicles", + width: 60, + value: compute(model._sequence, s => s), + minimum: 1, + maximum: compute(model._vehicles, c => c.length || 1), + step: model._multiplier, + visibility: model._isSequenceVisible, + onChange: v => model._sequence.set(v) + }) + ] + }), + horizontal({ + padding: { top: -4, right: 1 }, + content: [ + label({ + text: "Amount of vehicles to modify", + tooltip: "Selects which vehicle of the train is the last to modify", + width: 180, + visibility: model._isSequenceVisible + }), + spinner({ + tooltip: "Sets the amount of vehicles to modify", + width: 60, + value: compute(model._vehicles, c => c.length), + minimum: 1, + maximum: compute(model._vehicles, model._selectedVehicle, (c, s) => (s) ? c.length - s[1] : 1), + step: model._multiplier, + visibility: model._isSequenceVisible, + onChange: v => model._amount.set(v) + }) + ] }), horizontal([ button({ @@ -479,7 +527,7 @@ function applySelectedSettingsToRide(): void { applyToTargets( getVehicleSettings(vehicle[0], model._copyFilters.get()), - getTargets(model._copyTargetOption.get(), model._selectedRide.get(), model._selectedTrain.get(), vehicle) + getTargets(model._copyTargetOption.get(), model._selectedRide.get(), model._selectedTrain.get(), vehicle, model._amount.get(), model._sequence.get()) ); } } diff --git a/src/viewmodels/vehicleViewModel.ts b/src/viewmodels/vehicleViewModel.ts index 369be30..ac6a9d1 100644 --- a/src/viewmodels/vehicleViewModel.ts +++ b/src/viewmodels/vehicleViewModel.ts @@ -55,16 +55,21 @@ export class VehicleViewModel readonly _isUnpowered = compute(this._selectedVehicle, this._type, this._variant, v => !v || !v[0]._isPowered()); readonly _isPicking = store(false); readonly _isDragging = store(false); + readonly _isSequence = store(false); readonly _isEditDisabled = compute(this._selectedVehicle, v => !v); readonly _isSpinDisabled = compute(this._spinFrames, v => !v); readonly _isPositionDisabled = compute(this._isMoving, this._isEditDisabled, (m, e) => m || e); + readonly _isSequenceVisible = compute(this._isSequence, s => s ? "visible" : "none"); readonly _formatPosition = (pos: number): string => (this._isEditDisabled.get() ? "Not available" : pos.toString()); readonly _multiplierIndex = store(0); readonly _multiplier = compute(this._multiplierIndex, idx => (10 ** idx)); + readonly _sequence = store(1); + readonly _amount = compute(this._vehicles, c => c.length); + readonly _copyFilters = store(CopyFilter.Default); readonly _copyTargetOption = store(0); - readonly _copyTargets = compute(this._copyTargetOption, this._selectedVehicle, (o, v) => getTargets(o, this._selectedRide.get(), this._selectedTrain.get(), v)); + readonly _copyTargets = compute(this._copyTargetOption, this._selectedVehicle, this._amount, this._sequence, (o, v, a, s) => getTargets(o, this._selectedRide.get(), this._selectedTrain.get(), v, a, s )); readonly _synchronizeTargets = store(false); readonly _clipboard = store(null); @@ -302,7 +307,7 @@ export class VehicleViewModel } else { - action([[ vehicle[0]._id, 1 ]], value); + action([[ vehicle[0]._id, 1, this._sequence.get()]], value); } } else @@ -357,6 +362,19 @@ export class VehicleViewModel } } + /** + * Toggle the visibilty of specific vehicles options. + */ + _setSequence(index: number): void + { + const check = index === CopyOptions.SpecificVehiclesOnTrain || index === CopyOptions.SpecificVehiclesOnAllTrains; + this._isSequence.set(check); + if (!check) + { + this._sequence.set(1); + } + } + /** * Copies the currently selected vehicle to the clipboard, or clears clipboard. */ @@ -383,7 +401,7 @@ export class VehicleViewModel const settings = this._clipboard.get(); if (vehicle && settings) { - applyToTargets(settings, [[ vehicle[0]._id, 1 ]]); + applyToTargets(settings, [[ vehicle[0]._id, 1, this._sequence.get()]]); } } diff --git a/tests/services/vehicleCopier.tests.ts b/tests/services/vehicleCopier.tests.ts index 15089e1..668fbe0 100644 --- a/tests/services/vehicleCopier.tests.ts +++ b/tests/services/vehicleCopier.tests.ts @@ -20,7 +20,7 @@ function createTrain(startIndex: number): Car[] } -const getTargetsMacro = test.macro((t, option: CopyOptions, trainIndex: number, vehicleIndex: number, expectedTargets: [number, number | null][]) => +const getTargetsMacro = test.macro((t, option: CopyOptions, trainIndex: number, vehicleIndex: number, expectedTargets: [number, number | null, number][]) => { globalThis.map = Mock.map({ entities: [ ...createTrain(30), @@ -32,35 +32,35 @@ const getTargetsMacro = test.macro((t, option: CopyOptions, trainIndex: number, const train = ride._trains()[trainIndex]; const vehicle = train._at(vehicleIndex); - const targets = getTargets(option, [ride, 25], [train, trainIndex], [vehicle, vehicleIndex]); + const targets = getTargets(option, [ride, 25], [train, trainIndex], [vehicle, vehicleIndex], 1, 1); t.deepEqual(targets, expectedTargets); }); -test("Get targets of all vehicles on first train, first car", getTargetsMacro, CopyOptions.AllVehiclesOnTrain, 0, 0, [[ 10, null ]]); -test("Get targets of all vehicles on third train, third car", getTargetsMacro, CopyOptions.AllVehiclesOnTrain, 2, 2, [[ 30, null ]]); -test("Get targets of all vehicles on last train, last car", getTargetsMacro, CopyOptions.AllVehiclesOnTrain, 3, 4, [[ 40, null ]]); -test("Get targets of preceding vehicles on first train, first car", getTargetsMacro, CopyOptions.PrecedingVehiclesOnTrain, 0, 0, [[ 10, 1 ]]); -test("Get targets of preceding vehicles on third train, third car", getTargetsMacro, CopyOptions.PrecedingVehiclesOnTrain, 2, 2, [[ 30, 3 ]]); -test("Get targets of preceding vehicles on last train, last car", getTargetsMacro, CopyOptions.PrecedingVehiclesOnTrain, 3, 4, [[ 40, 5 ]]); -test("Get targets of following vehicles on first train, first car", getTargetsMacro, CopyOptions.FollowingVehiclesOnTrain, 0, 0, [[ 10, null ]]); -test("Get targets of following vehicles on third train, third car", getTargetsMacro, CopyOptions.FollowingVehiclesOnTrain, 2, 2, [[ 32, null ]]); -test("Get targets of following vehicles on last train, last car", getTargetsMacro, CopyOptions.FollowingVehiclesOnTrain, 3, 4, [[ 44, null ]]); +test("Get targets of all vehicles on first train, first car", getTargetsMacro, CopyOptions.AllVehiclesOnTrain, 0, 0, [[ 10, null, 1 ]]); +test("Get targets of all vehicles on third train, third car", getTargetsMacro, CopyOptions.AllVehiclesOnTrain, 2, 2, [[ 30, null, 1 ]]); +test("Get targets of all vehicles on last train, last car", getTargetsMacro, CopyOptions.AllVehiclesOnTrain, 3, 4, [[ 40, null, 1 ]]); +test("Get targets of preceding vehicles on first train, first car", getTargetsMacro, CopyOptions.PrecedingVehiclesOnTrain, 0, 0, [[ 10, 1, 1 ]]); +test("Get targets of preceding vehicles on third train, third car", getTargetsMacro, CopyOptions.PrecedingVehiclesOnTrain, 2, 2, [[ 30, 3, 1 ]]); +test("Get targets of preceding vehicles on last train, last car", getTargetsMacro, CopyOptions.PrecedingVehiclesOnTrain, 3, 4, [[ 40, 5, 1 ]]); +test("Get targets of following vehicles on first train, first car", getTargetsMacro, CopyOptions.FollowingVehiclesOnTrain, 0, 0, [[ 10, null, 1 ]]); +test("Get targets of following vehicles on third train, third car", getTargetsMacro, CopyOptions.FollowingVehiclesOnTrain, 2, 2, [[ 32, null, 1 ]]); +test("Get targets of following vehicles on last train, last car", getTargetsMacro, CopyOptions.FollowingVehiclesOnTrain, 3, 4, [[ 44, null, 1 ]]); -test("Get targets of all vehicles on all trains from first train, first car", getTargetsMacro, CopyOptions.AllVehiclesOnAllTrains, 0, 0, [[ 10, null ], [ 20, null ], [ 30, null ], [ 40, null ]]); -test("Get targets of all vehicles on all trains from third train, third car", getTargetsMacro, CopyOptions.AllVehiclesOnAllTrains, 2, 2, [[ 10, null ], [ 20, null ], [ 30, null ], [ 40, null ]]); -test("Get targets of all vehicles on all trains from last train, last car", getTargetsMacro, CopyOptions.AllVehiclesOnAllTrains, 3, 4, [[ 10, null ], [ 20, null ], [ 30, null ], [ 40, null ]]); -test("Get targets of preceding vehicles on all trains from first train, first car", getTargetsMacro, CopyOptions.PrecedingVehiclesOnAllTrains, 0, 0, [[ 10, 1 ], [ 20, 1 ], [ 30, 1 ], [ 40, 1 ]]); -test("Get targets of preceding vehicles on all trains from third train, third car", getTargetsMacro, CopyOptions.PrecedingVehiclesOnAllTrains, 2, 2, [[ 10, 3 ], [ 20, 3 ], [ 30, 3 ], [ 40, 3 ]]); -test("Get targets of preceding vehicles on all trains from last train, last car", getTargetsMacro, CopyOptions.PrecedingVehiclesOnAllTrains, 3, 4, [[ 10, 5 ], [ 20, 5 ], [ 30, 5 ], [ 40, 5 ]]); -test("Get targets of following vehicles on all trains from first train, first car", getTargetsMacro, CopyOptions.FollowingVehiclesOnAllTrains, 0, 0, [[ 10, null ], [ 20, null ], [ 30, null ], [ 40, null ]]); -test("Get targets of following vehicles on all trains from third train, third car", getTargetsMacro, CopyOptions.FollowingVehiclesOnAllTrains, 2, 2, [[ 12, null ], [ 22, null ], [ 32, null ], [ 42, null ]]); -test("Get targets of following vehicles on all trains from last train, last car", getTargetsMacro, CopyOptions.FollowingVehiclesOnAllTrains, 3, 4, [[ 14, null ], [ 24, null ], [ 34, null ], [ 44, null ]]); +test("Get targets of all vehicles on all trains from first train, first car", getTargetsMacro, CopyOptions.AllVehiclesOnAllTrains, 0, 0, [[ 10, null, 1 ], [ 20, null, 1 ], [ 30, null, 1 ], [ 40, null, 1 ]]); +test("Get targets of all vehicles on all trains from third train, third car", getTargetsMacro, CopyOptions.AllVehiclesOnAllTrains, 2, 2, [[ 10, null, 1 ], [ 20, null, 1 ], [ 30, null, 1 ], [ 40, null, 1 ]]); +test("Get targets of all vehicles on all trains from last train, last car", getTargetsMacro, CopyOptions.AllVehiclesOnAllTrains, 3, 4, [[ 10, null, 1 ], [ 20, null, 1 ], [ 30, null, 1 ], [ 40, null, 1 ]]); +test("Get targets of preceding vehicles on all trains from first train, first car", getTargetsMacro, CopyOptions.PrecedingVehiclesOnAllTrains, 0, 0, [[ 10, 1, 1 ], [ 20, 1, 1 ], [ 30, 1, 1 ], [ 40, 1, 1 ]]); +test("Get targets of preceding vehicles on all trains from third train, third car", getTargetsMacro, CopyOptions.PrecedingVehiclesOnAllTrains, 2, 2, [[ 10, 3, 1 ], [ 20, 3, 1 ], [ 30, 3, 1 ], [ 40, 3, 1 ]]); +test("Get targets of preceding vehicles on all trains from last train, last car", getTargetsMacro, CopyOptions.PrecedingVehiclesOnAllTrains, 3, 4, [[ 10, 5, 1 ], [ 20, 5, 1 ], [ 30, 5, 1 ], [ 40, 5, 1 ]]); +test("Get targets of following vehicles on all trains from first train, first car", getTargetsMacro, CopyOptions.FollowingVehiclesOnAllTrains, 0, 0, [[ 10, null, 1 ], [ 20, null, 1 ], [ 30, null, 1 ], [ 40, null, 1 ]]); +test("Get targets of following vehicles on all trains from third train, third car", getTargetsMacro, CopyOptions.FollowingVehiclesOnAllTrains, 2, 2, [[ 12, null, 1 ], [ 22, null, 1 ], [ 32, null, 1 ], [ 42, null, 1 ]]); +test("Get targets of following vehicles on all trains from last train, last car", getTargetsMacro, CopyOptions.FollowingVehiclesOnAllTrains, 3, 4, [[ 14, null, 1 ], [ 24, null, 1 ], [ 34, null, 1 ], [ 44, null, 1 ]]); -test("Get targets of same vehicle on all trains from first train, first car", getTargetsMacro, CopyOptions.SameVehicleOnAllTrains, 0, 0, [[ 10, 1 ], [ 20, 1 ], [ 30, 1 ], [ 40, 1 ]]); -test("Get targets of same vehicle on all trains from third train, third car", getTargetsMacro, CopyOptions.SameVehicleOnAllTrains, 2, 2, [[ 12, 1 ], [ 22, 1 ], [ 32, 1 ], [ 42, 1 ]]); -test("Get targets of same vehicle on all trains from last train, last car", getTargetsMacro, CopyOptions.SameVehicleOnAllTrains, 3, 4, [[ 14, 1 ], [ 24, 1 ], [ 34, 1 ], [ 44, 1 ]]); +test("Get targets of same vehicle on all trains from first train, first car", getTargetsMacro, CopyOptions.SameVehicleOnAllTrains, 0, 0, [[ 10, 1, 1 ], [ 20, 1, 1 ], [ 30, 1, 1 ], [ 40, 1, 1 ]]); +test("Get targets of same vehicle on all trains from third train, third car", getTargetsMacro, CopyOptions.SameVehicleOnAllTrains, 2, 2, [[ 12, 1, 1 ], [ 22, 1, 1 ], [ 32, 1, 1 ], [ 42, 1, 1 ]]); +test("Get targets of same vehicle on all trains from last train, last car", getTargetsMacro, CopyOptions.SameVehicleOnAllTrains, 3, 4, [[ 14, 1, 1 ], [ 24, 1, 1 ], [ 34, 1, 1 ], [ 44, 1, 1 ]]); test("Get all settings of the vehicle", t => @@ -226,7 +226,7 @@ test("Paste all vehicle settings on single car", t => colours: [ 13, 15, 18 ] }; - applyToTargets(settings, [[ 99, 1 ]]); + applyToTargets(settings, [[ 99, 1, 1]]); const targetCar = map.getEntity(99); t.is(targetCar.rideObject, 21); @@ -260,7 +260,7 @@ test("Paste all vehicle settings on a car does not affect other cars", t => colours: [ 13, 15, 18 ] }; - applyToTargets(settings, [[ 99, 3 ], [ 99, null ]]); + applyToTargets(settings, [[ 99, 3, 1 ], [ 99, null, 1 ]]); function testUnaffectedCar(carId: number): void { @@ -291,7 +291,7 @@ test("Paste empty vehicle settings on single car does not do anything", t => const settings: VehicleSettings = {}; - applyToTargets(settings, [[ 99, 1 ]]); + applyToTargets(settings, [[ 99, 1, 1]]); const targetCar = map.getEntity(99); t.is(targetCar.rideObject, 2); @@ -323,7 +323,7 @@ test("Paste all vehicle settings on multiple trains car affects all", t => colours: [ 8, 6, 5 ] }; - applyToTargets(settings, [[ 98, 4 ], [ 97, null ]]); + applyToTargets(settings, [[ 98, 4, 1 ], [ 97, null, 1 ]]); function testAffectedCar(carId: number): void { diff --git a/tests/services/vehicleEditor.tests.ts b/tests/services/vehicleEditor.tests.ts index 8a862a2..3cb534b 100644 --- a/tests/services/vehicleEditor.tests.ts +++ b/tests/services/vehicleEditor.tests.ts @@ -44,7 +44,7 @@ test("Set ride type", t => { const car = setupCarMock(99); - setRideType([[ 99, 1 ]], new RideType(Mock.rideObject({ index: 23 }))); + setRideType([[ 99, 1, 1]], new RideType(Mock.rideObject({ index: 23 }))); t.is(car.rideObject, 23); // Reset other properties @@ -54,7 +54,7 @@ test("Set ride type", t => t.is(car.poweredAcceleration, 40); t.is(car.poweredMaxSpeed, 35); - setRideType([[ 99, 1 ]], new RideType(Mock.rideObject({ index: 55 }))); + setRideType([[ 99, 1, 1]], new RideType(Mock.rideObject({ index: 55 }))); t.is(car.rideObject, 55); // Reset other properties @@ -70,7 +70,7 @@ test("Set variant", t => { const car = setupCarMock(56); - setVariant([[ 56, 1 ]], 3); + setVariant([[ 56, 1, 1]], 3); t.is(car.vehicleObject, 3); // Reset other properties @@ -80,7 +80,7 @@ test("Set variant", t => t.is(car.poweredAcceleration, 11); t.is(car.poweredMaxSpeed, 12); - setVariant([[ 56, 1 ]], 1); + setVariant([[ 56, 1, 1]], 1); t.is(car.vehicleObject, 1); // Reset other properties @@ -96,10 +96,10 @@ test("Set seat count", t => { const car = setupCarMock(58); - setSeatCount([[ 58, 1 ]], 26); + setSeatCount([[ 58, 1, 1]], 26); t.is(car.numSeats, 26); - setSeatCount([[ 58, 1 ]], 10); + setSeatCount([[ 58, 1, 1]], 10); t.is(car.numSeats, 10); }); @@ -108,10 +108,10 @@ test("Set mass", t => { const car = setupCarMock(58); - setMass([[ 58, 1 ]], 260); + setMass([[ 58, 1, 1]], 260); t.is(car.mass, 260); - setMass([[ 58, 1 ]], 9800); + setMass([[ 58, 1, 1]], 9800); t.is(car.mass, 9800); }); @@ -120,10 +120,10 @@ test("Set powered acceleration", t => { const car = setupCarMock(42); - setPoweredAcceleration([[ 42, 1 ]], 120); + setPoweredAcceleration([[ 42, 1, 1]], 120); t.is(car.poweredAcceleration, 120); - setPoweredAcceleration([[ 42, 1 ]], 5); + setPoweredAcceleration([[ 42, 1, 1]], 5); t.is(car.poweredAcceleration, 5); }); @@ -132,10 +132,10 @@ test("Set powered max speed", t => { const car = setupCarMock(9); - setPoweredMaximumSpeed([[ 9, 1 ]], 65); + setPoweredMaximumSpeed([[ 9, 1, 1]], 65); t.is(car.poweredMaxSpeed, 65); - setPoweredMaximumSpeed([[ 9, 1 ]], 30); + setPoweredMaximumSpeed([[ 9, 1, 1]], 30); t.is(car.poweredMaxSpeed, 30); }); @@ -144,10 +144,10 @@ test("Set primary colour", t => { const car = setupCarMock(9); - setPrimaryColour([[ 9, 1 ]], 5); + setPrimaryColour([[ 9, 1, 1]], 5); t.is(car.colours.body, 5); - setPrimaryColour([[ 9, 1 ]], 31); + setPrimaryColour([[ 9, 1, 1]], 31); t.is(car.colours.body, 31); }); @@ -156,10 +156,10 @@ test("Set secondary colour", t => { const car = setupCarMock(19); - setSecondaryColour([[ 19, 1 ]], 12); + setSecondaryColour([[ 19, 1, 1]], 12); t.is(car.colours.trim, 12); - setSecondaryColour([[ 19, 1 ]], 0); + setSecondaryColour([[ 19, 1, 1]], 0); t.is(car.colours.trim, 0); }); @@ -168,10 +168,10 @@ test("Set tertiary colour", t => { const car = setupCarMock(23); - setTertiaryColour([[ 23, 1 ]], 25); + setTertiaryColour([[ 23, 1, 1]], 25); t.is(car.colours.tertiary, 25); - setTertiaryColour([[ 23, 1 ]], 2); + setTertiaryColour([[ 23, 1, 1]], 2); t.is(car.colours.tertiary, 2); }); @@ -180,13 +180,13 @@ test("Set x position", t => { const car = setupCarMock(29); - setPositionX([[ 29, 1 ]], 10); + setPositionX([[ 29, 1, 1]], 10); t.is(car.x, 10); - setPositionX([[ 29, 1 ]], 10_090); + setPositionX([[ 29, 1, 1]], 10_090); t.is(car.x, 10 + 10_090); - setPositionX([[ 29, 1 ]], -3); + setPositionX([[ 29, 1, 1]], -3); t.is(car.x, 10 + 10_090 - 3); }); @@ -195,13 +195,13 @@ test("Set y position", t => { const car = setupCarMock(10); - setPositionY([[ 10, 1 ]], 5020); + setPositionY([[ 10, 1, 1]], 5020); t.is(car.y, 5020); - setPositionY([[ 10, 1 ]], -302_010); + setPositionY([[ 10, 1, 1]], -302_010); t.is(car.y, 5020 - 302_010); - setPositionY([[ 10, 1 ]], 15); + setPositionY([[ 10, 1, 1]], 15); t.is(car.y, 5020 - 302_010 + 15); }); @@ -210,12 +210,12 @@ test("Set z position", t => { const car = setupCarMock(101); - setPositionZ([[ 101, 1 ]], -698); + setPositionZ([[ 101, 1, 1]], -698); t.is(car.z, -698); - setPositionZ([[ 101, 1 ]], 653); + setPositionZ([[ 101, 1, 1]], 653); t.is(car.z, -698 + 653); - setPositionZ([[ 101, 1 ]], -10); + setPositionZ([[ 101, 1, 1]], -10); t.is(car.z, -698 + 653 - 10); });