From 00f48dbcdb1b608583216c0ba10f944542f21af1 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Sat, 14 Aug 2021 11:56:40 +0300 Subject: [PATCH] salesTax to depend on state form --- main.js | 7 ++++--- modules/burgs-and-states.js | 27 +++++++++++++++++++++++++-- modules/religions-generator.js | 8 ++++---- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/main.js b/main.js index c784b792..b05d1bdb 100644 --- a/main.js +++ b/main.js @@ -652,6 +652,10 @@ function generate() { BurgsAndStates.generate(); + Religions.generate(); + BurgsAndStates.defineStateForms(); + BurgsAndStates.defineTaxes(); + Production.collectResources(); Trade.defineCenters(); @@ -662,9 +666,6 @@ function generate() { pack.cells.road = new Uint16Array(pack.cells.i.length); pack.cells.crossroad = new Uint16Array(pack.cells.i.length); - Religions.generate(); - BurgsAndStates.defineStateForms(); - BurgsAndStates.generateProvinces(); BurgsAndStates.defineBurgFeatures(); diff --git a/modules/burgs-and-states.js b/modules/burgs-and-states.js index c50310b7..6620564e 100644 --- a/modules/burgs-and-states.js +++ b/modules/burgs-and-states.js @@ -91,11 +91,10 @@ window.BurgsAndStates = (function () { const basename = b.name.length < 9 && each5th(b.cell) ? b.name : Names.getCultureShort(b.culture); const name = Names.getState(basename, b.culture); const type = cultures[b.culture].type; - const salesTax = rn(Math.random() * 0.3, 2); const coa = COA.generate(null, null, null, type); coa.shield = COA.getShield(b.culture, null); - states.push({i, color: colors[i - 1], name, expansionism, capital: i, type, center: b.cell, culture: b.culture, coa, salesTax}); + states.push({i, color: colors[i - 1], name, expansionism, capital: i, type, center: b.cell, culture: b.culture, coa}); cells.burg[b.cell] = i; }); @@ -1051,6 +1050,29 @@ window.BurgsAndStates = (function () { return adjName ? `${getAdjective(s.name)} ${s.formName}` : `${s.formName} of ${s.name}`; }; + const defineTaxes = function () { + const {states} = pack; + const maxTaxPerForm = { + Monarchy: 0.3, + Republic: 0.1, + Union: 0.2, + Theocracy: 0.3, + Anarchy: 0 + }; + + for (const state of states) { + const {i, removed, form} = state; + if (removed) continue; + if (!i) { + state.salesTax = 0; + continue; + } + + const maxTax = maxTaxPerForm[form] || 0; + state.salesTax = maxTax ? rn(Math.random() * maxTax, 2) : 0; + } + }; + const generateProvinces = function (regenerate) { TIME && console.time('generateProvinces'); const localSeed = regenerate ? Math.floor(Math.random() * 1e9).toString() : seed; @@ -1255,6 +1277,7 @@ window.BurgsAndStates = (function () { generateDiplomacy, defineStateForms, getFullName, + defineTaxes, generateProvinces, updateCultures }; diff --git a/modules/religions-generator.js b/modules/religions-generator.js index 283e2ebe..2461acb1 100644 --- a/modules/religions-generator.js +++ b/modules/religions-generator.js @@ -491,10 +491,10 @@ window.Religions = (function () { const cultureCost = c !== cells.culture[e] ? 10 : 0; const stateCost = s !== cells.state[e] ? 10 : 0; - const biomeCost = cells.road[e] ? 1 : biomesData.cost[cells.biome[e]]; + const biomeCost = biomesData.cost[cells.biome[e]]; const populationCost = Math.max(rn(popCost - cells.pop[e]), 0); const heightCost = Math.max(cells.h[e], 20) - 20; - const waterCost = cells.h[e] < 20 ? (cells.road[e] ? 50 : 1000) : 0; + const waterCost = cells.h[e] < 20 ? 500 : 0; const totalCost = p + (cultureCost + stateCost + biomeCost + populationCost + heightCost + waterCost) / religions[r].expansionism; if (totalCost > neutral) return; @@ -534,9 +534,9 @@ window.Religions = (function () { cells.c[n].forEach(function (e) { const religionCost = cells.religion[e] === b ? 0 : 2000; - const biomeCost = cells.road[e] ? 0 : biomesData.cost[cells.biome[e]]; + const biomeCost = biomesData.cost[cells.biome[e]]; const heightCost = Math.max(cells.h[e], 20) - 20; - const waterCost = cells.h[e] < 20 ? (cells.road[e] ? 50 : 1000) : 0; + const waterCost = cells.h[e] < 20 ? 500 : 0; const totalCost = p + (religionCost + biomeCost + heightCost + waterCost) / Math.max(religions[r].expansionism, 0.1); if (totalCost > neutral) return;