* Fixed a bug that if opponent left tournament during a match, get got points for that mathc if he won more games (fixes #1310).

This commit is contained in:
LevelX2 2015-10-11 11:19:19 +02:00
parent f4b667650c
commit 673cd6b38a

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.game.tournament;
import java.util.ArrayList;
@ -209,7 +208,7 @@ public abstract class TournamentImpl implements Tournament {
}
protected void playRound(Round round) {
for (TournamentPairing pair: round.getPairs()) {
for (TournamentPairing pair : round.getPairs()) {
playMatch(pair);
}
updateResults(); // show points from byes
@ -227,7 +226,7 @@ public abstract class TournamentImpl implements Tournament {
protected List<TournamentPlayer> getActivePlayers() {
List<TournamentPlayer> activePlayers = new ArrayList<>();
for (TournamentPlayer player: players.values()) {
for (TournamentPlayer player : players.values()) {
if (!player.isEliminated()) {
activePlayers.add(player);
}
@ -240,13 +239,13 @@ public abstract class TournamentImpl implements Tournament {
*/
@Override
public void updateResults() {
for (TournamentPlayer player: players.values()) {
for (TournamentPlayer player : players.values()) {
player.setResults("");
player.setPoints(0);
player.setStateInfo("");
}
for (Round round: rounds) {
for (TournamentPairing pair: round.getPairs()) {
for (Round round : rounds) {
for (TournamentPairing pair : round.getPairs()) {
Match match = pair.getMatch();
if (match != null && match.hasEnded()) {
TournamentPlayer tp1 = pair.getPlayer1();
@ -276,9 +275,9 @@ public abstract class TournamentImpl implements Tournament {
tp2.setResults(addRoundResult(round.getRoundNumber(), pair, tp2, tp1));
// Add points
if (mp2.hasQuit() || mp1.getWins() > mp2.getWins()) {
if ((!mp1.hasQuit() && mp1.getWins() > mp2.getWins()) || mp2.hasQuit()) {
tp1.setPoints(tp1.getPoints() + 3);
} else if (mp1.hasQuit() || mp1.getWins() < mp2.getWins()) {
} else if ((!mp2.hasQuit() && mp1.getWins() < mp2.getWins()) || mp1.hasQuit()) {
tp2.setPoints(tp2.getPoints() + 3);
} else {
tp1.setPoints(tp1.getPoints() + 1);
@ -307,14 +306,14 @@ public abstract class TournamentImpl implements Tournament {
matchResult.append(p2.getPlayer().getName());
matchResult.append(" [").append(mp1.getWins());
if (mp1.hasQuit()) {
matchResult.append(mp1.getPlayer().hasIdleTimeout()? "I" :(mp1.getPlayer().hasTimerTimeout()?"T":"Q"));
matchResult.append(mp1.getPlayer().hasIdleTimeout() ? "I" : (mp1.getPlayer().hasTimerTimeout() ? "T" : "Q"));
}
if (match.getDraws() > 0) {
matchResult.append("-").append(match.getDraws());
}
matchResult.append("-").append(mp2.getWins());
if (mp2.hasQuit()) {
matchResult.append(mp2.getPlayer().hasIdleTimeout()? "I" :(mp2.getPlayer().hasTimerTimeout()?"T":"Q"));
matchResult.append(mp2.getPlayer().hasIdleTimeout() ? "I" : (mp2.getPlayer().hasTimerTimeout() ? "T" : "Q"));
}
matchResult.append("] ");
return matchResult.toString();
@ -322,7 +321,7 @@ public abstract class TournamentImpl implements Tournament {
@Override
public boolean isDoneConstructing() {
for (TournamentPlayer player: this.players.values()) {
for (TournamentPlayer player : this.players.values()) {
if (!player.isDoneConstructing()) {
return false;
}
@ -332,7 +331,7 @@ public abstract class TournamentImpl implements Tournament {
@Override
public boolean allJoined() {
for (TournamentPlayer player: this.players.values()) {
for (TournamentPlayer player : this.players.values()) {
if (!player.isJoined()) {
return false;
}
@ -358,7 +357,7 @@ public abstract class TournamentImpl implements Tournament {
public void construct() {
tableEventSource.fireTableEvent(EventType.CONSTRUCT);
if (!isAbort()) {
for (final TournamentPlayer player: players.values()) {
for (final TournamentPlayer player : players.values()) {
player.setConstructing();
new Thread(
@ -372,8 +371,7 @@ public abstract class TournamentImpl implements Tournament {
}
// add autosubmit trigger
synchronized(this) {
synchronized (this) {
while (!isDoneConstructing()) {
try {
this.wait();
@ -387,7 +385,7 @@ public abstract class TournamentImpl implements Tournament {
}
protected void openBoosters() {
for (TournamentPlayer player: this.players.values()) {
for (TournamentPlayer player : this.players.values()) {
player.setDeck(new Deck());
if (options.getLimitedOptions().getDraftCube() != null) {
DraftCube cube = options.getLimitedOptions().getDraftCube();
@ -395,7 +393,7 @@ public abstract class TournamentImpl implements Tournament {
player.getDeck().getSideboard().addAll(cube.createBooster());
}
} else {
for (ExpansionSet set: sets) {
for (ExpansionSet set : sets) {
player.getDeck().getSideboard().addAll(set.createBooster());
}
}
@ -406,7 +404,7 @@ public abstract class TournamentImpl implements Tournament {
public void resetBufferedCards() {
HashSet<ExpansionSet> setsDone = new HashSet<>();
for(ExpansionSet set: sets) {
for (ExpansionSet set : sets) {
if (!setsDone.contains(set)) {
set.removeSavedCards();
setsDone.add(set);
@ -454,7 +452,7 @@ public abstract class TournamentImpl implements Tournament {
protected void winners() {
List<TournamentPlayer> winners = new ArrayList<>();
int pointsWinner = 1; // with less than 1 point you can't win
for(TournamentPlayer tournamentPlayer: this.getPlayers()) {
for (TournamentPlayer tournamentPlayer : this.getPlayers()) {
if (pointsWinner < tournamentPlayer.getPoints()) {
winners.clear();
winners.add(tournamentPlayer);
@ -464,14 +462,14 @@ public abstract class TournamentImpl implements Tournament {
}
}
// set winner state for the players with the most points > 0
for (TournamentPlayer tournamentPlayer: winners) {
for (TournamentPlayer tournamentPlayer : winners) {
tournamentPlayer.setStateInfo("Winner");
}
}
@Override
public void cleanUpOnTournamentEnd() {
for(TournamentPlayer tournamentPlayer: players.values()) {
for (TournamentPlayer tournamentPlayer : players.values()) {
tournamentPlayer.CleanUpOnTournamentEnd();
}
}
@ -509,7 +507,6 @@ public abstract class TournamentImpl implements Tournament {
this.startTime = new Date();
}
@Override
public void setStepStartTime(Date stepStartTime) {
this.stepStartTime = stepStartTime;