mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
* Some changes to table and match view.
This commit is contained in:
parent
54de525401
commit
8426816b09
13 changed files with 205 additions and 95 deletions
|
|
@ -248,6 +248,10 @@ public class TableController {
|
|||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
if (userPlayerMap.containsKey(userId) && playerType.equals("Human")){
|
||||
user.showUserMessage("Join Table", new StringBuilder("You can join a table only one time.").toString());
|
||||
return false;
|
||||
}
|
||||
if (table.getState() != TableState.WAITING) {
|
||||
user.showUserMessage("Join Table", "No available seats.");
|
||||
return false;
|
||||
|
|
@ -644,6 +648,7 @@ public class TableController {
|
|||
public synchronized void startTournament(UUID userId) {
|
||||
try {
|
||||
if (userId.equals(this.userId) && table.getState().equals(TableState.STARTING)) {
|
||||
tournament.setStartTime();
|
||||
TournamentManager.getInstance().createTournamentSession(tournament, userPlayerMap, table.getId());
|
||||
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
|
||||
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ public class User {
|
|||
public String getGameInfo() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
int draft = 0, match = 0, sideboard = 0, tournament = 0, construct = 0;
|
||||
int draft = 0, match = 0, sideboard = 0, tournament = 0, construct = 0, waiting = 0;
|
||||
|
||||
for (Map.Entry<UUID, Table> tableEntry : tables.entrySet()) {
|
||||
if (tableEntry != null) {
|
||||
|
|
@ -389,6 +389,11 @@ public class User {
|
|||
if (tournamentPlayer != null) {
|
||||
if (!tournamentPlayer.isEliminated()) {
|
||||
switch (table.getState()) {
|
||||
case WAITING:
|
||||
case STARTING:
|
||||
case READY_TO_START:
|
||||
waiting++;
|
||||
break;
|
||||
case CONSTRUCTING:
|
||||
construct++;
|
||||
break;
|
||||
|
|
@ -415,6 +420,11 @@ public class User {
|
|||
}
|
||||
} else {
|
||||
switch (table.getState()) {
|
||||
case WAITING:
|
||||
case STARTING:
|
||||
case READY_TO_START:
|
||||
waiting++;
|
||||
break;
|
||||
case SIDEBOARDING:
|
||||
sideboard++;
|
||||
break;
|
||||
|
|
@ -426,6 +436,9 @@ public class User {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (waiting > 0) {
|
||||
sb.append("Wait: ").append(waiting).append(" ");
|
||||
}
|
||||
if (match > 0) {
|
||||
sb.append("Match: ").append(match).append(" ");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,36 +224,33 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
class TableListSorter implements Comparator<Table> {
|
||||
@Override
|
||||
public int compare(Table one, Table two) {
|
||||
// priority 1 - Not started yet
|
||||
if (one.getState().equals(TableState.READY_TO_START) || one.getState().equals(TableState.WAITING) || one.getState().equals(TableState.STARTING)) {
|
||||
if (two.getState().equals(TableState.READY_TO_START) || two.getState().equals(TableState.WAITING) || two.getState().equals(TableState.STARTING)) {
|
||||
return two.getCreateTime().compareTo(one.getCreateTime());
|
||||
} else {
|
||||
return -1; // one has higher priority
|
||||
if (!one.getState().equals(TableState.SIDEBOARDING) && !one.getState().equals(TableState.DUELING)) {
|
||||
if (one.getState().compareTo(two.getState()) != 0 ) {
|
||||
return one.getState().compareTo(two.getState());
|
||||
}
|
||||
}
|
||||
// priority 2 - Not finished yet -> Sorted by time started
|
||||
if (two.getState().equals(TableState.READY_TO_START) || two.getState().equals(TableState.WAITING) || two.getState().equals(TableState.STARTING)) {
|
||||
return 1; // two has higher priority
|
||||
} else if (one.getEndTime() == null) {
|
||||
if (two.getEndTime() == null) {
|
||||
if (two.getStartTime() == null) {
|
||||
return -1;
|
||||
} else if (one.getStartTime() == null) {
|
||||
return 1;
|
||||
}
|
||||
return two.getStartTime().compareTo(one.getStartTime());
|
||||
if (two.getEndTime() != null) {
|
||||
if (one.getEndTime() == null) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return two.getEndTime().compareTo(one.getEndTime());
|
||||
}
|
||||
}
|
||||
// priority 3 - Finished tables -> Sorted by time finished
|
||||
if (two.getEndTime() == null) {
|
||||
return 1;
|
||||
} else {
|
||||
return two.getEndTime().compareTo(one.getEndTime());
|
||||
if (two.getStartTime() != null) {
|
||||
if (one.getStartTime() == null) {
|
||||
return 1;
|
||||
} else {
|
||||
return two.getStartTime().compareTo(one.getStartTime());
|
||||
}
|
||||
}
|
||||
|
||||
if (two.getCreateTime() != null) {
|
||||
if (one.getCreateTime() == null) {
|
||||
return 1;
|
||||
} else {
|
||||
return two.getCreateTime().compareTo(one.getCreateTime());
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue