use of com.gianlu.pyxreborn.Exceptions.PyxException in project PretendYoureXyzzyReborn by devgianlu.
the class GlobalChatUI method send.
@FXML
@Override
protected void send(MouseEvent event) {
JsonObject req = client.createRequest(Operations.CHAT);
req.addProperty(Fields.TEXT.toString(), message.getText());
try {
client.sendMessageBlocking(req);
} catch (InterruptedException | PyxException ex) {
UIClient.notifyException(ex);
return;
}
message.setText(null);
}
use of com.gianlu.pyxreborn.Exceptions.PyxException in project PretendYoureXyzzyReborn by devgianlu.
the class GameOptionsUI method initialize.
@FXML
public void initialize() {
NumberStringFilteredConverter numberFormatter = new NumberStringFilteredConverter();
maxPlayers.setTextFormatter(new TextFormatter<>(numberFormatter, 0, numberFormatter.getFilter()));
maxPlayers.setText(String.valueOf(game.options.maxPlayers));
maxPlayers.textProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue.isEmpty())
newOptions.maxPlayers = Integer.parseInt(newValue);
});
maxSpectators.setTextFormatter(new TextFormatter<>(numberFormatter, 0, numberFormatter.getFilter()));
maxSpectators.setText(String.valueOf(game.options.maxSpectators));
maxSpectators.textProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue.isEmpty())
newOptions.maxSpectators = Integer.parseInt(newValue);
});
List<CCompactCardSet> allCardSets;
try {
allCardSets = Utils.toList(client.sendMessageBlocking(client.createRequest(Operations.LIST_CARD_SETS)).getAsJsonArray(Fields.CARD_SET.toString()), CCompactCardSet.class);
} catch (InterruptedException | PyxException ex) {
UIClient.notifyException(ex);
return;
}
boolean amHost = Objects.equals(game.host, me);
cardSets.setCellFactory(param -> new CheckboxCardSetCell(newOptions, amHost));
cardSets.setItems(new ObservableListWrapper<>(allCardSets));
maxPlayers.setDisable(!amHost);
maxSpectators.setDisable(!amHost);
apply.setDisable(!amHost);
}
use of com.gianlu.pyxreborn.Exceptions.PyxException in project PretendYoureXyzzyReborn by devgianlu.
the class GameUI method startGame.
@FXML
public void startGame(MouseEvent event) {
JsonObject obj = client.createRequest(Operations.START_GAME);
obj.addProperty(Fields.GID.toString(), game.gid);
try {
client.sendMessageBlocking(obj);
} catch (InterruptedException | PyxException ex) {
UIClient.notifyException(ex);
}
}
use of com.gianlu.pyxreborn.Exceptions.PyxException in project PretendYoureXyzzyReborn by devgianlu.
the class GameUI method onCardSelected.
@Override
public void onCardSelected(BaseCard card) {
if (Objects.equals(me, judge.user) && game.status == Game.Status.JUDGING) {
JsonObject obj = client.createRequest(Operations.JUDGE);
obj.addProperty(Fields.GID.toString(), game.gid);
obj.addProperty(Fields.CARD_ID.toString(), card.id);
try {
client.sendMessageBlocking(obj);
} catch (InterruptedException | PyxException ex) {
UIClient.notifyException(ex);
}
} else if (!Objects.equals(me, judge.user) && game.status == Game.Status.PLAYING) {
JsonObject obj = client.createRequest(Operations.PLAY_CARD);
obj.addProperty(Fields.GID.toString(), game.gid);
obj.addProperty(Fields.CARD_ID.toString(), card.id);
try {
client.sendMessageBlocking(obj);
} catch (InterruptedException | PyxException ex) {
UIClient.notifyException(ex);
return;
}
for (int i = hand.getChildren().size() - 1; i >= 0; i--) {
Node node = hand.getChildren().get(i);
if (node instanceof PyxCardGroup) {
List<WhiteCard> cards = ((PyxCardGroup) node).cards;
for (WhiteCard c : cards) {
if (c.id == card.id) {
hand.getChildren().remove(i);
break;
}
}
}
}
}
}
use of com.gianlu.pyxreborn.Exceptions.PyxException in project PretendYoureXyzzyReborn by devgianlu.
the class GameUI method leaveGame.
@FXML
public void leaveGame(MouseEvent event) {
JsonObject obj = client.createRequest(Operations.LEAVE_GAME);
obj.addProperty(Fields.GID.toString(), game.gid);
try {
client.sendMessageBlocking(obj);
} catch (InterruptedException | PyxException ex) {
UIClient.notifyException(ex);
}
stage.close();
chatStage.close();
mainStage.show();
}
Aggregations