Making a super bulk buy command

#1428 (comment 93044)

So as an advancement from there, I'd like to create a cheatmode only command to buyout every single slave in the other slaveowner databases[theres 3 db from what I can see].

This is what I can come up with so far;

<<if $cheatMode == 1>>

/*include the database*/
	
<<set _heroSlaves = App.Utils.buildHeroArray()>>

	/*start total cost*/
<<set _slaveCost = 0>>

/*build cost array, credit svornost*/ 

<<set _heroCosts = []>>

<<for _i = 0; _i < _heroSlaves.length; _i++>>
    <<set _backup = App.Utils.getHeroSlave(_heroSlaves[_i])>>
	<<set _backup.weekAcquired = $week>>
	
	<<set _heroCosts[_i] = heroSlaveCost(_backup)>>
	
	<<set _slaveCost += _heroCosts[_i]>>
	
    /*costing*/
	<</for>>
	
<br>Total cost <<print cashFormat(_slaveCost)>><br>
/*end total cost */

/*buy option, breaks if insufficient dough*/
<<if $cash < _slaveCost>>

<<set _diff = _slaveCost - $cash>> 

Need @@.yellowgreen;<<print cashFormat(_diff)>>.@@ more to buyout all slaves.

<<else>>
/*expenses spent*/
	
<<for _i = 0; _i < _heroSlaves.length; _i++>>
	<<set _backup = App.Utils.getHeroSlave(_heroSlaves[_i])>>
	
	<<run cashX(forceNeg(_heroCosts[_i]), "slaveTransfer", _backup)>>
		

	<br>Buying <<= _backup.slaveName>>
    <<run newSlave(_backup)>>/*send new slave to penthouse*/
	<<run $heroSlavesPurchased.push($heroSlaveID)>>
<<unset $heroSlaveID>>
	<</for>>

<</if>>
	
<</if>>
<br>/*credit to lowercasedonkey and svornost*/

@lowercasedonkey Pasted latest code block.

Edited by ZZC