-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwall.java
More file actions
42 lines (36 loc) · 894 Bytes
/
wall.java
File metadata and controls
42 lines (36 loc) · 894 Bytes
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
package slots;
import game.player;
import game.slot;
import game.world;
import items.pickaxe;
public class wall extends slot{
private boolean broken = false;
public char brokenChar = '_';
public wall() {
this.icon = '#';
}
public char getIcon(){
return this.broken ? this.brokenChar : this.icon;
}
public int hola = 2;
@Override
public void step(world world, player player) {
//If the wall is broken just return
if(this.broken){return;}
//If not, check if player has a pickaxe and use it
if(player.hasItemInInventory("pickaxe")){
pickaxe pickaxe = (pickaxe) player.getItemFormInventory("pickaxe");
pickaxe.use(world, player);
}else{
System.out.println("You can't go through this wall.");
player.goBack();
}
}
public void breakWall(){
if(!this.broken){
System.out.println("Breaking the wall!");
this.broken = true;
}else{
}
}
}