From e807e0fe7e7388a2df1e603396e231496458321c Mon Sep 17 00:00:00 2001 From: Charlie Wang Date: Sun, 30 Jun 2013 22:30:52 -0400 Subject: [PATCH] implemented updateAllSheep and refactored sheep updating --- src/gibstick/bukkit/discosheep/DiscoParty.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gibstick/bukkit/discosheep/DiscoParty.java b/src/gibstick/bukkit/discosheep/DiscoParty.java index 2e49f9d..335243f 100644 --- a/src/gibstick/bukkit/discosheep/DiscoParty.java +++ b/src/gibstick/bukkit/discosheep/DiscoParty.java @@ -87,9 +87,13 @@ public class DiscoParty { } // Set a random colour for all sheep in array - void randomizeSheepColours() { - for (Sheep sheep : getSheep()) { + void randomizeSheepColour(Sheep sheep) { sheep.setColor(discoColours[(int) Math.round(Math.random() * (discoColours.length - 1))]); + } + + void updateAllSheep() { + for (Sheep sheep: getSheep()) { + randomizeSheepColour(sheep); } } @@ -106,7 +110,7 @@ public class DiscoParty { void update() { if (duration > 0) { - randomizeSheepColours(); + updateAllSheep(); playSounds(); duration -= frequency; this.scheduleUpdate();