From 42262b918875149ae165d0374d3ee42801da3c0c Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 29 Aug 2013 20:26:03 -0400 Subject: [PATCH] Added support for premade detection in LeagueGame.java --- .../achimala/leaguelib/models/LeagueGame.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/com/achimala/leaguelib/models/LeagueGame.java b/src/com/achimala/leaguelib/models/LeagueGame.java index 00e26b5..bd39c8b 100644 --- a/src/com/achimala/leaguelib/models/LeagueGame.java +++ b/src/com/achimala/leaguelib/models/LeagueGame.java @@ -16,13 +16,17 @@ package com.achimala.leaguelib.models; -import com.gvaneyck.rtmp.TypedObject; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Comparator; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Comparator; -import java.util.Arrays; +import java.util.Set; + +import com.gvaneyck.rtmp.TypedObject; public class LeagueGame implements PlayerList { private class ObserverCredentials { @@ -71,6 +75,7 @@ public String getEncryptionKey() { private Map _summoners; private Map> _bannedChampions; private ObserverCredentials _observerCredentials; + private Map> premades; public LeagueGame() { } @@ -83,6 +88,16 @@ private void fillListWithPlayers(List list, Object[] team, Leagu sum = primarySummoner; _summoners.put(sum.getInternalName(), sum); list.add(sum); + Double teamParticipantId = to.getDouble("teamParticipantId"); + if(teamParticipantId != null){ + if(!premades.containsKey(teamParticipantId)){ + Set premade = new HashSet(); + premade.add(sum); + premades.put(teamParticipantId, premade); + } else { + premades.get(teamParticipantId).add(sum); + } + } } } @@ -96,6 +111,7 @@ public LeagueGame(TypedObject obj, LeagueSummoner primarySummoner) { _playerTeam = new ArrayList(); _enemyTeam = new ArrayList(); _summoners = new HashMap(); + premades = new HashMap>(); fillListWithPlayers(_playerTeam, obj.getArray("teamOne"), primarySummoner); fillListWithPlayers(_enemyTeam, obj.getArray("teamTwo"), primarySummoner); if(!_playerTeam.contains(primarySummoner)) @@ -201,5 +217,8 @@ public TeamType getEnemyTeamType() { public List getBannedChampionsForTeam(TeamType type) { return _bannedChampions.get(type); } - + + public Collection> getPremades(){ + return premades.values(); + } } \ No newline at end of file