33 * This RoomStateManager is responsible for keeping/changing the roomstate in local play. |
33 * This RoomStateManager is responsible for keeping/changing the roomstate in local play. |
34 * That is very straightforward, just react to every request by immediately changing the |
34 * That is very straightforward, just react to every request by immediately changing the |
35 * state. |
35 * state. |
36 */ |
36 */ |
37 public class LocalRoomStateManager extends BasicRoomState { |
37 public class LocalRoomStateManager extends BasicRoomState { |
38 private static final String TAG = LocalRoomStateManager.class.getSimpleName(); |
38 private static final String TAG = LocalRoomStateManager.class.getSimpleName(); |
39 |
39 |
40 public LocalRoomStateManager(Scheme defaultScheme, Weaponset defaultWeaponset) { |
40 public LocalRoomStateManager(Scheme defaultScheme, Weaponset defaultWeaponset) { |
41 setChief(true); |
41 setChief(true); |
42 setGameStyle(GameConfig.DEFAULT_STYLE); |
42 setGameStyle(GameConfig.DEFAULT_STYLE); |
43 setMapRecipe(MapRecipe.makeRandomMap(0, MapRecipe.makeRandomSeed(), GameConfig.DEFAULT_THEME)); |
43 setMapRecipe(MapRecipe.makeRandomMap(0, MapRecipe.makeRandomSeed(), GameConfig.DEFAULT_THEME)); |
44 setScheme(defaultScheme); |
44 setScheme(defaultScheme); |
45 setWeaponset(defaultWeaponset); |
45 setWeaponset(defaultWeaponset); |
46 } |
46 } |
47 |
|
48 public void changeMapRecipe(MapRecipe map) { |
|
49 setMapRecipe(map); |
|
50 } |
|
51 |
47 |
52 public void changeMapTheme(String theme) { |
48 public void changeMapRecipe(MapRecipe map) { |
53 setMapRecipe(getMapRecipe().withTheme(theme)); |
49 setMapRecipe(map); |
54 } |
50 } |
55 |
51 |
56 public void changeMapNameAndGenerator(String mapName) { |
52 public void changeMapTheme(String theme) { |
57 int newGenerator = MapRecipe.generatorForMapname(mapName); |
53 setMapRecipe(getMapRecipe().withTheme(theme)); |
58 setMapRecipe(getMapRecipe().withName(mapName).withMapgen(newGenerator)); |
54 } |
59 } |
|
60 |
55 |
61 public void changeMapTemplate(int template) { |
56 public void changeMapNameAndGenerator(String mapName) { |
62 setMapRecipe(getMapRecipe().withTemplateFilter(template)); |
57 int newGenerator = MapRecipe.generatorForMapname(mapName); |
63 } |
58 setMapRecipe(getMapRecipe().withName(mapName).withMapgen(newGenerator)); |
|
59 } |
64 |
60 |
65 public void changeMazeSize(int mazeSize) { |
61 public void changeMapTemplate(int template) { |
66 setMapRecipe(getMapRecipe().withMazeSize(mazeSize)); |
62 setMapRecipe(getMapRecipe().withTemplateFilter(template)); |
67 } |
63 } |
68 |
64 |
69 public void changeMapSeed(String seed) { |
65 public void changeMazeSize(int mazeSize) { |
70 setMapRecipe(getMapRecipe().withSeed(seed)); |
66 setMapRecipe(getMapRecipe().withMazeSize(mazeSize)); |
71 } |
67 } |
72 |
68 |
73 public void changeMapDrawdata(byte[] drawdata) { |
69 public void changeMapSeed(String seed) { |
74 setMapRecipe(getMapRecipe().withDrawData(drawdata)); |
70 setMapRecipe(getMapRecipe().withSeed(seed)); |
75 } |
71 } |
76 |
72 |
77 public void changeScheme(Scheme scheme) { |
73 public void changeMapDrawdata(byte[] drawdata) { |
78 setScheme(scheme); |
74 setMapRecipe(getMapRecipe().withDrawData(drawdata)); |
79 } |
75 } |
80 |
76 |
81 public void changeGameStyle(String style) { |
77 public void changeScheme(Scheme scheme) { |
82 setGameStyle(style); |
78 setScheme(scheme); |
83 } |
79 } |
84 |
80 |
85 public void changeWeaponset(Weaponset weaponset) { |
81 public void changeGameStyle(String style) { |
86 setWeaponset(weaponset); |
82 setGameStyle(style); |
87 } |
83 } |
88 |
84 |
89 public void requestAddTeam(Team team, int colorIndex) { |
85 public void changeWeaponset(Weaponset weaponset) { |
90 putTeam(new TeamInGame(team, new TeamIngameAttributes("Player", colorIndex, TeamIngameAttributes.DEFAULT_HOG_COUNT, false))); |
86 setWeaponset(weaponset); |
91 } |
87 } |
92 |
88 |
93 public void requestRemoveTeam(String teamname) { |
89 public void requestAddTeam(Team team, int colorIndex) { |
94 removeTeam(teamname); |
90 putTeam(new TeamInGame(team, new TeamIngameAttributes("Player", colorIndex, TeamIngameAttributes.DEFAULT_HOG_COUNT, false))); |
95 } |
91 } |
96 |
92 |
97 public void changeTeamColorIndex(String teamname, int colorIndex) { |
93 public void requestRemoveTeam(String teamname) { |
98 TeamInGame oldTeam = getTeams().get(teamname); |
94 removeTeam(teamname); |
99 if(oldTeam != null) { |
95 } |
100 putTeam(oldTeam.withAttribs(oldTeam.ingameAttribs.withColorIndex(colorIndex))); |
|
101 } else { |
|
102 Log.e(TAG, "Requested color change for unknown team "+ teamname); |
|
103 } |
|
104 } |
|
105 |
96 |
106 public void changeTeamHogCount(String teamname, int hogcount) { |
97 public void changeTeamColorIndex(String teamname, int colorIndex) { |
107 TeamInGame oldTeam = getTeams().get(teamname); |
98 TeamInGame oldTeam = getTeams().get(teamname); |
108 if(oldTeam != null) { |
99 if(oldTeam != null) { |
109 putTeam(oldTeam.withAttribs(oldTeam.ingameAttribs.withHogCount(hogcount))); |
100 putTeam(oldTeam.withAttribs(oldTeam.ingameAttribs.withColorIndex(colorIndex))); |
110 } else { |
101 } else { |
111 Log.e(TAG, "Requested hog count change for unknown team "+ teamname); |
102 Log.e(TAG, "Requested color change for unknown team "+ teamname); |
112 } |
103 } |
113 } |
104 } |
|
105 |
|
106 public void changeTeamHogCount(String teamname, int hogcount) { |
|
107 TeamInGame oldTeam = getTeams().get(teamname); |
|
108 if(oldTeam != null) { |
|
109 putTeam(oldTeam.withAttribs(oldTeam.ingameAttribs.withHogCount(hogcount))); |
|
110 } else { |
|
111 Log.e(TAG, "Requested hog count change for unknown team "+ teamname); |
|
112 } |
|
113 } |
114 } |
114 } |