Skip to content
Snippets Groups Projects

Budget screen

Hey all, the budget screen is finally coming together! This commit adds a budget screen and tracking of financial transactions and storing of income/expense records on each slave. The old upkeep screen is now a subscreen of the budget screen, found under "Slave Maintenance." The new screen can be found where the old one was, the upkeep link.

I go into more detail on this on #401 (closed).

Hopefully everything merged correctly. I'll keep working on bug fixing (currently chasing a missing expense that's divisible by 100) but I'd appreciate more eyes.

Edit: I don't have a long save, so if anyone could check if "upkeep" is the same on the master version and this one on the same save. I had to reorganize economyJS quite a bit to make this work, but it should still be the same results.

Edited by lowercasedonkey

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • lowercasedonkey changed the description

    changed the description

  • lowercasedonkey unmarked as a Work In Progress

    unmarked as a Work In Progress

  • @kopareigns

    Would appreciate an extra pair of eyes going over this one.

  • This is going to be a doozy to go through. Might be a couple days. Some quick comments/suggestions I noticed from a quick skim before I forget them:

    1. Change forceNeg to one of the following
    window.forceNeg = function(x) {
    	return -Math.abs(x);
    };
    window.forceNeg = function(x) {
    	return (x > 0 ? -x : x);
    };
    1. In the lines where you add a string to the week's error message, use template literals instead of adding a bunch of strings together.
    2. getNurseyCosts should be getNurseryCosts
    3. Stick all the JS into something like jshint.com and try to fix all the warnings it gives. Usually the warnings won't actually cause problems, but it falls under best practices.

    Another question to save me time searching, are the getXXXcost functions called anywhere outside economyJS?

  • Thanks guys. I fixed 1 and 3, and thanks for 4. Fixed some problems, mostly semicolons. I haven't done 2 before, and I'm not quite sure what you're asking for. Happy to fix it, I just need more info. Is the goal putting each thing on a separate line?

    The get cost functions aren't called anywhere else yet, but it seems like I've run into places where they would be useful. I keep seeing duplicate code that "guesses" at what something should cost.

    Edited by lowercasedonkey
  • added 1 commit

    Compare with previous version

  • Template literals are useful alternatives to strings that are easier to read if you need to put JS code in the middle. Instead of using + jsSomething + in the middle of your string, with quotation marks on either side, simply embed ${jsSomething} where you want it. No additional quotation marks or + signs needed. You use backticks to start/end them.

    In your case, V.lastWeeksErrors += (' NaN: \"' + cost + '\"" at ' + what + ','); becomes

    V.lastWeeksErrors += `NaN: "${cost}" at ${what},`;

    I only ask about whether the gen cost functions are called elsewhere, because if not, this economy js would be a fantastic place to use a self-executing function. That's something I would probably prefer to handle myself after you're done here though.

  • lowercasedonkey added 66 commits

    added 66 commits

    Compare with previous version

  • added 1 commit

    • 3aac81df - Add template literals and improve totals display

    Compare with previous version

  • Regarding your question, @kopareigns about using the functions elsewhere, maybe we won't need them after all. I took a look to see where facilityCostwas used, as a test, and it's mostly used in facility recording. For example, arcade report: b.maintenance = State.variables.arcade * State.variables.facilityCost * (0.5 + 0.2 * State.variables.arcadeUpgradeInjectors + 0.2 * State.variables.arcadeUpgradeCollectors);

    We could de-duplicate that, but that's about it.

    I think it could be used to show more "local" predictions, like a total cost of policies on the policy page, a total cost of the brothel on the brothel page, that sort of thing. Outside of that, maybe we don't need to expose them, if you've got another goal in mind.

    If there's one piece of my code you could take an especial look at it would be this:

    	//these two apply a multiplicative effect to all costs so far.
    	// Calculate what the deduced expenses would be, then subtract 
    	costSoFar = (oldCash - State.variables.cash); //expected to be positive.
    	fee = (costSoFar - getEnvironmentCosts(costSoFar));
    	cashX(forceNeg(fee), "environment");
    
    	costSoFar = (oldCash - State.variables.cash);
    	fee = (costSoFar - getPCMultiplierCosts(costSoFar));
    	cashX(forceNeg(fee), "PCskills");

    Basically the getEnvironment costs is a modifier for ALL expenses so far, which made it trickier than the others to record. I'm mostly worried I made negatives positive or vv, but it's difficult for me to test.

    Edit: also maybe I am missing something, but I can't find where the "pro cash" policies actually pay out. EconomyJS only adds costs, arcmgmt only changes the population. Bug?

    Edit2: Looks like it should be applied in persBusiness with CashforRep/RepforCash, but isn't.

    Edited by lowercasedonkey
  • lowercasedonkey added 2 commits

    added 2 commits

    • e1da320f - add a new category, small tweaks.
    • dd7f92ed - Books now balance on my save! Turns out it was rules.

    Compare with previous version

  • added 1 commit

    • 4f57d920 - Add missing schools, improve total display, tweaks.

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 1 commit

    • 77ac27da - Remember to define a function

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 1 commit

    • bea6e5d2 - Display dividend by reverse engineering.

    Compare with previous version

  • Single biggest issue right now: You've changed a lot of the places that have $cash += ..., and very few of the places that have $cash -= .... This means that you've got about 2000 more lines to switch out. For the sake of my sanity, it would be nice if you could change those over in smallish groups. Like 10 files/commit or less. It looks like you've already got a few of these in your recent batch of commits.

    Smaller issue: you should run sanityCheck, and fix anything related to this merge.

    Regarding the problem you're having in costsReport.tw, I'm almost certain it's because of a lack of <<capture>>. Replacing the for loop with the following should fix it.

    <<for $i = 0; $i < _SL; $i++>>
    	<<capture $i>>
    	<br style="clear:both" /><<if $lineSeparations == 0>><br><<else>><hr style="margin:0"><</if>>
    	[[$slaves[$i].slaveName|Slave Interact][$activeSlave = $slaves[$i]]] will $slaves[$i].assignment.
    	<<SlaveExpenses>>
    	<</capture>>
    <</for>>

    With the code you posted above, how about not using cashX for it? Just apply the multipliers, and in the budget screen just add a line saying how "such and such is saving you X% on your overall costs". Keep it simple.

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading