2
* Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game
3
* Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
package org.hedgewars.hedgeroid;
24
import org.hedgewars.hedgeroid.Datastructures.MapRecipe;
25
import org.hedgewars.hedgeroid.Datastructures.Scheme;
26
import org.hedgewars.hedgeroid.Datastructures.Team;
27
import org.hedgewars.hedgeroid.Datastructures.TeamInGame;
28
import org.hedgewars.hedgeroid.Datastructures.Weaponset;
31
* This interface is supposed to abstract the handling of room state for several
32
* fragments that can display and manipulate it. The purpose of this is to allow
33
* using these fragments both for setting up networked and local games, despite
34
* the fact that for local games the settings can be changed immediately in
35
* memory, while they have to be sent out to the server for networked games.
37
* If/when the state changes as result of calling one of the "changeX" or
38
* "requestX" functions, that will also trigger the corresponding change
39
* listener method. There is no guarantee that calling a changeX method will
40
* actually change the setting (e.g. if you're not room chief).
42
* For local games, getChiefStatus is always true.
44
* Implementations of this interface are probably not thread safe and should
45
* only be used on the UI thread.
47
public interface RoomStateManager {
48
// Query current state
49
MapRecipe getMapRecipe();
50
boolean getChiefStatus();
52
String getGameStyle();
53
Weaponset getWeaponset();
54
Map<String, TeamInGame> getTeams();
57
void changeMapRecipe(MapRecipe map);
58
void changeMapTheme(String theme);
61
* This function sets both the map's name and generator. There is no function
62
* to change them independendly since e.g. the QtFrontend relies on them being
65
* If the name parameter is equal to one of the MapRecipe.MAPNAME_REGULAR, MAPNAME_MAZE
66
* or MAPNAME_DRAWN constants, the map generator is set accordingly. Otherwise, the
67
* map generator is set to represent a mapfile. The map's name is always set to
70
void changeMapNameAndGenerator(String mapName);
71
void changeMapTemplate(int template);
72
void changeMazeSize(int mazeSize);
73
void changeMapSeed(String seed);
74
void changeMapDrawdata(byte[] drawdata);
76
void changeScheme(Scheme scheme);
77
void changeGameStyle(String style);
78
void changeWeaponset(Weaponset weaponset);
80
void requestAddTeam(Team team, int colorIndex);
81
void requestRemoveTeam(String teamname);
82
void changeTeamColorIndex(String teamname, int colorIndex);
83
void changeTeamHogCount(String teamname, int hogcount);
86
void addListener(Listener observer);
87
void removeListener(Listener observer);
89
public interface Listener {
90
void onMapChanged(MapRecipe recipe);
91
void onChiefStatusChanged(boolean isChief);
92
void onSchemeChanged(Scheme scheme);
93
void onGameStyleChanged(String gameStyle);
94
void onWeaponsetChanged(Weaponset weaponset);
95
void onTeamsChanged(Map<String, TeamInGame> teams);
98
public static class ListenerAdapter implements Listener {
99
public void onMapChanged(MapRecipe recipe) {}
100
public void onChiefStatusChanged(boolean isChief) {}
101
public void onSchemeChanged(Scheme scheme) {}
102
public void onGameStyleChanged(String gameStyle) {}
103
public void onWeaponsetChanged(Weaponset weaponset) {}
104
public void onTeamsChanged(Map<String, TeamInGame> teams) {}
107
public interface Provider {
108
RoomStateManager getRoomStateManager();