From 71acd16d403c9dd2debb0e9f38c4a8cd89df23b0 Mon Sep 17 00:00:00 2001 From: Empress Sela <empresssela@cock.li> Date: Fri, 17 Jul 2020 20:05:41 -0400 Subject: [PATCH] Fixes; implement calculation in Acquisition - Formatting, oversight in algorithm - Properly update missing table for NGP - Re-calculate coefficients of new starting slaves --- src/data/newGamePlus.js | 8 +++++--- src/js/ibcJS.js | 3 ++- src/npc/acquisition.tw | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/data/newGamePlus.js b/src/data/newGamePlus.js index 4a4b1d814fa..be9f97a606d 100644 --- a/src/data/newGamePlus.js +++ b/src/data/newGamePlus.js @@ -126,13 +126,15 @@ App.Data.NewGamePlus = (function() { if (so.father === s.ID) so.father = oldMissingParentID; }); - V.slaves.filter(so => (so.assignment === Job.IMPORTED)).forEach(so => { + V.slaves.concat([V.PC]).forEach(so => { if (so.mother === s.ID) so.mother = oldMissingParentID; if (so.father === s.ID) so.father = oldMissingParentID; - WombChangeID(so, s.ID, oldMissingParentID); - WombChangeGeneID(so, s.ID, oldMissingParentID); + if (so.assignment === Job.IMPORTED || so.ID === -1) { + WombChangeID(so, s.ID, oldMissingParentID); + WombChangeGeneID(so, s.ID, oldMissingParentID); + } }); oldMissingParentID--; }); diff --git a/src/js/ibcJS.js b/src/js/ibcJS.js index da8805f6e61..fea3329515e 100644 --- a/src/js/ibcJS.js +++ b/src/js/ibcJS.js @@ -77,11 +77,12 @@ globalThis.ibc = (() => { while (pfx.length > 0) { let p = pfx.pop(0); + pfx_s.pop(0); let ret = find_nc(p, a); ret.nodecodes.forEach(nc => { let i = pfx_s.indexOf(nc.join(';')); - if (i == -1) + if (i === -1) return; pfx.pop(i); diff --git a/src/npc/acquisition.tw b/src/npc/acquisition.tw index ebb7ec31987..59d74203b7f 100644 --- a/src/npc/acquisition.tw +++ b/src/npc/acquisition.tw @@ -178,6 +178,23 @@ <<set $missingParentID-->> <</if>> <</for>> +<<set _coeffSlaves = []>> +<<set _genePoolMap = {}>> +<<for _i = 0; _i < $genePool.length; _i++>> + <<set _genePoolMap[$genePool[_i].ID] = $genePool[_i]>> +<</for>> +<<for _i = 0; _i < $slaves.length; _i++>> + <<if $slaves[_i].newGamePlus == 0>> + <<set $slaves[_i].inbreedingCoeff = -1>> + <<set _genePoolMap[$slaves[_i].ID].inbreedingCoeff = -1>> + <<run _coeffSlaves.push($slaves[_i])>> + <</if>> +<</for>> +<<set _ibcoeffs = ibc.coeff_slaves(_coeffSlaves)>> +<<for _i = 0; _i < _coeffSlaves.length; _i++>> + <<set _coeffSlaves[_i].inbreedingCoeff = _ibcoeffs[_coeffSlaves[_i].ID]>> + <<set _genePoolMap[_coeffSlaves[_i].ID].inbreedingCoeff = _ibcoeffs[_coeffSlaves[_i].ID]>> +<</for>> <<if $plot == 1 && $neighboringArcologies > 0>> <<set _bestProsperity = 0, _bestProsperityIndex = 1>> <<for _acq = 1; _acq < $arcologies.length; _acq++>> -- GitLab