You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
923 B
31 lines
923 B
package visualiser.Commands.VisualiserRaceCommands;
|
|
|
|
import mock.model.commandFactory.Command;
|
|
import network.Messages.BoatState;
|
|
import shared.exceptions.BoatNotFoundException;
|
|
import visualiser.model.VisualiserBoat;
|
|
import visualiser.model.VisualiserRaceState;
|
|
|
|
/**
|
|
* Updates boats on visualiser when their health changes
|
|
*/
|
|
public class BoatStateCommand implements Command {
|
|
private BoatState boatState;
|
|
private VisualiserRaceState visualiserRace;
|
|
|
|
public BoatStateCommand(BoatState boatState, VisualiserRaceState visualiserRace) {
|
|
this.boatState = boatState;
|
|
this.visualiserRace = visualiserRace;
|
|
}
|
|
|
|
@Override
|
|
public void execute() {
|
|
try {
|
|
VisualiserBoat boat = visualiserRace.getBoat(boatState.getSourceID());
|
|
boat.setHealth(boatState.getBoatHealth());
|
|
} catch (BoatNotFoundException e) {
|
|
// Fail silently
|
|
}
|
|
}
|
|
}
|