-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTile.java
More file actions
62 lines (62 loc) · 1.29 KB
/
Copy pathTile.java
File metadata and controls
62 lines (62 loc) · 1.29 KB
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
62
public class Tile
{
private final boolean isRoom;
private final boolean[] exits;//0=up,1=r,2=d,3=l
private boolean search1=true;//has been searched once
private boolean search2=true;//has been searhced twice
private String effect;
public Tile(boolean isRoom,boolean[] exits,String eff)
{
this.isRoom=isRoom;
this.exits=exits;
effect=eff;
if(effect!=null&&!effect.equals("rotate"))
{//special rooms can't be searched
search1=false;
search2=false;
}
}
public String getEffect()
{
return effect;
}
public void search()//increments search counter
{
if(search1)
{
search1=false;
}
else
{
search2=false;
}
}
public boolean canSearch()
{
return search1||search2;
}
public boolean isRoom()
{
return isRoom;
}
public boolean[] getExits()
{
return exits;
}
//post: rotates the exits of the tile n times.
public void rotate(int n)
{
for(int k=0;k<n;k++)
{
boolean[] temp=new boolean[4];
for(int i=0;i<temp.length;i++)
{
temp[i]=exits[i];
}
exits[0]=temp[3];
exits[3]=temp[2];
exits[2]=temp[1];
exits[1]=temp[0];
}
}
}