* Game: fixed wrong booster pass order in drafts (#8075);

This commit is contained in:
Oleg Agafonov 2021-08-28 13:17:57 +04:00
parent 2efdb464fc
commit 65761b085f
8 changed files with 23 additions and 16 deletions

View file

@ -171,7 +171,7 @@
int left = draftView.getPlayers().size() - right; int left = draftView.getPlayers().size() - right;
int height = left * 18; int height = left * 18;
lblTableImage.setSize(new Dimension(lblTableImage.getWidth(), height)); lblTableImage.setSize(new Dimension(lblTableImage.getWidth(), height));
Image tableImage = ImageHelper.getImageFromResources((draftView.getBoosterNum() + 1) % 2 == 1 ? "/draft/table_left.png" : "/draft/table_right.png"); Image tableImage = ImageHelper.getImageFromResources(draftView.getBoosterNum() % 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()); BufferedImage resizedTable = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(tableImage, BufferedImage.TYPE_INT_ARGB), lblTableImage.getWidth(), lblTableImage.getHeight());
lblTableImage.setIcon(new ImageIcon(resizedTable)); lblTableImage.setIcon(new ImageIcon(resizedTable));

View file

@ -19,8 +19,8 @@ public class DraftView implements Serializable {
private final List<String> sets = new ArrayList<>(); private final List<String> sets = new ArrayList<>();
private final List<String> setCodes = new ArrayList<>(); private final List<String> setCodes = new ArrayList<>();
private final int boosterNum; private final int boosterNum; // starts with 1
private final int cardNum; private final int cardNum; // starts with 1
private final List<String> players = new ArrayList<>(); private final List<String> players = new ArrayList<>();
public DraftView(Draft draft) { public DraftView(Draft draft) {

View file

@ -84,7 +84,7 @@ class ChaosMoonEffect extends OneShotEffect {
StaticFilters.FILTER_PERMANENT, source.getSourceId(), source.getControllerId(), game StaticFilters.FILTER_PERMANENT, source.getSourceId(), source.getControllerId(), game
); );
// Odd // Odd
if (permanentsInPlay % 2 != 0) { if (permanentsInPlay % 2 == 1) {
game.addEffect(new BoostAllEffect(1, 1, Duration.EndOfTurn, filter, false), source); game.addEffect(new BoostAllEffect(1, 1, Duration.EndOfTurn, filter, false), source);
new CreateDelayedTriggeredAbilityEffect(new ChaosMoonOddTriggeredAbility()).apply(game, source); new CreateDelayedTriggeredAbilityEffect(new ChaosMoonOddTriggeredAbility()).apply(game, source);
} // Even } // Even

View file

@ -24,10 +24,11 @@ public class BoosterDraft extends DraftImpl {
cardNum = 1; cardNum = 1;
fireUpdatePlayersEvent(); fireUpdatePlayersEvent();
while (!isAbort() && pickCards()) { while (!isAbort() && pickCards()) {
if ((boosterNum + 1) % 2 == 1) { // pass booster order: left -> right -> left
passLeft(); if (boosterNum % 2 == 1) {
passBoosterToLeft();
} else { } else {
passRight(); passBoosterToRight();
} }
fireUpdatePlayersEvent(); fireUpdatePlayersEvent();
} }

View file

@ -149,11 +149,11 @@ public abstract class DraftImpl implements Draft {
this.addPick(playerId, booster.get(booster.size()-1).getId(), null); this.addPick(playerId, booster.get(booster.size()-1).getId(), null);
} }
protected void passLeft() { protected void passBoosterToLeft() {
synchronized (players) { synchronized (players) {
UUID startId = table.get(0); UUID startId = table.get(0);
UUID currentId = startId; UUID currentId = startId;
UUID nextId = table.getNext(); UUID nextId = table.getNext(); // getNext return left player by default
DraftPlayer current = players.get(currentId); DraftPlayer current = players.get(currentId);
DraftPlayer next = players.get(nextId); DraftPlayer next = players.get(nextId);
List<Card> currentBooster = current.booster; List<Card> currentBooster = current.booster;
@ -170,11 +170,11 @@ public abstract class DraftImpl implements Draft {
} }
} }
protected void passRight() { protected void passBoosterToRight() {
synchronized (players) { synchronized (players) {
UUID startId = table.get(0); UUID startId = table.get(0);
UUID currentId = startId; UUID currentId = startId;
UUID prevId = table.getPrevious(); UUID prevId = table.getPrevious(); // getPrevious return right player by default
DraftPlayer current = players.get(currentId); DraftPlayer current = players.get(currentId);
DraftPlayer prev = players.get(prevId); DraftPlayer prev = players.get(prevId);
List<Card> currentBooster = current.booster; List<Card> currentBooster = current.booster;

View file

@ -32,7 +32,8 @@ public class RichManBoosterDraft extends DraftImpl {
cardNum = 1; cardNum = 1;
fireUpdatePlayersEvent(); fireUpdatePlayersEvent();
while (!isAbort() && pickCards()) { while (!isAbort() && pickCards()) {
passLeft(); // new booster each time, so order is irrelevant
passBoosterToLeft();
fireUpdatePlayersEvent(); fireUpdatePlayersEvent();
} }
boosterNum++; boosterNum++;
@ -42,7 +43,7 @@ public class RichManBoosterDraft extends DraftImpl {
} }
@Override @Override
protected void passLeft() { protected void passBoosterToLeft() {
synchronized (players) { synchronized (players) {
UUID startId = table.get(0); UUID startId = table.get(0);
UUID currentId = startId; UUID currentId = startId;

View file

@ -30,7 +30,8 @@ public class RichManCubeBoosterDraft extends DraftImpl {
cardNum = 1; cardNum = 1;
fireUpdatePlayersEvent(); fireUpdatePlayersEvent();
while (!isAbort() && pickCards()) { while (!isAbort() && pickCards()) {
passLeft(); // new booster each time, so order is irrelevant
passBoosterToLeft();
fireUpdatePlayersEvent(); fireUpdatePlayersEvent();
} }
boosterNum++; boosterNum++;
@ -40,7 +41,7 @@ public class RichManCubeBoosterDraft extends DraftImpl {
} }
@Override @Override
protected void passLeft() { protected void passBoosterToLeft() {
synchronized (players) { synchronized (players) {
UUID startId = table.get(0); UUID startId = table.get(0);
UUID currentId = startId; UUID currentId = startId;

View file

@ -6,6 +6,8 @@ import mage.util.CircularList;
import java.util.UUID; import java.util.UUID;
/** /**
* Default players order: left (next player seated to the active player's left)
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class PlayerList extends CircularList<UUID> { public class PlayerList extends CircularList<UUID> {
@ -34,7 +36,9 @@ public class PlayerList extends CircularList<UUID> {
} }
/** /**
* checkNextTurnReached - use it turns/priority code only to mark leaved player as "reached next turn end" (need for some continous effects) * Find next player. Default order: next player from the left
*
* @checkNextTurnReached - use it turns/priority code only to mark leaved player as "reached next turn end" (need for some continous effects)
*/ */
public Player getNext(Game game, boolean checkNextTurnReached) { public Player getNext(Game game, boolean checkNextTurnReached) {
UUID start = this.get(); UUID start = this.get();