From 6495b970b488d9f3ed3a5cf519995d13dd2f042c Mon Sep 17 00:00:00 2001 From: Viliam Krizan Date: Tue, 28 Jan 2025 13:34:53 +0100 Subject: [PATCH 1/9] fix(game): fs25 difficulty --- server/model/game.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/model/game.js b/server/model/game.js index 31cb2e9..b876b59 100644 --- a/server/model/game.js +++ b/server/model/game.js @@ -10,7 +10,7 @@ module.exports.Game = function (game) { this.mapname = game.settings !== undefined ? game.settings.mapTitle._text : '-' this.timeScale = util.formatNumber(timeScale, 0, "x") this.saveInterval = game.settings !== undefined ? util.formatNumber(game.settings.autoSaveInterval._text, 0, '') : 0 - this.difficulty = game.settings !== undefined ? game.settings.difficulty._text : '-' + this.difficulty = game.settings !== undefined && game.settings.difficulty !== undefined ? game.settings.difficulty : '-' this.economicDifficulty = game.settings !== undefined ? game.settings.economicDifficulty._text : '-' this.isNewServer = game.settings === undefined || game.statistics === undefined ? true : false -} \ No newline at end of file +} From 4e75657a7c9084417b628fdd06fbab35d66c7b53 Mon Sep 17 00:00:00 2001 From: Viliam Krizan Date: Sat, 8 Feb 2025 15:14:27 +0100 Subject: [PATCH 2/9] feat: show game version in titles Use version of the game from the server to display it on page titles. --- client/index.pug | 2 +- client/layout.pug | 2 +- server/model/server.js | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client/index.pug b/client/index.pug index 83ffe27..ff7c557 100644 --- a/client/index.pug +++ b/client/index.pug @@ -6,7 +6,7 @@ html(lang="en").h-100 title=server.name + " - Oasis " + config.VERSION meta(charset="utf-8") meta(name='viewport', content='width=device-width, initial-scale=1, shrink-to-fit=no') - meta(name="description", content=server.name + " - Farming Simulator 22 Server - " + server.version + " - Oasis #{config.VERSION} - Farming Simulator 22 Live Map") + meta(name="description", content=server.name + " - " + server.game + " Server - " + server.version + " - Oasis #{config.VERSION} - " + server.game + " Live Map") meta(name="author", content="msdigital.ch") link(rel='shortcut icon', href='/images/Oasis_Favicon.png') link(rel='icon', type='image/png', href='/images/Oasis_Favicon.png', sizes='32x32') diff --git a/client/layout.pug b/client/layout.pug index a7862f7..ac8525a 100644 --- a/client/layout.pug +++ b/client/layout.pug @@ -38,7 +38,7 @@ mixin footer() span.text-muted Code & Design: © 2020 a(href='http://www.msdigital.ch', target='_blank') msdigital.ch span.text-muted.float-end - | Oasis #{config.VERSION} - Farming Simulator 22 Live Map + | Oasis #{config.VERSION} - Farming Simulator Live Map mixin newServerError() if isNewServer diff --git a/server/model/server.js b/server/model/server.js index 167f1ce..6257ef7 100644 --- a/server/model/server.js +++ b/server/model/server.js @@ -2,6 +2,7 @@ var lodash = require('lodash') module.exports.Server = function(server){ this.name = server._attributes.name + this.game = server._attributes.game || "Farming Simulator 22" this.version = server._attributes.version this.mods = getMods((server.Mods !== undefined ? server.Mods.Mod : null)) } From fac2086778b2f078d9a468c19a5e3983d9b75f65 Mon Sep 17 00:00:00 2001 From: Viliam Krizan Date: Sat, 8 Feb 2025 15:15:45 +0100 Subject: [PATCH 3/9] feat: contributors in the copyright --- client/layout.pug | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/layout.pug b/client/layout.pug index ac8525a..c0cfeb0 100644 --- a/client/layout.pug +++ b/client/layout.pug @@ -35,8 +35,10 @@ mixin scripts() mixin footer() footer.footer.mt-auto.py-3 .container - span.text-muted Code & Design: © 2020 + span.text-muted Code & Design: © 2026 a(href='http://www.msdigital.ch', target='_blank') msdigital.ch + | & + a(href='https://github.com/msdigital/oasis/graphs/contributors', target='_blank') Contributors span.text-muted.float-end | Oasis #{config.VERSION} - Farming Simulator Live Map From c10a0a0f1055b5581e39c1ce7eb394898fbed6fb Mon Sep 17 00:00:00 2001 From: Viliam Krizan Date: Sat, 8 Feb 2025 15:19:31 +0100 Subject: [PATCH 4/9] fix: skip UNKNOWN fillType --- server/model/economy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/model/economy.js b/server/model/economy.js index 123afde..714415f 100644 --- a/server/model/economy.js +++ b/server/model/economy.js @@ -10,7 +10,7 @@ var EXCLUDED_PRODUCTS = [ "LIME", "FORAGE", "FORAGE_MIXING", "TREESAPLINGS", "OILSEEDRADISH", "POPLAR", "DIESEL", "DEF", "ELECTRICCHARGE", "METHANE", "ROUNDBALE", "ROUNDBALE_GRASS", "ROUNDBALE_DRYGRASS", "ROUNDBALE_COTTON", - "LIQUIDFERTILIZER", + "LIQUIDFERTILIZER", "UNKNOWN" ] var ECONOMY_MONTHS = [ From e91cefa5248ff61ff32d506395c6be70d57c7f77 Mon Sep 17 00:00:00 2001 From: Viliam Krizan Date: Sat, 8 Feb 2025 15:11:46 +0100 Subject: [PATCH 5/9] feat(economy): rework price calculation Calculate prices from spring (starting with March) and ending with winter (ending with February). --- client/economy.pug | 2 +- server/model/economy.js | 74 ++++++++++------------------------------- 2 files changed, 19 insertions(+), 57 deletions(-) diff --git a/client/economy.pug b/client/economy.pug index 0a7257a..27745e9 100644 --- a/client/economy.pug +++ b/client/economy.pug @@ -15,7 +15,7 @@ block content th= month tbody.table-group-divider each fillType in economy.prices - if fillType.formattedPrices.length>0 + if fillType.formattedPrices.some(fp => fp.length > 0) tr td=__("product_"+fillType.name) - var nextPrice = 0 diff --git a/server/model/economy.js b/server/model/economy.js index 714415f..6f081f2 100644 --- a/server/model/economy.js +++ b/server/model/economy.js @@ -13,20 +13,15 @@ var EXCLUDED_PRODUCTS = [ "LIQUIDFERTILIZER", "UNKNOWN" ] -var ECONOMY_MONTHS = [ - {}, - { "month": 2, "name": "Mar." }, - { "month": 3, "name": "Apr." }, - { "month": 4, "name": "May" }, - { "month": 5, "name": "Jun." }, - { "month": 6, "name": "Jul." }, - { "month": 7, "name": "Aug." }, - { "month": 8, "name": "Sep." }, - { "month": 9, "name": "Oct." }, - { "month": 10, "name": "Nov." }, - { "month": 11, "name": "Dec." }, - { "month": 0, "name": "Jan." }, - { "month": 1, "name": "Feb." }, +const ECONOMY_MONTHS = [ + // Spring + "Mar.", "Apr.", "May", + // Summer + "Jun.", "Jul.", "Aug.", + // Autumn + "Sep.", "Oct.", "Nov.", + // Winter + "Dec.", "Jan.", "Feb." ] module.exports.Economy = function (economy) { @@ -34,50 +29,24 @@ module.exports.Economy = function (economy) { this.calculateEconomy = function (difficulty, cb) { var prices = calcluatePrices(this.rawPrices, getPriceFactor(difficulty)) - var months = getOrderMonths(); - + var months = ECONOMY_MONTHS; cb({ prices: prices, months: months }) } } -var getOrderMonths = function () { - var months = new Array(); - delete ECONOMY_MONTHS[0]; - - ECONOMY_MONTHS.forEach((month, ix) => { - months.splice(month.month, 0, month.name) - }) - return months; -} - var calcluatePrices = function (fillTypes, factor) { - var results = [] - , resultPrices = Array(2).fill(null).map(() => Array()); - if (!Array.isArray(fillTypes)) { fillTypes = [fillTypes] } - fillTypes.some((fillType, i) => { - if (!lodash.isEmpty(fillType)) { - fillType.prices.forEach((price, ix) => { - if (price > 0) { - var calcPrice = (price * factor) - , calcPriceFormat = util.formatNumber(calcPrice, 2, ' €') - , monthIndex = ECONOMY_MONTHS[ix].month - - resultPrices[0].splice(monthIndex, 0, calcPrice) - resultPrices[1].splice(monthIndex, 0, calcPriceFormat) - } - }) - fillType.prices = resultPrices[0] - fillType.formattedPrices = resultPrices[1] - results.push(fillType) - resultPrices[0] = new Array() - resultPrices[1] = new Array() + return fillTypes.map((fillType) => { + if (lodash.isEmpty(fillType)) { + return; } - }) - return results + fillType.prices = fillType.prices.map(price => (price > 0) ? price * factor : 0); + fillType.formattedPrices = fillType.prices.map(price => (price > 0) ? util.formatNumber(price, 2, ' €') : ''); + return fillType + }).filter((i) => !!i); } var mapPrices = function (fillTypes) { @@ -102,18 +71,11 @@ var FillType = function (type) { } var FillTypePrices = function (prices) { - var results = Array() - if (!Array.isArray(prices)) { prices = [prices]; } - prices.forEach(price => { - if (!lodash.isEmpty(price)) { - results[price._attributes.period] = Number(price._text) - } - }) - return results + return prices.sort((a, b) => a._attributes.period - b._attributes.period).map(p => Number(p._text)); } var getPriceFactor = function (difficulty) { From 215a916da8ed7fb2ecb473e617889a18f21dfa1b Mon Sep 17 00:00:00 2001 From: Viliam Krizan Date: Sat, 8 Feb 2025 15:50:24 +0100 Subject: [PATCH 6/9] refactor(economy): FillType as class --- server/model/economy.js | 53 ++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/server/model/economy.js b/server/model/economy.js index 6f081f2..d7a4154 100644 --- a/server/model/economy.js +++ b/server/model/economy.js @@ -39,43 +39,46 @@ var calcluatePrices = function (fillTypes, factor) { fillTypes = [fillTypes] } - return fillTypes.map((fillType) => { - if (lodash.isEmpty(fillType)) { - return; - } - fillType.prices = fillType.prices.map(price => (price > 0) ? price * factor : 0); - fillType.formattedPrices = fillType.prices.map(price => (price > 0) ? util.formatNumber(price, 2, ' €') : ''); - return fillType - }).filter((i) => !!i); + return fillTypes.filter(ft => !lodash.isEmpty(ft)). + map((fillType) => { + const prices = fillType.prices.map(price => (price > 0) ? price * factor : 0); + const formattedPrices = fillType.prices.map(price => (price > 0) ? util.formatNumber(price, 2, ' €') : ''); + return new FillType(fillType.name, prices, formattedPrices) + }); } var mapPrices = function (fillTypes) { - var results = [] - if (!Array.isArray(fillTypes)) { fillTypes = [fillTypes]; } - fillTypes.forEach(type => { - if (!lodash.isEmpty(type) && !EXCLUDED_PRODUCTS.includes(type._attributes.fillType)) { - results.push(new FillType(type)) - } - }) - return results + return fillTypes.filter( + type => !lodash.isEmpty(type) && !EXCLUDED_PRODUCTS.includes(type._attributes.fillType) + ).map( + type => FillType.fromEconomyFillType(type) + ); } -var FillType = function (type) { - this.name = type._attributes.fillType - this.prices = FillTypePrices(type.history.period) - this.formattedPrices = null -} +class FillType { + constructor(name, prices, formattedPrices) { + this.name = name; + this.prices = prices; + this.formattedPrices = formattedPrices; + } -var FillTypePrices = function (prices) { - if (!Array.isArray(prices)) { - prices = [prices]; + static fromEconomyFillType(type) { + const name = type._attributes.fillType; + const prices = this.pricesFromHistory(type.history.period); + return new FillType(name, prices, []); } - return prices.sort((a, b) => a._attributes.period - b._attributes.period).map(p => Number(p._text)); + static pricesFromHistory(historyPeriods) { + if (!Array.isArray(historyPeriods)) { + historyPeriods = [historyPeriods]; + } + + return historyPeriods.sort((a, b) => a._attributes.period - b._attributes.period).map(p => Number(p._text)); + } } var getPriceFactor = function (difficulty) { From 5284cef4719fb2d88fd981c3346d5b00d0c9f3fb Mon Sep 17 00:00:00 2001 From: Viliam Krizan Date: Sat, 8 Feb 2025 15:57:28 +0100 Subject: [PATCH 7/9] feat(economy): less price fractions --- server/model/economy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/model/economy.js b/server/model/economy.js index d7a4154..db371f6 100644 --- a/server/model/economy.js +++ b/server/model/economy.js @@ -42,7 +42,7 @@ var calcluatePrices = function (fillTypes, factor) { return fillTypes.filter(ft => !lodash.isEmpty(ft)). map((fillType) => { const prices = fillType.prices.map(price => (price > 0) ? price * factor : 0); - const formattedPrices = fillType.prices.map(price => (price > 0) ? util.formatNumber(price, 2, ' €') : ''); + const formattedPrices = fillType.prices.map(price => (price > 0) ? util.formatNumber(price, 0, ' €') : ''); return new FillType(fillType.name, prices, formattedPrices) }); } From 30957ad4887563a8b92ea73175b81af80aef98bd Mon Sep 17 00:00:00 2001 From: Viliam Krizan Date: Sat, 8 Feb 2025 16:14:16 +0100 Subject: [PATCH 8/9] feat(economy): support FS25 pricing periods --- server/model/economy.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/server/model/economy.js b/server/model/economy.js index db371f6..c455ca0 100644 --- a/server/model/economy.js +++ b/server/model/economy.js @@ -24,6 +24,13 @@ const ECONOMY_MONTHS = [ "Dec.", "Jan.", "Feb." ] +const PERIOD_NAMES = [ + "EARLY_SPRING", "MID_SPRING", "LATE_SPRING", + "EARLY_SUMMER", "MID_SUMMER", "LATE_SUMMER", + "EARLY_AUTUMN", "MID_AUTUMN", "LATE_AUTUMN", + "EARLY_WINTER", "MID_WINTER", "LATE_WINTER" +] + module.exports.Economy = function (economy) { this.rawPrices = mapPrices(economy.fillTypes.fillType) @@ -77,7 +84,13 @@ class FillType { historyPeriods = [historyPeriods]; } - return historyPeriods.sort((a, b) => a._attributes.period - b._attributes.period).map(p => Number(p._text)); + return historyPeriods.sort((a, b) => { + const periodA = a._attributes.period; + const periodB = b._attributes.period; + const periodAnum = Number(periodA) ? Number(periodA) : PERIOD_NAMES.indexOf(periodA); + const periodBnum = Number(periodB) ? Number(periodB) : PERIOD_NAMES.indexOf(periodB); + return periodAnum - periodBnum; + }).map(p => Number(p._text)); } } From ae0bcb7dc7c86db10b69499848bea003bd83abf7 Mon Sep 17 00:00:00 2001 From: Viliam Krizan Date: Sat, 8 Feb 2025 16:15:30 +0100 Subject: [PATCH 9/9] chore: version 1.23.0 --- package.json | 4 ++-- server/lib/appversion.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 0cf7570..3473f50 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "oasis", - "version": "1.22.8", - "description": "Live Map for Farming Simulator 22", + "version": "1.23.0", + "description": "Live Map for Farming Simulator", "main": "server/app.js", "private": false, "scripts": { diff --git a/server/lib/appversion.js b/server/lib/appversion.js index 0be49ec..4d1ee78 100644 --- a/server/lib/appversion.js +++ b/server/lib/appversion.js @@ -1,2 +1,2 @@ // Generated by genversion. -module.exports = '1.22.8' +module.exports = '1.23.0'