1 | package g0803.bindingofshiba.controller.game; | |
2 | ||
3 | import g0803.bindingofshiba.App; | |
4 | import g0803.bindingofshiba.bundles.Bundle; | |
5 | import g0803.bindingofshiba.controller.Controller; | |
6 | import g0803.bindingofshiba.events.IEventManager; | |
7 | import g0803.bindingofshiba.events.Observer; | |
8 | import g0803.bindingofshiba.events.game.MonsterDamagedEvent; | |
9 | import g0803.bindingofshiba.events.game.PlayerEnterDoorEvent; | |
10 | import g0803.bindingofshiba.events.game.PlayerUnlockDoorEvent; | |
11 | import g0803.bindingofshiba.math.BoundingBox; | |
12 | import g0803.bindingofshiba.model.game.Game; | |
13 | import g0803.bindingofshiba.model.game.elements.Player; | |
14 | import g0803.bindingofshiba.model.game.room.Door; | |
15 | import g0803.bindingofshiba.model.game.room.DoorPosition; | |
16 | import g0803.bindingofshiba.model.game.room.Room; | |
17 | ||
18 | public class RoomController extends Controller<Game> implements Observer { | |
19 | ||
20 | public RoomController(Game model, IEventManager eventManager) { | |
21 | super(model, eventManager); | |
22 | ||
23 |
1
1. <init> : removed call to g0803/bindingofshiba/events/IEventManager::addObserver → SURVIVED |
getEventManager().addObserver(this); |
24 | } | |
25 | ||
26 | private void handlePlayerToDoorCollisions(App app, DoorPosition position, double dt) { | |
27 | Bundle<BoundingBox> boundingBoxes = app.getBoundingBoxes(); | |
28 | Player player = getModel().getPlayer(); | |
29 | Room room = getModel().getCurrentRoom(); | |
30 | ||
31 | Door door = getModel().getCurrentRoom().getDoors().get(position); | |
32 |
1
1. handlePlayerToDoorCollisions : negated conditional → KILLED |
if (door == null) return; |
33 | ||
34 | BoundingBox playerBox = boundingBoxes.get("shiba"); | |
35 | BoundingBox doorBox = | |
36 | boundingBoxes.get( | |
37 |
1
1. handlePlayerToDoorCollisions : negated conditional → KILLED |
door.getUnlocked() ? position.getOpenKey() : position.getClosedKey()); |
38 | ||
39 | BoundingBox playerBoundingBox = playerBox.translate(player.getNextPosition(dt)); | |
40 | BoundingBox doorBoundingBox = doorBox.translate(door.getPositionByWall(room)); | |
41 | ||
42 |
1
1. handlePlayerToDoorCollisions : negated conditional → KILLED |
if (!playerBoundingBox.collides(doorBoundingBox)) return; |
43 | ||
44 |
1
1. handlePlayerToDoorCollisions : negated conditional → KILLED |
if (door.getUnlocked()) { |
45 | PlayerEnterDoorEvent event = new PlayerEnterDoorEvent(dt, app, player, door); | |
46 |
1
1. handlePlayerToDoorCollisions : removed call to g0803/bindingofshiba/events/IEventManager::dispatchEvent → KILLED |
getEventManager().dispatchEvent(event); |
47 | ||
48 |
1
1. handlePlayerToDoorCollisions : removed call to g0803/bindingofshiba/model/game/Game::setCurrentRoom → KILLED |
getModel().setCurrentRoom(door.getOtherRoom(room)); |
49 | } else { | |
50 | PlayerUnlockDoorEvent event = new PlayerUnlockDoorEvent(dt, app, player, door); | |
51 |
1
1. handlePlayerToDoorCollisions : removed call to g0803/bindingofshiba/events/IEventManager::dispatchEvent → KILLED |
getEventManager().dispatchEvent(event); |
52 | ||
53 |
1
1. handlePlayerToDoorCollisions : negated conditional → KILLED |
if (event.isCancelled()) return; |
54 | ||
55 |
1
1. handlePlayerToDoorCollisions : removed call to g0803/bindingofshiba/model/game/room/Door::unlock → KILLED |
door.unlock(); |
56 | } | |
57 | } | |
58 | ||
59 | private void handlePlayerToDoorCollisions(App app, double dt) { | |
60 | for (DoorPosition position : DoorPosition.values()) { | |
61 |
1
1. handlePlayerToDoorCollisions : removed call to g0803/bindingofshiba/controller/game/RoomController::handlePlayerToDoorCollisions → KILLED |
handlePlayerToDoorCollisions(app, position, dt); |
62 | } | |
63 | } | |
64 | ||
65 | @Override | |
66 | public void tick(App app, double dt) { | |
67 |
1
1. tick : removed call to g0803/bindingofshiba/controller/game/RoomController::handlePlayerToDoorCollisions → KILLED |
handlePlayerToDoorCollisions(app, dt); |
68 | } | |
69 | ||
70 | @Override | |
71 | public void onMonsterDamaged(MonsterDamagedEvent event) { | |
72 |
1
1. onMonsterDamaged : negated conditional → NO_COVERAGE |
if (!event.getMonster().isAlive()) { |
73 | getModel().getCurrentRoom().getMonsters().remove(event.getMonster()); | |
74 | } | |
75 | } | |
76 | } | |
Mutations | ||
23 |
1.1 |
|
32 |
1.1 |
|
37 |
1.1 |
|
42 |
1.1 |
|
44 |
1.1 |
|
46 |
1.1 |
|
48 |
1.1 |
|
51 |
1.1 |
|
53 |
1.1 |
|
55 |
1.1 |
|
61 |
1.1 |
|
67 |
1.1 |
|
72 |
1.1 |