* The list of completed matches and tournaments shows now also columns with start and end time.

This commit is contained in:
LevelX2 2013-06-10 14:12:24 +02:00
parent aef53bc4ce
commit dec8f24c68
6 changed files with 75 additions and 12 deletions

View file

@ -28,6 +28,7 @@
package mage.game.match;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import mage.cards.decks.Deck;
@ -71,4 +72,7 @@ public interface Match {
void addTableEventListener(Listener<TableEvent> listener);
void fireSideboardEvent(UUID playerId, Deck deck);
// match times
Date getStartTime();
Date getEndTime();
}

View file

@ -30,6 +30,7 @@ package mage.game.match;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.UUID;
@ -56,8 +57,12 @@ public abstract class MatchImpl implements Match {
protected TableEventSource tableEventSource = new TableEventSource();
protected Date startTime;
protected Date endTime;
public MatchImpl(MatchOptions options) {
this.options = options;
startTime = new Date();
}
@Override
@ -114,6 +119,7 @@ public abstract class MatchImpl implements Match {
public boolean isMatchOver() {
for (MatchPlayer player: players) {
if (player.getWins() >= options.getWinsNeeded()) {
endTime = new Date();
return true;
}
}
@ -255,5 +261,15 @@ public abstract class MatchImpl implements Match {
sb.append("\nGame has started\n");
return sb.toString();
}
@Override
public Date getStartTime() {
return startTime;
}
@Override
public Date getEndTime() {
return endTime;
}
}

View file

@ -29,6 +29,7 @@
package mage.game.tournament;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import mage.cards.ExpansionSet;
@ -69,4 +70,7 @@ public interface Tournament {
void addPlayerQueryEventListener(Listener<PlayerQueryEvent> listener);
void fireConstructEvent(UUID playerId);
// tournament times
Date getStartTime();
Date getEndTime();
}

View file

@ -58,10 +58,14 @@ public abstract class TournamentImpl implements Tournament {
protected TableEventSource tableEventSource = new TableEventSource();
protected PlayerQueryEventSource playerQueryEventSource = new PlayerQueryEventSource();
protected Date startTime;
protected Date endTime;
private static final int CONSTRUCT_TIME = 600;
public TournamentImpl(TournamentOptions options) {
this.options = options;
startTime = new Date();
}
@Override
@ -292,9 +296,20 @@ public abstract class TournamentImpl implements Tournament {
}
public void end() {
endTime = new Date();
tableEventSource.fireTableEvent(EventType.END);
}
protected abstract void runTournament();
@Override
public Date getStartTime() {
return startTime;
}
@Override
public Date getEndTime() {
return endTime;
}
}