mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
Choose a player at random - fixed that it wrongly choose same player (example: Scrambleverse, close #12679, close #13526);
Inniaz, the Gale Force - fixed that it wrongly choose left/right player (close #13526);
This commit is contained in:
parent
4ffb0ff014
commit
dcdf0ca4a5
2 changed files with 32 additions and 2 deletions
|
|
@ -115,6 +115,36 @@ public class PlayersListAndOrderTest extends CardTestMultiPlayerBase {
|
||||||
execute();
|
execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_Game_PlayerListMustHaveAccessByIndex() {
|
||||||
|
// make sure CircularList return same data by index, see #13526
|
||||||
|
|
||||||
|
PlayerList players = new PlayerList();
|
||||||
|
players.add(playerA.getId());
|
||||||
|
players.add(playerB.getId());
|
||||||
|
players.add(playerC.getId());
|
||||||
|
players.add(playerD.getId());
|
||||||
|
Assert.assertEquals("last added player must be current", players.get(0), playerD.getId());
|
||||||
|
List<UUID> staticList = new ArrayList<>(players);
|
||||||
|
|
||||||
|
// normal
|
||||||
|
Assert.assertEquals(players.get(0), staticList.get(0));
|
||||||
|
Assert.assertEquals(players.get(1), staticList.get(1));
|
||||||
|
Assert.assertEquals(players.get(2), staticList.get(2));
|
||||||
|
Assert.assertEquals(players.get(3), staticList.get(3));
|
||||||
|
Assert.assertEquals(players.get(2), staticList.get(2)); // make sure no depends on calls order
|
||||||
|
|
||||||
|
// make sure CircularList keeps inner structure
|
||||||
|
players.setCurrent(playerC.getId());
|
||||||
|
Assert.assertEquals(players.get(0), staticList.get(0));
|
||||||
|
Assert.assertEquals(players.get(1), staticList.get(1));
|
||||||
|
Assert.assertEquals(players.get(2), staticList.get(2));
|
||||||
|
Assert.assertEquals(players.get(3), staticList.get(3));
|
||||||
|
Assert.assertEquals(players.get(2), staticList.get(2)); // make sure no depends on calls order
|
||||||
|
|
||||||
|
Assert.assertNull("must return null on non existing item", players.get(999));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_Game_GetPlayerList() {
|
public void test_Game_GetPlayerList() {
|
||||||
// game.getPlayerList() - APNAP order, for cards usage
|
// game.getPlayerList() - APNAP order, for cards usage
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,8 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public E get(int index) {
|
public E get(int index) {
|
||||||
if (list.size() > this.index) {
|
if (list.size() > index) {
|
||||||
return list.get(this.index);
|
return list.get(index);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue