MCPcopy Create free account
hub / github.com/catabriga/graphwar / reorderPlayers

Method reorderPlayers

src/GraphServer/GraphServer.java:820–887  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

818 }
819
820 private void reorderPlayers()
821 {
822 List<Player> newPlayers = new ArrayList<Player>();
823
824 int currentTeam = Constants.TEAM1;
825
826 if(random.nextBoolean())
827 {
828 currentTeam = Constants.TEAM2;
829 }
830
831 while(players.size() > 0)
832 {
833 ListIterator<Player> pitr = players.listIterator();
834
835 boolean found = false;
836
837 while(pitr.hasNext())
838 {
839 Player player = pitr.next();
840
841 if(player.getTeam() == currentTeam)
842 {
843 pitr.remove();
844
845 newPlayers.add(player);
846
847 if(currentTeam == Constants.TEAM1)
848 {
849 currentTeam = Constants.TEAM2;
850 }
851 else
852 {
853 currentTeam = Constants.TEAM1;
854 }
855
856 found = true;
857 }
858 }
859
860 if(found==false)
861 {
862 if(currentTeam == Constants.TEAM1)
863 {
864 currentTeam = Constants.TEAM2;
865 }
866 else
867 {
868 currentTeam = Constants.TEAM1;
869 }
870 }
871 }
872
873 players = newPlayers;
874
875 String message = NetworkProtocol.REORDER+"";
876
877 ListIterator<Player> pitr = players.listIterator();

Callers 1

startGameMethod · 0.95

Calls 3

getTeamMethod · 0.95
getIDMethod · 0.95
sendMessageAllMethod · 0.95

Tested by

no test coverage detected