$include $lib/rp $include $lib/alynna $pubdef : $def }rps "/" array_join rpstat $def ALLJOBS "$RPSYSTEM" match "/Jobs/" array_get_propdirs $def jobfmt tolower capitalize ( d:jobs means a dict of jobs in the format dict:jp. If jp = 0, then the job is open and undeveloped ) : jobsDevelopable[ d:target -- dict:jobs ] ( Return all jobs with JP in them ) { target @ "/@rp/Jobs/" array_get_propvals foreach swap dup "*spent" smatch if pop pop else jobfmt swap then repeat }dict ; PUBLIC jobsDevelopable $libdef jobsDevelopable : jobsDeveloped[ d:target -- dict:jobs ] ( Return all jobs with JP SPENT in them ) { target @ "/@rp/Jobs/" array_get_propvals foreach swap dup "*spent" smatch if jobfmt "" "spent" subst swap else pop pop then repeat }dict ; PUBLIC jobsDeveloped $libdef jobsDeveloped : jobsJP[ d:target -- dict:jobs ] ( Return all jobs and the current amout of JP available ) { { target @ "/@rp/Jobs/" array_get_propvals foreach swap dup "*spent" smatch if pop pop else jobfmt swap then repeat }dict foreach var! jaypee var! job job @ jaypee @ target @ { "jobs/" job @ "spent" }cat getstat - repeat }dict ; PUBLIC jobsJP $libdef jobsJP : toLevels[ dict:jobs -- dict:levels ] { jobs @ foreach dup not if pop 0 else 50.0 / ++ toint 0 8 limit then repeat }dict ; PUBLIC toLevels $libdef toLevels : toLevelsEx[ dict:jobs -- dict:levels ] { jobs @ foreach 50.0 / ++ toint 1 8 limit repeat }dict ; PUBLIC toLevelsEx $libdef toLevelsEx : requirementsDict[ s:job -- dict:reqs ] { { "Jobs/" job @ "/requirement" }cat rpstat dup if ":" explode_array foreach swap pop "/" split toint repeat else pop then }dict ; PUBLIC requirementsDict $libdef requirementsDict : jobsQualified[ d:target -- dict:jobs ] ( Slow Ass O1 Algorithm, luckily only thrice nested ) var semaphore target @ jobsDevelopable toLevelsEx var! myJobs { ALLJOBS foreach var! job pop 1 semaphore ! job @ requirementsDict foreach var! lev var! job2 myJobs @ job2 @ [] lev @ < if 0 semaphore ! break then repeat semaphore @ if job @ target @ "jobs/" job @ strcat getstatfloat then repeat }dict ; PUBLIC jobsQualified $libdef jobsQualified : jobAnomalies[ d:target -- a:jobs ] { target @ jobsQualified array_keys array_make target @ jobsDeveloped array_keys array_make array_diff foreach var! job pop job @ target @ "jobs/" job @ strcat getstatfloat repeat }dict ; PUBLIC jobAnomalies $libdef jobAnomalies : jobTree[ d:target -- dict:jobs ] ( Return all jobs that have JP in them or would be open as job:JP ) { target @ jobsqualified array_keys array_make target @ jobsDevelopable array_keys array_make array_union foreach var! job pop job @ target @ "Jobs/" job @ strcat getstatfloat repeat }dict ; PUBLIC jobTree $libdef jobTree : jobTreeSpent[ d:target -- dict:jobs ] ( Return all jobs that have JP in them or would be open as job:JPspent ) { target @ jobsqualified array_keys array_make target @ jobsDevelopable array_keys array_make array_union foreach var! job pop job @ target @ "Jobs/" job @ "spent" strcat strcat getstatfloat repeat }dict ; PUBLIC jobTreeSpent $libdef jobTreeSpent : jobTreeFree[ d:target -- dict:jobs ] ( Return all jobs that have JP in them or would be open as job:JPFree ) { target @ jobsQualified array_keys array_make target @ jobsDevelopable array_keys array_make array_union foreach var! job pop job @ target @ "Jobs/" job @ strcat getstatfloat target @ "Jobs/" job @ "spent" strcat strcat getstatfloat - repeat }dict ; PUBLIC jobTreeFree $libdef jobTreeFree : safeToRefund?[ d:target s:job f:amount -- a:conflicts ] ( Save the current state ) target @ jobAnomalies var! before target @ "jobs/" job @ strcat getstatfloat var! jaypee ( Try removing the JP ) me @ "jobs/" job @ strcat over over getstatfloat amount @ - setstat me @ jobAnomalies var! after ( Test for conflicts ) before @ array_keys array_make after @ array_keys array_make array_diff ( And put the JP back. ) me @ "jobs/" job @ strcat jaypee @ setstat ; PUBLIC safeToRefund? $libdef safeToRefund?