Skip to content

Commit 4fda11b

Browse files
Refac
1 parent a578855 commit 4fda11b

File tree

5 files changed

+26
-23
lines changed

5 files changed

+26
-23
lines changed

pacman-app-arcade-mspacman/src/main/java/de/amr/pacmanfx/arcade/ms_pacman/ArcadeMsPacMan_GameModel.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,11 @@ protected LevelData createLevelData(int levelNumber) {
199199

200200
private static final int DEMO_LEVEL_MIN_DURATION_SEC = 20;
201201

202-
private final ArcadeMsPacMan_HUDData hud = new ArcadeMsPacMan_HUDData();
203-
private final ScoreManager scoreManager;
204-
private final HuntingTimer huntingTimer;
205-
private final ActorSpeedControl actorSpeedControl;
202+
protected final MapSelector mapSelector;
203+
protected final ArcadeMsPacMan_HUDData hud = new ArcadeMsPacMan_HUDData();
204+
protected final ScoreManager scoreManager;
205+
protected final HuntingTimer huntingTimer;
206+
protected final ActorSpeedControl actorSpeedControl;
206207

207208
/**
208209
* Called via reflection by builder.
@@ -263,6 +264,11 @@ public long huntingTicks(int levelNumber, int phaseIndex) {
263264
mapSelector.loadAllMaps();
264265
}
265266

267+
@Override
268+
public MapSelector mapSelector() {
269+
return mapSelector;
270+
}
271+
266272
@Override
267273
public ScoreManager scoreManager() {
268274
return scoreManager;
@@ -358,7 +364,7 @@ protected boolean isBonusReached() {
358364
* </table>
359365
* </p>
360366
*/
361-
private byte computeBonusSymbol(int levelNumber) {
367+
protected byte computeBonusSymbol(int levelNumber) {
362368
if (levelNumber <= 7) return (byte) (levelNumber - 1);
363369
int coin = randomInt(0, 320);
364370
if (coin < 50) return 0; // 5/32 probability
@@ -438,7 +444,7 @@ public void activateNextBonus() {
438444
eventManager().publishEvent(GameEventType.BONUS_ACTIVATED, bonus.tile());
439445
}
440446

441-
private Portal randomPortal(GameLevel level) {
447+
protected Portal randomPortal(GameLevel level) {
442448
return level.portals().get(new Random().nextInt(level.portals().size()));
443449
}
444450

pacman-app-arcade-pacman/src/main/java/de/amr/pacmanfx/arcade/pacman/ArcadeCommon_GameModel.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import de.amr.pacmanfx.model.AbstractGameModel;
1212
import de.amr.pacmanfx.model.GameLevel;
1313
import de.amr.pacmanfx.model.GateKeeper;
14-
import de.amr.pacmanfx.model.MapSelector;
1514
import de.amr.pacmanfx.model.actors.CommonAnimationID;
1615
import de.amr.pacmanfx.model.actors.Ghost;
1716
import de.amr.pacmanfx.model.actors.GhostState;
@@ -37,7 +36,6 @@ public abstract class ArcadeCommon_GameModel extends AbstractGameModel {
3736

3837
protected final GameContext gameContext;
3938
protected GameLevel gameLevel;
40-
protected MapSelector mapSelector;
4139
protected GateKeeper gateKeeper;
4240
protected Steering autopilot;
4341
protected Steering demoLevelSteering;
@@ -164,11 +162,6 @@ public void startNewGame() {
164162
@Override
165163
public Optional<GateKeeper> optGateKeeper() { return Optional.of(gateKeeper); }
166164

167-
@Override
168-
public MapSelector mapSelector() {
169-
return mapSelector;
170-
}
171-
172165
@Override
173166
public double pacPowerSeconds(GameLevel level) {
174167
return level.data().pacPowerSeconds();

pacman-app-arcade-pacman/src/main/java/de/amr/pacmanfx/arcade/pacman/ArcadePacMan_GameModel.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,16 @@ protected static LevelData createLevelData(int levelNumber) {
168168
}
169169

170170
// Note: level numbering starts with 1
171-
private static final byte[] BONUS_SYMBOLS_BY_LEVEL_NUMBER = { -1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7 };
171+
protected static final byte[] BONUS_SYMBOLS_BY_LEVEL_NUMBER = { -1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7 };
172172

173173
// bonus points = multiplier * 100
174-
private static final byte[] BONUS_VALUE_MULTIPLIERS = { 1, 3, 5, 7, 10, 20, 30, 50 };
174+
protected static final byte[] BONUS_VALUE_MULTIPLIERS = { 1, 3, 5, 7, 10, 20, 30, 50 };
175175

176-
private final HUDData hud = new ArcadePacMan_HUDData();
177-
private final ScoreManager scoreManager;
178-
private final HuntingTimer huntingTimer;
179-
private final ActorSpeedControl actorSpeedControl;
176+
protected final MapSelector mapSelector;
177+
protected final HUDData hud = new ArcadePacMan_HUDData();
178+
protected final ScoreManager scoreManager;
179+
protected final HuntingTimer huntingTimer;
180+
protected final ActorSpeedControl actorSpeedControl;
180181

181182
public ArcadePacMan_GameModel(GameContext gameContext, File highScoreFile) {
182183
this(gameContext, new ArcadePacMan_MapSelector(), highScoreFile);
@@ -248,6 +249,11 @@ public long huntingTicks(int levelNumber, int phaseIndex) {
248249
mapSelector.loadAllMaps();
249250
}
250251

252+
@Override
253+
public MapSelector mapSelector() {
254+
return mapSelector;
255+
}
256+
251257
@Override
252258
public ScoreManager scoreManager() {
253259
return scoreManager;

pacman-app-arcade-pacmanxxl/src/main/java/de/amr/pacmanfx/arcade/pacman_xxl/PacManXXL_MsPacMan_GameModel.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
import de.amr.pacmanfx.arcade.ms_pacman.ArcadeMsPacMan_GameModel;
99
import de.amr.pacmanfx.event.GameEventType;
1010
import de.amr.pacmanfx.model.MapSelectionMode;
11-
import de.amr.pacmanfx.model.MapSelector;
1211

1312
import java.io.File;
1413
import java.util.Random;
1514

1615
public class PacManXXL_MsPacMan_GameModel extends ArcadeMsPacMan_GameModel {
1716

18-
public PacManXXL_MsPacMan_GameModel(GameContext gameContext, MapSelector mapSelector, File higScoreFile) {
17+
public PacManXXL_MsPacMan_GameModel(GameContext gameContext, PacManXXL_Common_MapSelector mapSelector, File higScoreFile) {
1918
super(gameContext, mapSelector, higScoreFile);
2019
}
2120

pacman-app-arcade-pacmanxxl/src/main/java/de/amr/pacmanfx/arcade/pacman_xxl/PacManXXL_PacMan_GameModel.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import de.amr.pacmanfx.arcade.pacman.ArcadePacMan_GameModel;
99
import de.amr.pacmanfx.event.GameEventType;
1010
import de.amr.pacmanfx.model.MapSelectionMode;
11-
import de.amr.pacmanfx.model.MapSelector;
1211
import de.amr.pacmanfx.steering.RuleBasedPacSteering;
1312

1413
import java.io.File;
@@ -21,7 +20,7 @@
2120
*/
2221
public class PacManXXL_PacMan_GameModel extends ArcadePacMan_GameModel {
2322

24-
public PacManXXL_PacMan_GameModel(GameContext gameContext, MapSelector mapSelector, File highSCoreFile) {
23+
public PacManXXL_PacMan_GameModel(GameContext gameContext, PacManXXL_Common_MapSelector mapSelector, File highSCoreFile) {
2524
super(gameContext, mapSelector, highSCoreFile);
2625
// Demo level map could be custom map, so use generic automatic steering
2726
demoLevelSteering = new RuleBasedPacSteering(gameContext);

0 commit comments

Comments
 (0)