feat: team & sponsor restrictions added

This commit is contained in:
2024-04-07 22:00:09 +02:00
parent d98ec94a66
commit 26fd0c67e4
15 changed files with 243 additions and 234 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "pojazdownik", "name": "pojazdownik",
"version": "1.8.3.1", "version": "1.8.4",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
+2 -2
View File
@@ -28,7 +28,7 @@
{{ $t('inputs.input-vehicle') }} {{ $t('inputs.input-vehicle') }}
</option> </option>
<option v-for="loco in locoOptions" :value="loco" :key="loco.type"> <option v-for="loco in locoOptions" :value="loco" :key="loco.type">
{{ loco.type }}<b v-if="loco.isSponsorsOnly">*</b> {{ loco.type }}<b v-if="loco.restrictions['sponsorOnly']">*</b>
</option> </option>
</select> </select>
</div> </div>
@@ -59,7 +59,7 @@
</option> </option>
<option v-for="car in carOptions" :value="car" :key="car.type"> <option v-for="car in carOptions" :value="car" :key="car.type">
{{ car.type }}<b v-if="car.isSponsorsOnly">*</b> {{ car.type }}<b v-if="car.restrictions['sponsorOnly']">*</b>
</option> </option>
</select> </select>
</div> </div>
-1
View File
@@ -51,7 +51,6 @@ export default {
.logo-section { .logo-section {
grid-row: 1; grid-row: 1;
grid-column: 1; grid-column: 1;
margin-bottom: 1.5em;
display: flex; display: flex;
align-items: center; align-items: center;
+43 -34
View File
@@ -1,21 +1,22 @@
<template> <template>
<section class="train-image-section"> <section class="train-image-section">
<div class="train-image__content" :class="{ sponsor: store.chosenVehicle?.isSponsorsOnly }"> <div class="image-wrapper">
<img <img
tabindex="0"
:src=" :src="
store.chosenVehicle store.chosenVehicle
? getThumbnailURL(store.chosenVehicle.type, 'small') ? getThumbnailURL(store.chosenVehicle.type, 'small')
: '/images/placeholder.jpg' : '/images/placeholder.jpg'
" "
tabindex="0"
:data-sponsor-only="store.chosenVehicle?.restrictions.sponsorOnly"
:data-team-only="store.chosenVehicle?.restrictions.teamOnly"
@click="onImageClick" @click="onImageClick"
@keydown.enter="onImageClick" @keydown.enter="onImageClick"
@error="onImageError" @error="onImageError"
type="image/jpeg"
/> />
</div> </div>
<div class="train-image__info" v-if="store.chosenVehicle"> <div class="image-info" v-if="store.chosenVehicle">
<b class="text--accent">{{ store.chosenVehicle.type }}</b> &bull; <b class="text--accent">{{ store.chosenVehicle.type }}</b> &bull;
<b style="color: #ccc"> <b style="color: #ccc">
{{ {{
@@ -43,17 +44,21 @@
}} }}
</div> </div>
<b style="color: salmon" v-if="store.chosenVehicle.isSponsorsOnly">{{ <b style="color: salmon" v-if="store.chosenVehicle.restrictions['sponsorOnly']">{{
$t('preview.sponsor-only', [ $t('preview.sponsor-only', [
new Date(store.chosenVehicle.sponsorsOnlyTimestamp).toLocaleDateString( new Date(store.chosenVehicle.restrictions['sponsorOnly']).toLocaleDateString(
$i18n.locale == 'pl' ? 'pl-PL' : 'en-GB' $i18n.locale == 'pl' ? 'pl-PL' : 'en-GB'
), ),
]) ])
}}</b> }}</b>
<b style="color: gold" v-if="store.chosenVehicle.restrictions['teamOnly']">{{
$t('preview.team-only')
}}</b>
</div> </div>
</div> </div>
<div class="train-image__info" v-else>{{ $t('preview.desc') }}</div> <div class="image-info" v-else>{{ $t('preview.desc') }}</div>
</section> </section>
</template> </template>
@@ -121,7 +126,7 @@ export default defineComponent({
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '../../styles/global.scss'; @import '../../styles/global';
.train-image-section { .train-image-section {
display: flex; display: flex;
@@ -135,24 +140,41 @@ export default defineComponent({
height: 22em; height: 22em;
} }
.train-image { img {
&__content { max-width: 380px;
&.sponsor img { width: 100%;
border: 1px solid salmon; height: 100%;
} border: 1px solid white;
img { cursor: zoom-in;
max-width: 380px;
width: 100%;
height: 100%;
border: 1px solid white;
cursor: zoom-in; &[data-sponsor-only='true'] {
} border: 1px solid $sponsorColor;
}
&[data-team-only='true'] {
border: 1px solid $teamColor;
} }
} }
.train-image__info { // .train-image {
// &__content {
// &.sponsor img {
// border: 1px solid salmon;
// }
// img {
// max-width: 380px;
// width: 100%;
// height: 100%;
// border: 1px solid white;
// cursor: zoom-in;
// }
// }
// }
.image-info {
font-size: 1.1em; font-size: 1.1em;
padding: 0.5em; padding: 0.5em;
margin: 0.5em auto; margin: 0.5em auto;
@@ -165,19 +187,6 @@ export default defineComponent({
font-weight: bold; font-weight: bold;
} }
// Transition animations
.img-message-anim {
&-enter-from,
&-leave-to {
opacity: 0;
}
&-enter-active,
&-leave-active {
transition: opacity 75ms ease-in 100ms;
}
}
@media screen and (max-width: $breakpointMd) { @media screen and (max-width: $breakpointMd) {
.train-image-section { .train-image-section {
justify-content: center; justify-content: center;
+1 -2
View File
@@ -119,11 +119,10 @@ import { useStore } from '../../store';
import stockMixin from '../../mixins/stockMixin'; import stockMixin from '../../mixins/stockMixin';
import { ICargo, ICarWagon, IStock } from '../../types'; import { ICargo, ICarWagon, IStock } from '../../types';
import warningsMixin from '../../mixins/warningsMixin';
export default defineComponent({ export default defineComponent({
name: 'stock-generator', name: 'stock-generator',
mixins: [stockMixin, warningsMixin], mixins: [stockMixin],
data() { data() {
return { return {
+146 -94
View File
@@ -115,20 +115,29 @@
</Checkbox> </Checkbox>
</div> </div>
<div class="stock_warnings" v-if="stockHasWarnings"> <div class="stock_warnings" v-if="hasAnyWarnings">
<div class="warning" v-if="locoNotSuitable"> <div class="warning" v-if="locoNotSuitable">
(!) {{ $t('stocklist.warning-not-suitable') }} (!) {{ $t('stocklist.warning-not-suitable') }}
</div> </div>
<div class="warning" v-if="trainTooLong && store.isTrainPassenger"> <div class="warning" v-if="lengthExceeded && store.isTrainPassenger">
(!) {{ $t('stocklist.warning-passenger-too-long') }} (!) {{ $t('stocklist.warning-passenger-too-long') }}
</div> </div>
<div class="warning" v-if="trainTooLong && !store.isTrainPassenger"> <div class="warning" v-if="lengthExceeded && !store.isTrainPassenger">
(!) {{ $t('stocklist.warning-freight-too-long') }} (!) {{ $t('stocklist.warning-freight-too-long') }}
</div> </div>
<div class="warning" v-if="trainTooHeavy"> <div class="warning" v-if="teamOnlyVehicles.length > 0">
(!)
{{
$t('stocklist.warning-team-only-vehicle', [
teamOnlyVehicles.map((v) => v.type).join(', '),
])
}}
</div>
<div class="warning" v-if="weightExceeded">
(!) (!)
<i18n-t keypath="stocklist.warning-too-heavy"> <i18n-t keypath="stocklist.warning-too-heavy">
<template #href> <template #href>
@@ -142,7 +151,7 @@
</i18n-t> </i18n-t>
</div> </div>
<div class="warning" v-if="tooManyLocomotives"> <div class="warning" v-if="locoCountExceeded">
{{ $t('stocklist.warning-too-many-locos') }} {{ $t('stocklist.warning-too-many-locos') }}
</div> </div>
</div> </div>
@@ -150,52 +159,60 @@
<StockThumbnails :onListItemClick="onListItemClick" /> <StockThumbnails :onListItemClick="onListItemClick" />
<!-- Stock list --> <!-- Stock list -->
<ul ref="stock_list"> <div class="list-wrapper">
<li v-if="stockIsEmpty" class="list-empty"> <div v-if="stockIsEmpty" class="list-empty">
<div class="stock-info">{{ $t('stocklist.list-empty') }}</div> <div class="stock-info">{{ $t('stocklist.list-empty') }}</div>
</li> </div>
<TransitionGroup name="stock-list-anim" v-else> <ul v-else>
<li <transition-group name="stock-list-anim">
v-for="(stock, i) in store.stockList" <li
:key="stock.id" v-for="(stock, i) in store.stockList"
:class="{ loco: stock.isLoco }" :key="stock.id"
tabindex="0" :class="{ loco: stock.isLoco }"
@click="onListItemClick(i)" tabindex="0"
@keydown.enter="onListItemClick(i)" @click="onListItemClick(i)"
@keydown.w="moveUpStock(i)" @keydown.enter="onListItemClick(i)"
@keydown.s="moveDownStock(i)" @keydown.w="moveUpStock(i)"
@keydown.backspace="removeStock(i)" @keydown.s="moveDownStock(i)"
ref="itemRefs" @keydown.backspace="removeStock(i)"
> ref="itemRefs"
<div
class="stock-info"
@dragstart="onDragStart(i)"
@drop="onDrop($event, i)"
@dragover="allowDrop"
draggable="true"
> >
<span class="stock-info__no" :data-selected="i == store.chosenStockListIndex"> <div
<span v-if="i == store.chosenStockListIndex">&bull;&nbsp;</span> class="stock-info"
{{ i + 1 }}. @dragstart="onDragStart(i)"
</span> @drop="onDrop($event, i)"
@dragover="allowDrop"
<span class="stock-info__type" :class="{ sponsor: stock.isSponsorsOnly }"> draggable="true"
{{ stock.isLoco ? stock.type : getCarSpecFromType(stock.type) }}
</span>
<span class="stock-info__cargo" v-if="stock.cargo">
{{ stock.cargo.id }}
</span>
<span class="stock-info__length">{{ stock.length }}m</span>
<span class="stock-info__mass"
>{{ ((stock.weight + (stock.cargo?.weight ?? 0)) / 1000).toFixed(1) }}t</span
> >
<span class="stock-info__speed">{{ stock.maxSpeed }}km/h</span> <span class="stock-info-no" :data-selected="i == store.chosenStockListIndex">
</div> <span v-if="i == store.chosenStockListIndex">&bull;&nbsp;</span>
</li> {{ i + 1 }}.
</TransitionGroup> </span>
</ul>
<span
class="stock-info-type"
:data-sponsor-only="stock.restrictions.sponsorOnly"
:data-team-only="stock.restrictions.teamOnly"
>
{{ stock.isLoco ? stock.type : getCarSpecFromType(stock.type) }}
</span>
<span class="stock-info-cargo" v-if="stock.cargo">
{{ stock.cargo.id }}
</span>
<span class="stock-info-length">{{ stock.length }}m</span>
<span class="stock-info-mass">
{{ ((stock.weight + (stock.cargo?.weight ?? 0)) / 1000).toFixed(1) }}t
</span>
<span class="stock-info-speed">{{ stock.maxSpeed }}km/h</span>
</div>
</li>
</transition-group>
</ul>
</div>
</section> </section>
</template> </template>
@@ -204,7 +221,6 @@ import { defineComponent } from 'vue';
import { useStore } from '../../store'; import { useStore } from '../../store';
import warningsMixin from '../../mixins/warningsMixin';
import imageMixin from '../../mixins/imageMixin'; import imageMixin from '../../mixins/imageMixin';
import stockPreviewMixin from '../../mixins/stockPreviewMixin'; import stockPreviewMixin from '../../mixins/stockPreviewMixin';
import StockThumbnails from '../utils/StockThumbnails.vue'; import StockThumbnails from '../utils/StockThumbnails.vue';
@@ -215,7 +231,7 @@ export default defineComponent({
name: 'stock-list', name: 'stock-list',
components: { StockThumbnails, Checkbox }, components: { StockThumbnails, Checkbox },
mixins: [warningsMixin, imageMixin, stockMixin, stockPreviewMixin], mixins: [imageMixin, stockMixin, stockPreviewMixin],
setup() { setup() {
const store = useStore(); const store = useStore();
@@ -233,6 +249,12 @@ export default defineComponent({
}), }),
computed: { computed: {
chosenRealComposition() {
const currentStockString = this.store.stockList.map((s) => s.type).join(';');
return this.store.realCompositionList.find((rc) => rc.stockString == currentStockString);
},
stockString() { stockString() {
if (this.store.stockList.length == 0) return ''; if (this.store.stockList.length == 0) return '';
@@ -263,16 +285,47 @@ export default defineComponent({
: this.store.stockList[this.store.chosenStockListIndex]; : this.store.stockList[this.store.chosenStockListIndex];
}, },
stockHasWarnings() { lengthExceeded() {
return ( return (
this.tooManyLocomotives || this.trainTooHeavy || this.trainTooLong || this.locoNotSuitable (this.store.totalLength > 350 && this.store.isTrainPassenger) ||
(this.store.totalLength > 650 && !this.store.isTrainPassenger)
); );
}, },
chosenRealComposition() { weightExceeded() {
const currentStockString = this.store.stockList.map((s) => s.type).join(';'); return this.store.acceptableWeight && this.store.totalWeight > this.store.acceptableWeight;
},
return this.store.realCompositionList.find((rc) => rc.stockString == currentStockString); locoNotSuitable() {
return (
!this.store.isTrainPassenger &&
this.store.stockList.length > 1 &&
!this.store.stockList.every((stock) => stock.isLoco) &&
this.store.stockList.some((stock) => stock.isLoco && stock.type.startsWith('EP'))
);
},
locoCountExceeded() {
return (
this.store.stockList.reduce((acc, stock) => {
if (stock.isLoco) acc += stock.count;
return acc;
}, 0) > 2
);
},
teamOnlyVehicles() {
return this.store.stockList.filter((stock) => stock.restrictions.teamOnly);
},
hasAnyWarnings() {
return (
this.locoCountExceeded ||
this.weightExceeded ||
this.lengthExceeded ||
this.locoNotSuitable ||
this.teamOnlyVehicles
);
}, },
}, },
@@ -470,6 +523,7 @@ export default defineComponent({
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 0.5em; gap: 0.5em;
position: relative;
} }
.warning { .warning {
@@ -537,10 +591,20 @@ export default defineComponent({
} }
} }
ul { .list-wrapper {
position: relative; position: relative;
overflow: auto; }
max-height: 500px;
.list-empty {
background-color: $secondaryColor;
border-radius: 0.5em;
padding: 0.75em;
font-weight: bold;
}
ul {
overflow-y: scroll;
height: 500px;
} }
ul > li { ul > li {
@@ -557,16 +621,11 @@ ul > li {
&:focus-visible { &:focus-visible {
outline: 1px solid white; outline: 1px solid white;
} }
&.list-empty {
background-color: $secondaryColor;
border-radius: 0.5em;
padding: 0.75em;
}
} }
li > .stock-info { li > .stock-info {
display: flex; display: flex;
gap: 0.25em;
color: white; color: white;
font-weight: 700; font-weight: 700;
@@ -575,46 +634,39 @@ li > .stock-info {
& > span { & > span {
padding: 0.5em; padding: 0.5em;
margin-right: 0.25em;
display: flex;
justify-content: center;
align-items: center;
} }
} }
.sponsor { .stock-info-no,
color: salmon; .stock-info-type {
background-color: $secondaryColor;
&[data-team-only='true'] {
color: $teamColor;
}
&[data-sponsor-only] {
color: $sponsorColor;
}
} }
.stock-info { .stock-info-no {
&__no, min-width: 3.5em;
&__type { text-align: right;
background-color: $secondaryColor;
}
&__count { &[data-selected='true'] {
background-color: #e04e3e; color: $accentColor;
} }
}
&__no { .stock-info-cargo {
min-width: 3.5em; background-color: #333;
text-align: right; }
&[data-selected='true'] { .stock-info-length,
color: $accentColor; .stock-info-mass,
} .stock-info-speed {
} background-color: #555;
&__cargo {
background-color: #333;
}
&__length,
&__mass,
&__speed {
background-color: #555;
}
} }
.stock-list-anim { .stock-list-anim {
+17 -22
View File
@@ -57,26 +57,19 @@
<img width="120" src="" :data-src="getThumbnailURL(vehicle.type, 'small')" /> <img width="120" src="" :data-src="getThumbnailURL(vehicle.type, 'small')" />
</td> </td>
<td :data-sponsoronly="vehicle.isSponsorsOnly"> <td
{{ vehicle.type }} :data-sponsor-only="vehicle.restrictions.sponsorOnly > 0"
:data-team-only="vehicle.restrictions.teamOnly"
style="min-width: 150px"
>
{{ vehicle.type.replace(/_/g, ' ') }}
</td> </td>
<td v-if="isTractionUnit(vehicle)"> <td style="min-width: 100px">{{ $t(`wiki.${vehicle.group}`) }}</td>
{{ $t(`wiki.${vehicle.group}`) }}
</td>
<td v-else>{{ $t(`wiki.${vehicle.group}`) }}</td>
<td>{{ vehicle.constructionType }}</td> <td>{{ vehicle.constructionType }}</td>
<td>{{ vehicle.length }}</td> <td>{{ vehicle.length }}</td>
<td>{{ (vehicle.weight / 1000).toFixed(1) }}</td> <td>{{ (vehicle.weight / 1000).toFixed(1) }}</td>
<td>{{ vehicle.maxSpeed }}</td> <td>{{ vehicle.maxSpeed }}</td>
<td v-if="currentFilterMode == 'carriages'">
{{ !isTractionUnit(vehicle) ? vehicle.cargoTypes.length : '---' }}
</td>
<td v-if="currentFilterMode == 'tractions'">
{{ isTractionUnit(vehicle) ? (vehicle.coldStart ? `&check;` : '&cross;') : '---' }}
</td>
</tr> </tr>
</tbody> </tbody>
@@ -127,8 +120,8 @@ const headers: IWikiHeader[] = [
{ id: 'length', sortable: true, for: 'all' }, { id: 'length', sortable: true, for: 'all' },
{ id: 'weight', sortable: true, for: 'all' }, { id: 'weight', sortable: true, for: 'all' },
{ id: 'maxSpeed', sortable: true, for: 'all' }, { id: 'maxSpeed', sortable: true, for: 'all' },
{ id: 'coldStart', sortable: true, for: 'tractions' }, // { id: 'coldStart', sortable: true, for: 'tractions' },
{ id: 'cargoCount', sortable: true, for: 'carriages' }, // { id: 'cargoCount', sortable: true, for: 'carriages' },
]; ];
export default defineComponent({ export default defineComponent({
@@ -330,10 +323,6 @@ export default defineComponent({
cursor: pointer; cursor: pointer;
background-color: #333; background-color: #333;
&:first-child {
min-width: 120px;
}
&:nth-child(odd) { &:nth-child(odd) {
background-color: #444; background-color: #444;
} }
@@ -348,8 +337,14 @@ export default defineComponent({
padding: 0.25em; padding: 0.25em;
height: 75px; height: 75px;
&[data-sponsoronly='true'] { min-width: 95px;
color: salmon;
&[data-sponsor-only='true'] {
color: $sponsorColor;
}
&[data-team-only='true'] {
color: $teamColor;
} }
img { img {
+1 -1
View File
@@ -5,7 +5,7 @@
v-for="(stock, stockIndex) in store.stockList" v-for="(stock, stockIndex) in store.stockList"
:key="stockIndex" :key="stockIndex"
:data-selected="store.chosenStockListIndex == stockIndex" :data-selected="store.chosenStockListIndex == stockIndex"
:data-sponsor="stock.isSponsorsOnly" :data-sponsor="stock.restrictions.sponsorOnly"
draggable="true" draggable="true"
@dragstart="onDragStart(stockIndex)" @dragstart="onDragStart(stockIndex)"
@drop="onDrop($event, stockIndex)" @drop="onDrop($event, stockIndex)"
+3
View File
@@ -30,6 +30,7 @@
"loading": "IMAGE LOADING...", "loading": "IMAGE LOADING...",
"desc": "Choose a railway vehicle above to see its preview", "desc": "Choose a railway vehicle above to see its preview",
"sponsor-only": "* SPONSORS ONLY UNTIL {0}", "sponsor-only": "* SPONSORS ONLY UNTIL {0}",
"team-only": "* TD2 TEAM ONLY",
"loco-electric": "ELECTRIC LOCO", "loco-electric": "ELECTRIC LOCO",
"loco-diesel": "DIESEL LOCO", "loco-diesel": "DIESEL LOCO",
"unit-electric": "ELECTRIC M.U.", "unit-electric": "ELECTRIC M.U.",
@@ -68,11 +69,13 @@
"coldstart-info": "Locomotive cold start", "coldstart-info": "Locomotive cold start",
"doublemanning-info": "Double manning", "doublemanning-info": "Double manning",
"list-empty": "Stock list is empty!", "list-empty": "Stock list is empty!",
"warning-not-suitable": "EP series locomotives are designed for passenger traffic only!", "warning-not-suitable": "EP series locomotives are designed for passenger traffic only!",
"warning-passenger-too-long": "Maximum length of a passenger train may not be greater than 350m!", "warning-passenger-too-long": "Maximum length of a passenger train may not be greater than 350m!",
"warning-freight-too-long": "Maximum length of a freight train may not be greater than 650m!", "warning-freight-too-long": "Maximum length of a freight train may not be greater than 650m!",
"warning-too-many-locos": "This train has too many traction units!", "warning-too-many-locos": "This train has too many traction units!",
"warning-too-heavy": "This train is too heavy! Check {href}", "warning-too-heavy": "This train is too heavy! Check {href}",
"warning-team-only-vehicle": "There's at least one vehicle available only for TD2 team members in your stock composition! ({0})",
"acceptable-mass-docs": "acceptable rolling stock masses (PL)" "acceptable-mass-docs": "acceptable rolling stock masses (PL)"
}, },
"stockgen": { "stockgen": {
+4 -1
View File
@@ -9,7 +9,7 @@
"version-check": "Strona jest kompletna dla wersji {version} symulatora TD2" "version-check": "Strona jest kompletna dla wersji {version} symulatora TD2"
}, },
"inputs": { "inputs": {
"title": "WYBIERZ POJAZD SZYNOWY", "title": "WYBIERZ POJAZD",
"input-vehicle": "Wybierz pojazd trakcyjny", "input-vehicle": "Wybierz pojazd trakcyjny",
"input-carwagon": "Wybierz wagon", "input-carwagon": "Wybierz wagon",
"cargo-title": "Ładunek (tylko wybrane towarowe)", "cargo-title": "Ładunek (tylko wybrane towarowe)",
@@ -30,6 +30,7 @@
"loading": "ŁADOWANIE OBRAZU...", "loading": "ŁADOWANIE OBRAZU...",
"desc": "Wybierz pojazd lub wagon, aby zobaczyć jego podgląd powyżej", "desc": "Wybierz pojazd lub wagon, aby zobaczyć jego podgląd powyżej",
"sponsor-only": "* TYLKO DLA SPONSORÓW DO {0}", "sponsor-only": "* TYLKO DLA SPONSORÓW DO {0}",
"team-only": "* TYLKO DLA ZESPOŁU TD2",
"loco-electric": "ELEKTROWÓZ", "loco-electric": "ELEKTROWÓZ",
"loco-diesel": "SPALINOWÓZ", "loco-diesel": "SPALINOWÓZ",
"unit-electric": "EZT", "unit-electric": "EZT",
@@ -68,11 +69,13 @@
"coldstart-info": "Zimny start", "coldstart-info": "Zimny start",
"doublemanning-info": "Podwójna obsada", "doublemanning-info": "Podwójna obsada",
"list-empty": "Lista pojazdów jest pusta!", "list-empty": "Lista pojazdów jest pusta!",
"warning-not-suitable": "Lokomotywy serii EP są przeznaczone jedynie do ruchu pasażerskiego!", "warning-not-suitable": "Lokomotywy serii EP są przeznaczone jedynie do ruchu pasażerskiego!",
"warning-passenger-too-long": "Maksymalna długość składów pasażerskich nie może przekraczać 350m!", "warning-passenger-too-long": "Maksymalna długość składów pasażerskich nie może przekraczać 350m!",
"warning-freight-too-long": "Maksymalna długość składów innych niż pasażerskie nie może przekraczać 650m!", "warning-freight-too-long": "Maksymalna długość składów innych niż pasażerskie nie może przekraczać 650m!",
"warning-too-many-locos": "Ten skład posiada za dużo pojazdów trakcyjnych!", "warning-too-many-locos": "Ten skład posiada za dużo pojazdów trakcyjnych!",
"warning-too-heavy": "Ten skład jest za ciężki! Sprawdź {href}", "warning-too-heavy": "Ten skład jest za ciężki! Sprawdź {href}",
"warning-team-only-vehicle": "W zestawieniu znajduje się co najmniej jeden pojazd dostępny tylko dla członków zespołu TD2! ({0})",
"acceptable-mass-docs": "dopuszczalne masy składów" "acceptable-mass-docs": "dopuszczalne masy składów"
}, },
"stockgen": { "stockgen": {
+1 -2
View File
@@ -28,9 +28,8 @@ export default defineComponent({
cargo: !isLoco && vehicle.loadable && cargo ? cargo : undefined, cargo: !isLoco && vehicle.loadable && cargo ? cargo : undefined,
count, count,
group: isLoco ? vehicle.group : vehicle.group, group: isLoco ? vehicle.group : vehicle.group,
isSponsorsOnly: vehicle.isSponsorsOnly,
constructionType: vehicle.constructionType, constructionType: vehicle.constructionType,
sponsorsOnlyTimestamp: vehicle.sponsorsOnlyTimestamp, restrictions: vehicle.restrictions,
}; };
}, },
-42
View File
@@ -1,42 +0,0 @@
import { defineComponent } from 'vue';
import { useStore } from '../store';
export default defineComponent({
setup() {
const store = useStore();
return {
store,
};
},
computed: {
trainTooLong() {
return (
(this.store.totalLength > 350 && this.store.isTrainPassenger) ||
(this.store.totalLength > 650 && !this.store.isTrainPassenger)
);
},
trainTooHeavy() {
return this.store.acceptableWeight && this.store.totalWeight > this.store.acceptableWeight;
},
locoNotSuitable() {
return (
!this.store.isTrainPassenger &&
this.store.stockList.length > 1 &&
!this.store.stockList.every((stock) => stock.isLoco) &&
this.store.stockList.some((stock) => stock.isLoco && stock.type.startsWith('EP'))
);
},
tooManyLocomotives() {
return (
this.store.stockList.reduce((acc, stock) => {
if (stock.isLoco) acc += stock.count;
return acc;
}, 0) > 2
);
},
},
});
+3
View File
@@ -6,6 +6,9 @@ $textColor: #fff;
$secondaryColor: #1b1b1b; $secondaryColor: #1b1b1b;
$accentColor: #e4c428; $accentColor: #e4c428;
$sponsorColor: salmon;
$teamColor: gold;
@font-face { @font-face {
font-family: 'Lato'; font-family: 'Lato';
src: src:
+5 -17
View File
@@ -4,6 +4,7 @@ export type StockSectionMode = 'STOCK_LIST' | 'STOCK_GENERATOR';
export type LocoGroupType = 'loco-electric' | 'loco-diesel' | 'unit-electric' | 'unit-diesel'; export type LocoGroupType = 'loco-electric' | 'loco-diesel' | 'unit-electric' | 'unit-diesel';
export type WagonGroupType = 'wagon-passenger' | 'wagon-freight'; export type WagonGroupType = 'wagon-passenger' | 'wagon-freight';
export type VehicleGroupType = LocoGroupType | WagonGroupType; export type VehicleGroupType = LocoGroupType | WagonGroupType;
export type RestrictionType = 'sponsorOnly' | 'teamOnly';
export interface IVehicleProps { export interface IVehicleProps {
type: string; type: string;
@@ -13,7 +14,6 @@ export interface IVehicleProps {
cargoTypes?: ICargo[]; cargoTypes?: ICargo[];
coldStart?: boolean; coldStart?: boolean;
doubleManned?: boolean; doubleManned?: boolean;
supporterTimestamp?: number;
} }
export interface ICargo { export interface ICargo {
@@ -30,16 +30,7 @@ export interface IVehiclesAPI {
}; };
}; };
vehicleList: string[][]; vehicleList: any[][];
// vehiclesList: {
// 'loco-electric': string[][];
// 'loco-diesel': string[][];
// 'unit-electric': string[][];
// 'unit-diesel': string[][];
// 'wagon-passenger': string[][];
// 'wagon-freight': string[][];
// };
vehicleProps: IVehicleProps[]; vehicleProps: IVehicleProps[];
@@ -63,8 +54,7 @@ export interface ILocomotive {
constructionType: string; constructionType: string;
cabinType: string; cabinType: string;
maxSpeed: number; maxSpeed: number;
isSponsorsOnly: boolean; restrictions: Record<RestrictionType, any>;
sponsorsOnlyTimestamp: number;
weight: number; weight: number;
length: number; length: number;
coldStart: boolean; coldStart: boolean;
@@ -76,8 +66,7 @@ export interface ICarWagon {
group: WagonGroupType; group: WagonGroupType;
constructionType: string; constructionType: string;
loadable: boolean; loadable: boolean;
isSponsorsOnly: boolean; restrictions: Record<RestrictionType, any>;
sponsorsOnlyTimestamp: number;
maxSpeed: number; maxSpeed: number;
weight: number; weight: number;
length: number; length: number;
@@ -94,8 +83,7 @@ export interface IStock {
maxSpeed: number; maxSpeed: number;
cargo?: ICargo; cargo?: ICargo;
isLoco: boolean; isLoco: boolean;
isSponsorsOnly: boolean; restrictions: Record<RestrictionType, any>;
sponsorsOnlyTimestamp: number;
count: number; count: number;
} }
+16 -15
View File
@@ -20,11 +20,11 @@ export function isTractionUnit(vehicle: ILocomotive | ICarWagon): vehicle is ILo
export function locoDataList(vehiclesData: IVehiclesAPI | undefined) { export function locoDataList(vehiclesData: IVehiclesAPI | undefined) {
if (!vehiclesData) return []; if (!vehiclesData) return [];
return vehiclesData.vehicleList.reduce((acc, vehicleInfoArray) => { return vehiclesData.vehicleList.reduce<ILocomotive[]>((acc, vehicleInfoArray) => {
// check if data array has 4 elements (locos & units only) // check if data array has 5 elements (locos & units only)
if (vehicleInfoArray.length != 4) return acc; if (vehicleInfoArray.length != 5) return acc;
const [type, constructionType, cabinType, group] = vehicleInfoArray; const [type, constructionType, cabinType, group, restrictions] = vehicleInfoArray;
const locoProps = vehiclesData.vehicleProps.find((prop) => constructionType == prop.type); const locoProps = vehiclesData.vehicleProps.find((prop) => constructionType == prop.type);
if (!locoProps) { if (!locoProps) {
@@ -39,8 +39,7 @@ export function locoDataList(vehiclesData: IVehiclesAPI | undefined) {
constructionType, constructionType,
cabinType, cabinType,
isSponsorsOnly: (locoProps.supporterTimestamp ?? 0) > Date.now(), restrictions: restrictions ?? {},
sponsorsOnlyTimestamp: locoProps.supporterTimestamp ?? 0,
maxSpeed: locoProps.speed, maxSpeed: locoProps.speed,
length: locoProps.length, length: locoProps.length,
@@ -51,18 +50,20 @@ export function locoDataList(vehiclesData: IVehiclesAPI | undefined) {
}); });
return acc; return acc;
}, [] as ILocomotive[]); }, []);
} }
export function carDataList(vehiclesData: IVehiclesAPI | undefined) { export function carDataList(vehiclesData: IVehiclesAPI | undefined) {
if (!vehiclesData) return []; if (!vehiclesData) return [];
return vehiclesData.vehicleList.reduce((acc, vehicleInfoArray) => { console.log(vehiclesData);
// check if data array has 3 elements (wagons only)
if (vehicleInfoArray.length != 3) return acc;
const [type, constructionType, group] = vehicleInfoArray; return vehiclesData.vehicleList.reduce<ICarWagon[]>((acc, vehicleInfoArray) => {
const wagonProps = vehiclesData.vehicleProps.find((v) => type.toString().startsWith(v.type)); // check if data array has 4 elements (wagons only)
if (vehicleInfoArray.length != 4) return acc;
const [type, constructionType, group, restrictions] = vehicleInfoArray;
const wagonProps = vehiclesData.vehicleProps.find((prop) => constructionType == prop.type);
if (!wagonProps) { if (!wagonProps) {
console.warn('Brak atrybutów dla pojazdu:', type); console.warn('Brak atrybutów dla pojazdu:', type);
@@ -74,17 +75,17 @@ export function carDataList(vehiclesData: IVehiclesAPI | undefined) {
type, type,
constructionType, constructionType,
loadable: wagonProps.cargoTypes ? wagonProps.cargoTypes.length > 0 : false, loadable: wagonProps.cargoTypes ? wagonProps.cargoTypes.length > 0 : false,
isSponsorsOnly: (wagonProps.supporterTimestamp ?? 0) > Date.now(),
sponsorsOnlyTimestamp: wagonProps.supporterTimestamp ?? 0,
cargoTypes: wagonProps?.cargoTypes ?? [], cargoTypes: wagonProps?.cargoTypes ?? [],
restrictions: restrictions ?? {},
maxSpeed: wagonProps.speed, maxSpeed: wagonProps.speed,
weight: wagonProps?.weight || 0, weight: wagonProps?.weight || 0,
length: wagonProps?.length || 0, length: wagonProps?.length || 0,
}); });
return acc; return acc;
}, [] as ICarWagon[]); }, []);
} }
export function totalWeight(stockList: IStock[]) { export function totalWeight(stockList: IStock[]) {