-
Notifications
You must be signed in to change notification settings - Fork 0
/
CrashGem.java
39 lines (38 loc) · 1.26 KB
/
CrashGem.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
import java.awt.Color;
import java.awt.Point;
public class CrashGem extends Block{
public CrashGem(int pxX, int pxY, Color color){
super(pxX, pxY, color);
}
public CrashGem(int pxX, int pxY, Color color, Board board){
super(pxX, pxY, color, board);
}
//accessors
public CrashGem copy(Board destination){
return new CrashGem(getPixelsX(), getPixelsY(), blockColor, destination);
}
public CrashGem copyNoBoard(){
return new CrashGem(0, 0, blockColor);
}
public String toString(){
return "CrashGem-"+CounterGemSet.parseColor(blockColor);
}
//mutators
public boolean destroyNeighbors(){
Block[] nextToNoNumbers=container.removeCounterGems(container.getNeighborsSameColor(getRow(),getCol()));
if(nextToNoNumbers.length>0){
Block[] nextTo=container.getLegalDestroyTargets(getRow(), getCol());
container.destroyBlock(this, Board.DEFAULT_FACTOR);
for(Block b : nextTo)
b.destroyNeighborsInternal();
return true;
}
return false;
}
public void destroyNeighborsInternal(){
Block[] nextTo=container.getLegalDestroyTargets(getRow(), getCol());
container.destroyBlock(this, Board.DEFAULT_FACTOR);
for(Block b : nextTo)
b.destroyNeighborsInternal();
}
}