-
Notifications
You must be signed in to change notification settings - Fork 8
/
Card.java
94 lines (79 loc) · 2.78 KB
/
Card.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import java.util.ArrayList;
public class Card {
//Name(Set of moves, name)
private String name;
private int[][] moves;
private int color;
public static ArrayList<Card> allCards = new ArrayList<Card>();
public static Card tiger;
public static Card dragon;
public static Card frog;
public static Card rabbit;
public static Card crab;
public static Card elephant;
public static Card goose;
public static Card rooster;
public static Card monkey;
public static Card mantis;
public static Card horse;
public static Card ox;
public static Card crane;
public static Card boar;
public static Card eel;
public static Card cobra;
public String toString() {
return name;
}
public static void init() {
tiger = new Card(new int[][] {{0,2}, {0,-1}} ,"Tiger", Board.blue);
dragon = new Card(new int[][] {{-2,1}, {-1,-1}, {1,-1}, {2,1}} ,"Dragon", Board.red);
frog = new Card(new int[][] {{-2,0}, {-1,1}, {1,-1}} ,"Frog", Board.red);
rabbit = new Card(new int[][] {{1,1}, {-1,-1}, {2,0}} ,"Rabbit", Board.blue);
crab = new Card(new int[][] {{2,0}, {-2,0}, {0,1}} ,"Crab", Board.blue);
elephant = new Card(new int[][] {{1,0}, {-1,0}, {1,1}, {-1,1}},"Elephant", Board.red);
goose = new Card(new int[][] {{-1,1}, {1,-1}, {-1,0}, {1,0}} ,"Goose", Board.blue);
rooster = new Card(new int[][] {{-1,-1},{1,1}, {-1,0}, {1,0}} ,"Rooster", Board.red);
monkey = new Card(new int[][] {{1,1}, {-1,-1}, {1,-1}, {-1,1}},"Monkey", Board.blue);
mantis = new Card(new int[][] {{0,-1}, {-1,1}, {1,1}} ,"Mantis", Board.red);
horse = new Card(new int[][] {{-1,0}, {0,1}, {0,-1}} ,"Horse", Board.red);
ox = new Card(new int[][] {{1,0}, {0,1}, {0,-1}} ,"Ox", Board.blue);
crane = new Card(new int[][] {{-1,-1},{1,-1}, {0,1}} ,"Crane", Board.blue);
boar = new Card(new int[][] {{-1,0}, {1,0}, {0,1}} ,"Boar", Board.red);
eel = new Card(new int[][] {{-1,1}, {-1,-1}, {1,0}} ,"Eel", Board.blue);
cobra = new Card(new int[][] {{1,1}, {1,-1}, {-1,0}} ,"Cobra", Board.red);
}
Card(int [][] moves, String name, int color) {
this.moves = moves;
this.name = name;
this.color = color;
allCards.add(this);
}
public Card(Card c) {
moves = c.getMoves();
name = c.getName();
color = c.getColor();
}
public int [][] getMoves() {
return moves;
}
public String getName() {
return name;
}
public int getColor() {
return color;
}
public String getColorString() {
String col = "Blue";
if(color == Board.red) col = "Red";
return col;
}
public static Card getCardByName(String name) {
for(Card c : allCards)
if(c.name == name)
return c;
return null;
}
public boolean equals(Card c) {
return c.getName().equals(name);
}
}