-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFaction.java
65 lines (56 loc) · 1.54 KB
/
Faction.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
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
import java.io.IOException;
/**
* Faction désigne un ensemble d'unités qui sont dans le même camp. Elle permet de les retrouver facilement lorsqu'on recrute.
*/
public enum Faction
{
HUMAINS("humains"),
ROBOTS("robots"),
NEUTRE("neutre");
public String aNom;
private List<TypeUnite> aListeUnites;
Faction(final String pNom)
{
Scanner fichier = null;
aListeUnites = new ArrayList<TypeUnite>();
aNom=pNom;
try {
fichier = new Scanner(getClass().getResource("Config/Faction.txt").openStream());
} catch (IOException e) {
e.printStackTrace();
}
String ligne;
String[] tab;
while(fichier.hasNextLine()){
ligne = fichier.nextLine();
tab = ligne. split(":");
if(tab[0].equals(pNom)){
for(TypeUnite type : TypeUnite.values()) {
if(type.getNom().equals(tab[1])) {
aListeUnites.add(type);break;
}
}
}
}
fichier.close();
}
/**
* Accesseur pour l'attribut aListeUnites contenant la liste des Unite
* @return aListeUnites
*/
public List<TypeUnite> getListe()
{
return aListeUnites;
}
/**
* Accesseur pour l'attribut aNom
* @return aNom
*/
public String getNom()
{
return aNom;
}
}