async function tryRaiseCapital(ns) {
    // First, spend hacknet hashes.
    if (options['can-spend-hashes'] && myCorporation.funds < 10e9) 
        await doSpendHashes(ns, 'Sell for Corporation Funds');
    // If we're not public, then raise private funding.
    if (!myCorporation.public) {
        let offer = ns.corporation.getInvestmentOffer();
        // If we've finished round 4, clear our raising capital flag.
        if (offer.round > 4) raisingCapital = 0;
        let willAccept = true;
        if (offer && offer.round <= 4) {
            log(ns, `  Considering raising private capital round ${offer.round}. Offered ${mf(offer.funds)} for ${nf(offer.shares)} shares.`);

            // Make sure all employees are happy.
            let satisfied = allEmployeesSatisfied(ns);
            if (!satisfied) {
                let prefix = '    *';
                if (!willAccept) prefix = '     ';
                log(ns, `${prefix}  Round ${offer.round} financing waiting on employee stats to stabilize.`);
                willAccept = false;
            }

            // Make sure we have filled a reasonable amount of our warehouses with materials.
            for (const division of myCorporation.divisions) {
                let industry = industries.find((i) => i.name === division.type);
                for (const city of division.cities) {
                    let warehouse = ns.corporation.getWarehouse(division.name, city);
                    let warehouseSpaceRequiredForCycle = getReservedWarehouseSpace(ns, industry, division, city);
                    let warehouseSpaceAvailable = warehouse.size - warehouseSpaceRequiredForCycle - warehouse.sizeUsed;
                    if (warehouseSpaceAvailable > warehouseSpaceRequiredForCycle * 0.2) {
                        let prefix = '    *';
                        if (!willAccept) prefix = '     ';
                        log(ns, `${prefix}  Round ${offer.round} financing waiting on ${division.name} warehouses to gain materials.`);
                        willAccept = false;
                        break;
                    }
                }
            }
            // If we have a product division, make sure it has a maximum number of products before we accept the offer.
            for (const division of myCorporation.divisions) {
                const maxProducts = getMaxProducts(ns, division.name);
                let industry = industries.find((i) => i.name === division.type);
                if (industry.makesProducts && division.products.length < maxProducts) {
                    let prefix = '    *';
                    if (!willAccept) prefix = '     ';
                    log(ns, `${prefix}  Round ${offer.round} financing waiting on ${division.name} division to create products (${division.products.length}/${maxProducts})`);
                    willAccept = false;
                }
                if (offer.round >= 4 && industry.makesProducts) {
                    // Wait for the last product to finish researching
                    let completeProducts = division.products.map((prodName) => ns.corporation.getProduct(division.name, prodName)).filter((prod) => prod.developmentProgress >= 100);
                    if (completeProducts.length < maxProducts) {
                        let prefix = '    *';
                        if (!willAccept) prefix = '     ';
                        log(ns, `${prefix}  Round ${offer.round} financing waiting on ${division.name} division to complete products (${completeProducts.length}/${maxProducts})`);
                        willAccept = false;
                    }
                }
            }
            // TODO: Funding is proportional to revenue. We can cook the books so that revenue looks higher than it should by stockpiling goods, then selling them all at once.

            // Make sure we aren't spending money on materials when we get funding. Each time we come through the loop and would purchase, increment the counter. After 4 times, purchase.
            if (willAccept) raisingCapital++;
            else raisingCapital = 0;

            // If we've passed all the checks, then accept the next round of funding.
            if (options['can-accept-funding'] && raisingCapital > 4 && !options.mock) {
                let success = ns.corporation.acceptInvestmentOffer();
                raisingCapital = 0;
                if (success) log(ns, `WARNING: Accepted round ${offer.round} funding. Took ${mf(offer.funds)} for ${nf(offer.shares)} shares.`);
                else log(ns, `ERROR: Tried to accept round ${offer.round} funding, but something went wrong.`);
            } else if (options['can-accept-funding'] && raisingCapital > 0) {
                log(ns, `SUCCESS: Raising capital in ${5 - raisingCapital} cycles.`);
            }
        } else {
            // We're public, so we can't be raising capital.
            raisingCapital = 0;
        }
        // Finally, if we're out of private funding, we may as well go public
        offer = ns.corporation.getInvestmentOffer();
        if (options['can-go-public'] && !options.mock && offer.round > 4) {
            // Looks like we're out of private funding. Time to go public.
            log(ns, `SUCCESS: Private funding complete. Time to IPO. Selling ${options['issue-shares']} shares.`);
            ns.corporation.goPublic(options['issue-shares']);
            // and set our dividend to 10%
            ns.corporation.issueDividends(0.1);
        }
    } else {
        // We're public, so we can't be raising capital.
        raisingCapital = 0;
    }
}
/**
 * Try to raise money.
 * Advances through the funding rounds, eventually going public. Potentially spends hacknet hashes for money.
 * @param {NS} ns
 */
