Win duel event uses lobby player, match does not make difference.

This commit is contained in:
Maxmtg
2013-03-28 20:28:48 +00:00
parent 16a90b3130
commit 9e4aa72b15
3 changed files with 15 additions and 12 deletions

View File

@@ -94,15 +94,18 @@ public class MatchController {
result.setTurnsPlayed(game.getPhaseHandler().getTurn());
gamesPlayed.add(result);
// Play the win/lose sound
game.getEvents().post(new DuelOutcomeEvent(result.getWinner()));
game.getGameLog().add("Final", result.getWinner() + " won", 0);
// add result entries to the game log
LobbyPlayer human = Singletons.getControl().getPlayer().getLobbyPlayer();
String title = result.isWinner(human) ? "You Win" : "You Lost";
game.getGameLog().add("Final", title, 0);
List<String> outcomes = new ArrayList<String>();
for (Entry<LobbyPlayer, PlayerStatistics> p : result) {
String outcome = String.format("%s %s", p.getKey().equals(human) ? "You have" : p.getKey().getName() + " has",
p.getValue().getOutcome().toString());
String whoHas = p.getKey().equals(human) ? "You have" : p.getKey().getName() + " has";
String outcome = String.format("%s %s", whoHas, p.getValue().getOutcome().toString());
outcomes.add(outcome);
game.getGameLog().add("Final", outcome, 0);
}
@@ -117,9 +120,6 @@ public class MatchController {
v.setTitle(title);
v.setOutcomes(outcomes);
v.setStatsSummary(statsSummary);
// Play the win/lose sound
game.getEvents().post(new DuelOutcomeEvent(result.isWinner(human)));
}

View File

@@ -1,9 +1,11 @@
package forge.game.event;
public class DuelOutcomeEvent extends Event {
public final boolean humanWonTheDuel;
import forge.game.player.LobbyPlayer;
public DuelOutcomeEvent(boolean humanWon) {
humanWonTheDuel = humanWon;
public class DuelOutcomeEvent extends Event {
public final LobbyPlayer winner;
public DuelOutcomeEvent(LobbyPlayer winner) {
this.winner = winner;
}
}

View File

@@ -27,6 +27,7 @@ import forge.game.event.SetTappedEvent;
import forge.game.event.ShuffleEvent;
import forge.game.event.SpellResolvedEvent;
import forge.game.event.TokenCreatedEvent;
import forge.game.player.PlayerType;
/**
* This class is in charge of converting any forge.game.event.Event to a SoundEffectType.
@@ -80,7 +81,7 @@ public class EventVisualizer {
return getSoundEffectForTapState(((SetTappedEvent) evt).Tapped);
}
if (evt instanceof DuelOutcomeEvent) {
return getSoundEffectForDuelOutcome(((DuelOutcomeEvent) evt).humanWonTheDuel);
return getSoundEffectForDuelOutcome(((DuelOutcomeEvent) evt).winner.getType() == PlayerType.HUMAN);
}
return fromMap;