mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-02 17:00:19 +01:00
Fix getting game from group; resolves #896
This commit is contained in:
parent
7e79b52091
commit
6bedccb29f
@ -287,9 +287,7 @@ public interface PlayerGroup {
|
|||||||
*
|
*
|
||||||
* @return the game of the game world the group is in.
|
* @return the game of the game world the group is in.
|
||||||
*/
|
*/
|
||||||
default Game getGame() {
|
Game getGame();
|
||||||
return getGameWorld() != null ? getGameWorld().getGame() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the game world the group is in.
|
* Returns the game world the group is in.
|
||||||
|
@ -63,11 +63,7 @@ public class DGame implements Game {
|
|||||||
tutorial = false;
|
tutorial = false;
|
||||||
started = false;
|
started = false;
|
||||||
|
|
||||||
groups.add(group);
|
addGroup(group);
|
||||||
group.setGameWorld(world);
|
|
||||||
group.setInitialLives(getRules().getState(GameRule.INITIAL_GROUP_LIVES));
|
|
||||||
group.setLives(getRules().getState(GameRule.INITIAL_GROUP_LIVES));
|
|
||||||
group.setScore(getRules().getState(GameRule.INITIAL_SCORE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DGame(DungeonsXL plugin, PlayerGroup group, GameWorld world) {
|
public DGame(DungeonsXL plugin, PlayerGroup group, GameWorld world) {
|
||||||
@ -112,6 +108,7 @@ public class DGame implements Game {
|
|||||||
public void addGroup(PlayerGroup group) {
|
public void addGroup(PlayerGroup group) {
|
||||||
groups.add(group);
|
groups.add(group);
|
||||||
|
|
||||||
|
((DGroup) group).setGame(this);
|
||||||
group.setGameWorld(world);
|
group.setGameWorld(world);
|
||||||
group.setInitialLives(getRules().getState(GameRule.INITIAL_GROUP_LIVES));
|
group.setInitialLives(getRules().getState(GameRule.INITIAL_GROUP_LIVES));
|
||||||
group.setLives(getRules().getState(GameRule.INITIAL_GROUP_LIVES));
|
group.setLives(getRules().getState(GameRule.INITIAL_GROUP_LIVES));
|
||||||
|
@ -74,6 +74,7 @@ public class DGroup implements PlayerGroup {
|
|||||||
private PlayerCollection invitedPlayers = new PlayerCollection();
|
private PlayerCollection invitedPlayers = new PlayerCollection();
|
||||||
private Dungeon dungeon;
|
private Dungeon dungeon;
|
||||||
private List<ResourceWorld> unplayedFloors = new ArrayList<>();
|
private List<ResourceWorld> unplayedFloors = new ArrayList<>();
|
||||||
|
private Game game;
|
||||||
private GameWorld gameWorld;
|
private GameWorld gameWorld;
|
||||||
private boolean playing;
|
private boolean playing;
|
||||||
private int floorCount;
|
private int floorCount;
|
||||||
@ -334,6 +335,18 @@ public class DGroup implements PlayerGroup {
|
|||||||
this.gameWorld = gameWorld;
|
this.gameWorld = gameWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Game getGame() {
|
||||||
|
if (game == null && gameWorld != null) {
|
||||||
|
game = gameWorld.getGame();
|
||||||
|
}
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGame(Game game) {
|
||||||
|
this.game = game;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dungeon getDungeon() {
|
public Dungeon getDungeon() {
|
||||||
return dungeon;
|
return dungeon;
|
||||||
|
Loading…
Reference in New Issue
Block a user