-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJudge.java
More file actions
95 lines (88 loc) · 1.65 KB
/
Judge.java
File metadata and controls
95 lines (88 loc) · 1.65 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
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
94
95
package process;
import state.Card;
public class Judge {
int bingo;
// ボールと一致したら0へ変換
public int match(int card, int ball) {
if (ball == card) {
card = 0;
return card;
}
return card;
}
// 各行列斜めのビンゴ判定
int bingo(Card card) {
int bingo = 0;
int sumSlash = 0, sumReslash = 0;
// 縦横
for (int i = 0; i < 5; i++) {
int sumCol = 0;
int sumRow = 0;
for (int j = 0; j < 5; j++) {
sumCol += card.getCard()[i][j]; // 横
sumRow += card.getCard()[j][i]; // 縦
}
if (sumCol == 0)
bingo++;
if (sumRow == 0)
bingo++;
}
// 斜め
for (int i = 0; i < 5; i++) {
sumSlash += card.getCard()[4 - i][i]; // 右上
sumReslash += card.getCard()[i][i]; // 左上
}
if (sumSlash == 0)
bingo++;
if (sumReslash == 0)
bingo++;
// 全面0の場合終了
if (bingo == 12)
this.bingo = bingo;
return bingo;
}
// 各行列斜めのリーチ判定
int reach(Card card) {
int reach = 0;
int slash = 0, reSlash = 0;
// 縦横
for (int i = 0; i < 5; i++) {
int col = 0;
int row = 0;
for (int j = 0; j < 5; j++) {
// 横
if (card.getCard()[i][j] == 0) {
col++;
}
// 縦
if (card.getCard()[j][i] == 0) {
row++;
}
// リーチカウント
if (col == 4 && j == 4) {
reach++;
}
if (row == 4 && j == 4) {
reach++;
}
}
// 斜め
// 右上
if (card.getCard()[i][4 - i] == 0) {
slash++;
}
// 左上
if (card.getCard()[i][i] == 0) {
reSlash++;
}
}
// リーチカウント
if (slash == 4) {
reach++;
}
if (reSlash == 4) {
reach++;
}
return reach;
}
}