package engine;

import java.util.ArrayList;

import engine.api.Computer;
import engine.api.Player;

public class GameEngine {
  private ArrayList<InternalPlayer> internalPlayers;
  private ArrayList<Heroine> heroines;
  private ArrayList<Computer> computers;

  public GameEngine() {
    internalPlayers = new ArrayList<InternalPlayer>();
    heroines = new ArrayList<Heroine>();
    for (int i = 0; i < 4; i++) {
      heroines.add(new Heroine());
    }
  }

  public void proceed() {
    ArrayList<Integer> mostFavoritePlayers = new ArrayList<Integer>();
    for (Heroine heroine : heroines) {
      int bestPlayer = 0;
      int bestEvaluation = 0;
      for (int i = 0; i < internalPlayers.size(); i++) {
        int evaluation = heroine.getEvaluation(internalPlayers.get(i));
        if (bestEvaluation < heroine.getEvaluation(internalPlayers.get(i))) {
          bestPlayer = i;
          bestEvaluation = evaluation;
        }
      }
      mostFavoritePlayers.add(bestPlayer);
    }

    ArrayList<Player> players = new ArrayList<Player>();
    for (Player player : internalPlayers) {
      players.add(player);
    }

    for (int i = 0; i < computers.size(); i++) {
      int index = computers.get(i).doTurn(i, players, mostFavoritePlayers);
      internalPlayers.get(i).addParameter(index);
    }
  }
}

@@ -1351,11 +1351,410 @@
 %7D%0D%0A  %7D%0D%0A
+  %0D%0A  public int getWinner() %7B%0D%0A    int winner = 0;%0D%0A    int winnerScore = 0;%0D%0A    for (int i = 0; i %3C internalPlayers.size(); i++) %7B%0D%0A      int score = 0;%0D%0A      for (Heroine heroine : heroines) %7B%0D%0A        score += heroine.getEvaluation(internalPlayers.get(i));%0D%0A      %7D%0D%0A      if (winnerScore %3C score) %7B%0D%0A        winner = i;%0D%0A        winnerScore = score;%0D%0A      %7D%0D%0A    %7D%0D%0A    return winner;%0D%0A  %7D%0D%0A
 %7D%0D%0A

Add main