-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransporterRoom.java
61 lines (57 loc) · 1.9 KB
/
TransporterRoom.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* La class transporter determine au hasard une room dans laquel le player peut se teleporter
* Elle extends de Room
* @author (Antoine)
* @version 08/05/21
*/
public class TransporterRoom extends Room
{
private RoomRandomizer aRoomRandomizer;
private boolean aBooleanAllow;
/**
* Constructeur naturel de TransporterRoom;
* @param pDescription est la description de la piece
* @param pImage est limage attribué a la piece
* @param pRooms est le tableau de Room definit dans creatRoom de GE.
*/
public TransporterRoom(final String pDescription, final String pImage, final Room[] pRooms) //rajout d'un boolean pour savoir il y a deja eut 1 teleportation ?
{
super(pDescription, pImage);
this.aRoomRandomizer = new RoomRandomizer(pRooms);
this.aBooleanAllow = true;
}//TransporterRoom(...)
/**
* Getter de aBooleanAllow
* @return aBooleanAllow un boolean
*/
public boolean getRoomRandomizerBool()
{
return this.aBooleanAllow;
}
/**
* Permet de savoir si on peut se teleporter
* @param pBoolean est l'etat de boolean
*/
public void setBooleanAllow(final boolean pBoolean)
{
this.aBooleanAllow = pBoolean;
}//setBooleanAllow(.)
/**
* return a random room, independent of th e Direction.
* @param pDirection
* @return findRandomRoom()
*/
@Override public Room getExit(final String pDirection)
{
if(this.aBooleanAllow){
System.out.println("teleportation");
this.setBooleanAllow(false);
System.out.println(aBooleanAllow);
return this.aRoomRandomizer.findRandomRoom(4);
}else{
System.out.println("pas de teleportation");
System.out.println("on doit aller en A50");
return this.aRoomRandomizer.determineRoom(4);
}
}//getExit(.)
}//TransporterRoom