mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
* Fixed draft start handling to prevent unneccessary waiting check start thread.
This commit is contained in:
parent
b206983e75
commit
03337221c9
3 changed files with 29 additions and 13 deletions
|
@ -149,19 +149,9 @@ public class DraftController {
|
|||
return false;
|
||||
}
|
||||
|
||||
private synchronized void startDraft() {
|
||||
for (final Entry<UUID, DraftSession> entry: draftSessions.entrySet()) {
|
||||
if (!entry.getValue().init()) {
|
||||
logger.fatal("Unable to initialize client for playerId " + entry.getKey());
|
||||
//TODO: generate client error message
|
||||
return;
|
||||
}
|
||||
}
|
||||
draft.start();
|
||||
}
|
||||
|
||||
private void checkStart() {
|
||||
if (allJoined()) {
|
||||
private synchronized void checkStart() {
|
||||
if (!draft.isStarted() && allJoined()) {
|
||||
draft.setStarted();
|
||||
ThreadExecutor.getInstance().getCallExecutor().execute(
|
||||
new Runnable() {
|
||||
@Override
|
||||
|
@ -172,6 +162,17 @@ public class DraftController {
|
|||
}
|
||||
}
|
||||
|
||||
private void startDraft() {
|
||||
for (final Entry<UUID, DraftSession> entry: draftSessions.entrySet()) {
|
||||
if (!entry.getValue().init()) {
|
||||
logger.fatal("Unable to initialize client for playerId " + entry.getKey());
|
||||
//TODO: generate client error message
|
||||
return;
|
||||
}
|
||||
}
|
||||
draft.start();
|
||||
}
|
||||
|
||||
private boolean allJoined() {
|
||||
if (!draft.allJoined()) {
|
||||
return false;
|
||||
|
|
|
@ -56,6 +56,9 @@ public interface Draft extends MageItem, Serializable {
|
|||
int getCardNum();
|
||||
boolean addPick(UUID playerId, UUID cardId);
|
||||
void start();
|
||||
boolean isStarted();
|
||||
void setStarted();
|
||||
|
||||
boolean allJoined();
|
||||
void leave(UUID playerId);
|
||||
void autoPick(UUID playerId);
|
||||
|
@ -68,4 +71,5 @@ public interface Draft extends MageItem, Serializable {
|
|||
|
||||
boolean isAbort();
|
||||
void setAbort(boolean abort);
|
||||
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ public abstract class DraftImpl implements Draft {
|
|||
protected int[] times = {75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5};
|
||||
|
||||
protected boolean abort = false;
|
||||
protected boolean started = false;
|
||||
|
||||
protected transient TableEventSource tableEventSource = new TableEventSource();
|
||||
protected transient PlayerQueryEventSource playerQueryEventSource = new PlayerQueryEventSource();
|
||||
|
@ -340,4 +341,14 @@ public abstract class DraftImpl implements Draft {
|
|||
this.abort = abort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
return started;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStarted() {
|
||||
started = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue