Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Trying again on lonewolf

  • Loading branch information...
commit b88b243aaebe8b004d405c6de7d48be9317be3a9 1 parent db03de0
Martin Ellis authored April 16, 2012
23  src/no/arcticdrakefox/wolfbot/management/victory/LoneWolfVictory.java
@@ -8,6 +8,8 @@
8 8
 import no.arcticdrakefox.wolfbot.model.WolfBotModel;
9 9
 import no.arcticdrakefox.wolfbot.predicates.TeamPredicate;
10 10
 
  11
+import com.google.common.base.Predicate;
  12
+import com.google.common.base.Predicates;
11 13
 import com.google.common.collect.Collections2;
12 14
 
13 15
 
@@ -32,8 +34,23 @@ public String getVictoryMessage(PlayerList players) {
32 34
 	public boolean inhibitsOthersVictory(PlayerList players) {
33 35
 		WolfBotModel data = WolfBotModel.getInstance();
34 36
 		
35  
-		Collection<Player> loneWolves = Collections2.filter(data.getPlayers().getList(), 
36  
-				new TeamPredicate (Team.LoneWolf));
37  
-		return !loneWolves.isEmpty();
  37
+		
  38
+		Predicate<Player> p_wolves = new TeamPredicate(Team.Wolves);
  39
+		Predicate<Player> p_loneWolf = new TeamPredicate(Team.LoneWolf);
  40
+		Predicate<Player> p_others = Predicates.and(Predicates.not(p_wolves), Predicates.not(p_loneWolf));
  41
+		
  42
+		
  43
+		Collection<Player> loneWolves = Collections2.filter(players.getLivingPlayers(), p_loneWolf);
  44
+		Collection<Player> wolves = Collections2.filter(players.getLivingPlayers(), p_wolves);
  45
+		Collection<Player> others = Collections2.filter(players.getLivingPlayers(), p_others);
  46
+		
  47
+		if (others.isEmpty() && !isVictory(players)) {
  48
+			for (Player p: loneWolves) {
  49
+				p.die("Was killed by the remaing Wolves");
  50
+				return false;
  51
+			}
  52
+		}
  53
+		
  54
+		return (!loneWolves.isEmpty());
38 55
 	}
39 56
 }

0 notes on commit b88b243

Please sign in to comment.
Something went wrong with that request. Please try again.