mirror of
https://github.com/Spythere/pojazdownik.git
synced 2026-05-03 05:18:10 +00:00
feat: team & sponsor restrictions added
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
{{ $t('inputs.input-vehicle') }}
|
||||
</option>
|
||||
<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>
|
||||
</select>
|
||||
</div>
|
||||
@@ -59,7 +59,7 @@
|
||||
</option>
|
||||
|
||||
<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>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -51,7 +51,6 @@ export default {
|
||||
.logo-section {
|
||||
grid-row: 1;
|
||||
grid-column: 1;
|
||||
margin-bottom: 1.5em;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
<template>
|
||||
<section class="train-image-section">
|
||||
<div class="train-image__content" :class="{ sponsor: store.chosenVehicle?.isSponsorsOnly }">
|
||||
<div class="image-wrapper">
|
||||
<img
|
||||
tabindex="0"
|
||||
:src="
|
||||
store.chosenVehicle
|
||||
? getThumbnailURL(store.chosenVehicle.type, 'small')
|
||||
: '/images/placeholder.jpg'
|
||||
"
|
||||
tabindex="0"
|
||||
:data-sponsor-only="store.chosenVehicle?.restrictions.sponsorOnly"
|
||||
:data-team-only="store.chosenVehicle?.restrictions.teamOnly"
|
||||
@click="onImageClick"
|
||||
@keydown.enter="onImageClick"
|
||||
@error="onImageError"
|
||||
type="image/jpeg"
|
||||
/>
|
||||
</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> •
|
||||
<b style="color: #ccc">
|
||||
{{
|
||||
@@ -43,17 +44,21 @@
|
||||
}}
|
||||
</div>
|
||||
|
||||
<b style="color: salmon" v-if="store.chosenVehicle.isSponsorsOnly">{{
|
||||
<b style="color: salmon" v-if="store.chosenVehicle.restrictions['sponsorOnly']">{{
|
||||
$t('preview.sponsor-only', [
|
||||
new Date(store.chosenVehicle.sponsorsOnlyTimestamp).toLocaleDateString(
|
||||
new Date(store.chosenVehicle.restrictions['sponsorOnly']).toLocaleDateString(
|
||||
$i18n.locale == 'pl' ? 'pl-PL' : 'en-GB'
|
||||
),
|
||||
])
|
||||
}}</b>
|
||||
|
||||
<b style="color: gold" v-if="store.chosenVehicle.restrictions['teamOnly']">{{
|
||||
$t('preview.team-only')
|
||||
}}</b>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="train-image__info" v-else>{{ $t('preview.desc') }}</div>
|
||||
<div class="image-info" v-else>{{ $t('preview.desc') }}</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -121,7 +126,7 @@ export default defineComponent({
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '../../styles/global.scss';
|
||||
@import '../../styles/global';
|
||||
|
||||
.train-image-section {
|
||||
display: flex;
|
||||
@@ -135,24 +140,41 @@ export default defineComponent({
|
||||
height: 22em;
|
||||
}
|
||||
|
||||
.train-image {
|
||||
&__content {
|
||||
&.sponsor img {
|
||||
border: 1px solid salmon;
|
||||
}
|
||||
img {
|
||||
max-width: 380px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 1px solid white;
|
||||
|
||||
img {
|
||||
max-width: 380px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 1px solid white;
|
||||
cursor: zoom-in;
|
||||
|
||||
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;
|
||||
padding: 0.5em;
|
||||
margin: 0.5em auto;
|
||||
@@ -165,19 +187,6 @@ export default defineComponent({
|
||||
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) {
|
||||
.train-image-section {
|
||||
justify-content: center;
|
||||
|
||||
@@ -119,11 +119,10 @@ import { useStore } from '../../store';
|
||||
|
||||
import stockMixin from '../../mixins/stockMixin';
|
||||
import { ICargo, ICarWagon, IStock } from '../../types';
|
||||
import warningsMixin from '../../mixins/warningsMixin';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'stock-generator',
|
||||
mixins: [stockMixin, warningsMixin],
|
||||
mixins: [stockMixin],
|
||||
|
||||
data() {
|
||||
return {
|
||||
|
||||
@@ -115,20 +115,29 @@
|
||||
</Checkbox>
|
||||
</div>
|
||||
|
||||
<div class="stock_warnings" v-if="stockHasWarnings">
|
||||
<div class="stock_warnings" v-if="hasAnyWarnings">
|
||||
<div class="warning" v-if="locoNotSuitable">
|
||||
(!) {{ $t('stocklist.warning-not-suitable') }}
|
||||
</div>
|
||||
|
||||
<div class="warning" v-if="trainTooLong && store.isTrainPassenger">
|
||||
<div class="warning" v-if="lengthExceeded && store.isTrainPassenger">
|
||||
(!) {{ $t('stocklist.warning-passenger-too-long') }}
|
||||
</div>
|
||||
|
||||
<div class="warning" v-if="trainTooLong && !store.isTrainPassenger">
|
||||
<div class="warning" v-if="lengthExceeded && !store.isTrainPassenger">
|
||||
(!) {{ $t('stocklist.warning-freight-too-long') }}
|
||||
</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">
|
||||
<template #href>
|
||||
@@ -142,7 +151,7 @@
|
||||
</i18n-t>
|
||||
</div>
|
||||
|
||||
<div class="warning" v-if="tooManyLocomotives">
|
||||
<div class="warning" v-if="locoCountExceeded">
|
||||
{{ $t('stocklist.warning-too-many-locos') }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -150,52 +159,60 @@
|
||||
<StockThumbnails :onListItemClick="onListItemClick" />
|
||||
|
||||
<!-- Stock list -->
|
||||
<ul ref="stock_list">
|
||||
<li v-if="stockIsEmpty" class="list-empty">
|
||||
<div class="list-wrapper">
|
||||
<div v-if="stockIsEmpty" class="list-empty">
|
||||
<div class="stock-info">{{ $t('stocklist.list-empty') }}</div>
|
||||
</li>
|
||||
</div>
|
||||
|
||||
<TransitionGroup name="stock-list-anim" v-else>
|
||||
<li
|
||||
v-for="(stock, i) in store.stockList"
|
||||
:key="stock.id"
|
||||
:class="{ loco: stock.isLoco }"
|
||||
tabindex="0"
|
||||
@click="onListItemClick(i)"
|
||||
@keydown.enter="onListItemClick(i)"
|
||||
@keydown.w="moveUpStock(i)"
|
||||
@keydown.s="moveDownStock(i)"
|
||||
@keydown.backspace="removeStock(i)"
|
||||
ref="itemRefs"
|
||||
>
|
||||
<div
|
||||
class="stock-info"
|
||||
@dragstart="onDragStart(i)"
|
||||
@drop="onDrop($event, i)"
|
||||
@dragover="allowDrop"
|
||||
draggable="true"
|
||||
<ul v-else>
|
||||
<transition-group name="stock-list-anim">
|
||||
<li
|
||||
v-for="(stock, i) in store.stockList"
|
||||
:key="stock.id"
|
||||
:class="{ loco: stock.isLoco }"
|
||||
tabindex="0"
|
||||
@click="onListItemClick(i)"
|
||||
@keydown.enter="onListItemClick(i)"
|
||||
@keydown.w="moveUpStock(i)"
|
||||
@keydown.s="moveDownStock(i)"
|
||||
@keydown.backspace="removeStock(i)"
|
||||
ref="itemRefs"
|
||||
>
|
||||
<span class="stock-info__no" :data-selected="i == store.chosenStockListIndex">
|
||||
<span v-if="i == store.chosenStockListIndex">• </span>
|
||||
{{ i + 1 }}.
|
||||
</span>
|
||||
|
||||
<span class="stock-info__type" :class="{ sponsor: stock.isSponsorsOnly }">
|
||||
{{ 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
|
||||
<div
|
||||
class="stock-info"
|
||||
@dragstart="onDragStart(i)"
|
||||
@drop="onDrop($event, i)"
|
||||
@dragover="allowDrop"
|
||||
draggable="true"
|
||||
>
|
||||
<span class="stock-info__speed">{{ stock.maxSpeed }}km/h</span>
|
||||
</div>
|
||||
</li>
|
||||
</TransitionGroup>
|
||||
</ul>
|
||||
<span class="stock-info-no" :data-selected="i == store.chosenStockListIndex">
|
||||
<span v-if="i == store.chosenStockListIndex">• </span>
|
||||
{{ i + 1 }}.
|
||||
</span>
|
||||
|
||||
<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>
|
||||
</template>
|
||||
|
||||
@@ -204,7 +221,6 @@ import { defineComponent } from 'vue';
|
||||
|
||||
import { useStore } from '../../store';
|
||||
|
||||
import warningsMixin from '../../mixins/warningsMixin';
|
||||
import imageMixin from '../../mixins/imageMixin';
|
||||
import stockPreviewMixin from '../../mixins/stockPreviewMixin';
|
||||
import StockThumbnails from '../utils/StockThumbnails.vue';
|
||||
@@ -215,7 +231,7 @@ export default defineComponent({
|
||||
name: 'stock-list',
|
||||
components: { StockThumbnails, Checkbox },
|
||||
|
||||
mixins: [warningsMixin, imageMixin, stockMixin, stockPreviewMixin],
|
||||
mixins: [imageMixin, stockMixin, stockPreviewMixin],
|
||||
|
||||
setup() {
|
||||
const store = useStore();
|
||||
@@ -233,6 +249,12 @@ export default defineComponent({
|
||||
}),
|
||||
|
||||
computed: {
|
||||
chosenRealComposition() {
|
||||
const currentStockString = this.store.stockList.map((s) => s.type).join(';');
|
||||
|
||||
return this.store.realCompositionList.find((rc) => rc.stockString == currentStockString);
|
||||
},
|
||||
|
||||
stockString() {
|
||||
if (this.store.stockList.length == 0) return '';
|
||||
|
||||
@@ -263,16 +285,47 @@ export default defineComponent({
|
||||
: this.store.stockList[this.store.chosenStockListIndex];
|
||||
},
|
||||
|
||||
stockHasWarnings() {
|
||||
lengthExceeded() {
|
||||
return (
|
||||
this.tooManyLocomotives || this.trainTooHeavy || this.trainTooLong || this.locoNotSuitable
|
||||
(this.store.totalLength > 350 && this.store.isTrainPassenger) ||
|
||||
(this.store.totalLength > 650 && !this.store.isTrainPassenger)
|
||||
);
|
||||
},
|
||||
|
||||
chosenRealComposition() {
|
||||
const currentStockString = this.store.stockList.map((s) => s.type).join(';');
|
||||
weightExceeded() {
|
||||
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;
|
||||
flex-direction: column;
|
||||
gap: 0.5em;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.warning {
|
||||
@@ -537,10 +591,20 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
ul {
|
||||
.list-wrapper {
|
||||
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 {
|
||||
@@ -557,16 +621,11 @@ ul > li {
|
||||
&:focus-visible {
|
||||
outline: 1px solid white;
|
||||
}
|
||||
|
||||
&.list-empty {
|
||||
background-color: $secondaryColor;
|
||||
border-radius: 0.5em;
|
||||
padding: 0.75em;
|
||||
}
|
||||
}
|
||||
|
||||
li > .stock-info {
|
||||
display: flex;
|
||||
gap: 0.25em;
|
||||
|
||||
color: white;
|
||||
font-weight: 700;
|
||||
@@ -575,46 +634,39 @@ li > .stock-info {
|
||||
|
||||
& > span {
|
||||
padding: 0.5em;
|
||||
margin-right: 0.25em;
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.sponsor {
|
||||
color: salmon;
|
||||
.stock-info-no,
|
||||
.stock-info-type {
|
||||
background-color: $secondaryColor;
|
||||
|
||||
&[data-team-only='true'] {
|
||||
color: $teamColor;
|
||||
}
|
||||
|
||||
&[data-sponsor-only] {
|
||||
color: $sponsorColor;
|
||||
}
|
||||
}
|
||||
|
||||
.stock-info {
|
||||
&__no,
|
||||
&__type {
|
||||
background-color: $secondaryColor;
|
||||
}
|
||||
.stock-info-no {
|
||||
min-width: 3.5em;
|
||||
text-align: right;
|
||||
|
||||
&__count {
|
||||
background-color: #e04e3e;
|
||||
&[data-selected='true'] {
|
||||
color: $accentColor;
|
||||
}
|
||||
}
|
||||
|
||||
&__no {
|
||||
min-width: 3.5em;
|
||||
text-align: right;
|
||||
.stock-info-cargo {
|
||||
background-color: #333;
|
||||
}
|
||||
|
||||
&[data-selected='true'] {
|
||||
color: $accentColor;
|
||||
}
|
||||
}
|
||||
|
||||
&__cargo {
|
||||
background-color: #333;
|
||||
}
|
||||
|
||||
&__length,
|
||||
&__mass,
|
||||
&__speed {
|
||||
background-color: #555;
|
||||
}
|
||||
.stock-info-length,
|
||||
.stock-info-mass,
|
||||
.stock-info-speed {
|
||||
background-color: #555;
|
||||
}
|
||||
|
||||
.stock-list-anim {
|
||||
|
||||
@@ -57,26 +57,19 @@
|
||||
<img width="120" src="" :data-src="getThumbnailURL(vehicle.type, 'small')" />
|
||||
</td>
|
||||
|
||||
<td :data-sponsoronly="vehicle.isSponsorsOnly">
|
||||
{{ vehicle.type }}
|
||||
<td
|
||||
:data-sponsor-only="vehicle.restrictions.sponsorOnly > 0"
|
||||
:data-team-only="vehicle.restrictions.teamOnly"
|
||||
style="min-width: 150px"
|
||||
>
|
||||
{{ vehicle.type.replace(/_/g, ' ') }}
|
||||
</td>
|
||||
|
||||
<td v-if="isTractionUnit(vehicle)">
|
||||
{{ $t(`wiki.${vehicle.group}`) }}
|
||||
</td>
|
||||
<td v-else>{{ $t(`wiki.${vehicle.group}`) }}</td>
|
||||
|
||||
<td style="min-width: 100px">{{ $t(`wiki.${vehicle.group}`) }}</td>
|
||||
<td>{{ vehicle.constructionType }}</td>
|
||||
<td>{{ vehicle.length }}</td>
|
||||
<td>{{ (vehicle.weight / 1000).toFixed(1) }}</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 ? `✓` : '✗') : '---' }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -127,8 +120,8 @@ const headers: IWikiHeader[] = [
|
||||
{ id: 'length', sortable: true, for: 'all' },
|
||||
{ id: 'weight', sortable: true, for: 'all' },
|
||||
{ id: 'maxSpeed', sortable: true, for: 'all' },
|
||||
{ id: 'coldStart', sortable: true, for: 'tractions' },
|
||||
{ id: 'cargoCount', sortable: true, for: 'carriages' },
|
||||
// { id: 'coldStart', sortable: true, for: 'tractions' },
|
||||
// { id: 'cargoCount', sortable: true, for: 'carriages' },
|
||||
];
|
||||
|
||||
export default defineComponent({
|
||||
@@ -330,10 +323,6 @@ export default defineComponent({
|
||||
cursor: pointer;
|
||||
background-color: #333;
|
||||
|
||||
&:first-child {
|
||||
min-width: 120px;
|
||||
}
|
||||
|
||||
&:nth-child(odd) {
|
||||
background-color: #444;
|
||||
}
|
||||
@@ -348,8 +337,14 @@ export default defineComponent({
|
||||
padding: 0.25em;
|
||||
height: 75px;
|
||||
|
||||
&[data-sponsoronly='true'] {
|
||||
color: salmon;
|
||||
min-width: 95px;
|
||||
|
||||
&[data-sponsor-only='true'] {
|
||||
color: $sponsorColor;
|
||||
}
|
||||
|
||||
&[data-team-only='true'] {
|
||||
color: $teamColor;
|
||||
}
|
||||
|
||||
img {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
v-for="(stock, stockIndex) in store.stockList"
|
||||
:key="stockIndex"
|
||||
:data-selected="store.chosenStockListIndex == stockIndex"
|
||||
:data-sponsor="stock.isSponsorsOnly"
|
||||
:data-sponsor="stock.restrictions.sponsorOnly"
|
||||
draggable="true"
|
||||
@dragstart="onDragStart(stockIndex)"
|
||||
@drop="onDrop($event, stockIndex)"
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
"loading": "IMAGE LOADING...",
|
||||
"desc": "Choose a railway vehicle above to see its preview",
|
||||
"sponsor-only": "* SPONSORS ONLY UNTIL {0}",
|
||||
"team-only": "* TD2 TEAM ONLY",
|
||||
"loco-electric": "ELECTRIC LOCO",
|
||||
"loco-diesel": "DIESEL LOCO",
|
||||
"unit-electric": "ELECTRIC M.U.",
|
||||
@@ -68,11 +69,13 @@
|
||||
"coldstart-info": "Locomotive cold start",
|
||||
"doublemanning-info": "Double manning",
|
||||
"list-empty": "Stock list is empty!",
|
||||
|
||||
"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-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-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)"
|
||||
},
|
||||
"stockgen": {
|
||||
|
||||
+4
-1
@@ -9,7 +9,7 @@
|
||||
"version-check": "Strona jest kompletna dla wersji {version} symulatora TD2"
|
||||
},
|
||||
"inputs": {
|
||||
"title": "WYBIERZ POJAZD SZYNOWY",
|
||||
"title": "WYBIERZ POJAZD",
|
||||
"input-vehicle": "Wybierz pojazd trakcyjny",
|
||||
"input-carwagon": "Wybierz wagon",
|
||||
"cargo-title": "Ładunek (tylko wybrane towarowe)",
|
||||
@@ -30,6 +30,7 @@
|
||||
"loading": "ŁADOWANIE OBRAZU...",
|
||||
"desc": "Wybierz pojazd lub wagon, aby zobaczyć jego podgląd powyżej",
|
||||
"sponsor-only": "* TYLKO DLA SPONSORÓW DO {0}",
|
||||
"team-only": "* TYLKO DLA ZESPOŁU TD2",
|
||||
"loco-electric": "ELEKTROWÓZ",
|
||||
"loco-diesel": "SPALINOWÓZ",
|
||||
"unit-electric": "EZT",
|
||||
@@ -68,11 +69,13 @@
|
||||
"coldstart-info": "Zimny start",
|
||||
"doublemanning-info": "Podwójna obsada",
|
||||
"list-empty": "Lista pojazdów jest pusta!",
|
||||
|
||||
"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-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-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"
|
||||
},
|
||||
"stockgen": {
|
||||
|
||||
@@ -28,9 +28,8 @@ export default defineComponent({
|
||||
cargo: !isLoco && vehicle.loadable && cargo ? cargo : undefined,
|
||||
count,
|
||||
group: isLoco ? vehicle.group : vehicle.group,
|
||||
isSponsorsOnly: vehicle.isSponsorsOnly,
|
||||
constructionType: vehicle.constructionType,
|
||||
sponsorsOnlyTimestamp: vehicle.sponsorsOnlyTimestamp,
|
||||
restrictions: vehicle.restrictions,
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
@@ -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
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -6,6 +6,9 @@ $textColor: #fff;
|
||||
$secondaryColor: #1b1b1b;
|
||||
$accentColor: #e4c428;
|
||||
|
||||
$sponsorColor: salmon;
|
||||
$teamColor: gold;
|
||||
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
src:
|
||||
|
||||
+5
-17
@@ -4,6 +4,7 @@ export type StockSectionMode = 'STOCK_LIST' | 'STOCK_GENERATOR';
|
||||
export type LocoGroupType = 'loco-electric' | 'loco-diesel' | 'unit-electric' | 'unit-diesel';
|
||||
export type WagonGroupType = 'wagon-passenger' | 'wagon-freight';
|
||||
export type VehicleGroupType = LocoGroupType | WagonGroupType;
|
||||
export type RestrictionType = 'sponsorOnly' | 'teamOnly';
|
||||
|
||||
export interface IVehicleProps {
|
||||
type: string;
|
||||
@@ -13,7 +14,6 @@ export interface IVehicleProps {
|
||||
cargoTypes?: ICargo[];
|
||||
coldStart?: boolean;
|
||||
doubleManned?: boolean;
|
||||
supporterTimestamp?: number;
|
||||
}
|
||||
|
||||
export interface ICargo {
|
||||
@@ -30,16 +30,7 @@ export interface IVehiclesAPI {
|
||||
};
|
||||
};
|
||||
|
||||
vehicleList: string[][];
|
||||
|
||||
// vehiclesList: {
|
||||
// 'loco-electric': string[][];
|
||||
// 'loco-diesel': string[][];
|
||||
// 'unit-electric': string[][];
|
||||
// 'unit-diesel': string[][];
|
||||
// 'wagon-passenger': string[][];
|
||||
// 'wagon-freight': string[][];
|
||||
// };
|
||||
vehicleList: any[][];
|
||||
|
||||
vehicleProps: IVehicleProps[];
|
||||
|
||||
@@ -63,8 +54,7 @@ export interface ILocomotive {
|
||||
constructionType: string;
|
||||
cabinType: string;
|
||||
maxSpeed: number;
|
||||
isSponsorsOnly: boolean;
|
||||
sponsorsOnlyTimestamp: number;
|
||||
restrictions: Record<RestrictionType, any>;
|
||||
weight: number;
|
||||
length: number;
|
||||
coldStart: boolean;
|
||||
@@ -76,8 +66,7 @@ export interface ICarWagon {
|
||||
group: WagonGroupType;
|
||||
constructionType: string;
|
||||
loadable: boolean;
|
||||
isSponsorsOnly: boolean;
|
||||
sponsorsOnlyTimestamp: number;
|
||||
restrictions: Record<RestrictionType, any>;
|
||||
maxSpeed: number;
|
||||
weight: number;
|
||||
length: number;
|
||||
@@ -94,8 +83,7 @@ export interface IStock {
|
||||
maxSpeed: number;
|
||||
cargo?: ICargo;
|
||||
isLoco: boolean;
|
||||
isSponsorsOnly: boolean;
|
||||
sponsorsOnlyTimestamp: number;
|
||||
restrictions: Record<RestrictionType, any>;
|
||||
count: number;
|
||||
}
|
||||
|
||||
|
||||
+16
-15
@@ -20,11 +20,11 @@ export function isTractionUnit(vehicle: ILocomotive | ICarWagon): vehicle is ILo
|
||||
export function locoDataList(vehiclesData: IVehiclesAPI | undefined) {
|
||||
if (!vehiclesData) return [];
|
||||
|
||||
return vehiclesData.vehicleList.reduce((acc, vehicleInfoArray) => {
|
||||
// check if data array has 4 elements (locos & units only)
|
||||
if (vehicleInfoArray.length != 4) return acc;
|
||||
return vehiclesData.vehicleList.reduce<ILocomotive[]>((acc, vehicleInfoArray) => {
|
||||
// check if data array has 5 elements (locos & units only)
|
||||
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);
|
||||
|
||||
if (!locoProps) {
|
||||
@@ -39,8 +39,7 @@ export function locoDataList(vehiclesData: IVehiclesAPI | undefined) {
|
||||
constructionType,
|
||||
cabinType,
|
||||
|
||||
isSponsorsOnly: (locoProps.supporterTimestamp ?? 0) > Date.now(),
|
||||
sponsorsOnlyTimestamp: locoProps.supporterTimestamp ?? 0,
|
||||
restrictions: restrictions ?? {},
|
||||
|
||||
maxSpeed: locoProps.speed,
|
||||
length: locoProps.length,
|
||||
@@ -51,18 +50,20 @@ export function locoDataList(vehiclesData: IVehiclesAPI | undefined) {
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, [] as ILocomotive[]);
|
||||
}, []);
|
||||
}
|
||||
|
||||
export function carDataList(vehiclesData: IVehiclesAPI | undefined) {
|
||||
if (!vehiclesData) return [];
|
||||
|
||||
return vehiclesData.vehicleList.reduce((acc, vehicleInfoArray) => {
|
||||
// check if data array has 3 elements (wagons only)
|
||||
if (vehicleInfoArray.length != 3) return acc;
|
||||
console.log(vehiclesData);
|
||||
|
||||
const [type, constructionType, group] = vehicleInfoArray;
|
||||
const wagonProps = vehiclesData.vehicleProps.find((v) => type.toString().startsWith(v.type));
|
||||
return vehiclesData.vehicleList.reduce<ICarWagon[]>((acc, vehicleInfoArray) => {
|
||||
// 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) {
|
||||
console.warn('Brak atrybutów dla pojazdu:', type);
|
||||
@@ -74,17 +75,17 @@ export function carDataList(vehiclesData: IVehiclesAPI | undefined) {
|
||||
type,
|
||||
constructionType,
|
||||
loadable: wagonProps.cargoTypes ? wagonProps.cargoTypes.length > 0 : false,
|
||||
isSponsorsOnly: (wagonProps.supporterTimestamp ?? 0) > Date.now(),
|
||||
sponsorsOnlyTimestamp: wagonProps.supporterTimestamp ?? 0,
|
||||
cargoTypes: wagonProps?.cargoTypes ?? [],
|
||||
|
||||
restrictions: restrictions ?? {},
|
||||
|
||||
maxSpeed: wagonProps.speed,
|
||||
weight: wagonProps?.weight || 0,
|
||||
length: wagonProps?.length || 0,
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, [] as ICarWagon[]);
|
||||
}, []);
|
||||
}
|
||||
|
||||
export function totalWeight(stockList: IStock[]) {
|
||||
|
||||
Reference in New Issue
Block a user