Implmented initial version of Corporation Research & ResearchTree classes

This commit is contained in:
danielyxie 2018-12-13 19:24:08 -08:00
parent 6973dd8fca
commit 70b87b3ffb
13 changed files with 1325 additions and 596 deletions

865
dist/engine.bundle.js vendored

File diff suppressed because it is too large Load Diff

665
dist/vendor.bundle.js vendored

File diff suppressed because it is too large Load Diff

5
package-lock.json generated

@ -12006,6 +12006,11 @@
"punycode": "1.4.1"
}
},
"treantjs": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/treantjs/-/treantjs-1.0.0.tgz",
"integrity": "sha1-28PwU+aRz3AOZx/xfG5oySSoE6o="
},
"trim": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz",

@ -32,6 +32,7 @@
"numeral": "2.0.6",
"sprintf-js": "^1.1.1",
"tapable": "^1.0.0",
"treantjs": "^1.0.0",
"uglifyjs-webpack-plugin": "^1.2.5",
"uuid": "^3.2.1",
"w3c-blob": "0.0.1"

@ -509,7 +509,7 @@ export let CONSTANTS: IMap<any> = {
* Corporation Changes:
** Changed initial market prices for many materials
** Changed the way a material's demand, competition, and market price change over time
**
** The sale price of materials can no longer be marked-up as high
`
}

@ -716,11 +716,11 @@ Industry.prototype.processMaterials = function(marketCycles=1, company) {
}
//Calculate how much of the material sells (per second)
var markup = 1, markupLimit = mat.qlt / mat.mku;
let markup = 1, markupLimit = mat.qlt / mat.mku;
if (sCost > mat.bCost) {
//Penalty if difference between sCost and bCost is greater than markup limit
if ((sCost - mat.bCost) > markupLimit) {
markup = markupLimit / (sCost - mat.bCost);
markup = Math.pow(markupLimit / (sCost - mat.bCost), 2);
}
} else if (sCost < mat.bCost) {
if (sCost <= 0) {

@ -1,7 +1,27 @@
import { IMap } from "../types";
import { ResearchTree } from "./ResearchTree";
import { BaseResearchTree } from "./data/BaseResearchTree";
import { numeralWrapper } from "../ui/numeralFormat";
export const Industries: IMap<string> = {
interface IIndustryMap<T> {
Energy: T;
Utilities: T;
Agriculture: T;
Fishing: T;
Mining: T;
Food: T;
Tobacco: T;
Chemical: T;
Pharmaceutical: T;
Computer: T;
Robotics: T;
Software: T;
Healthcare: T;
RealEstate: T;
}
// Map of official names for each Industry
export const Industries: IIndustryMap<string> = {
Energy: "Energy",
Utilities: "Water Utilities",
Agriculture: "Agriculture",
@ -18,7 +38,8 @@ export const Industries: IMap<string> = {
RealEstate: "RealEstate",
}
export const IndustryStartingCosts: IMap<number> = {
// Map of how much money it takes to start each industry
export const IndustryStartingCosts: IIndustryMap<number> = {
Energy: 225e9,
Utilities: 150e9,
Agriculture: 40e9,
@ -35,7 +56,8 @@ export const IndustryStartingCosts: IMap<number> = {
RealEstate: 600e9,
}
export const IndustryDescriptions: IMap<string> = {
// Map of description for each industry
export const IndustryDescriptions: IIndustryMap<string> = {
Energy: "Engage in the production and distribution of energy.<br><br>" +
"Starting cost: " + numeralWrapper.format(IndustryStartingCosts.Energy, "$0.000a") + "<br>" +
"Recommended starting Industry: NO",
@ -79,3 +101,22 @@ export const IndustryDescriptions: IMap<string> = {
"Starting cost: " + numeralWrapper.format(IndustryStartingCosts.RealEstate, "$0.000a") + "<br>" +
"Recommended starting Industry: NO",
}
// Map of available Research for each Industry. This data is held in a
// ResearchTree object
export const IndustryResearchTrees: IIndustryMap<ResearchTree> = {
Energy: BaseResearchTree,
Utilities: BaseResearchTree,
Agriculture: BaseResearchTree,
Fishing: BaseResearchTree,
Mining: BaseResearchTree,
Food: BaseResearchTree,
Tobacco: BaseResearchTree,
Chemical: BaseResearchTree,
Pharmaceutical: BaseResearchTree,
Computer: BaseResearchTree,
Robotics: BaseResearchTree,
Software: BaseResearchTree,
Healthcare: BaseResearchTree,
RealEstate: BaseResearchTree,
}

@ -0,0 +1,51 @@
export interface IConstructorParams {
name: string;
cost: number;
desc: string;
advertisingMult?: number;
employeeCreMult?: number;
employeeChaMult?: number;
employeeEffMult?: number;
employeeIntMult?: number;
productionMult?: number;
salesMult?: number;
sciResearchMult?: number;
storageMult?: number;
}
export class Research {
// Name of research. This will be used to identify researches in the Research Tree
name: string = "";
// How much scientific research it costs to unlock this
cost: number = 0;
// Description of what the Research does
desc: string = "";
// All possible generic upgrades for the company, in the form of multipliers
advertisingMult: number = 1;
employeeCreMult: number = 1;
employeeChaMult: number = 1;
employeeEffMult: number = 1;
employeeIntMult: number = 1;
productionMult: number = 1;
salesMult: number = 1;
sciResearchMult: number = 1;
storageMult: number = 1;
constructor(p: IConstructorParams={name: "", cost: 0, desc: ""}) {
this.name = p.name;
this.cost = p.cost;
this.desc = p.desc;
if (p.advertisingMult) { this.advertisingMult = p.advertisingMult; }
if (p.employeeCreMult) { this.employeeCreMult = p.employeeCreMult; }
if (p.employeeChaMult) { this.employeeChaMult = p.employeeChaMult; }
if (p.employeeEffMult) { this.employeeEffMult = p.employeeEffMult; }
if (p.employeeIntMult) { this.employeeIntMult = p.employeeIntMult; }
if (p.productionMult) { this.productionMult = p.productionMult; }
if (p.salesMult) { this.salesMult = p.salesMult; }
if (p.sciResearchMult) { this.sciResearchMult = p.sciResearchMult; }
if (p.storageMult) { this.storageMult = p.storageMult; }
}
}

@ -0,0 +1,19 @@
// The Research Map is an object that holds all Corporation Research objects
// as values. They are identified by their names
import { Research,
IConstructorParams } from "./Research";
import { researchMetadata } from "./data/ResearchMetadata";
import { IMap } from "../types";
export let ResearchMap: IMap<Research> = {};
function addResearch(p: IConstructorParams) {
if (ResearchMap[p.name] != null) {
console.warn(`Duplicate Research being defined: ${p.name}`);
}
ResearchMap[p.name] = new Research(p);
}
for (const metadata of researchMetadata) {
addResearch(metadata);
}

@ -0,0 +1,65 @@
// Defines a "Research Tree"
// Each Industry has a unique Research Tree
// Each Node in the Research Trees only holds the name(s) of Research,
// not an actual Research object. The name can be used to obtain a reference
// to the corresponding Research object using the ResearchMap
import { ResearchMap } from "./ResearchMap";
interface IConstructorParams {
children?: Node[];
data: string;
parent?: Node | null;
}
export class Node {
// All child Nodes in the tree
// The Research held in this Node is a prerequisite for all Research in
// child Nodes
children: Node[] = [];
// Name of the Research held in this Node
data: string = "";
// Parent node in the tree
// The parent node defines the prerequisite Research (there can only be one)
// Set as null for no prerequisites
parent: Node | null = null;
constructor(p: IConstructorParams) {
if (ResearchMap[p.data] == null) {
throw new Error(`Invalid Research name used when constructing ResearchTree Node: ${p.data}`);
}
this.data = p.data;
if (p.children && p.children.length > 0) {
this.children = p.children;
}
if (p.parent != null) {
this.parent = p.parent;
}
}
addChild(n: Node) {
this.children.push(n);
n.parent = this;
}
setParent(n: Node) {
this.parent = n;
}
}
// A ResearchTree defines all available Research in an Industry
// The root node in a Research Tree must always be the "Hi-Tech R&D Laboratory"
export class ResearchTree {
root: Node | null = null;
constructor() {}
setRoot(root: Node): void {
this.root = root;
}
}

@ -0,0 +1,47 @@
// Defines the ResearchTree that is common to all Corporation Industries
// i.e. all Industries have these types of Research available to unlock
import { ResearchTree,
Node } from "../ResearchTree";
export const BaseResearchTree: ResearchTree = new ResearchTree();
const rootNode = new Node({data: "Hi-Tech R&D Laboratory"});
const autoBrew = new Node({data: "AutoBrew"});
const autoParty = new Node({data: "AutoPartyManager"});
const autoDrugs = new Node({data: "Automatic Drug Administration"});
const cph4 = new Node({data: "CPH4 Injections"});
const drones = new Node({data: "Drones"});
const dronesAssembly = new Node({data: "Drones - Assembly"});
const dronesTransport = new Node({data: "Drones - Transport"});
const goJuice = new Node({data: "Go-Juice"});
const joywire = new Node({data: "JoyWire"});
const marketta1 = new Node({data: "Market-TA.I"});
const marketta2 = new Node({data: "Market-TA.II"});
const overclock = new Node({data: "Overclock"});
const scAssemblers = new Node({data: "Self-Correcting Assemblers"});
const stimu = new Node({data: "Sti.mu"});
autoDrugs.addChild(goJuice);
autoDrugs.addChild(cph4);
drones.addChild(dronesAssembly);
drones.addChild(dronesTransport);
marketta1.addChild(marketta2);
overclock.addChild(stimu);
rootNode.addChild(autoBrew);
rootNode.addChild(autoParty);
rootNode.addChild(autoDrugs);
rootNode.addChild(drones);
rootNode.addChild(joywire);
rootNode.addChild(marketta1);
rootNode.addChild(overclock);
rootNode.addChild(scAssemblers);
BaseResearchTree.setRoot(rootNode);
export function getBaseResearchTreeCopy(): ResearchTree {
return Object.assign(Object.create(Object.getPrototypeOf(BaseResearchTree)), BaseResearchTree);
}

@ -0,0 +1,124 @@
import { IConstructorParams } from "../Research";
export const researchMetadata: IConstructorParams[] = [
{
name: "AutoBrew",
cost: 12e3,
desc: "Automatically keep your employees fully caffeinated with " +
"coffee injections. This research will keep the energy of all " +
"employees at its maximum possible value, for no cost. " +
"This will also disable the Coffee upgrade.",
},
{
name: "AutoPartyManager",
cost: 15e3,
desc: "Automatically analyzes your employees' happiness and morale " +
"and boosts them whenever it detects a decrease. This research will " +
"keep the morale and happiness of all employees at their maximum possible " +
"values, for no cost. " +
"This will also disable the 'Throw Party' feature.",
},
{
name: "Automatic Drug Administration",
cost: 10e3,
desc: "Research how to automatically administer performance-enhacing drugs to all of " +
"your employees. This unlocks Drug-related Research.",
},
{
name: "CPH4 Injections",
cost: 25e3,
desc: "Develop an advanced and harmless synthetic drug that is administered to " +
"employees to increase all of their stats, except experience, by 10%.",
employeeCreMult: 1.1,
employeeChaMult: 1.1,
employeeEffMult: 1.1,
employeeIntMult: 1.1,
},
{
name: "Drones",
cost: 5e3,
desc: "Acquire the knowledge needed to create advanced drones. This research does nothing " +
"by itself, but unlocks other Drone-related research.",
},
{
name: "Drones - Assembly",
cost: 25e3,
desc: "Manufacture and use Assembly Drones to improve the efficiency of " +
"your production lines. This increases all production by 20%.",
productionMult: 1.2,
},
{
name: "Drones - Transport",
cost: 30e3,
desc: "Manufacture and use intelligent Transport Drones to optimize " +
"your warehouses. This increases the storage space of all warehouses " +
"by 50%.",
storageMult: 1.5,
},
{
name: "Go-Juice",
cost: 25e3,
desc: "Provide employees with Go-Juice, a coffee-derivative that further enhances " +
"the brain's dopamine production. This increases the maximum energy of all " +
"employees by 10.",
},
{
name: "Hi-Tech R&D Laboratory",
cost: 10e3,
desc: "Construct a cutting edge facility dedicated to advanced research and " +
"and development. This allows you to spend Scientific Research " +
"on powerful upgrades. It also globally increases Scientific Research " +
"production by 10%.",
sciResearchMult: 1.1,
},
{
name: "JoyWire",
cost: 20e3,
desc: "A brain implant which is installed in employees, increasing their " +
"maximum happiness by 10.",
},
{
name: "Market-TA.I",
cost: 20e3,
desc: "Develop advanced AI software that uses technical analysis to " +
"help you understand and exploit the market. This research " +
"allows you to know what price to sell your Materials/Products " +
"at in order to avoid losing sales due to having too high of a mark-up.",
},
{
name: "Market-TA.II",
cost: 40e3,
desc: "Develop double-advanced AI software that uses technical analysis to " +
"help you understand and exploit the market. This research " +
"allows you to know how many sales of a Material/Product you lose or gain " +
"from having too high or too low or a sale price.",
},
{
name: "Overclock",
cost: 15e3,
desc: "Equip employees with a headset that uses transcranial direct current " +
"stimulation (tDCS) to increase the speed of their neurotransmitters. " +
"This research increases the intelligence and efficiency of all " +
"employees by 25%.",
employeeEffMult: 1.25,
employeeIntMult: 1.25,
},
{
name: "Self-Correcting Assemblers",
cost: 25e3,
desc: "Create assemblers that can be used for universal production. " +
"These assemblers use deep learning to improve their efficiency " +
"at their tasks. This research increases all production by 10%",
productionMult: 1.1,
},
{
name: "Sti.mu",
cost: 30e3,
desc: "Upgrade the tDCS headset to stimulate regions of the brain that " +
"control confidence and enthusiasm. This research increases the max " +
"morale of all employees by 10.",
},
];

@ -1,14 +1,16 @@
import {Augmentations, AugmentationNames,
PlayerOwnedAugmentation} from "../Augmentations";
import {BitNodeMultipliers} from "../BitNodeMultipliers";
import {CONSTANTS} from "../Constants";
import {Engine} from "../engine";
import {FactionInfos} from "./FactionInfo";
import {Locations} from "../Location";
import {HackingMission, setInMission} from "../Missions";
import {Player} from "../Player";
import {PurchaseAugmentationsOrderSetting} from "../SettingEnums";
import {Settings} from "../Settings";
import { Augmentations, AugmentationNames,
PlayerOwnedAugmentation } from "../Augmentations";
import { BitNodeMultipliers } from "../BitNodeMultipliers";
import { CONSTANTS } from "../Constants";
import { Engine } from "../engine";
import { Faction } from "./Faction";
import { Factions } from "./Factions";
import { FactionInfos } from "./FactionInfo";
import { Locations} from "../Location";
import { HackingMission, setInMission } from "../Missions";
import { Player } from "../Player";
import { PurchaseAugmentationsOrderSetting } from "../SettingEnums";
import { Settings } from "../Settings";
import {Page, routing} from "../ui/navigationTracking";
import {numeralWrapper} from "../ui/numeralFormat";