JavaScript must be enabled to play.
Browser lacks capabilities required to play.
Upgrade or switch to another browser.
Loading…
<<script>> $.ajaxSetup({ async: false }); var fileList = []; $.getJSON("files.json", function(data) { $.each(data, function(key,value) { console.log("Push: "+value); fileList = value; }); console.log("FileList: "+fileList); }); for(var i=0; i<fileList.length;i++) { console.log("loading filename: "+fileList[i]); $.getJSON(fileList[i], function(data) { $.each(data, function(key,value) { State.variables[key] = value; console.log(key); console.log(State.variables[key]); }); }); } $.ajaxSetup({ async: true }); <</script>> Welcome to Scientist Written and programmed in Twine/Sugarcube 2 by The2ndSolution [[Begin|Game Begin]] [[Summary|Game Content]]
<<initiateVars>> <<toggleSpan "Mod Menu" "<<printModdingMenu>>" "1" false>><br> Character Creation Personal Info First: <<textbox "$player.fname" "Joshen">> Last: <<textbox "$player.lname" "Wright">> Sex: <<listbox "$player.sex">><<option "Male" m>><<option "Female" f>><</listbox>> Pronouns <<listbox "$player.pronouns">><<option "He/Him" m>><<option "She/Her" f>><<option "They/Them" b>> <</listbox>> Background <<listbox "_initPerk">><<option "Biology" bio>><<option "Technology" tech>><<option "Psychology" psych>><<option "Finances" money>><</listbox>> Facility Location <<listbox "$baseLocation">> <<optionsfrom $baseLocations>> <</listbox>> <<button [[Ready to Begin|Game Start]]>><<set $player.traits.push(_initPerk)>><</button>>
If any content listed here makes you uncomfortable, please choose not to play this game. List content here- (There is no content yet...) [[Sounds good, let's go!|Game Begin]]
Mods are stored in lsm files, which are just JSON files with a fancy wrapper so your browser security doesn't block them. They should look something like this; ---------------------------------- window.getLSMData = function() { return { "listVariable1" : ["newValue"], "listVariable2" : [{"name":"Item"}] }}; ---------------------------------- Those middle lines there represent the JSON Content Only certain things are supported through mods New Technologies "techList" : [] New Facilities with Jobs "facilityList" : [] New Traits "traitList" : [] New Names "femaleNames" : [], "maleNames" : [], "lastNames" : [] Each of these things has an expected structure. You can see the structure of my built-in json files from my site page https://the2ndsolution.neocities.org/scientist/index.html [[Return to Loading Page|Game Begin]]
<<widget printModdingMenu>><<nobr>> <<button [[Load Mod Data|Game Begin]]>> <<script>> function handler (data, fname, success) { if (success) { if(data.techList != null) { State.variables.techList.concat(data.techList) } if(data.facilityList != null) { State.variables.facilityList.concat(data.facilityList) } if(data.traitList != null) { State.variables.traitList.concat(data.traitList) } if(data.femaleNames != null) { State.variables.femaleNames.concat(data.femaleNames) } if(data.maleNames != null) { State.variables.maleNames.concat(data.maleNames) } if(data.lastNames != null) { State.variables.lastNames.concat(data.lastNames) } Engine.play(passage()); } else { // error } } setup.loadLSMDialog(handler); <</script>> <</button>><br> [[Mode File Info|Modding Info]] <</nobr>><</widget>>
/* <<toggleSpan>> _arg[0] - Link text _arg[1] - Togglable content _arg[2] - ID w/o `#` _arg[3] - Optional, initial display state (default: true) */ <<widget "toggleSpan">><<nobr>> <<silently>> <<if ndef _toggleSpanInitComplete>> <<if not _toggleSpanInitComplete>> <<set _initStyle to []>> <<set _target to []>> <<set _toggleSpanInitComplete to true>> <</if>><</if>> <<if (ndef _args[3]) or _args[3]>> <<set _initStyle[_args[2]] to "display: block;">> <<else>> <<set _initStyle[_args[2]] to "display: none;">> <</if>> <</silently>> <<link _args[0]>> <<set _target[_args[2]] to $("#" + _args[2])>> <<if _target[_args[2]].css("display") is "block">> <<run _target[_args[2]].css("display", "none")>> <<else>> <<run _target[_args[2]].css("display", "block")>> <</if>> <</link>> <span @id="_args[2]" @style="_initStyle[_args[2]]">_args[1]</span> <</nobr>><</widget>>
<<listCleanup>> <<updateLists>> <<selectTechOptions>> <<script>>console.log("Qualities List"); console.log(State.variables.qualityList);<</script>> <<set $activeDepartments to ["researchDepartment","logisticsDepartment","lifestyleDepartment","maintenanceDepartment","containmentDepartment","headquartersDepartment","personalDepartment"]>> <<set $constructedFacilities to [ { "id" : "kidnappingCoordination", "status" : "enabled", "workers" : ["",""], "damage" : 0, "repairWorker" : "", "prisoners" : [] },{ "id" : "traffickingOffice", "status" : "enabled", "damage" : 0, "repairWorker" : "", "prisoners" : [] },{ "id" : "resourceProcurement", "status" : "enabled", "workers" : [""], "damage" : 0, "repairWorker" : "" },{ "id" : "salesOffices", "status" : "enabled", "workers" : [""], "damage" : 0, "repairWorker" : "" },{ "id" : "constructionOffice", "status" : "enabled", "workers" : [3,""], "damage" : 0, "repairWorker" : "" },{ "id" : "mainLabs", "status" : "enabled", "damage" : 0, "repairWorker" : "" },{ "id" : "holdingCells", "status" : "enabled", "workers" : [""], "damage" : 0, "repairWorker" : "", "prisoners" : [{ "id" : 1, "fname" : "Joshen", "lname" : "Wright", "sex" : "male", "traits" : ["intelligent"], "qualities" : ["maleAnatomy","maleIdentity","maleAppearance","heterosexual"] }] }, { "id" : "testSubjectContainment", "status" : "enabled", "workers" : [], "damage" : 0, "repairWorker" : "", "prisoners" : [] }]>> <<switch $baseLocation>> <<case "Remote Island">> <<set $constructedFacilities.push({"id":"solarCellGenerator","status":"enabled"})>> <</switch>> <<set $initiateComplete to true>> <<set $completedTechs to ["startingTech"]>> <<set $employeeList["headquartersDepartment"] to [{ "id" : 4, "fname" : "Joslyn", "lname" : "Wright", "sex" : "female", "department" : "headquartersDepartment", "traits" : ["deployed"], "status" : "employee", "enroute" : 0 }]>> <<set $employeeList["maintenanceDepartment"] to [{ "id" : 1, "fname" : "Jill", "lname" : "Smith", "sex" : "female", "department" : "maintenanceDepartment", "traits" : ["intelligent","strong"], "qualities" : ["femaleAnatomy","femaleIdentity","femaleAppearance","heterosexual"], "status" : "employee", "enroute" : 0 },{ "id" : 2, "fname" : "Sam", "lname" : "Witwicky", "sex" : "male", "department" : "maintenanceDepartment", "traits" : [], "qualities" : ["maleAnatomy","maleIdentity","maleAppearance","heterosexual"], "status" : "employee", "enroute" : 0 },{ "id" : 3, "fname" : "John", "lname" : "Smith", "sex" : "male", "department" : "maintenanceDepartment", "traits" : [], "qualities" : ["maleAnatomy","maleIdentity","maleAppearance","heterosexual"], "status" : "employee", "enroute" : 0 }]>> You've arrived at your lab.
<<widget initiateVars>><<nobr>> <<set $empId to 5>> <<set $prisId to 5>> <<silently>> set above two vars to one greater than the highest ID of any starting employees/prisoners; 5 is a temp value <</silently>> <<set $baseEmpWage to 2>> <<set $baseEmpFeed to 3>> <<set $basePrisWage to 0>> <<set $basePrisFeed to 2>> <<set $globalSetting to { "hideEmployeeLists" : false, "hideFacilityLists" : false, "defaultFacilityStatus" : "enabled" }>> <<set $toggleSpanVars to {}>> <<set $jobTraitsApproved to false>> <<set $selectedTech to "">> <<set $selectedFacility to "">> <<set $selectedTrait to "">> <<set $selectedQuality to "">> <<set $selectedDepartment to "">> <<set $selectedEmployeeId to "">> <<set $selectedEmployeeDep to "">> <<set $selectedPrisonerFacility to "">> <<set $selectedPrisonerListInd to "">> <<set $skillCheck to false>> <<set $funds to 1500>> <<set $science to 0>> <<set $intel to 10>> <<set $morale to 50>> <<set $power to 0>> <<set $food to 0>> <<set $agentList = []>> <<set $day to 1>> <<set $activeDepartments to []>> <<set $currentTech to "None">> <<set $completedTechs = [0]>> <<set $drawnTechs = []>> <<set $availableTechs = []>> <<set $techOption to {}>> <<set $techOption.bio to "">> <<set $techOption.psych to "">> <<set $techOption.mech to "">> <<set $techOption.gen to "">> <<set $techOption.reselect to true>> <<set $addedTechs = []>> <<set $availableFacilities = []>> <<set $underConstruction = []>> <<set $constructedFacilities = []>> <<set $constructionLimit to 1>> <<set $addedFacilities = []>> <<set $employeeFlags to { "accountant" : false, "supplyManager" : false, "salesManager" : false, "prisonerTrader" : false }>> <<set $prisonerFlags to { "testSubject" : false }>> <<set $facilitySpace to 5>> <<set $spaceUsed to 0>> <<set $travelTime to 5>> <<set $travelRate to 1>> <<set $tradeCap to 50>> <<set $price to { "food" : 1, "good" : 2 }>> <<set $changeIn to { "funds" : 0, "intel" : 0, "power" : 0, "science" : 0, "morale" : 0, "food" : 0, "goods" : 0, "tradeCap" : 0, "construction" : [], "repair" : [] }>> <<set $employeeList to {}>> <<for _i to 0; _i lt $departmentList.length; _i++>> <<set $employeeList[$departmentList[_i].id] to []>> <</for>> <<set $prisonerList to []>> <<set $lockNav to false>> <<set $player to { "traits" : [] }>> <</nobr>><</widget>>
<<if $initiateComplete>>Day $day Funds: $$funds Intel: $intel Morale: $morale Tech Progress <<if $currentTech eq "None">><br>No Current Tech<<else>><<selectTech $currentTech>> Current Tech: <<print $techList[$selectedTech].label>> $science/<<print $techList[$selectedTech].researchReq>> research<</if>> Departments<<nobr>><br> <<if $lockNav>> <i>Navigation locked</i> <<else>> <<set _tempPas to passage()>> <<if $activeDepartments.contains(_tempPas)>> <<link [[Refresh Current Department|_tempPas]]>><<onDeparture>><</link>><br><br><</if>> <<for _i to 0; _i lt $departmentList.length; _i++>><<capture _i>> <<arrayContainsId $activeDepartments $departmentList[_i].id>> <<if $arrayContains>> <<link [[$departmentList[_i].label|$departmentList[_i].id]]>> <<onDeparture)>> <</link>> <br> <</if>> <</capture>><</for>><</if>> <</nobr>> <</if>>
<<widget updateLists>><<nobr>> <<updateFacilityList>> <<updateTechList>> <</nobr>><</widget>>
<<widget listCleanup>><<nobr>> <<facilityCleanup>> <<techCleanup>> <<traitCleanup>> <</nobr>><</widget>>
<<widget arrayContainsId>><<nobr>><<silently>> arg0 - The array to be searched arg1 - the string to be found in the array If the array is of objects with an id property, that is checked. If not, then the array variable itself is checked <<set $arrayContains to false>> <<set _array to _args[0]>> <<if _array.length > 0>> <<for _aCId to 0;_aCId < _array.length; _aCId++>> <<if def _array[_aCId].id>> <<if _array[_aCId].id == _args[1]>> <<set $arrayContains to true>> <<break>> <</if>> <<else>> <<if _array[_aCId] == _args[1]>> <<set $arrayContains to true>> <<break>> <</if>> <</if>> <</for>> <</if>> <</silently>><</nobr>><</widget>>
<<widget updateFacilityList>><<nobr>><<silently>> <<set $availableFacilities to []>> <<for _i to 0; _i lt $facilityList.length; _i++>> //Unlocked starts true; failing any criteria makes it false <<set _unlocked to true>> //check maximum value for keyword strings <<if $facilityList[_i].maximum != "none" || $facilityList[_i].maximum != "space">> //if not, count up current instances of that facility <<set _count to 0>> <<for _e to 0; _e lt $constructedFacilities.length; _e++>> <<if $constructedFacilities[_e].id == $facilityList[_i].id>> <<set _count++>> <</if>> <</for>> <<if $underConstruction.length gt 0>> <<for _e to 0; _e lt $underConstruction.length; _e++>> <<if $underConstruction[_e].id == $facilityList[_i].id>> <<set count++>> <</if>> <</for>> <</if>> //if at or over the maximum, prevent construction <<if _count gte $facilityList[_i].maximum>> <<set _unlocked to false>> <</if>> <</if>> //check tech reqs <<if _unlocked && ($facilityList[_i].reqs.tech.length gt 0)>> <<for _e to 0; _e lt $facilityList[_i].reqs.tech.length; _e++>> <<arrayContainsId $completedTechs $facilityList[_i].reqs.tech[_e]>> <<if not $arrayContains>> <<set _unlocked to false>> <<break>> <</if>> <</for>> <</if>> //check facility reqs <<if _unlocked && ($facilityList[_i].reqs.facility.length gt 0)>> <<for _e to 0; _e lt $facilityList[_i].reqs.facility.length; _e++>> <<arrayContainsId $constructedFacilities $facilityList[_i].reqs.facility[_e]>> <<if not $arrayContains>> <<set _unlocked to false>> <<break>> <</if>> <</for>> <</if>> //check base reqs <<if _unlocked && ($facilityList[_i].baseReqs.length gt 0)>> <<if $facilityList[_i].baseReqs[0] != "any">> <<arrayContainsId $facilityList[_i].baseReqs $baseLocation>> <<if not $arrayContains>> <<set _unlocked to false>> <</if>> <</if>><</if>> <<if _unlocked>> <<set _temp to $facilityList[_i].id>> <<set $availableFacilities.push(_temp)>> <</if>> <</for>> //the addedFacilities list is a list of facilities unlocked through special means like events. These are always re-added to the available facility list <<set $availableFacilities.concat($addedFacilities)>> <</silently>><</nobr>><</widget>>
<<widget updateTechList>><<nobr>><<silently>> <<set $availableTechs to []>> <<for _i to 0; _i lt $techList.length; _i++>> //Unlocked starts true; failing any criteria makes it false <<set _unlocked to true>> //check if tech has already been researched <<arrayContainsId $completedTechs $techList[_i].id>> <<if $arrayContains>> <<set _unlocked to false>> <</if>> //check tech reqs <<if _unlocked && ($techList[_i].reqs.tech.length gt 0)>> <<for _e to 0; _e lt $techList[_i].reqs.tech.length; _e++>> <<arrayContainsId $completedTechs $techList[_i].reqs.tech[_e]>> <<if not $arrayContains>> <<set _unlocked to false>> <<break>> <</if>> <</for>> <</if>> //check facility reqs <<if _unlocked && ($techList[_i].reqs.facility.length gt 0)>> <<for _e to 0; _e lt $techList[_i].reqs.facility.length; _e++>> <<arrayContainsId $constructedFacilities $techList[_i].reqs.facility[_e]>> <<if not $arrayContains>> <<set _unlocked to false>> <<break>> <</if>> <</for>> <</if>> //check base reqs <<if _unlocked && ($techList[_i].baseReqs.length gt 0)>> <<arrayContainsId $techList[_i].baseReqs $baseLocation>> <<if not $arrayContains>> <<set _unlocked to false>> <</if>> <</if>> <<if _unlocked>> <<set _temp to $techList[_i].id>> <<set $availableTechs.push(_temp)>> <</if>> <</for>> //addedTechs concat <<set $availableTechs.concat($addedTechs)>> <</silently>><</nobr>><</widget>>
<<widget techCleanup>><<nobr>> <<for _i = 0; _i lt $techList.length; _i++>> <<if ndef $techList[_i].cost>> <<set $techList[_i].cost to {}>><</if>> <<if ndef $techList[_i].reqs>> <<set $techList[_i].reqs to {"tech":[],"facility":[]}>> <<else>> <<if ndef $techList[_i].reqs.tech>> <<set $techList[_i].reqs.tech to []>><</if>> <<if ndef $techList[_i].reqs.facility>> <<set $techList[_i].reqs.facility to []>><</if>> <</if>> <<if ndef $techList[_i].category>> <<set $techList[_i].category to "generic">><</if>> <<if ndef $techList[_i].baseReqs>> <<set $techList[_i].baseReqs to []>><</if>> <<if ndef $techList[_i].dailyEventList>> <<set $techList[_i].dailyEventList to []>><</if>> <<if ndef $techList[_i].completeEventList>> <<set $techList[_i].completeEventList to []>><</if>> <<if ndef $techList[_i].alwaysAvailable>> <<set $techList[_i].alwaysAvailable to false>><</if>> <<if ndef $techList[_i].needTestSubject>> <<set $techList[_i].needTestSubject to false>><</if>> <<if not $techList[_i].needTestSubject>> <<set $techList[_i].chanceConsumeSubjectDaily to 0>> <<set $techList[_i].chanceConsumeSubjectComplete to 0>><</if>> <<if ndef $techList[_i].chanceConsumeSubjectDaily>> <<set $techList[_i].chanceConsumeSubjectDaily to 0>><</if>> <<if ndef $techList[_i].chanceConsumeSubjectComplete>> <<set $techList[_i].chanceConsumeSubjectComplete to 0>><</if>> <</for>> <</nobr>><</widget>>
<<widget facilityCleanup>><<nobr>> <<for _i to 0;_i lt $facilityList.length;_i++>> <<if ndef $facilityList[_i].reqs>> <<set $facilityList[_i].reqs to {"tech":[],"facility":[]}>> <<else>> <<if ndef $facilityList[_i].reqs.tech>> <<set $facilityList[_i].reqs.tech to []>><</if>> <<if ndef $facilityList[_i].reqs.facility>> <<set $facilityList[_i].reqs.facility to []>><</if>> <</if>> <<if ndef $facilityList[_i].baseReqs>> <<set $facilityList[_i].baseReqs to []>><</if>> <<if ndef $facilityList[_i].cost>> <<set $facilityList[_i].cost to {}>><</if>> <<if ndef $facilityList[_i].construction>> <<set $facilityList[_i].construction to 0>><</if>> <<if ndef $facilityList[_i].powerUpkeep>> <<set $facilityList[_i].powerUpkeep to 0>><</if>> <<if ndef $facilityList[_i].maximum>> <<set $facilityList[_i].maximum to 1>><</if>> <<if ndef $facilityList[_i].output>> <<set $facilityList[_i].output to {}>><</if>> <<if ndef $facilityList[_i].upkeep>> <<set $facilityList[_i].upkeep to {}>><</if>> <<if ndef $facilityList[_i].size>> <<set $facilityList[_i].size to 1>><</if>> <<if ndef $facilityList[_i].constructionSlots>> <<set $facilityList[_i].constructionSlots to 0>><</if>> <<if ndef $facilityList[_i].damageImmune>> <<set $facilityList[_i].damageImmune to false>><</if>> <<if ndef $facilityList[_i].jobQuantity>> <<set $facilityList[_i].jobQuantity to 1>><</if>> <<if ndef $facilityList[_i].jobs>> <<set $facilityList[_i].jobs to []>> <<elseif $facilityList[_i].jobs.length gt 0>> <<for _e to 0;_e lt $facilityList[_i].jobs.length; _e++>> <<if ndef $facilityList[_i].jobs[_e].upkeep>> <<set $facilityList[_i].jobs[_e].upkeep to {}>><</if>> <<if ndef $facilityList[_i].jobs[_e].output>> <<set $facilityList[_i].jobs[_e].output to {}>><</if>> <<if ndef $facilityList[_i].jobs[_e].forEmployees>> <<set $facilityList[_i].jobs[_e].forEmployees to true>><</if>> <<if ndef $facilityList[_i].jobs[_e].traitReqs>> <<set $facilityList[_i].jobs[_e].traitReqs to []>><</if>> <<if ndef $facilityList[_i].jobs[_e].traitExcl>> <<set $facilityList[_i].jobs[_e].traitExcl to []>><</if>> <<if not $facilityList[_i].jobs[_e].traitReqs.includes("deployed")>> <<set $facilityList[_i].jobs[_e].traitExcl.push("deployed")>> <</if>> <<if ndef $facilityList[_i].jobs[_e].employeeFlag>> <<set $facilityList[_i].jobs[_e].employeeFlag to "">><</if>> <</for>> <</if>> <<if ndef $facilityList[_i].prisonerCapacity>> <<set $facilityList[_i].prisonerCapacity to 0>> <<set $facilityList[_i].prisonerJob to {}>><</if>> <<if ndef $facilityList[_i].prisonerJob>> <<set $facilityList[_i].prisonerJob to {}>><</if>> <<if ($facilityList[_i].prisonerCapacity gt 0) && ($facilityList[_i].prisonerJob is {})>> <<script>>console.log("Prisoner job is absent on facility with prisoner capacity! i="+State.temporary.i<</script>> <<set $facilityList[_i].prisonerCapacity to 0>> <</if>> <<if (def $facilityList[_i].prisonerJob) && $facilityList[_i].prisonerJob isnot {} && ($facilityList[_i].prisonerCapacity gt 0 || $facilityList[_i].prisonerCapacity eq "unlimited")>> <<if ndef $facilityList[_i].prisonerJob.upkeep>> <<set $facilityList[_i].prisonerJob.upkeep to {}>><</if>> <<if ndef $facilityList[_i].prisonerJob.output>> <<set $facilityList[_i].prisonerJob.output to {}>><</if>> <<if ndef $facilityList[_i].prisonerJob.traitReqs>> <<set $facilityList[_i].prisonerJob.traitReqs to []>><</if>> <<if ndef $facilityList[_i].prisonerJob.traitExcl>> <<set $facilityList[_i].prisonerJob.traitExcl to []>><</if>> <<if ndef $facilityList[_i].prisonerJob.prisonerFlag>> <<set $facilityList[_i].prisonerJob.prisonerFlag to "">><</if>> <<if ndef $facilityList[_i].prisonerJob.forSale>> <<set $facilityList[_i].prisonerJob.forSale to false>><</if>> <</if>> <</for>> <</nobr>><</widget>>
<<widget traitCleanup>><<nobr>> <<for _i to 0; _i lt $traitList.length; _i++>> <<if ndef $traitList[_i].modifiers>> <<set $traitList[_i].modifiers to []>><</if>> <</for>> <</nobr>><</widget>>
This is the Lab <<script>>console.log(State.variables.currentTech);<</script>> <<nobr>> <<if $currentTech == "None">> Select a new Tech to Research<br><br> <<if $techOption.bio neq "None Available">><<button [[Biology Research|researchDepartment]]>><<applyTech $techOption.bio>><<onDeparture>><</button>><br> <<printTech $techOption.bio>><br> <<else>>No options available<br><</if>> <<if $techOption.bio neq "None Available">><<button [[Psychology Research|researchDepartment]]>><<applyTech $techOption.psych>><<onDeparture>><</button>><br> <<printTech $techOption.psych>><br> <<else>>No options available<br><</if>> <<if $techOption.bio neq "None Available">><<button [[Mechanical Research|researchDepartment]]>><<applyTech $techOption.mech>><<onDeparture>><</button>><br> <<printTech $techOption.mech>><br> <<else>>No options available<br><</if>> <<if $techOption.bio neq "None Available">><<button [[General Option|researchDepartment]]>><<applyTech $techOption.gen>><<onDeparture>><</button>><br> <<printTech $techOption.gen>><br> <<else>>No options available<br><</if>><br> <<if $addedTechs.length gt 0>> Always-Available Techs <<for _aat to 0; _aat lt $addedTechs.length; _aat++>><<capture _aat>> <<button [[Research|researchDepartment]]>><<applyTech $addedTechs[_aat]>><<onDeparture>><</button>><br> <<printTech $addedTechs[_aat]>> <</capture>><</for>> <</if>> <<else>> <<selectTech $currentTech>> Current Tech: <<printTech $currentTech>><br> $science/<<print $techList[$selectedTech].researchReq>> research<br> <</if>> <</nobr>> <<toggleSpan "Lab Employees" "<br><<printEmployees>>" "1" $globalSetting.hideEmployeeLists>> <<toggleSpan "Research Facilities" "<br><<printFacilities>>" "2" $globalSetting.hideFacilityLists>>
Maintenance technicians, engineers and construction workers bustle in and out; moving equipment from here to their worksites. <<toggleSpan "Current Employees" "<br><<printEmployees>>" "1" $globalSetting.hideEmployeeLists>> <<updateSpaceUsage>> Currently we use $spaceUsed/$facilitySpace available space. <<displayConstructionLink>> <<repairSpan>> <<toggleSpan "Facilities Under Construction" "<br><<printFacilitiesUnderConstruction>>" "2" $globalSetting.hideFacilityLists>> <<toggleSpan "Maintenance Facilities" "<br><<printFacilities>>" "3" $globalSetting.hideFacilityLists>> <<script>>console.log(State.variables.employeeList);<</script>> <<button [[TestRefresh|logisticsDepartment]] >><<script>>console.log(State.variables.employeeList);<</script>><</button>>
Bookkeepers, managers, and accountants work in this office-space. <<toggleSpan "Logistic Employees" "<br><<printEmployees>>" "1" $globalSetting.hideEmployeeLists>> <<toggleSpan "Facilities" "<br><<printFacilities>>" "2" $globalSetting.hideFacilityLists>>
Employees off their shifts flit around; socializing and making use of their free time. <<toggleSpan "Employees" "<br><<printEmployees>>" "1" $globalSetting.hideEmployeeLists>> <<toggleSpan "Facilities" "<br><<printFacilities>>" "2" $globalSetting.hideFacilityLists>>
<<widget printObjectPairs>><<nobr>> <<silently>> arg0 - object with key/value pairs arg1 - New Line boolean, defaults to false <</silently>> <<if def _args[1]>> <<set _newLine to _args[1]>> <<else>> <<set _newLine to false>> <</if>> <<if ndef _args[0]>> <<script>>console.log("ERROR: printObjectPairs first argument is undefined");<</script>> <<else>> <<set _keyList to Object.keys(_args[0])>> <<if _keyList.length gte 1>> <<for _kl to 0;_kl lt _keyList.length; _kl++>> <<print ucFirst(_keyList[_kl])>>: <<print _args[0][_keyList[_kl]]>> <<if _newLine>> <br> <<elseif _kl+1 neq _keyList.length>> <<print ", ">> <</if>> <</for>> <<else>> <<script>>console.log("ERROR: printObjectPairs first argument has no key/values to print");<</script>> <</if>> <</if>> <</nobr>><</widget>>
<<widget selectTech>><<nobr>><<silently>> arg0 - tech ID. sets selectedTech to index of tech in TechList <<set $selectedTech to "">> <<for _t to 0; _t lt $techList.length; _t++>> <<if $techList[_t].id eq _args[0]>> <<set $selectedTech to _t>> <<break>> <</if>> <</for>> <</silently>><</nobr>><</widget>>
<<widget selectFacility>><<nobr>><<silently>> arg0 - facility ID. sets selectedFacility to index of facility in facilityList <<set $selectedFacility to "">> <<for _t to 0; _t lt $facilityList.length; _t++>> <<if $facilityList[_t].id eq _args[0]>> <<set $selectedFacility to _t>> <<break>> <</if>> <</for>> <</silently>><</nobr>><</widget>>
<<widget printFacilities>><<nobr>> <<set _currentPassage to passage()>> <<for _i to 0;_i lt $constructedFacilities.length; _i++>><<capture _i>> <<selectFacility $constructedFacilities[_i].id>> <<if $facilityList[$selectedFacility].department == _currentPassage>> <<linkappend $facilityList[$selectedFacility].label>><br> <<print $facilityList[$selectedFacility].description>><br> <<if Object.keys($facilityList[$selectedFacility].upkeep).length lt 1>> No Upkeep <<else>> Upkeep: <<printObjectPairs $facilityList[$selectedFacility].upkeep>> <</if>><br> <<if Object.keys($facilityList[$selectedFacility].output).length lt 1>> No Output <<else>> Output: <<printObjectPairs $facilityList[$selectedFacility].output>> <</if>> <</linkappend>><br> Current Status: <<if $constructedFacilities[_i].status eq "enabled">>Enabled <<link [[(Disable?)|_currentPassage]]>> <<set $constructedFacilities[_i].status to "disabled">> <<if $constructedFacilities[_i].workers.length gt 0>> <<for _cfw to 0; _cfw lt $constructedFacilities[_i].workers.length; _cfw++>> <<unassignEmployee _i _cfw>> <</for>> <</if>> <</link>> <<elseif $constructedFacilities[_i].status eq "disabled">>Disabled <<link [[(Enable?)|_currentPassage]]>> <<set $constructedFacilities[_i].status to "enabled">> <</link>> <<else>> Damaged - see <<link [[construction menu|constructionOptions]]>><<onDeparture>><</link>> to repair <</if>><br> <<if $facilityList[$selectedFacility].jobs.length gt 0>> <<linkappend "Jobs">> <<printJobs _i>> <</linkappend>> <<else>> No Jobs <</if>> <<if $facilityList[$selectedFacility].prisonerCapacity gt 0 || $facilityList[$selectedFacility].prisonerCapacity eq "unlimited">> <br><<linkappend "Prisoners">> <<printPrisoners _i>> <</linkappend>><</if>> <</if>> <br> <</capture>><</for>><</nobr>><</widget>>
The following facilities are available for construction. <<nobr>> <<silently>> Currently assuming that when construction is started on unique facilities, they are removed from the availableFacilities list. If this stops being the case, a check for unique must be added here <</silently>> <<updateFacilityList>> <<for _i to 0; _i lt $availableFacilities.length;_i++>><<capture _i>> <<selectFacility $availableFacilities[_i]>> <<set _e to $selectedFacility>><<capture _e>> <br><<linkappend $facilityList[_e].label>><br> $facilityList[_e].description <</linkappend>><br> <<set _purchaseString to "Can't construct">> <<set _purchaseBool to true>> Cost: <<printObjectPairs $facilityList[_e].cost>><br> Space Required: $facilityList[_e].size<br> <<if $facilityList[_e].maximum == "size">> <<set _count to 0>> <<for _mx to 0; _mx lt $constructedFacilities.length; _mx++>> <<if $constructedFacilities[_mx].id == $availableFacilities[_e]>> <<set _count++>> <</if>> <</for>> <<if _count gte ($facilitySpace / 5)>> <<set _purchaseBool to false>> <<set _purchaseString += ", only 1 of these can be built per Facility Expansion">> <</if>> <</if>> <<canAffordCost $facilityList[_e].cost>> <<if not $canAfford>> <<set _purchaseBool to false>> <<set _purchaseString += ", not enough resources">> <</if>> <<if ($facilitySpace - $spaceUsed) lt $facilityList[_e].size>> <<set _purchaseBool to false>> <<set _purchaseString += ", not enough space">> <</if>> <<if _purchaseBool>> <<button "Start Construction">> <<constructFacility _e>><</button>> <<else>> <<print _purchaseString>> <</if>><br> <</capture>><</capture>><</for>><</nobr>> [[Return to Maintenance Department|maintenanceDepartment]]
<<widget updateSpaceUsage>><<nobr>><<silently>> <<set $spaceUsed to 0>> <<for _sz to 0; _sz lt $constructedFacilities.length; _sz++>> <<selectFacility $constructedFacilities[_sz].id>> <<set $spaceUsed += $facilityList[$selectedFacility].size>> <</for>> <<for _sz to 0; _sz lt $underConstruction.length; _sz++>> <<selectFacility $underConstruction[_sz].id>> <<set $spaceUsed += $facilityList[$selectedFacility].size>> <</for>> <</silently>><</nobr>><</widget>>
<<widget canAffordCost>><<nobr>><<silently>> arg0 - cost object <<set _carray to Object.keys(_args[0])>> <<set $canAfford to true>> <<for _ca to 0; _ca lt _carray.length; _ca++>> <<switch _carray[_ca]>> //add cases for any new payment-type currencies here <<case "funds">> <<if $funds lt _args[0].funds>> <<set $canAfford to false>> <</if>> <<case "intel">> <<if $intel lt _args[0].intel>> <<set $canAfford to false>> <</if>> <<default>> <<script>>console.log("canAffordCost not configured to handle "+State.temporary.carray[State.temporary.ca]);<</script>> <</switch>> //break out of loop once canAfford is false <<if not $canAfford>> <<break>> <</if>> <</for>> <</silently>><</nobr>><</widget>>
<<widget constructFacility>><<nobr>> arg0 - index of facility to be constructed on facilityList <<set _b to _args[0]>> <<set _barray to Object.keys($facilityList[_b].cost)>> <<if _barray.length gt 0>> <<for _e to 0; _e lt _barray.length; _e++>> <<switch _barray[_e]>> <<case "funds">> <<set $funds -= $facilityList[_b].cost.funds>> <<case "intel">> <<set $intel -= $facilityList[_b].cost.intel>> <</switch>><</for>><</if>> create underConstruction facility object <<set _toPush to { "id" : $facilityList[_b].id, "constructionReq" : $facilityList[_b].construction, "constructionProg" : 0, "workers" : [], "jobs" : [], "prisoners" : [] }>> the number of construction workers available should equal the facility size, but should always be at least 1 <<set _toLoop to $facilityList[_b].size>> <<if _toLoop lt 1>> <<set _toLoop to 1>> <</if>> populate workers and jobs lists <<for _w to 0; _w lt _toLoop; _w++>> <<set _toPush.workers.push("")>> <<set _toPush.jobs.push({ "jobTitle" : "Builder", "description" : "Builds this facility.", "upkeep" : {"funds" : 5}, "output" : {"construction" : 10} })>> <</for>> <<set $underConstruction.push(_toPush)>> <<goto "maintenanceDepartment">> <</nobr>><</widget>>
<<widget repairSpan>><<nobr>> <<set _damaged to false>> <<for _rp to 0; _rp lt $constructedFacilities.length; _rp++>> <<if $constructedFacilities[_rp].status == "damaged">> <<set _damaged to true>> <<break>> <</if>> <</for>> <<if _damaged>> <<toggleSpan "Damaged Facilities" "<<printDamagedFacilities>>" "4" $globalSetting.hideFacilityLists>> <</if>> <</nobr>><</widget>>
<<widget displayConstructionLink>><<nobr>> <<set _tempCount to 0>> <<for _dpl to 0; _dpl lt $constructedFacilities.length; _dpl++>> <<if $constructedFacilities[_dpl].status == "damaged">> <<set _tempCount += 1>><</if>> <</for>> <<if (_tempCount + $underConstruction.length) lt $constructionLimit>> Currently we are using <<print (_tempCount + $underConstruction.length)>>/<<print $constructionLimit>> construction slots.<br> <<link [[Build new Facilities or Expand Space|constructionOptions]]>> <<onDeparture>> <</link>> <<else>> Currently you are using <<print (_tempCount + $underConstruction.length)>>/$constructionLimit available construction slots. Wait for a building to finish construction, or finish repairs since damaged facilities use construction slots. Some facilities increase your construction capacity. <</if>> <</nobr>><</widget>>
<<widget printEmployees>><<nobr>> <<silently>> //arg0 - department to print from. Defaults to current department <</silently>> <<if ndef _args[0]>> <<set _dep to passage()>> <<else>> <<set _dep to _args[0]>> <</if>> <<set _listboxOptionsDep to {}>> <<for _lbo to 0; _lbo lt $activeDepartments.length; _lbo++>> <<selectDepartment $activeDepartments[_lbo]>> <<set _listboxOptionsDep[$departmentList[$selectedDepartment].label] to $departmentList[$selectedDepartment].id>> <</for>> <<if $employeeList.hasOwnProperty(_dep)>><<if $employeeList[_dep].length gt 0>> <<for _i to 0; _i lt $employeeList[_dep].length; _i++>><<capture _i>> <<linkappend "<<printEmployee _i _dep>>">><br> Qualities: <<printTraits "qualities" $employeeList[_dep][_i].id _dep>><br> Traits: <<printTraits "traits" $employeeList[_dep][_i].id _dep>><br> <<if not $employeeList[_dep][_i].traits.includes("deployed") && $employeeList[_dep][_i].enroute gte 0>> Department: <<listbox "$employeeList[_dep][_i].department" autoselect>> <<optionsfrom _listboxOptionsDep>> <</listbox>> <<if _dep eq "headquartersDepartment">> <br><<button "Deploy">><<deployAgent _i>><<onDeparture>><</button>><br> <</if>> <<else>> Agent Deployed: retrieve agent to assign to other departments. <<button "Retrieve">><<retrieveAgent _i>><<onDeparture>><</button>> <</if>> <<if $employeeList[_dep][_i].enroute lt 0>> <br>Agent Enroute for <<print Math.ceil(($employeeList[_dep][_i].enroute * -1 / $travelRate))>> more days. <</if>> <</linkappend>><br><br> <</capture>><</for>><</if>><</if>> <</nobr>><</widget>>
<<widget printTraits>><<nobr>> <<silently>> // args[0] - "traits" or "qualtities" //If two args are provided, its the empId. Search all lists //If three args are provided, the second is the dep <</silently>> <<set _id to _args[1]>> <<if def _args[2]>> <<for _pt to 0; _pt lt $employeeList[_args[2]].length; _pt++>> <<if _id eq $employeeList[_args[2]][_pt].id>> <<displayTraits _args[0] $employeeList[_args[2]][_pt][_args[0]]>> <<break>> <</if>> <</for>> <<else>> <<for _pt1 to 0; _pt1 lt $departmentList.length; _pt1++>> <<for _pt2 to 0; _pt2 lt $employeeList[_pt1].length; _pt2++>> <<if _id eq $employeeList[_pt1][_pt2].id>> <<displayTraits _args[0] $employeeList[_pt1][_pt2][_args[0]]>> <<break>> <</if>> <</for>><</for>> <</if>> <</nobr>><</widget>>
<<widget displayTraits>><<nobr>> <<if _args[1].length gt 0>> <<for _ks to 0; _ks lt _args[1].length; _ks++>><<capture _ks>> <<if _args[0] eq "traits">> <<selectTrait _args[1][_ks]>> <span class='tooltip'><<print $traitList[$selectedTrait].label>><span class='tooltiptext'><<print $traitList[$selectedTrait].description>></span></span> <<if _ks neq (_args[1].length -1)>> <<print ", ">> <</if>> <<elseif _args[0] eq "qualities">> <<selectQuality _args[1][_ks]>> <<script>>console.log("SelectQuality: "); console.log(State.temporary.args[1][State.temporary.ks]); console.log(State.variables.selectedQuality);<</script>> <span class='tooltip'><<print $qualityList[$selectedQuality].label>><span class='tooltiptext'><<print $qualityList[$selectedQuality].description>></span></span> <<if _ks neq (_args[1].length -1)>> <<print ", ">> <</if>> <</if>> <</capture>><</for>> <<else>> None <</if>> <</nobr>><</widget>>
<<widget selectTrait>><<nobr>><<silently>> arg[0] - trait ID. Sets selectedTrait to trait object from traitList <<set $selectedTrait to "">> <<for _t to 0; _t lt $traitList.length; _t++>> <<if $traitList[_t].id eq _args[0]>> <<set $selectedTrait to _t>> <<break>> <</if>> <</for>> <</silently>><</nobr>><</widget>>
<<widget selectDepartment>><<nobr>><<silently>> arg[0] - dep ID. Sets selectedDepartment to trait id from departmentList <<set $selectedDepartment to "">> <<for _t to 0; _t lt $departmentList.length; _t++>> <<if $departmentList[_t].id eq _args[0]>> <<set $selectedDepartment to _t>> <<break>> <</if>> <</for>> <</silently>><</nobr>><</widget>>
<<widget onDeparture>><<nobr>><<silently>> This widget is triggered whenever a facility is left, allowing employee and job assignments to be updated <<set _passage to passage()>> This section clears toggleSpanVars <<set $toggleSpanVars to {}>> This section updates employees by finding which passage we are in and sorting through that department's subset of the employee list and checking the department variable of each employee, and moving them to the appropriate department <<if $employeeList.hasOwnProperty(_passage)>> <<if $employeeList[_passage].length gt 0>> <<for _empUp to 0; _empUp lt $employeeList[_passage].length; _empUp++>> <<if $employeeList[_passage][_empUp].department neq _passage>> <<set _newDep to $employeeList[_passage][_empUp].department>> <<set _tempEmp to $employeeList[_passage].deleteAt(_empUp)>> <<set $employeeList[_newDep].push(_tempEmp[0])>> <<set _empUp-->> <</if>> <</for>><</if>><</if>> This section checks all worker lists on constructed facilities in this department to ensure that no workers are assigned to two jobs at once, and to make sure that employees are still assigned to this department <<set _workingList to []>> <<if def $employeeList[_passage]>> <<if $employeeList[_passage].length gt 0>> <<for _el to 0; _el lt $employeeList[_passage].length; _el++>> <<set _workingList.push($employeeList[_passage][_el].id)>> <</for>> <<for _cf to 0; _cf lt $constructedFacilities.length; _cf++>> <<selectFacility $constructedFacilities[_cf].id>> <<if $facilityList[$selectedFacility].department eq _passage>> <<if $facilityList[$selectedFacility].jobs.length gt 0>> <<for _cw to 0; _cw lt $constructedFacilities[_cf].workers.length; _cw++>> <<if $constructedFacilities[_cf].workers[_cw] isnot "">> <<if _workingList.includes($constructedFacilities[_cf].workers[_cw])>> <<run _workingList.delete($constructedFacilities[_cf].workers[_cw])>> <<else>> <<unassignEmployee _cf _cw>> <</if>> <</if>> <</for>> <</if>><</if>> <<if _passage eq "maintenanceDepartment" && $constructedFacilities[_cf].status eq "damaged">> <<if $constructedFacilities[_cf].repairWorker isnot "">> <<if _workingList.includes($constructedFacilities[_cf].repairWorker)>> <<run _workingList.delete($constructedFacilities[_cf].repairWorker)>> <<else>> <<set $constructedFacilities[_cf].repairWorker to "">> <</if>> <</if>> <</if>> <</for>> <<if _passage eq "maintenanceDepartment">> <<for _cf to 0; _cf lt $underConstruction.length; _cf++>> <<for _cw to 0; _cw lt $underConstruction[_cf].workers.length; _cw++>> <<if $underConstruction[_cf].workers[_cw] isnot "">> <<if _workingList.includes($underConstruction[_cf].workers[_cw])>> <<run _workingList.delete($underConstruction[_cf].workers[_cw])>> <<else>> <<set $underConstruction[_cf].workers[_cw] to "">> <</if>> <</if>> <</for>><</for>> <</if>> <<else>> <<for _cf to 0; _cf lt $constructedFacilities.length; _cf++>> <<selectFacility $constructedFacilities[_cf].id>> <<if $facilityList[$selectedFacility].department eq _passage>> <<if $facilityList[$selectedFacility].jobs gt 0>> <<for _cw to 0; _cw lt $constructedFacilities[_cf].workers.length; _cw++>> <<unassignEmployee _cf _cw>> <</for>> <</if>><</if>> <</for>> <</if>><</if>> <</silently>><</nobr>><</widget>>
<<widget printJobs>><<nobr>> <<silently>> args0 - index of facility on $constructedFacilities list <</silently>> <<set _id to $constructedFacilities[_args[0]].id>> <<selectFacility _id>> <<set _facility to $selectedFacility>> <<for _jb to 0; _jb lt $facilityList[_facility].jobs.length; _jb++>><<capture _jb>> <<set _tempTitle to $facilityList[_facility].jobs[_jb].jobTitle>> <<set _tempDesc to $facilityList[_facility].jobs[_jb].description>> <br><<linkappend _tempTitle>><br>_tempDesc<</linkappend>><br> Produces: <<printObjectPairs $facilityList[_facility].jobs[_jb].output>><br> Consumes: <<printObjectPairs $facilityList[_facility].jobs[_jb].upkeep>><br> <<if $facilityList[_facility].jobs[_jb].traitReqs.length gt 0>> Required Traits: <<for _rt to 0; _rt lt $facilityList[_facility].jobs[_jb].traitReqs.length; _rt++>> <<selectTrait $facilityList[_facility].jobs[_jb].traitReqs[_rt]>> <<print $traitList[$selectedTrait].label>><<if _rt neq $facilityList[_facility].jobs[_jb].traitReqs.length -1>>, <</if>> <</for>><br><</if>> <<if ($facilityList[_facility].jobs[_jb].traitExcl.length gt 0 && not $facilityList[_facility].jobs[_jb].traitExcl.includes("deployed")) || $facilityList[_facility].jobs[_jb].traitExcl.length gt 1>> Excluded Traits: <<for _et to 0; _et lt $facilityList[_facility].jobs[_jb].traitExcl.length; _et++>> <<if $facilityList[_facility].jobs[_jb].traitExcl[_et] neq "deployed">> <<selectTrait $facilityList[_facility].jobs[_jb].traitExcl[_et]>> <<print $traitList[$selectedTrait].label>><<if _et neq $facilityList[_facility].jobs[_jb].traitExcl.length -1>>, <</if>> <</if>><</for>><br><</if>> <<if def $constructedFacilities[_args[0]].workers[_jb]>> <<if $constructedFacilities[_args[0]].workers[_jb] isnot "">> Worker: <<selectEmployee $constructedFacilities[_args[0]].workers[_jb] passage()>> <<printEmployee>><br> <<set _passage to passage()>> <<button [[Unassign|_passage]]>><<unassignEmployee _args[0] _jb>><</button>> <<else>> Assign: <<assignEmployee _args[0] _jb>> <</if>><<else>> Error: workerList contains undefined index; error at construction completion <</if>><br> <</capture>><</for>><br> <</nobr>><</widget>>
<<widget selectEmployee>><<nobr>><<silently>> arg0 - employee id arg1 - optional, if defined check only indicated department's list. If some variant of "passage", check current department's list <<set $selectedEmployeeId to "">> <<set $selectedEmployeeDep to "">> <<set _depInd to []>> if arg[1] exists, check its contents <<if def _args[1]>> if arg[1] is some variant of "passage", set the departmentIndex to _temp <<if _args[1] eq "passage" || _args[1] eq "passage()">> <<set _temp to passage()>> <<set _depInd to [_temp]>> Otherwise, treat args[1] as a list of department ids <<else>> If the id in args[1] is valid, set department index to the id <<for _se to 0; _se lt $departmentList.length; _se++>> <<if _args[0] eq $departmentList[_se]>> <<set _depInd to [$departmentList[_se].id]>> <<break>> <</if>> <</for>> <</if>> <</if>> <<set _empKeys to Object.keys($employeeList)>> If department id is still empty, set it to all keys <<if _depInd.length lt 1>> <<for _se to 0; _se lt _empKeys.length; _se++>> <<set _depInd[_se] to _empKeys[_se]>> <</for>> <</if>> perform the search <<for _se to 0; _se lt _depInd.length; _se++>> <<for _ek to 0; _ek lt _empKeys.length; _ek++>> <<if _depInd[_se] eq _empKeys[_ek]>> <<for _sfl to 0; _sfl lt $employeeList[_empKeys[_ek]].length; _sfl++>> <<if $employeeList[_empKeys[_ek]][_sfl].id eq _args[0]>> <<set $selectedEmployeeDep to _empKeys[_ek]>> <<set $selectedEmployeeId to _sfl>> <<break>> <</if>> <</for>><</if>><</for>><</for>> <</silently>><</nobr>><</widget>>
<<widget unassignEmployee>><<nobr>><<silently>> args[0] - index of facility in constructedFacilities args[1] - worker index sets value at index to empty string because the workers array is mapped by index to the job array in the facilityList <<set $constructedFacilities[_args[0]].workers[_args[1]] to "">> <</silently>><</nobr>><</widget>>
<<widget assignEmployee>><<nobr>><<silently>> args[0] - constructedFacilities id args[1] - job index; or "repair" args[2]- optional "construction" <</silently>> <<selectFacility $constructedFacilities[_args[0]].id>> <<set _facilityWithJob to $selectedFacility>> <<set _aEDep to $facilityList[$selectedFacility].department>> <<set _tempList to Array.from($employeeList[_aEDep])>> <<for _ae to 0; _ae lt $constructedFacilities.length; _ae++>><<capture _ae>> <<selectFacility $constructedFacilities[_ae].id>> <<if $facilityList[$selectedFacility].department eq _aEDep>> <<set _toRemove to []>> <<for _aw to 0; _aw lt _tempList.length; _aw++>> <<if $constructedFacilities[_ae].hasOwnProperty("workers")>> <<if $constructedFacilities[_ae].workers.includes(_tempList[_aw].id)>> <<set _toRemove.push(_tempList[_aw])>> <</if>><</if>> <</for>> <<for _tr to 0; _tr lt _toRemove.length; _tr++>><<capture _tr>> <<run _tempList.delete(_toRemove[_tr])>> <</capture>><</for>> <</if>> <<silently>> In maintenance department, we must also check for anyone assigned to repair jobs in the repairWorker variable <</silently>> <<if _aEDep eq "maintenanceDepartment">> <<if $constructedFacilities[_ae].status eq "damaged">> <<if $constructedFacilities[_ae].repairWorker isnot "">> <<for _aw to 0; _aw lt _tempList.length; _aw++>> <<if _tempList[_aw].id eq $constructedFacilities[_ae].repairWorker>> <<run _tempList.deleteAt(_aw)>> <<break>> <</if>> <</for>> <</if>> <</if>> <</if>> <</capture>><</for>> <<silently>> In maintenance department, we must also check for anyone assigned to builder jobs in the underConstruction list <<if _aEDep eq "maintenanceDepartment">> <<for _ae to 0; _ae lt $underConstruction.length; _ae++>><<capture _ae>> <<set _toRemove to []>> <<for _aw to 0; _aw lt _tempList.length; _aw++>> <<if $underConstruction[_ae].workers.includes(_tempList[_aw].id)>> <<set _toRemove.push(_tempList[_aw])>> <</if>> <</for>> <<for _tr to 0; _tr lt _toRemove.length; _tr++>><<capture _tr>> <<run _tempList.delete(_toRemove[_tr])>> <</capture>><</for>> <</capture>><</for>> <</if>> remove enroute employees <<for _tl to 0; _tl lt _tempList.length; _tl++>> <<if _tempList[_tl].enroute lt 0>> <<set _tempList.deleteAt(_tl)>> <<set _tl-->> <</if>> <</for>> <</silently>> <<script>>console.log("tempList final:"); console.log(State.temporary.tempList);<</script>> <<set _listboxOptionsAssign to {"None" : ""}>> <<for _tl to 0; _tl lt _tempList.length; _tl++>><<capture _tl>> <<script>> console.log("passing emp traits, tempList index: "+State.temporary.tl); console.log(State.temporary.tempList); console.log(State.temporary.tempList[State.temporary.tl].traits); <</script>> <<checkJobTraits _tempList[_tl].traits $facilityList[_facilityWithJob].jobs[_args[1]]>> <<if $jobTraitsApproved>> <<set _tempName to ("#"+_tempList[_tl].id+": "+_tempList[_tl].fname + " " + _tempList[_tl].lname)>> <<set _listboxOptionsAssign[_tempName] to _tempList[_tl].id>> <</if>> <</capture>><</for>> <<if (ndef _args[2] || _args[2] neq "construction") && _args[1] neq "repair">> <<script>>console.log("default listbox");<</script>> <<listbox "$constructedFacilities[_args[0]].workers[_args[1]]">> <<optionsfrom _listboxOptionsAssign>> <</listbox>> <<silently>> if "construction" is provided as args[2], assign worker to the underConstruction list instead <</silently>> <<elseif _args[2] eq "construction" && _args[1] neq "repair">> <<listbox "$underConstruction[_args[0]].workers[_args[1]]">> <<optionsfrom _listboxOptionsAssign>> <</listbox>> <<elseif _args[1] eq "repair">> <<listbox "$constructedFacilities[_args[0]].repairWorker">> <<optionsfrom _listboxOptionsAssign>> <</listbox>> <</if>> <</nobr>><</widget>>
These are your quarters <<button [[Next Day|processNewDay]]>><<set $lockNav to true>><<onDeparture>><</button>> <<toggleSpan "People Here" "<br><<printEmployees>>" "1" $globalSetting.hideEmployeeLists>> <<toggleSpan "Additions" "<br><<printFacilities>>" "2" $globalSetting.hideFacilityLists>>
Night is passing <<link [[Next Morning|personalDepartment]]>><<set $lockNav to false>><</link>> <<nightlyProduction>> - need to check/update employeeFlags <<applyChangeIn>> <<completedConstructionCheck>> <<completedRepairCheck>> <<completedResearchCheck>> <<updateLists>> <<silently>>Lists could theoretically be updated only when tech or facility is completed, but this seems easier. Lists need to be updated after completedConstruction and completedTech checks, but before the techOptions are updated, otherwise techOptions won't include newly eligible techs<</silently>> <<if $techOptions.reselect>> <<selectTechOptions>> <</if>> update travel time/rate Manage deliveries check for and route to events check facilities for damage and lack of damage; update status accordingly Check facilities for projects that may be completed <<updateConstructionSlots>> handle shortages Daily Summary <<nobr>> <<set _keys to Object.keys($changeIn)>> <<for _i to 0; _i lt _keys.length; _i++>> <<if _keys[_i] neq "construction" && _keys[_i] neq "repair">> <<print ucFirst(_keys[_i])>>: <<print $changeIn[_keys[_i]]>><br> <</if>> <</for>> <</nobr>>
<<widget printDamagedFacilities>><<nobr>> <<for _ro to 0;_ro lt $constructedFacilities.length; _ro++>><<capture _ro>> <<if $constructedFacilities[_ro].status == "damaged">> <<selectFacility $constructedFacilities[_ro].id>> <<set _roFac to $selectedFacility>> <<linkappend $facilityList[_roFac].label>><br> <<print $facilityList[_roFac].description>><br> <<if Object.keys($facilityList[_roFac].upkeep).length lt 1>> No Upkeep <<else>> <span class='tooltip'>Upkeep: <<printObjectPairs $facilityList[_roFac].upkeep>><span class='tooltiptext'>Upkeeps are not paid and Outputs are not produced while a facility is damaged, as it cannot operate.</span></span><b <</if>> <<if Object.keys($facilityList[$selectedFacility].output).length lt 1>> No Output <<else>> <span class='tooltip'>Output: <<printObjectPairs $facilityList[_roFac].output>><span class='tooltiptext'>Upkeeps are not paid and Outputs are not produced while a facility is damaged, as it cannot operate.</span></span> <</if>> <</linkappend>><br> <span class='tooltip'>Current Damage: <<print $constructedFacilities[_ro].damage>><br><span class='tooltiptext'>When damage is reduced to 0, the facility will become operational again.</span></span><br> <<printRepairWorkerJob _ro>> <</if>> <br> <</capture>><</for>> <</nobr>><</widget>>
<<widget nightlyProduction>><<nobr>><<silently>> store all variables in change variables to be applied all at once at the end <<set $changeIn to { "funds" : 0, "intel" : 0, "power" : 0, "science" : 0, "morale" : 0, "food" : 0, "goods" : 0, "tradeCap" : 0, "construction" : [], "repair" : [] }>> <<set _prisList to []>> reset flags <<set _empFlags to Object.keys($employeeFlags)>> <<set _prisFlags to Object.keys($prisonerFlags)>> <<for _ef to 0; _ef lt _empFlags.length; _ef++>> <<set $employeeFlags[_empFlags[_ef]] to false>> <</for>> <<for _pf to 0; _pf lt _prisFlags.length; _pf++>> <<set $prisonerFlags[_prisFlags[_pf]] to false>> <</for>> loop through constructed facilities <<for _i to 0; _i lt $constructedFacilities.length; _i++>> Check for enabled <<if $constructedFacilities[_i].status == "enabled">> <<selectFacility $constructedFacilities[_i].id>> <<set _flInd to $selectedFacility>> Apply facility upkeep/output <<applyUpkeepOutput "upkeep" $facilityList[_flInd].upkeep>> <<applyUpkeepOutput "output" $facilityList[_flInd].output>> Worker processing <<if def $constructedFacilities[_i].workers>> <<if $constructedFacilities[_i].workers.length gt 0>> <<for _fw to 0; _fw lt $constructedFacilities[_i].workers.length; _fw++>> <<if $constructedFacilities[_i].workers[_fw] isnot "">> Apply job upkeep/output; arg[2] uneccessary since construction/repair isn't in constructedFacilities, but is in underConstruction and elsewhere make sure worker is currently active at job. If not, add value to enroute <<if $constructedFacilities[_i].workers[_fw].enroute gte 0>> <<applyUpkeepOutput "upkeep" $facilityList[_flInd].jobs[_fw].upkeep>> <<applyUpkeepOutput "output" $facilityList[_flInd].jobs[_fw].output>> <<set $constructedFacilities[_i].workers[_fw].enroute to 0>> <<else>> <set $constructedFacilities[_i].workers[_fw].enroute += $travelRate>> <</if>> Check for flags <<if $facilityList[_flInd].jobs[_fw].employeeFlag isnot "">> <<set $employeeFlag[$facilityList[_flInd].jobs[_fw].employeeFlag] to true>> <</if>> <</if>> <</for>><</if>><</if>> Prisoner processing <<if def $constructedFacilities[_i].prisoners>> <<if $constructedFacilities[_i].prisoners.length gt 0>> <<for _fp to 0; _fp lt $constructedFacilities[_i].prisoners.length; _fp++>> <<applyUpkeepOutput "upkeep" $facilityList[_flInd].prisonerJob.upkeep>> <<applyUpkeepOutput "output" $facilityList[_flInd].prisonerJob.output>> Check for flags <<if $facilityList[_flInd].prisonerJob.prisonerFlag isnot "">> <<set $prisonerFlag[$facilityList[_flInd].prisonerJob.prisonerFlag] to true>> <</if>> <<if not $facilityList[_flInd].prisonerJob.forSale>> Check if prisoner is for sale; if so, sell. If not, add to prisoner list <<set _prisList.push($constructedFacilities[_i].prisoners[_fp])>> <<else>> <<sellPrisoner _i _fp>> <<set _fp-->> <</if>> <</for>><</if>><</if>> check damaged facilities for repair workers <<elseif $constructedFacilities[_i].status == "damaged">> <<if $constructedFacilities[_i].repairWorker isnot "">> <<applyUpkeepOutput "repair" _i>> <</if>> <</if>> <</for>> loop through under construction facilities and process builder jobs <<for _i to 0; _i lt $underConstruction.length; _i++>> <<for _fw to 0; _fw lt $underConstruction[_i].workers.length; _fw++>> <<if $underConstruction[_i].workers[_fw] isnot "">> <<applyUpkeepOutput "upkeep" $underConstruction[_i].jobs[_fw].upkeep>> <<applyUpkeepOutput "output" $underConstruction[_i].jobs[_fw].output _i>> <</if>> <</for>> <</for>> <<unitUpkeep _prisList>> <<script>>console.log("changeIn:"); console.log(State.variables.changeIn);<</script>> <</silently>><</nobr>><</widget>>
<<widget applyUpkeepOutput>><<silently>> This will probably have to be modified to accept a traits argument as well, since trait modifiers probably need to get calculated here args0 - "upkeep" or "output" args1 - upkeep/output object pairs, or constructedFacilities index for repairs args2 - used for construction; value of facility to be included in the object pair return only for output <<set _args1 to clone(_args[1])>> <<if _args[0] neq "repair">> <<set _keys to Object.keys(_args1)>> if upkeep, multiply all values by -1 <<if _args[0] eq "upkeep">> <<for _auo to 0; _auo lt _keys.length; _auo++>> <<set _args1[_keys[_auo]] to _args1[_keys[_auo]] * -1>> <</for>><<elseif _args[0] neq "output">> <<script>>console.log("Bad arg[0] on applyUpkeepOutput; defaulting to output");<</script>> <</if>> apply <<for _auo to 0; _auo lt _keys.length; _auo++>> <<switch _keys[_auo]>> <<case "funds" "intel" "power" "science" "morale" "food" "goods" "tradeCap">> <<set $changeIn[_keys[_auo]] += _args1[_keys[_auo]]>> <<case "construction">> <<set $changeIn[_keys[_auo]].push({[_args[2]]:_args[1][_keys[_auo]]})>> <<case "enableImport" "enableExport">> <<script>>console.log("enableImport/Export used; this is deprecated to employeeFlags system.");<</script>> <<case "recruit" "kidnap">> <<set _roll to random(1,100)>> <<if _roll lte _args1[_keys[_auo]]>> <<newUnit _keys[_auo]>> <</if>> <<default>> <<script>>console.log("nightlyProduction not configured to handle upkeep of "+State.temporary.keys[State.temporary.uk]);<</script>> <</switch>> <</for>> Stats for repair worker job are hardcoded here <<else>> <<script>>console.log(State.variables.changeIn); console.log(State.temporary._args1);<</script>> <<set $changeIn.funds -= 10>> <<set $changeIn.repair.push({[_args1]:5})>> <</if>> <<script>>console.log("changinFunds update: "+State.temporary.args[0]+", "+State.variables.changeIn.funds);<</script>> <</silently>><</widget>>
<<widget applyChangeIn>><<silently>> <<script>> console.log("day end funds: "+State.variables.funds); console.log("changein.funds: "+State.variables.changeIn.funds); <</script>> <<if $changeIn.tradeCap gte 0>> <<set $tradeCap to $changeIn.tradeCap>> <<else>> <<set $tradeCap to 0>> <</if>> <<if $employeeFlags.supplyManager>> <<if $changeIn.food lt 0>> <<if ($changeIn.food * -1) lt $tradeCap>> <<set $changeIn.food to 0>> <<set $changeIn.funds to -= (($tradeCap - ($changeIn.food * -1)) * $price.food)>> <</if>> <</if>><</if>> <<if $employeeFlags.salesManager>> <<if $changeIn.goods gt 0>> <<if $changeIn.goods gt $tradeCap>> <<set $changeIn.goods to $tradeCap>> <</if>> <<set $changeIn.funds += ($changeIn.goods * $price.goods)>> <</if>><</if>> <<set $funds += $changeIn.funds>> <<script>>console.log("day start funds: "+State.variables.funds);<</script>> <<set $intel += $changeIn.intel>> //We must check if a test subject is present on relevant techs <<selectTech $currentTech>> <<if $techList[$selectedTech].needTestSubject>> <<for _cfc to 0; _cfc lt $constructedFacilities.length; _cfc++>> <<if $constructedFacilities[_cfc].id eq "testSubjectContainment">> <<if $constructedFacilities[_cfc].prisoners.length gt 0>> <<set $science += $changeIn.science>> <</if>> <</if>> <</for>> <<else>> <<set $science += $changeIn.science>> <</if>> <<set $morale += $changeIn.morale>> <<if $changeIn.power lt 0>> Power defecit - do something <</if>> <<if $changeIn.construction.length gt 0>> <<for _cic to 0; _cic lt $changeIn.construction.length; _cic++>> <<set _ucVal to Object.keys($changeIn.construction[_cic])>> <<if _ucVal.length gt 1>> <<script>>console.log("Error applyChangeIn" construction object has more than one key");<</script>> <</if>> <<set $underConstruction[_ucVal[0]].constructionProg += $changeIn.construction[_cic][_ucVal[0]]>> <</for>><</if>> <<if $changeIn.repair.length gt 0>> <<script>>console.log("Repair List:"); console.log(State.variables.changeIn.repair);<</script>> <<for _cir to 0; _cir lt $changeIn.repair.length; _cir++>> <<set _urVal to Object.keys($changeIn.repair[_cir])>> <<if _urVal.length gt 1>> <<script>>console.log("Error applyChangeIn" repair object has more than one key");<</script>> <</if>> <<script>> console.log("urVal: "+State.temporary.urVal[0]); console.log(State.variables.changeIn.repair[State.temporary.cir][State.temporary.urVal[0]]);<</script>> <<set $constructedFacilities[_urVal[0]].damage -= $changeIn.repair[_cir][_urVal[0]]>> <</for>><</if>> <</silently>><</widget>>
<<widget printFacilitiesUnderConstruction>><<nobr>> <<for _uc to 0; _uc lt $underConstruction.length; _uc++>><<capture _uc>> <<selectFacility $underConstruction[_uc].id>> <<set _fac to $selectedFacility>> <<linkappend $facilityList[_fac].label>> <br><<print $facilityList[_fac].description>><br> Construction Progress: <<print $underConstruction[_uc].constructionProg>>/<<print $underConstruction[_uc].constructionReq>> <</linkappend>><br> <<linkappend "Builders">> <<for _cw to 0; _cw lt $underConstruction[_uc].jobs.length; _cw++>><<capture _cw>> <br><<linkappend $underConstruction[_uc].jobs[_cw].jobTitle>> <br><<print $underConstruction[_uc].jobs[_cw].description>><br> Produces: <<printObjectPairs $underConstruction[_uc].jobs[_cw].output>><br> Consumes: <<printObjectPairs $underConstruction[_uc].jobs[_cw].upkeep>> <</linkappend>><br> <<if $underConstruction[_uc].workers[_cw] isnot "">> Worker: <<selectEmployee $underConstruction[_uc].workers[_cw] "maintenanceDepartment">> <<printEmployee>> <<button [[Unassign|maintenanceDepartment]]>><<set $underConstruction[_uc].workers[_cw] to "">><</button>><br> <<else>> Assign: <<assignEmployee _uc _cw "construction">> <</if>> <</capture>><</for>> <</linkappend>><br> <</capture>><</for>> <</nobr>><</widget>>
//arg0 - constructedFacilities index of damaged facility <<widget printRepairWorkerJob>><<nobr>> Repair Worker: <<if $constructedFacilities[_args[0]].repairWorker isnot "">> <<selectEmployee $constructedFacilities[_args[0]].repairWorker>> <<printEmployee>> <<button [[Unassign|maintenanceDepartment]]>><<set $constructedFacilities[_args[0]].repairWorker to "">><</button>><br> <<else>> Assign: <<assignEmployee _args[0] "repair">> <</if>> <</nobr>><</widget>>
//arg0 - if not included, use $selectedEmployee vars; if only arg, it is employee Id; if arg1 included, it is employee index //arg1 - optional; if included, it is employee department <<widget printEmployee>><<nobr>> <<if ndef _args[0]>> <<set _empDep to $selectedEmployeeDep>> <<set _empInd to $selectedEmployeeId>> <<elseif ndef _args[1]>> <<selectEmployee _args[1]>> <<set _empDep to $selectedEmployeeDep>> <<set _empInd to $selectedEmployeeId>> <<else>> <<set _empDep to _args[1]>> <<set _empInd to _args[0]>> <</if>> <<set _tt1 to "E#"+$employeeList[_empDep][_empInd].id+": "+$employeeList[_empDep][_empInd].fname+" "+$employeeList[_empDep][_empInd].lname>> <<set _tt2 to "">> <<for _pet to 0; _pet lt $employeeList[_empDep][_empInd].traits.length; _pet++>> <<set _tt2 += $employeeList[_empDep][_empInd].traits[_pet]>> <<if _pet != $employeeList[_empDep][_empInd].traits.length -1>> <<set _tt2 += ", ">> <</if>> <</for>> <<tooltip _tt1 _tt2>> <</nobr>><</widget>>
//args[0] - text to display //args[1] - tooltip text <<widget tooltip>><<nobr>> <span class='tooltip'><<print _args[0]>><span class='tooltiptext'><<print _args[1]>></span></span> <</nobr>><</widget>>
<<widget completedConstructionCheck>><<nobr>> <<if $underConstruction.length gt 0>> <<for _i to 0; _i lt $underConstruction.length; _i++>> <<if $underConstruction[_i].constructionProg gte $underConstruction[_i].constructionReq>> <<selectFacility $underConstruction[_i].id>> Construction completed for <<print $facilityList[$selectedFacility].label>> <<completeConstruction _i>> <</if>> <</for>> <</if>> <</nobr>><</widget>>
<<widget completeConstruction>><<silently>> args[0] - index of underConstruction <<set _temp to $underConstruction.deleteAt(_args[0])[0]>> <<set _toInsert to { "id" : _temp.id, "status" : $globalSetting.defaultFacilityStatus, "workers" : [], "damage" : 0, "repairWorker" : "" }>> <<selectFacility _temp.id>> <<script>> console.log(State.variables.facilityList); console.log(State.temporary.temp); console.log(State.variables.selectedFacility); <</script>> <<if $facilityList[$selectedFacility].jobs.length gt 0>> <<for _wk to 0; _wk lt $facilityList[$selectedFacility].jobs.length; _wk++>> <<set _toInsert.workers.push("")>> <</for>><</if>> <<set $constructedFacilities.push(_toInsert)>> <</silently>><</widget>>
<<widget completedRepairCheck>><<nobr>> <<for _i to 0; _i lt $constructedFacilities.length; _i++>> <<if $constructedFacilities[_i].status == "damaged">> <<if $constructedFacilities[_i].damage lte 0>> <<set $constructedFacilities[_i].damage to 0>> <<set $constructedFacilities[_i].status to $globalSetting.defaultFacilityStatus>> <<set $constructedFacilities[_i].repairWorker to "">> <<selectFacility $constructedFacilities[_i].id>> Completed repairs for $facilityList[$selectedFacility].label <</if>> <<else>> <<if $constructedFacilities[_i].damage neq 0>> <<set $constructedFacilities[_i].damage to 0>> <</if>> <<if $constructedFacilities[_i].repairWorker isnot "">> <<set $constructedFacilities[_i].repairWorker to "">> <</if>> <</if>> <</for>> <</nobr>><</widget>>
<<widget updateConstructionSlots>><<nobr>> <<set _slots to 0>> <<for _i to 0; _i lt $constructedFacilities.length; _i++>> <<selectFacility $constructedFacilities[_i].id>> <<set _slots += $facilityList[$selectedFacility].constructionSlots>> <</for>> <<set $constructionLimit to _slots>> <</nobr>><</widget>>
Welcome to Containment <<printEmployees>> <<printFacilities>>
<<widget departmentCleanup>><<silently>> <<for _i to 0; _i lt $departmentList.length; _i++>> <<if ndef $departmentList[_i].prisonersAllowed>> <<set $departmentList[_i].prisonersAllowed to false>><</if>> <</for>> <</silently>><</widget>>
//args0 - constructedFacilities index <<widget printPrisoners>><<nobr>> <<selectFacility $constructedFacilities[_i].id>> <<set _facilityInd to $selectedFacility>> <br><<linkappend "<<print $facilityList[_facilityInd].prisonerJob.jobTitle>>">><br> <<print $facilityList[_facilityInd].prisonerJob.description>><br> <<script>>console.log("upkeep/output"); console.log(State.variables.facilityList[State.temporary.facilityInd].prisonerJob); console.log(Object.keys(State.variables.facilityList[State.temporary.facilityInd].prisonerJob.upkeep).length);<</script>> Prisoner Upkeep: <<if Object.keys($facilityList[_facilityInd].prisonerJob.upkeep).length gt 0>><<printObjectPairs $facilityList[_facilityInd].prisonerJob.upkeep>><<else>>None<</if>><br> Prisoner Output: <<if Object.keys($facilityList[_facilityInd].prisonerJob.output).length gt 0>><<printObjectPairs $facilityList[_facilityInd].prisonerJob.output>><<else>>None<</if>><br> <<if $facilityList[_facilityInd].prisonerJob.traitReqs.length gt 0>> Required Traits: <<for _rt to 0; _rt lt $facilityList[_facilityInd].prisonerJob.traitReqs.length; _rt++>> <<selectTrait $facilityList[_facilityInd].prisonerJob.traitReqs[_rt]>> <<print traitList[$selectedTrait].label>><<if _rt neq $facilityList[_facilityInd].prisonerJob.traitReqs.length -1>>, <</if>><</for>><br><</if>> <<if $facilityList[_facilityInd].prisonerJob.traitExcl.length gt 0>> Excluded Traits: <<for _et to 0; _et lt $facilityList[_facilityInd].prisonerJob.traitExcl.length; _et++>> <<selectTrait $facilityList[_facilityInd].prisonerJob.traitExcl[_et]>> <<print traitList[$selectedTrait].label>><<if _et neq $facilityList[_facilityInd].prisonerJob.traitExcl.length -1>>, <</if>><</for>><</if>> <</linkappend>><br> Capacity: <<print $constructedFacilities[_i].prisoners.length>>/<<print $facilityList[_facilityInd].prisonerCapacity>><br> <<if $constructedFacilities[_i].prisoners.length gt 0>> <<script>>console.log("first if");<</script>> <<for _pr to 0; _pr lt $constructedFacilities[_i].prisoners.length; _pr++>><<capture _pr>> <<script>>console.log("for loop");<</script>> <<printPrisoner _i _pr>> <</capture>><</for>> <<else>> No prisoners assigned <<script>>console.log("else");<</script>> <</if>> <<script>>console.log("after if");<</script>> <</nobr>><</widget>>
//args0 - prisoner id or constructedFacilities index //args1 - if defined, args0 is cF index. prisoner list index <<widget printPrisoner>><<nobr>> <<script>>console.log("print prisoner");<</script>> <<if def _args[1]>> <<set _cfInd to _args[0]>> <<set _plInd to _args[1]>> <<else>> <<selectPrisoner _args[0]>> <<set _cfInd to $selectedPrisonerFacility>> <<set _plInd to $selectedPrisonerListInd>> <</if>> <<set _link to "P#"+$constructedFacilities[_cfInd].prisoners[_plInd].id+" "+$constructedFacilities[_cfInd].prisoners[_plInd].fname+" "+$constructedFacilities[_cfInd].prisoners[_plInd].lname>> <<linkappend _link>><br> Sex: <<print $constructedFacilities[_cfInd].prisoners[_plInd].sex>><br> Qualities: <<displayTraits "qualities" $constructedFacilities[_cfInd].prisoners[_plInd].qualities>><br> Traits: <<displayTraits "traits" $constructedFacilities[_cfInd].prisoners[_plInd].traits>><br> <<relocatePrisoner _cfInd _plInd>> <</linkappend>> <</nobr>><</widget>>
<<widget selectPrisoner>><<silently>> //args0 - prisoner ID <<for _spf to 0; _spf lt $constructedFacilities.length; _spf++>> <<if $constructedFacilities[_spf].prisoners.length gt 0>> <<for _spi to 0; _spi lt $constructedFacilities[_spf].prisoners.length; _spi++>> <<if $constructedFacilities[_spf].prisoners[_spi].id eq _args[0]>> <<set $selectedPrisonerFacility to _spf>> <<set $selectedPrisonerListInd to _spi>> <<break>> <</if>> <</for>><</if>> <</for>> <</silently>><</widget>>
//args0 - cf index //args1 - pl index //note - prisonerRelocateOptions default value needs to be a facility with infinite capacity that disposes of excess prisoners at end of day. The disposal method will be based on a global setting <<widget relocatePrisoner>><<nobr>> <<set _prisonerRelocateOptions to {}>> <<for _rll to 0; _rll lt $constructedFacilities.length; _rll++>> <<selectFacility $constructedFacilities[_rll].id>> <<if $constructedFacilities[_rll].prisoners lt $facilityList[$selectedFacility].prisonerCapacity>> <<script>>console.log(State.variables.constructedFacilities[State.temporary.args[0]].prisoners[State.temporary.args[1]]);<</script>> <<checkJobTraits $constructedFacilities[_args[0]].prisoners[_args[1]].traits $facilityList[$selectedFacility].prisonerJob>> <<if $jobTraitsApproved>> <<set _prisonerRelocateOptions[$facilityList[$selectedFacility].label] to _rll>> <</if>> <</if>> <</for>> Relocate: <<listbox "$constructedFacilities[_args[0]].prisoners[_args[1]].destination">> <<optionsfrom _prisonerRelocateOptions>> <</listbox>> <<set _refresh to passage()>> <<button [[Confirm|_refresh]]>> <<set _tempPris to $constructedFacilities[_args[0]].prisoners.deleteAt(_args[1])[0]>> <<script>>console.log(State.temporary.tempPris);<</script>> <<set $constructedFacilities[_tempPris.destination].prisoners.push(_tempPris)>> <<onDeparture>> <</button>> <</nobr>><</widget>>
//args0 - traits object //args1 - job object <<widget checkJobTraits>><<silently>> <<script>>console.log(State.temporary.args[1]);<</script>> <<set $jobTraitsApproved to false>> <<set _exclusionsPassed to true>> <<if _args[0].length gt 0>> <<if _args[1].traitExcl.length gt 0>> <<script>>console.log(State.temporary.args[0]);<</script>> <<for _texl to 0; _texl lt _args[1].traitExcl.length; _texl++>> <<script>>console.log("checking trait: "+State.temporary.args[1].traitExcl[State.temporary.texl]);<</script>> <<if _args[0].includes(_args[1].traitExcl[_texl])>> <<set _exclusionsPassed to false>> <<break>> <</if>> <</for>><</if>> <</if>> <<set _requirementsPassed to true>> <<if _exclusionsPassed>> <<if _args[1].traitReqs.length gt 0>> <<if _args[0].length gt 0>> <<for _tinc to 0; _tinc lt _args[1].traitReqs.length; _tinc++>> <<if not _args[0].includes(_args[1].traitReqs[_tinc])>> <<set _requirementsPassed to false>> <<break>> <</if>> <</for>> <<else>> <<set _requirementsPassed to false>> <</if>> <</if>> <</if>> <<script>>console.log("exclusionsPassed: "+State.temporary.exclusionsPassed+"; requirementsPassed: "+State.temporary.requirementsPassed); <</script>> <<if _exclusionsPassed && _requirementsPassed>> <<set $jobTraitsApproved to true>> <</if>> <</silently>><</widget>>
arg0 - constructedFacility index arg1 - prisonerList index arg2 - prisonerJob sale value modifiers - come back to this when deciding how sales are calculated <<widget sellPrisoner>><<silently>> <<script>> console.log("arg0: "+State.temporary.args[0]); console.log("arg1: "+State.temporary.args[1]); <</script>> <<set _prisSold to $constructedFacilities[_args[0]].prisoners.deleteAt(_args[1])[0]>> Add a method of calculating prisoner value based off base value, sales reps, and traits. Add value modifier to traits? <<set $changeIn.funds += 1000>> <</silently>><</widget>>
Here the efforts of Field Agents can be coordinated. <<toggleSpan "Employees" "<br><<printEmployees>>" "1" $globalSetting.hideEmployeeLists>> <<toggleSpan "Facilities" "<br><<printFacilities>>" "2" $globalSetting.hideFacilityLists>>
args0 - emp Index <<widget deployAgent>><<silently>> <<if not $employeeList.headquartersDepartment[_args[0]].traits.includes("deployed")>> <<set $employeeList.headquartersDepartment[_args[0]].traits.push("deployed")>> <<set $employeeList.headquartersDepartment[_args[0]].enroute to ($travelTime * -1)>> <</if>> <</silently>><</widget>>
args0 - emp index <<widget retrieveAgent>><<silently>> <<if $employeeList.headquartersDepartment[_args[0]].traits.includes("deployed")>> <<set $employeeList.headquartersDepartment[_args[0]].traits.deleteAt($employeeList.headquartersDepartment[_args[0]].traits.indexOf("deployed"))>> <<set $employeeList.headquartersDepartment[_args[0]].enroute to ($travelTime * -1)>> <</if>> <</silently>><</widget>>
args0 - prisList <<widget unitUpkeep>><<silently>> <<set _keyVals to Object.keys($employeeList)>> <<for _kvs to 0; _kvs lt _keyVals.length; _kvs++>> <<for _epi to 0; _epi lt $employeeList[_kvs].length; _epi++>> <<set $changeIn.funds -= $baseEmpWage>> <<if not $employeeList[_kvs][_epi].traits.includes("deployed")>> <<set $changeIn.food -= $baseEmpFeed>><</if>> <</for>><</for>> <<for _pri to 0; _pri lt _args[0].length; _pri++>> <<set $changeIn.funds -= $basePrisWage>> <<set $changeIn.food -= $basePrisFeed>> <</for>> <</silently>><</widget>>
args0 - string recruit or kidnap, indicating new employee or prisoner <<widget newUnit>><<silently>> <</silently>><</widget>>
<<widget selectTechOptions>><<silently>> <<set _shuffleList to Array.from($availableTechs)>> <<run _shuffleList.shuffle()>> <<set $techOption.bio to "None Available">> <<set $techOption.psych to "None Available">> <<set $techOption.mech to "None Available">> <<set $techOption.gen to "None Available">> <<set $techOption.reselect to false>> select tech from 3 main categories <<for _sc to 0; _sc lt _shuffleList.length; _sc++>> <<selectTech _shuffleList[_sc]>> <<set _shTech to $selectedTech>> <<if $techList[_shTech].category eq "biology">> <<set $techOption.bio to _shuffleList[_sc]>> <<elseif $techList[_shTech].category eq "psychology">> <<set $techOption.psych to _shuffleList[_sc]>> <<elseif $techList[_shTech].category eq "mechanical">> <<set $techOption.mech to _shuffleList[_sc]>> <<else>> <</if>> <<if $techOption.bio neq "None Available" && $techOption.psych neq "None Available" && $techOption.mech neq "None Available">> <<break>> <</if>> <</for>> Fill any categories that remain empty with generic techs, including generic category <<for _sc to 0; _sc lt _shuffleList.length; _sc++>> <<selectTech _shuffleList[_sc]>> <<set _shTech to $selectedTech>> <<if $techList[_shTech].category eq "generic">> <<if $techOption.bio eq "None Available">> <<set $techOption.bio to _shuffleList[_sc]>> <<elseif $techOption.psych eq "None Available">> <<set $techOption.psych to _shuffleList[_sc]>> <<elseif $techOption.mech eq "None Available">> <<set $techOption.mech to _shuffleList[_sc]>> <<elseif $techOption.gen eq "None Available">> <<set $techOption.gen to _shuffleList[_sc]>> <<else>> <</if>><</if>> <<if $techOption.bio neq "None Available" && $techOption.psych neq "None Available" && $techOption.mech neq "None Available" && $techOption.gen neq "None Available">> <<break>> <</if>> <</for>> <</silently>><</widget>>
<<widget completedResearchCheck>><<silently>> <<if $currentTech neq "None">> <<selectTech $currentTech>> <<if $science gte $selectedTech.researchReq>> <<set $science -= $selectedTech.researchReq>> <<set $completedTechs.push($currentTech)>> <<set $currentTech to "None">> <<set $techOptions.reselect to true>> <<if $addedTechs.length gt 0>> <<for _at to 0; _at lt $addedTechs.length; _at++>> <<if $currentTech eq $addedTechs[_at]>> <<run $addedTechs.deleteAt(_ac)>> <<break>> <</if>> <</for>><</if>> <</if>><</if>> <</silently>><</widget>>
<<widget printTech>><<nobr>> <<if ndef _args[0].id>> <<selectTech _args[0]>> <<set _tech to $techList[$selectedTech]>> <<else>> <<set _tech to _args[0]>> <</if>> <<linkappend "<<print _tech.label>>">>: <<print _tech.description>><</linkappend>><br> Research Required: _tech.researchReq<br> Category: <<print ucFirst(_tech.category)>><br> <<if _tech.needTestSubject>>Test Subject Required<br><</if>> <br> <</nobr>><</widget>>
<<widget applyTech>><<silently>> <<if ndef _args[0].id>> <<selectTech _args[0]>> <<set _tech to $techList[$selectedTech]>> <<else>> <<set _tech to _args[0]>> <</if>> <<set $currentTech to _tech.id>> <</silently>><</widget>>
<<widget selectQuality>><<nobr>><<silently>> arg[0] - quality ID. Sets selectedQuality to quality object index from qualityList <<set $selectedQuality to "">> <<for _t to 0; _t lt $qualityList.length; _t++>> <<if $qualityList[_t].id eq _args[0]>> <<set $selectedQuality to _t>> <<break>> <</if>> <</for>> <</silently>><</nobr>><</widget>>