1 package de.jos.game.xml;
2
3 import java.util.ArrayList;
4 import java.util.HashSet;
5 import java.util.List;
6 import java.util.Set;
7
8 import de.jos.game.Constants;
9 import de.jos.game.objects.Bullet;
10 import de.jos.game.objects.ResourceContainer;
11
12 public class Level {
13
14 private Integer levelAdvanceScore = null;
15 private Integer boardClearScore = null;
16 private String data = null;
17 private Integer mode = null;
18 private Integer id = null;
19 private Integer numberColors = null;
20 private Integer nextLevelNewColor = null;
21
22 private List<Combination> combinations = null;
23 private List<Combination> accumulatedCombinations = null;
24
25 private Set<Bullet> bullets = null;
26
27 public Level() {}
28
29 public void initLists() {
30 bullets = new HashSet<Bullet>();
31 accumulatedCombinations = new ArrayList<Combination>();
32 }
33
34 /***
35 * initialize the bullets on the board, only for puzzle levels
36 *
37 * @param resourceContainer
38 */
39 public void initBullets(ResourceContainer resourceContainer) {
40
41 bullets.clear();
42 if (getData() != null) {
43 String data = getData().trim().replaceAll(" ", "");
44 data = data.replaceAll("\n", "").replaceAll("\r", "");
45 for (int i = 0; i < data.length(); i++) {
46 String value = String.valueOf(data.charAt(i));
47 if (!"-".equals(value)) {
48 int color = Integer.parseInt(value);
49 Bullet bullet = new Bullet();
50 bullet.setColor(Integer.valueOf(color));
51 bullet.setBoardX(i % Constants.BOARD_WIDTH_X);
52 bullet.setBoardY(i / Constants.BOARD_WIDTH_Y);
53 bullet.setResourceContainer(resourceContainer);
54 bullet.init();
55 getBullets().add(bullet);
56 }
57 }
58 }
59 }
60
61 public Integer getNextLevelId() {
62 return Integer.valueOf(getId().intValue() + 1);
63 }
64
65 public Set<Bullet> getBullets() {
66 return bullets;
67 }
68
69 public List<Combination> getCombinations() {
70 return combinations;
71 }
72
73 public void setCombinations(List<Combination> combinations) {
74 this.combinations = combinations;
75 }
76
77 public Integer getBoardClearScore() {
78 return boardClearScore;
79 }
80
81 public void setBoardClearScore(Integer boardClearScore) {
82 this.boardClearScore = boardClearScore;
83 }
84
85 public String getData() {
86 return data;
87 }
88
89 public void setData(String data) {
90 this.data = data;
91 }
92
93 public Integer getId() {
94 return id;
95 }
96
97 public void setId(Integer id) {
98 this.id = id;
99 }
100
101 public Integer getLevelAdvanceScore() {
102 return levelAdvanceScore;
103 }
104
105 public void setLevelAdvanceScore(Integer levelAdvanceScore) {
106 this.levelAdvanceScore = levelAdvanceScore;
107 }
108
109 public Integer getMode() {
110 return mode;
111 }
112
113 public void setMode(Integer mode) {
114 this.mode = mode;
115 }
116
117 public List<Combination> getAccumulatedCombinations() {
118 return accumulatedCombinations;
119 }
120
121 public Integer getNextLevelNewColor() {
122 return nextLevelNewColor;
123 }
124
125 public void setNextLevelNewColor(Integer nextLevelNewColor) {
126 this.nextLevelNewColor = nextLevelNewColor;
127 }
128
129 public Integer getNumberColors() {
130 return numberColors;
131 }
132
133 public void setNumberColors(Integer numberColors) {
134 this.numberColors = numberColors;
135 }
136
137 }