Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added premade detection to LeagueGame #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions src/com/achimala/leaguelib/models/LeagueGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -71,6 +75,7 @@ public String getEncryptionKey() {
private Map<String, LeagueSummoner> _summoners;
private Map<TeamType, List<LeagueChampion>> _bannedChampions;
private ObserverCredentials _observerCredentials;
private Map<Double,Set<LeagueSummoner>> premades;

public LeagueGame() {
}
Expand All @@ -83,6 +88,16 @@ private void fillListWithPlayers(List<LeagueSummoner> 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<LeagueSummoner> premade = new HashSet<LeagueSummoner>();
premade.add(sum);
premades.put(teamParticipantId, premade);
} else {
premades.get(teamParticipantId).add(sum);
}
}
}
}

Expand All @@ -96,6 +111,7 @@ public LeagueGame(TypedObject obj, LeagueSummoner primarySummoner) {
_playerTeam = new ArrayList<LeagueSummoner>();
_enemyTeam = new ArrayList<LeagueSummoner>();
_summoners = new HashMap<String, LeagueSummoner>();
premades = new HashMap<Double,Set<LeagueSummoner>>();
fillListWithPlayers(_playerTeam, obj.getArray("teamOne"), primarySummoner);
fillListWithPlayers(_enemyTeam, obj.getArray("teamTwo"), primarySummoner);
if(!_playerTeam.contains(primarySummoner))
Expand Down Expand Up @@ -201,5 +217,8 @@ public TeamType getEnemyTeamType() {
public List<LeagueChampion> getBannedChampionsForTeam(TeamType type) {
return _bannedChampions.get(type);
}


public Collection<Set<LeagueSummoner>> getPremades(){
return premades.values();
}
}