-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoadMaker.java
86 lines (77 loc) · 3.6 KB
/
LoadMaker.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
import javafx.scene.paint.Color;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class LoadMaker {
MyField[][] fields;
List<Organism> organisms;
int gameWidth, gameHeight;
Scanner input;
File fileToReadFrom;
LoadMaker(File fileToReadFrom, MyField[][] fields) throws FileNotFoundException {
input = new Scanner(fileToReadFrom);
this.fields = fields;
this.fileToReadFrom = fileToReadFrom;
}
public void readBoardSize() {
gameWidth = input.nextInt();
gameHeight = input.nextInt();
input.nextLine();
}
public void readOrganisms() {
organisms = new ArrayList<>();
String name;
int posX, posY, age, strenght, initiation, cooldown;
boolean toDelete;
Color color;
while (input.hasNext()) {
name = input.nextLine();
posX = Integer.parseInt(input.nextLine());
posY = Integer.parseInt(input.nextLine());
age = Integer.parseInt(input.nextLine());
strenght = Integer.parseInt(input.nextLine());
initiation = Integer.parseInt(input.nextLine());
toDelete = Boolean.parseBoolean(input.nextLine());
color = Color.valueOf(input.nextLine());
cooldown = Integer.parseInt(input.nextLine());
switch (name) {
case "Wolf":
organisms.add(new Wolf(fields, organisms, posX, posY, strenght, initiation, name, color, toDelete, cooldown, age));
break;
case "Wild Berry":
organisms.add(new WildBerry(fields, organisms, posX, posY, strenght, initiation, name, color, toDelete, cooldown, age));
break;
case "Tortoise":
organisms.add(new Tortoise(fields, organisms, posX, posY, strenght, initiation, name, color, toDelete, cooldown, age));
break;
case "Sosnowsky's Hogweed":
organisms.add(new SosnowskyHogweed(fields, organisms, posX, posY, strenght, initiation, name, color, toDelete, cooldown, age));
break;
case "Sheep":
organisms.add(new Sheep(fields, organisms, posX, posY, strenght, initiation, name, color, toDelete, cooldown, age));
break;
case "Human":
organisms.add(new Human(fields, organisms, posX, posY, strenght, initiation, name, color, toDelete, cooldown, age));
break;
case "Guarana":
organisms.add(new Guarana(fields, organisms, posX, posY, strenght, initiation, name, color, toDelete, cooldown, age));
break;
case "Grass":
organisms.add(new Grass(fields, organisms, posX, posY, strenght, initiation, name, color, toDelete, cooldown, age));
break;
case "Fox":
organisms.add(new Fox(fields, organisms, posX, posY, strenght, initiation, name, color, toDelete, cooldown, age));
break;
case "Dandelion":
organisms.add(new Dandelion(fields, organisms, posX, posY, strenght, initiation, name, color, toDelete, cooldown, age));
break;
case "Antelope":
organisms.add(new Antelope(fields, organisms, posX, posY, strenght, initiation, name, color, toDelete, cooldown, age));
break;
}
}
input.close();
}
}