-
Notifications
You must be signed in to change notification settings - Fork 0
/
Blue.java
76 lines (61 loc) · 2.42 KB
/
Blue.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package SnakeAndLadder;
/**
*
* @author Alizey
*/
public class Blue extends Piece{
public Blue(String colour){
this.colour = colour;
}
@Override
void move(int inirow, int inicol, int firow, int ficol){
boolean check = true;
if(inirow == firow && inirow == 3 && ficol-inicol <= 6 && ficol-inicol > 0 ){
if(ficol > 100){
System.out.println("You should be getting less, best of luck next time xD");
Board.chance++;
check = false;
}
if(check == true){
if(Board.chance%4 == 2){
Snake s = new Snake(0);
Ladder l = new Ladder(0);
Board.board[firow][ficol] = Board.board[inirow][inicol];
Board.board[inirow][inicol] = null;
if(Board.board[0][ficol] != null){
if(Board.board[0][ficol].getClass() == s.getClass()){
Snake s1 = (Snake)Board.board[0][ficol];
int bite = s1.poison;
int change = ficol - bite;
Board.board[firow][change] = Board.board[firow][ficol];
Board.board[firow][ficol] = null;
}
else if(Board.board[0][ficol].getClass() == l.getClass()){
Ladder l1 = (Ladder)Board.board[0][ficol];
int climb = l1.climb;
int change = ficol + climb;
Board.board[firow][change] = Board.board[firow][ficol];
Board.board[firow][ficol] = null;
}
}
}
}
}
else
check = false;
if(check == true){
Board.chance++;
}
else
System.out.println("Invalid chance/move!");
}
@Override
public String toString(){
return "B";
}
}