From e91a7cf666eaa5300e10406793ad610a2b566bfa Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Sat, 30 May 2020 12:43:25 -0700
Subject: [PATCH] Calculate average prosperity with _.mean

---
 src/cheats/mod_EditNeighborArcologyCheat.tw | 6 +-----
 src/uncategorized/neighborInteract.tw       | 8 +-------
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/src/cheats/mod_EditNeighborArcologyCheat.tw b/src/cheats/mod_EditNeighborArcologyCheat.tw
index b4903162a27..ea9afda1f12 100644
--- a/src/cheats/mod_EditNeighborArcologyCheat.tw
+++ b/src/cheats/mod_EditNeighborArcologyCheat.tw
@@ -35,11 +35,7 @@
 <</if>>
 
 <br>
-<<set $averageProsperity = 0, _seed = 0>>
-<<for _eca = 0; _eca < $arcologies.length; _eca++>>
-	<<set $averageProsperity += $arcologies[_eca].prosperity, _seed++>>
-<</for>>
-<<set $averageProsperity = $averageProsperity/_seed>>
+<<set $averageProsperity = _.mean($arcologies.map((a) => a.prosperity))>>
 
 <<for $i = 1; $i < $arcologies.length; $i++>>
 	<<if $arcologies[$i].direction != 0>>
diff --git a/src/uncategorized/neighborInteract.tw b/src/uncategorized/neighborInteract.tw
index 1a927112f3e..bb7620634a9 100644
--- a/src/uncategorized/neighborInteract.tw
+++ b/src/uncategorized/neighborInteract.tw
@@ -1,12 +1,6 @@
 :: Neighbor Interact [nobr jump-to-safe jump-from-safe]
 
-<<set $averageProsperity = 0>>
-<<set _neighboringArcologyCount = 0>>
-<<for $i = 0; $i < $arcologies.length; $i++>>
-	<<set $averageProsperity += $arcologies[$i].prosperity>>
-	<<set _neighboringArcologyCount += 1>>
-<</for>>
-<<set $averageProsperity = $averageProsperity/_neighboringArcologyCount>>
+<<set $averageProsperity = _.mean($arcologies.map((a) => a.prosperity))>>
 
 <<if $cheatMode == 1>>
 	[[Cheat Edit Neighboring Arcologies|MOD_Edit Neighbor Arcology Cheat]]<br><br>
-- 
GitLab