-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeck.java
124 lines (96 loc) · 3.28 KB
/
Deck.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import javax.smartcardio.Card;
import java.util.ArrayList;
import java.util.Collection;
import static java.util.Collections.shuffle;
/**
* Created by Nathan on 21/11/2016.
*/
public class Deck extends ArrayList {
public ArrayList<Cards>list;
public ArrayList<Cards> hand;
public ArrayList<Cards> defausse;
public ArrayList<Cards> tapis;
public ArrayList<Cards> construc;
public int nbDeCarteRestanteAPiocher;
public int tailleDeLaListe;
public Deck(){
this.list=new ArrayList<Cards>();
this.hand=new ArrayList<Cards>();
this.defausse=new ArrayList<Cards>();
this.tapis=new ArrayList<Cards>();
this.construc=new ArrayList<Cards>();
}
public ArrayList<Cards> getHand() {return hand;}
public ArrayList<Cards> getTapis() {return tapis;}
public ArrayList<Cards> getDefausse() {return defausse;}
public ArrayList<Cards> getList() {return list;}
public ArrayList<Cards> getConstruc() {return construc;}
public void piocher(int nbDeCartePiocher) {
for (int i=0; i<nbDeCartePiocher; i++){
if (list.size()==0){
remplirDeck();
}
getHand().add(getList().get(0));
getList().remove(getList().get(0));
}
}
public void melange(ArrayList<Cards> idk) {
shuffle(idk);
}
public int tailleMain() {
return hand.size();
}
public int nombreDeCarteDansSonDeck() {
return list.size();
}
public boolean isListVide() {
if (list.size()==0) return true;
else return false;
}
public void remplirDeck(){
if (isListVide()){
for (int i=0;i<defausse.size();i++){
Cards c =defausse.get(i);
list.add(c);
}
defausse.clear();
melange(list);
}
}
public void piocherMain() {
piocher(5);
}
public void initialiserDeck(){
Cards apprentis1=new Cards("Apprentice",7,"Héros",1,0,"",0);
Cards apprentis2=new Cards("Apprentice",7,"Héros",1,0,"",0);
Cards apprentis3=new Cards("Apprentice",7,"Héros",1,0,"",0);
Cards apprentis4=new Cards("Apprentice",7,"Héros",1,0,"",0);
Cards apprentis5=new Cards("Apprentice",7,"Héros",1,0,"",0);
Cards apprentis6=new Cards("Apprentice",7,"Héros",1,0,"",0);
Cards apprentis7=new Cards("Apprentice",7,"Héros",1,0,"",0);
Cards apprentis8=new Cards("Apprentice",7,"Héros",1,0,"",0);
list.add(apprentis1);
list.add(apprentis2);
list.add(apprentis3);
list.add(apprentis4);
list.add(apprentis5);
list.add(apprentis6);
list.add(apprentis7);
list.add(apprentis8);
Cards milice1=new Cards("Militia",3,"Héros",0,1,"",0);
Cards milice2=new Cards("Militia",3,"Héros",0,1,"",0);
list.add(milice1);
list.add(milice2);
shuffle(list);
}
public void afficherLesCartesDansSaMain(){
for (Cards c : hand) {
c.print();
}
}
public void afficherLesCartesDansSonDeck() {
for (Cards c : list){
c.print();
}
}
}