Add vehicle management features in Falukant

- Introduced vehicle types and transport management in the backend, including new models and associations for vehicles and transports.
- Implemented service methods to retrieve vehicle types and handle vehicle purchases, ensuring user validation and transaction management.
- Updated the FalukantController and router to expose new endpoints for fetching vehicle types and buying vehicles.
- Enhanced the frontend with a new transport tab in BranchView, allowing users to buy vehicles, and added localization for vehicle-related terms.
- Included initialization logic for vehicle types in the database setup.
This commit is contained in:
Torsten Schulz (local)
2025-11-24 20:15:45 +01:00
parent 5ed27e5a6a
commit 3f043fc315
14 changed files with 544 additions and 12 deletions

View File

@@ -12,6 +12,7 @@ import TitleOfNobility from "../../models/falukant/type/title_of_nobility.js";
import PartyType from "../../models/falukant/type/party.js";
import MusicType from "../../models/falukant/type/music.js";
import BanquetteType from "../../models/falukant/type/banquette.js";
import VehicleType from "../../models/falukant/type/vehicle.js";
import LearnRecipient from "../../models/falukant/type/learn_recipient.js";
import PoliticalOfficeType from "../../models/falukant/type/political_office_type.js";
import PoliticalOfficeBenefitType from "../../models/falukant/type/political_office_benefit_type.js";
@@ -41,6 +42,7 @@ export const initializeFalukantTypes = async () => {
await initializePoliticalOfficeTypes();
await initializePoliticalOfficePrerequisites();
await initializeUndergroundTypes();
await initializeVehicleTypes();
};
const regionTypes = [];
@@ -273,6 +275,16 @@ const learnerTypes = [
{ tr: 'director', },
];
const vehicleTypes = [
{ tr: 'cargo_cart', name: 'Lastkarren', cost: 100, capacity: 20, transportMode: 'land', speed: 1 },
{ tr: 'ox_cart', name: 'Ochsenkarren', cost: 200, capacity: 50, transportMode: 'land', speed: 2 },
{ tr: 'small_carriage', name: 'kleine Pferdekutsche', cost: 300, capacity: 35, transportMode: 'land', speed: 3 },
{ tr: 'large_carriage', name: 'große Pferdekutsche', cost: 1000, capacity: 100, transportMode: 'land', speed: 3 },
{ tr: 'four_horse_carriage', name: 'Vierspänner', cost: 5000, capacity: 200, transportMode: 'land', speed: 4 },
{ tr: 'raft', name: 'Floß', cost: 100, capacity: 25, transportMode: 'water', speed: 1 },
{ tr: 'sailing_ship', name: 'Segelschiff', cost: 500, capacity: 200, transportMode: 'water', speed: 3 },
];
const politicalOfficeBenefitTypes = [
{ tr: 'salary' },
{ tr: 'reputation' },
@@ -883,6 +895,21 @@ export const initializeLearnerTypes = async () => {
}
};
export const initializeVehicleTypes = async () => {
for (const v of vehicleTypes) {
await VehicleType.findOrCreate({
where: { tr: v.tr },
defaults: {
tr: v.tr,
cost: v.cost,
capacity: v.capacity,
transportMode: v.transportMode,
speed: v.speed,
},
});
}
};
export const initializePoliticalOfficeBenefitTypes = async () => {
for (const benefitType of politicalOfficeBenefitTypes) {
await PoliticalOfficeBenefitType.findOrCreate({