diff --git a/src/markets/bulkSlave/bulkSlaveIntro.js b/src/markets/bulkSlave/bulkSlaveIntro.js index fd78303482ec59c9370a430d26d067a6a9c50822..18ca0d1bcd652376e6c555eaf4d182138a5b9c6a 100644 --- a/src/markets/bulkSlave/bulkSlaveIntro.js +++ b/src/markets/bulkSlave/bulkSlaveIntro.js @@ -1,6 +1,7 @@ App.Markets.bulkSlaveIntro = function() { const el = new DocumentFragment(); const r = []; + const discount = App.Markets.getDiscount(); let seed; let p; if (!V.market.introType || V.market.newSlaves.length === 0) { @@ -34,10 +35,10 @@ App.Markets.bulkSlaveIntro = function() { } if (V.market.slaveMarket === "TFS") { /* Put line about The Futanari Sisters discount & pricing */ - } else if (V.discount === 475) { + } else if (discount === 475) { r.push(`Your bulk delivery came with a <span class="yellowgreen">5%</span> discount.`); } else { - r.push(`With all your discounts factored in you got a <span class="yellowgreen">${(500 - V.discount) / 5}%</span> discount;`); + r.push(`With all your discounts factored in you got a <span class="yellowgreen">${(500 - discount) / 5}%</span> discount;`); } r.push(`You spent <span class="yellowgreen">${cashFormat(V.spent)}</span> on your new slaves.`); break; @@ -45,10 +46,10 @@ App.Markets.bulkSlaveIntro = function() { r.push(`You clear out ${App.Markets.marketName(V.market.slaveMarket, V.market.numArcology)} of its stock of ${V.market.newSlaves.length} slaves.`); if (V.market.slaveMarket === "TFS") { /* Put line about The Futanari Sisters discount & pricing */ - } else if (V.discount === 475) { + } else if (discount === 475) { r.push(`Your bulk delivery came with a <span class="yellowgreen">5%</span> discount.`); } else { - r.push(`With all your discounts factored in you got a <span class="yellowgreen">${(500 - V.discount) / 5}%</span> discount`); + r.push(`With all your discounts factored in you got a <span class="yellowgreen">${(500 - discount) / 5}%</span> discount`); } r.push(`You spent <span class="yellowgreen">${cashFormat(V.spent)}</span> on your new slaves.`); break; @@ -119,3 +120,77 @@ App.Markets.bulkSlaveIntro = function() { V.market.newSlaveIndex++; return el; }; + +App.Markets.getDiscount = function() { + /* Discount calculation. Gives 5% on top of slave school discount */ + let discount = 475; + let opinion; + switch (V.market.slaveMarket) { + case "TSS": + if (V.TSS.schoolUpgrade !== 0) { + discount = 375; + } + break; + case "TUO": + if (V.TUO.schoolUpgrade !== 0) { + discount = 375; + } + break; + case "GRI": + if (V.GRI.schoolUpgrade !== 0) { + discount = 375; + } + break; + case "SCP": + if (V.SCP.schoolUpgrade !== 0) { + discount = 375; + } + break; + case "LDE": + if (V.LDE.schoolUpgrade !== 0) { + discount = 375; + } + break; + case "TGA": + if (V.TGA.schoolUpgrade !== 0) { + discount = 375; + } + break; + case "HA": + if (V.HA.schoolUpgrade !== 0) { + discount = 375; + } + break; + case "NUL": + if (V.NUL.schoolUpgrade !== 0) { + discount = 375; + } + break; + case "TCR": + if (V.TCR.schoolUpgrade !== 0) { + discount = 375; + } + break; + case "TFS": + if (V.TFS.schoolUpgrade !== 0) { + discount = 300; + } else { + discount = 380; + } + break; + case "corporate": + if (V.corp.Market === 1) { + discount = 350; + } + break; + case "neighbor": + if (V.market.numArcology >= V.arcologies.length) { + V.market.numArcology = 1; + } + opinion = App.Neighbor.opinion(0, V.market.numArcology); + opinion = Math.clamp(Math.trunc(opinion/20), -10, 10); + discount -= (opinion * 25); + break; + } + return discount; +}; diff --git a/src/uncategorized/bulkSlaveGenerate.tw b/src/uncategorized/bulkSlaveGenerate.tw index df6d83a2b8f26483ff93809778375f3ec1c00f04..82b3a8e14c94080adea4e6127e175c79389fab75 100644 --- a/src/uncategorized/bulkSlaveGenerate.tw +++ b/src/uncategorized/bulkSlaveGenerate.tw @@ -6,75 +6,7 @@ <<set $market.numSlaves = 5>> <</if>> -/* Discount calculation. Gives 5% on top of slave school discount */ -<<set $discount = 475>> -<<switch $market.slaveMarket>> -<<case "TSS">> - <<if $TSS.schoolUpgrade != 0>> - <<set $discount = 375>> - <</if>> - -<<case "TUO">> - <<if $TUO.schoolUpgrade != 0>> - <<set $discount = 375>> - <</if>> - -<<case "GRI">> - <<if $GRI.schoolUpgrade != 0>> - <<set $discount = 375>> - <</if>> - -<<case "SCP">> - <<if $SCP.schoolUpgrade != 0>> - <<set $discount = 375>> - <</if>> - -<<case "LDE">> - <<if $LDE.schoolUpgrade != 0>> - <<set $discount = 375>> - <</if>> - -<<case "TGA">> - <<if $TGA.schoolUpgrade != 0>> - <<set $discount = 375>> - <</if>> - -<<case "HA">> - <<if $HA.schoolUpgrade != 0>> - <<set $discount = 375>> - <</if>> - -<<case "NUL">> - <<if $NUL.schoolUpgrade != 0>> - <<set $discount = 375>> - <</if>> - -<<case "TCR">> - <<if $TCR.schoolUpgrade != 0>> - <<set $discount = 375>> - <</if>> - -<<case "TFS">> - <<if $TFS.schoolUpgrade != 0>> - <<set $discount = 300>> - <<else>> - <<set $discount = 380>> - <</if>> - -<<case "corporate">> - <<if $corp.Market == 1>> - <<set $discount = 350>> - <</if>> - -<<case "neighbor">> - <<if $market.numArcology >= $arcologies.length>> - <<set $market.numArcology = 1>> - <</if>> - <<set _opinion = App.Neighbor.opinion(0, $market.numArcology)>> - <<set _opinion = Math.clamp(Math.trunc(_opinion/20), -10, 10)>> - <<set $discount -= (_opinion * 25)>> - -<</switch>> +<<set _discount = App.Markets.getDiscount()>> <<for _i = 0; _i < $market.numSlaves; _i++>> <<set $activeSlave = (generateMarketSlave($market.slaveMarket, $market.numArcology)).slave>> @@ -98,7 +30,7 @@ <</if>> /* Apply discount modifier */ - <<set _slaveCost = $discount*Math.trunc(_slaveCost/500)>> + <<set _slaveCost = _discount*Math.trunc(_slaveCost/500)>> /* Charge the Player for the slave, or break out if cannot afford */ <<if $cash < _slaveCost>>