forked from c0g4ih4l4n/AI_OAQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameState.java
88 lines (68 loc) · 2.13 KB
/
GameState.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
/*
* 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 testSQuares2;
/**
*
* @author Administrator
*/
public class GameState {
VillaSave q0Save, q6Save; // Luu Quan
int[] houseSave; // Luu house
Step buocDiTruoc; // Luu buocdi
PlayerSave p1Save, p2Save; // luu player
public GameState() {
this.q0Save = new VillaSave(0, true);
this.q6Save = new VillaSave(0, true);
this.houseSave = new int[12];
for (int i = 1; i < 12; i++) {
if (i == 6) continue;
this.houseSave[i] = 5;
}
p1Save = new PlayerSave();
p2Save = new PlayerSave();
this.buocDiTruoc = new Step();
}
public GameState(Game game, Step buocDiTruoc) {
// luu buoc di
this.buocDiTruoc = new Step();
this.buocDiTruoc.chose = buocDiTruoc.chose;
this.buocDiTruoc.direc = buocDiTruoc.direc;
// luu Quan
this.q0Save = new VillaSave(game.board.q0.getDanSo(), game.board.q0.coQuan);
this.q6Save = new VillaSave(game.board.q6.getDanSo(), game.board.q6.coQuan);
// luu house
houseSave = new int[12];
for (int i = 1; i < 6; i++) {
houseSave[i] = game.board.houses[i].getDanSo();
}
for (int i = 7; i < 12; i++) {
houseSave[i] = game.board.houses[i].getDanSo();
}
// luu diem player
p1Save = new PlayerSave(game.p1.soDanAnDuoc, game.p1.soQuanAnDuoc);
p2Save = new PlayerSave(game.p2.soDanAnDuoc, game.p2.soQuanAnDuoc);
}
}
class VillaSave {
int soDan;
boolean coQuan;
public VillaSave() {
}
public VillaSave(int soDan, boolean coQuan) {
this.soDan = soDan;
this.coQuan = coQuan;
}
}
class PlayerSave {
int soQuanAnDuoc;
int soDanAnDuoc;
public PlayerSave() {
}
public PlayerSave(int soDanAnDuoc, int soQuanAnDuoc) {
this.soQuanAnDuoc = soQuanAnDuoc;
this.soDanAnDuoc = soDanAnDuoc;
}
}