Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/economy.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion client/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 4 additions & 2 deletions client/layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ 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 22 Live Map
| Oasis #{config.VERSION} - Farming Simulator Live Map

mixin newServerError()
if isNewServer
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion server/lib/appversion.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 51 additions & 73 deletions server/model/economy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,110 +10,88 @@ 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 = [
{},
{ "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."
]

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)

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 results
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, 0, ' €') : '');
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
}

var FillType = function (type) {
this.name = type._attributes.fillType
this.prices = FillTypePrices(type.history.period)
this.formattedPrices = null
return fillTypes.filter(
type => !lodash.isEmpty(type) && !EXCLUDED_PRODUCTS.includes(type._attributes.fillType)
).map(
type => FillType.fromEconomyFillType(type)
);
}

var FillTypePrices = function (prices) {
var results = Array()
class FillType {
constructor(name, prices, formattedPrices) {
this.name = name;
this.prices = prices;
this.formattedPrices = formattedPrices;
}

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, []);
}

prices.forEach(price => {
if (!lodash.isEmpty(price)) {
results[price._attributes.period] = Number(price._text)
static pricesFromHistory(historyPeriods) {
if (!Array.isArray(historyPeriods)) {
historyPeriods = [historyPeriods];
}
})
return results

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));
}
}

var getPriceFactor = function (difficulty) {
Expand Down
4 changes: 2 additions & 2 deletions server/model/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
1 change: 1 addition & 0 deletions server/model/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down