Try to raise money.
Advances through the funding rounds, eventually going public. Potentially spends hacknet hashes for money.
@param {NS} ns
Try to raise money . Advances through the funding rounds eventually going public . Potentially spends hacknet hashes for money . @param { NS } ns
async function tryRaiseCapital(ns) {
    if (options['can-spend-hashes'] && myCorporation.funds < 10e9) 
        await doSpendHashes(ns, 'Sell for Corporation Funds');
    if (!myCorporation.public) {
        let offer = ns.corporation.getInvestmentOffer();
        if (offer.round > 4) raisingCapital = 0;
        let willAccept = true;
        if (offer && offer.round <= 4) {
            log(ns, `  Considering raising private capital round ${offer.round}. Offered ${mf(offer.funds)} for ${nf(offer.shares)} shares.`);
            let satisfied = allEmployeesSatisfied(ns);
            if (!satisfied) {
                let prefix = '    *';
                if (!willAccept) prefix = '     ';
                log(ns, `${prefix}  Round ${offer.round} financing waiting on employee stats to stabilize.`);
                willAccept = false;
            }
            for (const division of myCorporation.divisions) {
                let industry = industries.find((i) => i.name === division.type);
                for (const city of division.cities) {
                    let warehouse = ns.corporation.getWarehouse(division.name, city);
                    let warehouseSpaceRequiredForCycle = getReservedWarehouseSpace(ns, industry, division, city);
                    let warehouseSpaceAvailable = warehouse.size - warehouseSpaceRequiredForCycle - warehouse.sizeUsed;
                    if (warehouseSpaceAvailable > warehouseSpaceRequiredForCycle * 0.2) {
                        let prefix = '    *';
                        if (!willAccept) prefix = '     ';
                        log(ns, `${prefix}  Round ${offer.round} financing waiting on ${division.name} warehouses to gain materials.`);
                        willAccept = false;
                        break;
                    }
                }
            }
            for (const division of myCorporation.divisions) {
                const maxProducts = getMaxProducts(ns, division.name);
                let industry = industries.find((i) => i.name === division.type);
                if (industry.makesProducts && division.products.length < maxProducts) {
                    let prefix = '    *';
                    if (!willAccept) prefix = '     ';
                    log(ns, `${prefix}  Round ${offer.round} financing waiting on ${division.name} division to create products (${division.products.length}/${maxProducts})`);
                    willAccept = false;
                }
                if (offer.round >= 4 && industry.makesProducts) {
                    let completeProducts = division.products.map((prodName) => ns.corporation.getProduct(division.name, prodName)).filter((prod) => prod.developmentProgress >= 100);
                    if (completeProducts.length < maxProducts) {
                        let prefix = '    *';
                        if (!willAccept) prefix = '     ';
                        log(ns, `${prefix}  Round ${offer.round} financing waiting on ${division.name} division to complete products (${completeProducts.length}/${maxProducts})`);
                        willAccept = false;
                    }
                }
            }
            if (willAccept) raisingCapital++;
            else raisingCapital = 0;
            if (options['can-accept-funding'] && raisingCapital > 4 && !options.mock) {
                let success = ns.corporation.acceptInvestmentOffer();
                raisingCapital = 0;
                if (success) log(ns, `WARNING: Accepted round ${offer.round} funding. Took ${mf(offer.funds)} for ${nf(offer.shares)} shares.`);
                else log(ns, `ERROR: Tried to accept round ${offer.round} funding, but something went wrong.`);
            } else if (options['can-accept-funding'] && raisingCapital > 0) {
                log(ns, `SUCCESS: Raising capital in ${5 - raisingCapital} cycles.`);
            }
        } else {
            raisingCapital = 0;
        }
        offer = ns.corporation.getInvestmentOffer();
        if (options['can-go-public'] && !options.mock && offer.round > 4) {
            log(ns, `SUCCESS: Private funding complete. Time to IPO. Selling ${options['issue-shares']} shares.`);
            ns.corporation.goPublic(options['issue-shares']);
            ns.corporation.issueDividends(0.1);
        }
    } else {
        raisingCapital = 0;
    }
}
async function tryRaiseCapital ( ns ) { if ( options [ 'can-spend-hashes' ] && myCorporation . funds < 10e9 ) await doSpendHashes ( ns , 'Sell for Corporation Funds' ) ; if ( ! myCorporation . public ) { let offer = ns . corporation . getInvestmentOffer ( ) ; if ( offer . round > 4 ) raisingCapital = 0 ; let willAccept = true ; if ( offer && offer . round <= 4 ) { log ( ns , ` ${ offer . round } ${ mf ( offer . funds ) } ${ nf ( offer . shares ) } ` ) ; let satisfied = allEmployeesSatisfied ( ns ) ; if ( ! satisfied ) { let prefix = '    *' ; if ( ! willAccept ) prefix = '     ' ; log ( ns , ` ${ prefix } ${ offer . round } ` ) ; willAccept = false ; } for ( const division of myCorporation . divisions ) { let industry = industries . find ( ( i ) => i . name === division . type ) ; for ( const city of division . cities ) { let warehouse = ns . corporation . getWarehouse ( division . name , city ) ; let warehouseSpaceRequiredForCycle = getReservedWarehouseSpace ( ns , industry , division , city ) ; let warehouseSpaceAvailable = warehouse . size - warehouseSpaceRequiredForCycle - warehouse . sizeUsed ; if ( warehouseSpaceAvailable > warehouseSpaceRequiredForCycle * 0.2 ) { let prefix = '    *' ; if ( ! willAccept ) prefix = '     ' ; log ( ns , ` ${ prefix } ${ offer . round } ${ division . name } ` ) ; willAccept = false ; break ; } } } for ( const division of myCorporation . divisions ) { const maxProducts = getMaxProducts ( ns , division . name ) ; let industry = industries . find ( ( i ) => i . name === division . type ) ; if ( industry . makesProducts && division . products . length < maxProducts ) { let prefix = '    *' ; if ( ! willAccept ) prefix = '     ' ; log ( ns , ` ${ prefix } ${ offer . round } ${ division . name } ${ division . products . length } ${ maxProducts } ` ) ; willAccept = false ; } if ( offer . round >= 4 && industry . makesProducts ) { let completeProducts = division . products . map ( ( prodName ) => ns . corporation . getProduct ( division . name , prodName ) ) . filter ( ( prod ) => prod . developmentProgress >= 100 ) ; if ( completeProducts . length < maxProducts ) { let prefix = '    *' ; if ( ! willAccept ) prefix = '     ' ; log ( ns , ` ${ prefix } ${ offer . round } ${ division . name } ${ completeProducts . length } ${ maxProducts } ` ) ; willAccept = false ; } } } if ( willAccept ) raisingCapital ++ ; else raisingCapital = 0 ; if ( options [ 'can-accept-funding' ] && raisingCapital > 4 && ! options . mock ) { let success = ns . corporation . acceptInvestmentOffer ( ) ; raisingCapital = 0 ; if ( success ) log ( ns , ` ${ offer . round } ${ mf ( offer . funds ) } ${ nf ( offer . shares ) } ` ) ; else log ( ns , ` ${ offer . round } ` ) ; } else if ( options [ 'can-accept-funding' ] && raisingCapital > 0 ) { log ( ns , ` ${ 5 - raisingCapital } ` ) ; } } else { raisingCapital = 0 ; } offer = ns . corporation . getInvestmentOffer ( ) ; if ( options [ 'can-go-public' ] && ! options . mock && offer . round > 4 ) { log ( ns , ` ${ options [ 'issue-shares' ] } ` ) ; ns . corporation . goPublic ( options [ 'issue-shares' ] ) ; ns . corporation . issueDividends ( 0.1 ) ; } } else { raisingCapital = 0 ; } }
Try to raise money.
Try to raise money .
// First, spend hacknet hashes.
 // If we're not public, then raise private funding.
 // If we've finished round 4, clear our raising capital flag.
 // Make sure all employees are happy.
 // Make sure we have filled a reasonable amount of our warehouses with materials.
 // If we have a product division, make sure it has a maximum number of products before we accept the offer.
 // Wait for the last product to finish researching
 // TODO: Funding is proportional to revenue. We can cook the books so that revenue looks higher than it should by stockpiling goods, then selling them all at once.
 // Make sure we aren't spending money on materials when we get funding. Each time we come through the loop and would purchase, increment the counter. After 4 times, purchase.
 // If we've passed all the checks, then accept the next round of funding.
 // We're public, so we can't be raising capital.
 // Finally, if we're out of private funding, we may as well go public
 // Looks like we're out of private funding. Time to go public.
 // and set our dividend to 10%
 // We're public, so we can't be raising capital.
