Skip to content
Snippets Groups Projects
Commit 84e24b5e authored by Pregmodder's avatar Pregmodder
Browse files

Merge branch 'fixes' into 'pregmod-master'

Security report fixes

See merge request pregmodfan/fc-pregmod!8384
parents 26d9746a b98f01e1
No related branches found
No related tags found
No related merge requests found
...@@ -51,57 +51,58 @@ App.SecExp.bulkUpgradeUnit = function(unit) { ...@@ -51,57 +51,58 @@ App.SecExp.bulkUpgradeUnit = function(unit) {
/** Reports changes to the supplied unit's loyalty. /** Reports changes to the supplied unit's loyalty.
* @param {FC.SecExp.PlayerHumanUnitData} input the unit type to be checked. * @param {FC.SecExp.PlayerHumanUnitData} input the unit type to be checked.
* @param {FC.SecExp.PlayerHumanUnitType} type * @param {FC.SecExp.PlayerHumanUnitType} type
* @returns {HTMLDivElement}
*/ */
App.SecExp.humanUnitLoyaltyChanges = function(input, type) { App.SecExp.humanUnitLoyaltyChanges = function(input, type) {
let loyaltyChange = 0, el = document.createElement("div"); let loyaltyChange = 0, el = document.createElement("div");
el.append(`${input.platoonName}: `); el.append(`${input.platoonName}: `);
if (V.SecExp.buildings.barracks && V.SecExp.buildings.barracks.loyaltyMod >= 1) { if (V.SecExp.buildings.barracks && V.SecExp.buildings.barracks.loyaltyMod >= 1) {
el.append("is periodically sent to the indoctrination facility in the barracks for thought correction therapy."); el.append("is periodically sent to the indoctrination facility in the barracks for thought correction therapy. ");
loyaltyChange += 2 * V.SecExp.buildings.barracks.loyaltyMod; loyaltyChange += 2 * V.SecExp.buildings.barracks.loyaltyMod;
} }
if (input.commissars >= 1) { if (input.commissars >= 1) {
el.append("The commissars attached to the unit carefully monitor the officers and grunts for signs of insubordination."); el.append("The commissars attached to the unit carefully monitor the officers and grunts for signs of insubordination. ");
loyaltyChange += 2 * input.commissars; loyaltyChange += 2 * input.commissars;
} }
if (V.SecExp.edicts.defense.soldierWages === 2) { if (V.SecExp.edicts.defense.soldierWages === 2) {
if (type === 'slave') { if (type === 'slave') {
el.append("The slaves greatly appreciate the generous wage given to them for their service as soldiers. Occasions to earn money for a slave are scarce after all."); el.append("The slaves greatly appreciate the generous wage given to them for their service as soldiers. Occasions to earn money for a slave are scarce after all. ");
} else if (type === 'citizens') { } else if (type === 'citizens') {
el.append("The soldiers greatly appreciate the generous wage given to them for their service. They are proud to defend their homes while making a small fortune out of it."); el.append("The soldiers greatly appreciate the generous wage given to them for their service. They are proud to defend their homes while making a small fortune out of it. ");
} else if (type === 'mercenary') { } else if (type === 'mercenary') {
el.append("The mercenaries greatly appreciate the generous wage given to them for their service. After all coin is the fastest way to reach their hearts."); el.append("The mercenaries greatly appreciate the generous wage given to them for their service. After all coin is the fastest way to reach their hearts. ");
} }
loyaltyChange += random(5, 10); loyaltyChange += random(5, 10);
} else if (V.SecExp.edicts.defense.soldierWages === 1) { } else if (V.SecExp.edicts.defense.soldierWages === 1) {
if (type === 'slave') { if (type === 'slave') {
el.append("The slaves appreciate the wage given to them for their service as soldiers, despite it being just adequate. Occasions to earn money for a slave are scarce after all."); el.append("The slaves appreciate the wage given to them for their service as soldiers, despite it being just adequate. Occasions to earn money for a slave are scarce after all. ");
} else if (type === 'citizens') { } else if (type === 'citizens') {
el.append("The soldiers appreciate the wage given to them for their service, despite it being just adequate. They are proud to defend their homes, though at the cost of possible financial gains."); el.append("The soldiers appreciate the wage given to them for their service, despite it being just adequate. They are proud to defend their homes, though at the cost of possible financial gains. ");
} else if (type === 'mercenary') { } else if (type === 'mercenary') {
el.append("The mercenaries do not appreciate the barely adequate wage given to them for their service. Still their professionalism keeps them determined to finish their contract."); el.append("The mercenaries do not appreciate the barely adequate wage given to them for their service. Still their professionalism keeps them determined to finish their contract. ");
} }
loyaltyChange += random(-5, 5); loyaltyChange += random(-5, 5);
} else { } else {
if (type === 'slave') { if (type === 'slave') {
el.append("The slaves do not appreciate the low wage given to them for their service as soldiers, but occasions to earn money for a slave are scarce, so they're not too affected by it."); el.append("The slaves do not appreciate the low wage given to them for their service as soldiers, but occasions to earn money for a slave are scarce, so they're not too affected by it. ");
} else if (type === 'citizens') { } else if (type === 'citizens') {
el.append("The soldiers do not appreciate the low wage given to them for their service. Their sense of duty keeps them proud of their role as defenders of the arcology, but many do feel its financial weight."); el.append("The soldiers do not appreciate the low wage given to them for their service. Their sense of duty keeps them proud of their role as defenders of the arcology, but many do feel its financial weight. ");
} else if (type === 'mercenary') { } else if (type === 'mercenary') {
el.append("The mercenaries do not appreciate the low wage given to them for their service. Their skill would be better served by a better contract and this world does not lack demand for guns for hire."); el.append("The mercenaries do not appreciate the low wage given to them for their service. Their skill would be better served by a better contract and this world does not lack demand for guns for hire. ");
} }
loyaltyChange -= random(5, 10); loyaltyChange -= random(5, 10);
} }
if (type === 'slave' && V.SecExp.edicts.defense.privilege.slaveSoldier) { if (type === 'slave' && V.SecExp.edicts.defense.privilege.slaveSoldier) {
el.append("Allowing them to hold material possessions earns you their devotion and loyalty."); el.append("Allowing them to hold material possessions earns you their devotion and loyalty. ");
loyaltyChange += random(1, 2); loyaltyChange += random(1, 2);
} }
if (type === 'citizens' && V.SecExp.edicts.defense.privilege.militiaSoldier) { if (type === 'citizens' && V.SecExp.edicts.defense.privilege.militiaSoldier) {
el.append("Allowing them to avoid rent payment for their military service earns you their happiness and loyalty."); el.append("Allowing them to avoid rent payment for their military service earns you their happiness and loyalty. ");
loyaltyChange += random(1, 2); loyaltyChange += random(1, 2);
} }
if (type === 'mercenary' && V.SecExp.edicts.defense.privilege.mercSoldier) { if (type === 'mercenary' && V.SecExp.edicts.defense.privilege.mercSoldier) {
el.append("Allowing them to keep part of the loot gained from your enemies earns you their trust and loyalty."); el.append("Allowing them to keep part of the loot gained from your enemies earns you their trust and loyalty. ");
loyaltyChange += random(1, 2); loyaltyChange += random(1, 2);
} }
......
...@@ -6,13 +6,13 @@ App.SecExp.securityReport = function() { ...@@ -6,13 +6,13 @@ App.SecExp.securityReport = function() {
emigration = V.oldACitizens - V.ACitizens; // takes into account citizens leaving and those getting enslaved emigration = V.oldACitizens - V.ACitizens; // takes into account citizens leaving and those getting enslaved
} }
const activeUnits = App.SecExp.battle.activeUnits(); const activeUnits = App.SecExp.battle.activeUnits();
let SF, t = ``; /** @type {(string|HTMLElement|DocumentFragment)[]} */
let r = V.useTabs === 0 ? ['&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>__Security__<br>'] : []; let r = V.useTabs === 0 ? ['<h2>Security</h2>'] : [];
if (V.SecExp.buildings.secHub && V.SecExp.buildings.secHub.menials > 0) { if (V.SecExp.buildings.secHub && V.SecExp.buildings.secHub.menials > 0) {
r.push(`${num(V.SecExp.buildings.secHub.menials)} slaves work to improve the security of your arcology, while your`); r.push(`${num(V.SecExp.buildings.secHub.menials)} slaves work to improve the security of your arcology, while your`);
} else { } else {
r.push(`Your `); r.push(`Your`);
} }
if (V.mercenaries >= 1 && V.arcologyUpgrade.drones === 1) { if (V.mercenaries >= 1 && V.arcologyUpgrade.drones === 1) {
...@@ -149,11 +149,11 @@ App.SecExp.securityReport = function() { ...@@ -149,11 +149,11 @@ App.SecExp.securityReport = function() {
if (V.SecExp.buildings.transportHub) { if (V.SecExp.buildings.transportHub) {
secGrowth -= (V.SecExp.buildings.transportHub.airport + V.SecExp.buildings.transportHub.surfaceTransport - V.SecExp.buildings.transportHub.security * 3) / 2; secGrowth -= (V.SecExp.buildings.transportHub.airport + V.SecExp.buildings.transportHub.surfaceTransport - V.SecExp.buildings.transportHub.security * 3) / 2;
t = `The transport hub, for all its usefulness, is a hotspot of malicious`; r.push(`The transport hub, for all its usefulness, is a hotspot of malicious`);
if (V.SecExp.buildings.transportHub.airport + V.SecExp.buildings.transportHub.surfaceTransport > V.SecExp.buildings.transportHub.security * 3) { if (V.SecExp.buildings.transportHub.airport + V.SecExp.buildings.transportHub.surfaceTransport > V.SecExp.buildings.transportHub.security * 3) {
r.push(t + `activity and hub security forces are not sufficient to keep up with all threats.`); r.push(`activity and hub security forces are not sufficient to keep up with all threats.`);
} else { } else {
r.push(t + `activity, but the hub security forces are up to the task.`); r.push(`activity, but the hub security forces are up to the task.`);
} }
} }
...@@ -164,8 +164,8 @@ App.SecExp.securityReport = function() { ...@@ -164,8 +164,8 @@ App.SecExp.securityReport = function() {
const assistantDamaged = V.garrison.assistantTime; const assistantDamaged = V.garrison.assistantTime;
if (assistantDamaged > 0) { if (assistantDamaged > 0) {
t = `With the central CPU core of the assistant down, managing security is a much harder task. Inevitably some little but important details will slip past your agents.`; r.push(`With the central CPU core of the assistant down, managing security is a much harder task. Inevitably some little but important details will slip past your agents.`);
r.push(t + `${numberWithPluralOne(assistantDamaged, 'week')} to finish repair works.`); r.push(`${numberWithPluralOne(assistantDamaged, 'week')} to finish repair works.`);
secGrowth--; secGrowth--;
crimeGrowth++; crimeGrowth++;
V.garrison.assistantTime--; IncreasePCSkills('engineering', 0.1); V.garrison.assistantTime--; IncreasePCSkills('engineering', 0.1);
...@@ -192,18 +192,18 @@ App.SecExp.securityReport = function() { ...@@ -192,18 +192,18 @@ App.SecExp.securityReport = function() {
r.push(`The limited infrastructure available slowly erodes away the security level of the arcology.`); r.push(`The limited infrastructure available slowly erodes away the security level of the arcology.`);
} }
t = `The security level of the arcology is`; r.push(`The security level of the arcology is`);
if (V.SecExp.core.security > (secRest + 5)) { if (V.SecExp.core.security > (secRest + 5)) {
r.push(t + `over its effective resting point, limiting the achievable growth this week.`); r.push(`over its effective resting point, limiting the achievable growth this week.`);
secGrowth *= 0.5; secGrowth *= 0.5;
} else if (V.SecExp.core.security < (secRest - 5)) { } else if (V.SecExp.core.security < (secRest - 5)) {
r.push(t + `under its effective resting point, speeding up its growth.`); r.push(`under its effective resting point, speeding up its growth.`);
secGrowth *= 1.5; secGrowth *= 1.5;
} else if (V.SecExp.core.security === secRest) { } else if (V.SecExp.core.security === secRest) {
r.push(t + `at its effective resting point, this severely limits the influence of external factors on the change achievable this week.`); r.push(`at its effective resting point, this severely limits the influence of external factors on the change achievable this week.`);
secGrowth *= 0.3; secGrowth *= 0.3;
} else { } else {
r.push(t + `near its effective resting point, this severely limits the influence of external factors on the change achievable this week.`); r.push(`near its effective resting point, this severely limits the influence of external factors on the change achievable this week.`);
if (secGrowth < 0) { if (secGrowth < 0) {
secGrowth *= 0.3; secGrowth *= 0.3;
} }
...@@ -221,24 +221,24 @@ App.SecExp.securityReport = function() { ...@@ -221,24 +221,24 @@ App.SecExp.securityReport = function() {
V.SecExp.core.security = Math.clamp(newSec, 0, 100); V.SecExp.core.security = Math.clamp(newSec, 0, 100);
r.push(`<br><br><strong>Crime</strong>:`); r.push(`<br><br><strong>Crime</strong>:`);
t = `Due to the deterioration of the old world countries, organized crime focuses more and more on the prosperous Free Cities, yours included. This has a`; r.push(`Due to the deterioration of the old world countries, organized crime focuses more and more on the prosperous Free Cities, yours included. This has a`);
if (V.week < 30) { if (V.week < 30) {
t += `small`; r.push(`small`);
crimeGrowth += 0.5; crimeGrowth += 0.5;
} else if (V.week < 60) { } else if (V.week < 60) {
t += `noticeable`; r.push(`noticeable`);
crimeGrowth += 1; crimeGrowth += 1;
} else if (V.week < 90) { } else if (V.week < 90) {
t += `moderate`; r.push(`moderate`);
crimeGrowth += 1.5; crimeGrowth += 1.5;
} else if (V.week < 120) { } else if (V.week < 120) {
t += `big`; r.push(`big`);
crimeGrowth += 2; crimeGrowth += 2;
} else { } else {
r.push(`huge`); r.push(`huge`);
crimeGrowth += 2.5; crimeGrowth += 2.5;
} }
r.push(t + `impact on the growth of criminal activities in your arcology.`); r.push(`impact on the growth of criminal activities in your arcology.`);
if (V.arcologies[0].prosperity < 50) { if (V.arcologies[0].prosperity < 50) {
r.push(`The low prosperity of the arcology facilitates criminal recruitment and organization.`); r.push(`The low prosperity of the arcology facilitates criminal recruitment and organization.`);
...@@ -313,11 +313,11 @@ App.SecExp.securityReport = function() { ...@@ -313,11 +313,11 @@ App.SecExp.securityReport = function() {
if (V.SecExp.core.authority > 12000) { if (V.SecExp.core.authority > 12000) {
if (V.SecExp.buildings.secHub.coldstorage < 6) { if (V.SecExp.buildings.secHub.coldstorage < 6) {
if (V.SecExp.buildings.secHub.coldstorage === 0) { if (V.SecExp.buildings.secHub.coldstorage === 0) {
t = `Adding a facility`; r.push(`Adding a facility`);
} else { } else {
t = `Improving the cold storage facility attached`; r.push(`Improving the cold storage facility attached`);
} }
r.push(t + ` to the SecurityHQ should allow the staff to be more efficient in dealing with crime.`); r.push(`to the SecurityHQ should allow the staff to be more efficient in dealing with crime.`);
} else { } else {
r.push(`The cold storage facility attached to SecurityHQ allows the staff to be more efficient in dealing with crime.`); r.push(`The cold storage facility attached to SecurityHQ allows the staff to be more efficient in dealing with crime.`);
} }
...@@ -337,7 +337,7 @@ App.SecExp.securityReport = function() { ...@@ -337,7 +337,7 @@ App.SecExp.securityReport = function() {
if (V.SecExp.edicts.defense.militia >= 1) { if (V.SecExp.edicts.defense.militia >= 1) {
let recruitsMultiplier = 1, recruitLimit = 0, adjst; let recruitsMultiplier = 1, recruitLimit = 0, adjst;
SF = App.SecExp.assistanceSF('security', 'militia'); const SF = App.SecExp.assistanceSF('security', 'militia');
r.push(SF.text); recruitsMultiplier += SF.bonus; r.push(SF.text); recruitsMultiplier += SF.bonus;
const propagandaEffects = App.SecExp.propagandaEffects("recruitment"); const propagandaEffects = App.SecExp.propagandaEffects("recruitment");
...@@ -432,7 +432,7 @@ App.SecExp.securityReport = function() { ...@@ -432,7 +432,7 @@ App.SecExp.securityReport = function() {
newMercs += random(1, 2); newMercs += random(1, 2);
} }
SF = App.SecExp.assistanceSF('security', 'mercs'); const SF = App.SecExp.assistanceSF('security', 'mercs');
r.push(SF.text); newMercs += SF.bonus; r.push(SF.text); newMercs += SF.bonus;
if (V.SecExp.edicts.defense.discountMercenaries > 0) { if (V.SecExp.edicts.defense.discountMercenaries > 0) {
...@@ -446,18 +446,18 @@ App.SecExp.securityReport = function() { ...@@ -446,18 +446,18 @@ App.SecExp.securityReport = function() {
} else { } else {
r.push(`This week no new mercenaries reached the arcology.<br>`); r.push(`This week no new mercenaries reached the arcology.<br>`);
} }
V.mercFreeManpower = Math.clamp(V.mercFreeManpower, 0, 2000); V.mercFreeManpower = Math.clamp(V.mercFreeManpower, 0, 2000);
} }
if (activeUnits > 0) { // loyalty and training if (activeUnits > 0) { // loyalty and training
for (const unit of V.slaveUnits) { for (const unit of V.slaveUnits) {
App.SecExp.humanUnitLoyaltyChanges(unit, 'slave'); r.push(App.SecExp.humanUnitLoyaltyChanges(unit, 'slave'));
} }
for (const unit of V.militiaUnits) { for (const unit of V.militiaUnits) {
App.SecExp.humanUnitLoyaltyChanges(unit, 'citizens'); r.push(App.SecExp.humanUnitLoyaltyChanges(unit, 'citizens'));
} }
for (const unit of V.mercUnits) { for (const unit of V.mercUnits) {
App.SecExp.humanUnitLoyaltyChanges(unit, 'mercenary'); r.push(App.SecExp.humanUnitLoyaltyChanges(unit, 'mercenary'));
} }
} }
} }
...@@ -469,13 +469,13 @@ App.SecExp.securityReport = function() { ...@@ -469,13 +469,13 @@ App.SecExp.securityReport = function() {
r.push(`The project has been completed!`); r.push(`The project has been completed!`);
V.SecExp.buildings.riotCenter.brainImplant = 106; V.SecExp.buildings.riotCenter.brainImplant = 106;
} else { } else {
t = `The great brain implant project is proceeding steadily. This week we made `; r.push(`The great brain implant project is proceeding steadily. This week we made`);
if (V.SecExp.buildings.riotCenter.brainImplantProject <= 2) { if (V.SecExp.buildings.riotCenter.brainImplantProject <= 2) {
r.push(t + `some small progress.`); r.push(`some small progress.`);
} else if (V.SecExp.buildings.riotCenter.brainImplantProject <= 4) { } else if (V.SecExp.buildings.riotCenter.brainImplantProject <= 4) {
r.push(t + `some progress.`); r.push(`some progress.`);
} else { } else {
r.push(t + `good progress.`); r.push(`good progress.`);
} }
} }
} }
...@@ -486,7 +486,7 @@ App.SecExp.securityReport = function() { ...@@ -486,7 +486,7 @@ App.SecExp.securityReport = function() {
} }
if (jsDef(V.SecExp.buildings.weapManu.upgrades.queue) && V.SecExp.buildings.weapManu.upgrades.queue.length > 0 && V.SecExp.buildings.weapManu.upgrades.queue[0].time > 0) { if (jsDef(V.SecExp.buildings.weapManu.upgrades.queue) && V.SecExp.buildings.weapManu.upgrades.queue.length > 0 && V.SecExp.buildings.weapManu.upgrades.queue[0].time > 0) {
let current = App.SecExp.weapManuUpgrade.current(); V.SecExp.buildings.weapManu.upgrades.queue[0].time--; let current = App.SecExp.weapManuUpgrade.current(); V.SecExp.buildings.weapManu.upgrades.queue[0].time--;
t = `<br>In the research lab, ${current.dec} `; r.push(`<br>In the research lab, ${current.dec}`);
switch (current.dec) { switch (current.dec) {
case "adaptive armored frames": case "adaptive armored frames":
case "advanced synthetic alloys": case "advanced synthetic alloys":
...@@ -495,22 +495,25 @@ App.SecExp.securityReport = function() { ...@@ -495,22 +495,25 @@ App.SecExp.securityReport = function() {
case "universal cyber enhancements": case "universal cyber enhancements":
case "remote neural links": case "remote neural links":
case "combined training regimens with the special force": case "combined training regimens with the special force":
t += `are`; break; r.push(`are`); break;
default: t += `is`; default: r.push(`is`);
} }
t += ` being developed with the aim of enhancing ${current.unit}' ${current.purpose}.`; r.push(`being developed with the aim of enhancing ${current.unit}' ${current.purpose}.`);
if (V.SecExp.buildings.weapManu.upgrades.queue[0].time <= 0) { if (V.SecExp.buildings.weapManu.upgrades.queue[0].time <= 0) {
t += ` Reports indicate it is ready for deployment and will be issued in the following days.`; r.push(`Reports indicate it is ready for deployment and will be issued in the following days.`);
V.SecExp.buildings.weapManu.upgrades.completed.push(current.ID); V.SecExp.buildings.weapManu.upgrades.completed.push(current.ID);
V.SecExp.buildings.weapManu.upgrades.queue.splice(0, 1); V.SecExp.buildings.weapManu.upgrades.queue.splice(0, 1);
} else { } else {
t += ` It will be finished in ${numberWithPluralOne(V.SecExp.buildings.weapManu.upgrades.queue[0].time, "week")}.`; r.push(`It will be finished in ${numberWithPluralOne(V.SecExp.buildings.weapManu.upgrades.queue[0].time, "week")}.`);
} }
for (let i = 1; i < V.SecExp.buildings.weapManu.upgrades.queue.length; i++) { for (let i = 1; i < V.SecExp.buildings.weapManu.upgrades.queue.length; i++) {
current = App.SecExp.weapManu.currentUpgrade(V.SecExp.buildings.weapManu.upgrades.queue[i].ID); current = App.SecExp.weapManu.currentUpgrade(V.SecExp.buildings.weapManu.upgrades.queue[i].ID);
r.push(t + `<br>${ordinalSuffix(i + 1)} in queue: ${current.dec} for ${current.unit}. It will enhance their ${current.purpose}.`); r.push(`<br>${ordinalSuffix(i + 1)} in queue: ${current.dec} for ${current.unit}. It will enhance their ${current.purpose}.`);
} }
} }
} }
return r.join(" ");
const frag = new DocumentFragment();
$(frag).append(...App.Events.spaceSentences(r));
return frag;
}; };
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<<if $secExpEnabled > 0>> <<if $secExpEnabled > 0>>
<br> <br>
<<= App.SecExp.authorityReport()>> <<= App.SecExp.authorityReport()>>
<<= App.SecExp.securityReport()>> <<includeDOM App.SecExp.securityReport()>>
<</if>> <</if>>
<<includeDOM App.EndWeek.reputation()>> <<includeDOM App.EndWeek.reputation()>>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment