| 1 | package g0803.bindingofshiba.controller.game; | |
| 2 | ||
| 3 | import g0803.bindingofshiba.App; | |
| 4 | import g0803.bindingofshiba.controller.Controller; | |
| 5 | import g0803.bindingofshiba.controller.game.events.CollisionEventsController; | |
| 6 | import g0803.bindingofshiba.events.IEventManager; | |
| 7 | import g0803.bindingofshiba.events.Observer; | |
| 8 | import g0803.bindingofshiba.events.game.PlayerEnterDoorEvent; | |
| 9 | import g0803.bindingofshiba.model.game.Game; | |
| 10 | import g0803.bindingofshiba.model.game.room.Door; | |
| 11 | import g0803.bindingofshiba.model.game.room.LastRoom; | |
| 12 | import g0803.bindingofshiba.model.game.room.Room; | |
| 13 | import g0803.bindingofshiba.state.end.GameOverState; | |
| 14 | import java.util.Arrays; | |
| 15 | import java.util.List; | |
| 16 | ||
| 17 | public class GameController extends Controller<Game> implements Observer { | |
| 18 | ||
| 19 | private final List<? extends Controller<?>> controllers; | |
| 20 | ||
| 21 | public GameController(Game model, IEventManager eventManager) { | |
| 22 | super(model, eventManager); | |
| 23 | ||
| 24 | this.controllers = | |
| 25 | Arrays.asList( | |
| 26 | new CollisionEventsController(getModel(), getEventManager()), | |
| 27 | new PlayerController(getModel(), getEventManager()), | |
| 28 | new MonsterController(getModel(), getEventManager()), | |
| 29 | new ProjectileController(getModel(), getEventManager()), | |
| 30 | new RoomController(getModel(), getEventManager())); | |
| 31 | ||
| 32 |
1
1. <init> : removed call to g0803/bindingofshiba/events/IEventManager::addObserver → NO_COVERAGE |
getEventManager().addObserver(this); |
| 33 | } | |
| 34 | ||
| 35 | public GameController( | |
| 36 | Game model, IEventManager eventManager, List<? extends Controller<?>> controllers) { | |
| 37 | super(model, eventManager); | |
| 38 | ||
| 39 | this.controllers = controllers; | |
| 40 | } | |
| 41 | ||
| 42 | @Override | |
| 43 | public void tick(App app, double dt) { | |
| 44 |
1
1. tick : removed call to g0803/bindingofshiba/controller/Controller::tick → KILLED |
for (Controller<?> controller : controllers) controller.tick(app, dt); |
| 45 | } | |
| 46 | ||
| 47 | @Override | |
| 48 | public void onPlayerEnterDoor(PlayerEnterDoorEvent event) { | |
| 49 | Room currentRoom = getModel().getCurrentRoom(); | |
| 50 | Door door = event.getDoor(); | |
| 51 | ||
| 52 | Room destination = door.getOtherRoom(currentRoom); | |
| 53 |
2
1. onPlayerEnterDoor : negated conditional → NO_COVERAGE 2. onPlayerEnterDoor : removed call to g0803/bindingofshiba/App::setState → NO_COVERAGE |
if (destination instanceof LastRoom) event.getApp().setState(new GameOverState(true)); |
| 54 | } | |
| 55 | } | |
Mutations | ||
| 32 |
1.1 |
|
| 44 |
1.1 |
|
| 53 |
1.1 2.2 |