1 | package g0803.bindingofshiba.model.game.room; | |
2 | ||
3 | import g0803.bindingofshiba.model.game.elements.Monster; | |
4 | import g0803.bindingofshiba.model.game.elements.Obstacle; | |
5 | import g0803.bindingofshiba.model.game.elements.Projectile; | |
6 | import java.util.*; | |
7 | ||
8 | public class Room { | |
9 | private final int width; | |
10 | private final int height; | |
11 | private final List<Monster> monsters; | |
12 | private final Map<DoorPosition, Door> doors = new HashMap<>(); | |
13 | private final List<Obstacle> obstacles; | |
14 | private final Set<Projectile> projectiles = new HashSet<>(); | |
15 | ||
16 | public Room(int width, int height, List<Monster> monsters, List<Obstacle> obstacles) { | |
17 | this.width = width; | |
18 | this.height = height; | |
19 | this.monsters = new ArrayList<>(); | |
20 | this.obstacles = new ArrayList<>(); | |
21 | ||
22 |
1
1. <init> : negated conditional → KILLED |
if (obstacles != null) { |
23 | this.obstacles.addAll(obstacles); | |
24 | } | |
25 | ||
26 |
1
1. <init> : negated conditional → KILLED |
if (monsters != null) { |
27 | this.monsters.addAll(monsters); | |
28 | } | |
29 | } | |
30 | ||
31 | public int getWidth() { | |
32 |
1
1. getWidth : replaced int return with 0 for g0803/bindingofshiba/model/game/room/Room::getWidth → KILLED |
return width; |
33 | } | |
34 | ||
35 | public int getHeight() { | |
36 |
1
1. getHeight : replaced int return with 0 for g0803/bindingofshiba/model/game/room/Room::getHeight → KILLED |
return height; |
37 | } | |
38 | ||
39 | public List<Obstacle> getObstacles() { | |
40 |
1
1. getObstacles : replaced return value with Collections.emptyList for g0803/bindingofshiba/model/game/room/Room::getObstacles → KILLED |
return this.obstacles; |
41 | } | |
42 | ||
43 | public List<Monster> getMonsters() { | |
44 |
1
1. getMonsters : replaced return value with Collections.emptyList for g0803/bindingofshiba/model/game/room/Room::getMonsters → KILLED |
return this.monsters; |
45 | } | |
46 | ||
47 | public Set<Projectile> getProjectiles() { | |
48 |
1
1. getProjectiles : replaced return value with Collections.emptySet for g0803/bindingofshiba/model/game/room/Room::getProjectiles → SURVIVED |
return projectiles; |
49 | } | |
50 | ||
51 | public Map<DoorPosition, Door> getDoors() { | |
52 |
1
1. getDoors : replaced return value with null for g0803/bindingofshiba/model/game/room/Room::getDoors → KILLED |
return this.doors; |
53 | } | |
54 | ||
55 | public void addDoor(Door door) { | |
56 |
2
1. addDoor : negated conditional → KILLED 2. addDoor : negated conditional → KILLED |
if (this != door.getOriginRoom() && this != door.getDestinationRoom()) { |
57 | throw new IllegalArgumentException("Door does not belong to this room"); | |
58 | } | |
59 | ||
60 | DoorPosition position = | |
61 |
1
1. addDoor : negated conditional → KILLED |
this == door.getOriginRoom() |
62 | ? door.getOriginPosition() | |
63 | : door.getDestinationPosition(); | |
64 |
1
1. addDoor : negated conditional → KILLED |
if (doors.containsKey(position)) { |
65 | throw new IllegalStateException("There can't be two doors in the same position"); | |
66 | } | |
67 | ||
68 | doors.put(position, door); | |
69 | } | |
70 | ||
71 | public void addProjectile(Projectile projectile) { | |
72 | this.projectiles.add(projectile); | |
73 | } | |
74 | ||
75 | public void removeProjectile(Projectile projectile) { | |
76 | this.projectiles.remove(projectile); | |
77 | } | |
78 | } | |
Mutations | ||
22 |
1.1 |
|
26 |
1.1 |
|
32 |
1.1 |
|
36 |
1.1 |
|
40 |
1.1 |
|
44 |
1.1 |
|
48 |
1.1 |
|
52 |
1.1 |
|
56 |
1.1 2.2 |
|
61 |
1.1 |
|
64 |
1.1 |