Skip to content
Snippets Groups Projects
Commit e0f783fe authored by Pregmodder's avatar Pregmodder
Browse files

Merge branch 'fix-customizenationalities' into 'pregmod-master'

fix Global Realism preset error by using _.uniq instead of a for loop

See merge request !388
parents c2204fcf 171d0c3d
No related branches found
No related tags found
No related merge requests found
......@@ -14,22 +14,17 @@
<</if>>
<br>
/* Generates cloned array of $nationalities, removing duplicates */
<<set $nationalitiescheck = clone($nationalities)>>
<<for _i = 0; _i < $nationalitiescheck.length; _i++>>
<<set _nation = $nationalitiescheck[_i]>>
<<if $nationalitiescheck.count(_nation) > 1>>
<<set $nationalitiescheck.deleteAt(_i), _i-->>
<</if>>
<</for>>
<<set $nationalitiescheck.sort()>>
/* Generates cloned array of $nationalities, removing duplicates and then sorting */
<<set $nationalitiescheck = _.uniq($nationalities, false).sort()>>
/* Prints distribution of $nationalities, using $nationalitiescheck to render array */
<<set _totalPercentage = 0>>
<<for _i = 0; _i < $nationalitiescheck.length; _i++>>
<<set _nation = $nationalitiescheck[_i]>>
<<print _nation>> @@.orange;<<print (($nationalities.count(_nation)/$nationalities.length)*100).toFixed(2)>>%@@
<<if _i < $nationalitiescheck.length-1>> | <</if>>
<<set _nation = $nationalitiescheck[_i], _percentage = (($nationalities.count(_nation)/$nationalities.length)*100), _totalPercentage += _percentage>>
<<print _nation>> @@.orange;<<print _percentage.toFixed(2)>>%@@
<<if _i < $nationalitiescheck.length-1>> | <</if>>
<</for>>
<<if _totalPercentage != 100>><br>//Percentages add up to _totalPercentage//<</if>>
<br><br>
/* Fine control tweaking of populations */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment