Created
April 26, 2018 19:32
-
-
Save theAprel/28d46acca7480be9284b8d77c116f448 to your computer and use it in GitHub Desktop.
Proposal to update Role
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Called when this {@code Role} is created, either at the start of the game | |
| * or after a player has been converted. Role logic that happens in both of | |
| * those scenarios should be implemented here. This method is called in both | |
| * {@link #onGameStart(mafia.Game.State)} and | |
| * {@link #onConversion(mafia.Game.State)}. | |
| * <p> | |
| * The default implementation registers this {@code Role} as a | |
| * {@link TimeSensitive}. | |
| * | |
| * @param state the gamestate at game start or after conversion of the | |
| * player with this {@code Role} | |
| * @return | |
| */ | |
| public List<UiUpdate> onCreation(Game.State state) { | |
| state.registerTimeSensitive(this); | |
| return new ArrayList<>(); | |
| } | |
| /** | |
| * Called at the start of the game. Not called if a player is converted into | |
| * this {@code Role}. This method calls | |
| * {@link #onCreation(mafia.Game.State)}. Role logic that should happen only | |
| * at the start of the game and <i>not</i> after a conversion should be | |
| * implemented in this method. | |
| * <p> | |
| * The default implementation informs the user of their role (if overridden, | |
| * call {@code super}). | |
| * | |
| * @param state | |
| * @return | |
| */ | |
| public Result onGameStart(Game.State state) { | |
| Result res = new Result().sendSystemMessage(ROLE_REVEAL_SELF_MESSAGE_PREFIX | |
| + getRoleNameAsAppearsToSelf() + ROLE_REVEAL_SELF_MESSAGE_SUFFIX, self); | |
| res.add(onCreation(state)); | |
| return res; | |
| } | |
| /** | |
| * Called when a player has been converted into this role. Not called at the | |
| * start of the game. This method calls | |
| * {@link #onCreation(mafia.Game.State)}. Role logic that should happen only | |
| * after conversion and <i>not</i> at the start of the game should be | |
| * implemented in this method. | |
| * <p> | |
| * The default implementation informs the user that they have been converted | |
| * and their new role (if overridden, call {@code super}). | |
| * | |
| * @param state | |
| * @return | |
| */ | |
| public List<UiUpdate> onConversion(Game.State state) { | |
| List<UiUpdate> updates = onCreation(state); | |
| updates.add(UiUpdate.createSystemMessage(self, "You've been converted to " + getRoleNameAsAppearsToSelf() + "!")); | |
| updates.add(self.revealSelf()); | |
| return updates; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment