diff --git a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java index 61df041b6a..390b7a0423 100644 --- a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java +++ b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java @@ -62,9 +62,11 @@ private List setCodes; // Number of the current booster (for draft log writing). + // starts with 1 private int packNo; // Number of the current card pick (for draft log writing). + // starts with 1 private int pickNo; // Cached booster data to be written into the log (see logLastPick). @@ -155,9 +157,9 @@ this.txtPack2.setText(draftView.getSets().get(1)); this.txtPack3.setText(draftView.getSets().get(2)); } - this.chkPack1.setSelected(draftView.getBoosterNum() > 0); - this.chkPack2.setSelected(draftView.getBoosterNum() > 1); - this.chkPack3.setSelected(draftView.getBoosterNum() > 2); + this.chkPack1.setSelected(draftView.getBoosterNum() > 1); + this.chkPack2.setSelected(draftView.getBoosterNum() > 2); + this.chkPack3.setSelected(draftView.getBoosterNum() > 3); this.txtCardNo.setText(Integer.toString(draftView.getCardNum())); packNo = draftView.getBoosterNum(); @@ -169,7 +171,7 @@ int left = draftView.getPlayers().size() - right; int height = left * 18; lblTableImage.setSize(new Dimension(lblTableImage.getWidth(), height)); - Image tableImage = ImageHelper.getImageFromResources(draftView.getBoosterNum() == 2 ? "/draft/table_left.png" : "/draft/table_right.png"); + Image tableImage = ImageHelper.getImageFromResources((draftView.getBoosterNum() + 1) % 2 == 1 ? "/draft/table_left.png" : "/draft/table_right.png"); BufferedImage resizedTable = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(tableImage, BufferedImage.TYPE_INT_ARGB), lblTableImage.getWidth(), lblTableImage.getHeight()); lblTableImage.setIcon(new ImageIcon(resizedTable)); @@ -414,7 +416,7 @@ if (currentBooster != null) { String lastPick = getCardName(getLastPick(pickView.getPicks().values())); if (lastPick != null && currentBooster.length > 1) { - draftLogger.logPick(getCurrentSetCode(), packNo, pickNo - 1, lastPick, currentBooster); + draftLogger.logPick(getCurrentSetCode(), packNo, pickNo - 1, lastPick, currentBooster); // wtf pickno need -1? } currentBooster = null; } diff --git a/Mage.Common/src/main/java/mage/view/TableView.java b/Mage.Common/src/main/java/mage/view/TableView.java index f32a822667..32d09ee79a 100644 --- a/Mage.Common/src/main/java/mage/view/TableView.java +++ b/Mage.Common/src/main/java/mage/view/TableView.java @@ -177,7 +177,7 @@ public class TableView implements Serializable { case DRAFTING: Draft draft = table.getTournament().getDraft(); if (draft != null) { - stateText.append(' ').append(draft.getBoosterNum()).append('/').append(draft.getCardNum() - 1); + stateText.append(' ').append(draft.getBoosterNum()).append('/').append(draft.getCardNum()); } break; default: diff --git a/Mage.Common/src/main/java/mage/view/TournamentView.java b/Mage.Common/src/main/java/mage/view/TournamentView.java index c8fc65ef1b..9da79bd8ca 100644 --- a/Mage.Common/src/main/java/mage/view/TournamentView.java +++ b/Mage.Common/src/main/java/mage/view/TournamentView.java @@ -53,7 +53,7 @@ public class TournamentView implements Serializable { tournamentState = tournament.getTournamentState(); if (tournament.getTournamentState().equals("Drafting") && tournament.getDraft() != null) { - runningInfo = "booster/card: " + tournament.getDraft().getBoosterNum() + '/' + (tournament.getDraft().getCardNum() -1); + runningInfo = "booster/card: " + tournament.getDraft().getBoosterNum() + '/' + (tournament.getDraft().getCardNum()); } else { runningInfo = ""; } diff --git a/Mage/src/main/java/mage/game/draft/BoosterDraft.java b/Mage/src/main/java/mage/game/draft/BoosterDraft.java index 152572e313..ee5901a05f 100644 --- a/Mage/src/main/java/mage/game/draft/BoosterDraft.java +++ b/Mage/src/main/java/mage/game/draft/BoosterDraft.java @@ -17,18 +17,21 @@ public class BoosterDraft extends DraftImpl { @Override public void start() { - cardNum = 0; - while (!isAbort() && boosterNum < numberBoosters) { + cardNum = 1; + boosterNum = 1; + while (!isAbort() && boosterNum <= numberBoosters) { openBooster(); - cardNum = 0; + cardNum = 1; + fireUpdatePlayersEvent(); while (!isAbort() && pickCards()) { - if (boosterNum % 2 == 1) { + if ((boosterNum + 1) % 2 == 1) { passLeft(); } else { passRight(); } fireUpdatePlayersEvent(); } + boosterNum++; } resetBufferedCards(); this.fireEndDraftEvent(); diff --git a/Mage/src/main/java/mage/game/draft/DraftImpl.java b/Mage/src/main/java/mage/game/draft/DraftImpl.java index f0b031ba5b..cadea09ddc 100644 --- a/Mage/src/main/java/mage/game/draft/DraftImpl.java +++ b/Mage/src/main/java/mage/game/draft/DraftImpl.java @@ -22,8 +22,8 @@ public abstract class DraftImpl implements Draft { protected DraftCube draftCube; protected List sets; protected List setCodes; - protected int boosterNum = 0; - protected int cardNum = 0; // increases +1 on first picking (so draft get 1 as first card number) + protected int boosterNum = 1; // starts with booster 1 + protected int cardNum = 1; // starts with card number 1, increases by +1 after each picking protected TimingOption timing; protected boolean abort = false; @@ -192,21 +192,18 @@ public abstract class DraftImpl implements Draft { } protected void openBooster() { - if (boosterNum < numberBoosters) { + if (boosterNum <= numberBoosters) { for (DraftPlayer player : players.values()) { if (draftCube != null) { player.setBooster(draftCube.createBooster()); } else { - player.setBooster(sets.get(boosterNum).createBooster()); + player.setBooster(sets.get(boosterNum - 1).createBooster()); } } } - boosterNum++; - fireUpdatePlayersEvent(); } protected boolean pickCards() { - cardNum++; for (DraftPlayer player : players.values()) { if (player.getBooster().isEmpty()) { return false; @@ -214,6 +211,7 @@ public abstract class DraftImpl implements Draft { player.setPicking(); player.getPlayer().pickCard(player.getBooster(), player.getDeck(), this); } + cardNum++; synchronized (this) { while (!donePicking()) { try { @@ -264,9 +262,7 @@ public abstract class DraftImpl implements Draft { @Override public void firePickCardEvent(UUID playerId) { DraftPlayer player = players.get(playerId); - if (cardNum > 15) { - cardNum = 15; - } + int cardNum = Math.min(15, this.cardNum); int time = timing.getPickTimeout(cardNum); playerQueryEventSource.pickCard(playerId, "Pick card", player.getBooster(), time); } diff --git a/Mage/src/main/java/mage/game/draft/DraftOptions.java b/Mage/src/main/java/mage/game/draft/DraftOptions.java index 7220c191ba..35937e1007 100644 --- a/Mage/src/main/java/mage/game/draft/DraftOptions.java +++ b/Mage/src/main/java/mage/game/draft/DraftOptions.java @@ -22,7 +22,7 @@ public class DraftOptions extends LimitedOptions implements Serializable { REGULAR("x1.5", "Regular (x1.5)", 1.5, Arrays.asList(113, 105, 98, 90, 83, 75, 68, 60, 35, 30, 25, 20, 15, 10, 8) ), - PROFI("x1.0", "Profi (x1.0)", 1.0, + PROFI("x1.0", "Professional (x1.0)", 1.0, Arrays.asList(75, 70, 65, 60, 55, 50, 45, 40, 30, 25, 20, 15, 12, 10, 7) ), NONE("ERROR", "", 0, diff --git a/Mage/src/main/java/mage/game/draft/DraftPlayer.java b/Mage/src/main/java/mage/game/draft/DraftPlayer.java index 0c7c49ca5f..134f21bbbd 100644 --- a/Mage/src/main/java/mage/game/draft/DraftPlayer.java +++ b/Mage/src/main/java/mage/game/draft/DraftPlayer.java @@ -69,11 +69,6 @@ public class DraftPlayer { picking = false; } -// public void openBooster(ExpansionSet set) { -// synchronized(booster) { -// booster = set.createBooster(); -// } -// } public void setBooster(List booster) { this.booster = booster; } diff --git a/Mage/src/main/java/mage/game/draft/RandomBoosterDraft.java b/Mage/src/main/java/mage/game/draft/RandomBoosterDraft.java index a38c787608..629c13fd52 100644 --- a/Mage/src/main/java/mage/game/draft/RandomBoosterDraft.java +++ b/Mage/src/main/java/mage/game/draft/RandomBoosterDraft.java @@ -26,13 +26,11 @@ public class RandomBoosterDraft extends BoosterDraft { @Override protected void openBooster() { - if (boosterNum < numberBoosters) { + if (boosterNum <= numberBoosters) { for (DraftPlayer player: players.values()) { player.setBooster(getNextBooster().create15CardBooster()); } } - boosterNum++; - fireUpdatePlayersEvent(); } private ExpansionSet getNextBooster() { diff --git a/Mage/src/main/java/mage/game/draft/RichManBoosterDraft.java b/Mage/src/main/java/mage/game/draft/RichManBoosterDraft.java index 1660e7ede8..b8b63f5e05 100644 --- a/Mage/src/main/java/mage/game/draft/RichManBoosterDraft.java +++ b/Mage/src/main/java/mage/game/draft/RichManBoosterDraft.java @@ -25,14 +25,17 @@ public class RichManBoosterDraft extends DraftImpl { @Override public void start() { - cardNum = 0; - while (!isAbort() && cardNum < 36) { + cardNum = 1; + boosterNum = 1; + while (!isAbort() && cardNum <= 36) { openBooster(); - cardNum = 0; + cardNum = 1; + fireUpdatePlayersEvent(); while (!isAbort() && pickCards()) { passLeft(); fireUpdatePlayersEvent(); } + boosterNum++; } resetBufferedCards(); this.fireEndDraftEvent(); @@ -46,7 +49,7 @@ public class RichManBoosterDraft extends DraftImpl { UUID nextId = table.getNext(); DraftPlayer next = players.get(nextId); while (true) { - List nextBooster = sets.get(cardNum % sets.size()).createBooster(); + List nextBooster = sets.get((cardNum - 1) % sets.size()).createBooster(); next.setBooster(nextBooster); if (Objects.equals(nextId, startId)) { break; @@ -59,7 +62,6 @@ public class RichManBoosterDraft extends DraftImpl { @Override protected boolean pickCards() { - cardNum++; for (DraftPlayer player : players.values()) { if (cardNum > 36) { return false; @@ -67,6 +69,7 @@ public class RichManBoosterDraft extends DraftImpl { player.setPicking(); player.getPlayer().pickCard(player.getBooster(), player.getDeck(), this); } + cardNum++; synchronized (this) { while (!donePicking()) { try { @@ -81,13 +84,7 @@ public class RichManBoosterDraft extends DraftImpl { @Override public void firePickCardEvent(UUID playerId) { DraftPlayer player = players.get(playerId); - if (cardNum > 36) { - cardNum = 36; - } - if (cardNum <= 0) { - cardNum = 1; - } - + int cardNum = Math.min(36, this.cardNum); // richman uses custom times int time = (int) Math.ceil(customProfiTimes[cardNum - 1] * timing.getCustomTimeoutFactor()); playerQueryEventSource.pickCard(playerId, "Pick card", player.getBooster(), time); diff --git a/Mage/src/main/java/mage/game/draft/RichManCubeBoosterDraft.java b/Mage/src/main/java/mage/game/draft/RichManCubeBoosterDraft.java index 3bfd8edc84..7045e0b70b 100644 --- a/Mage/src/main/java/mage/game/draft/RichManCubeBoosterDraft.java +++ b/Mage/src/main/java/mage/game/draft/RichManCubeBoosterDraft.java @@ -23,14 +23,17 @@ public class RichManCubeBoosterDraft extends DraftImpl { @Override public void start() { - cardNum = 0; - while (!isAbort() && cardNum < 36) { + cardNum = 1; + boosterNum = 1; + while (!isAbort() && cardNum <= 36) { openBooster(); - cardNum = 0; + cardNum = 1; + fireUpdatePlayersEvent(); while (!isAbort() && pickCards()) { passLeft(); fireUpdatePlayersEvent(); } + boosterNum++; } resetBufferedCards(); this.fireEndDraftEvent(); @@ -74,7 +77,6 @@ public class RichManCubeBoosterDraft extends DraftImpl { @Override protected boolean pickCards() { - cardNum++; for (DraftPlayer player : players.values()) { if (cardNum > 36) { return false; @@ -82,6 +84,7 @@ public class RichManCubeBoosterDraft extends DraftImpl { player.setPicking(); player.getPlayer().pickCard(player.getBooster(), player.getDeck(), this); } + cardNum++; synchronized (this) { while (!donePicking()) { try { @@ -96,12 +99,7 @@ public class RichManCubeBoosterDraft extends DraftImpl { @Override public void firePickCardEvent(UUID playerId) { DraftPlayer player = players.get(playerId); - if (cardNum > 36) { - cardNum = 36; - } - if (cardNum <= 0) { - cardNum = 1; - } + int cardNum = Math.min(36, this.cardNum); // richman uses custom times int time = (int) Math.ceil(customProfiTimes[cardNum - 1] * timing.getCustomTimeoutFactor());