forked from unimatrix/web
Recover a committed Rihla voucher after lost client response
This commit is contained in:
parent
021f68c602
commit
e56a20c909
3 changed files with 34 additions and 6 deletions
|
|
@ -22,6 +22,7 @@ final class AtmMenu extends Menu {
|
|||
DunemarkDenomination.COIN_1DM, DunemarkDenomination.COIN_2DM);
|
||||
private Tab tab;
|
||||
private final List<DunemarkDenomination> selected = new ArrayList<>();
|
||||
private boolean recoveredDeposit;
|
||||
private String issued; // RIA ID created by the last deposit
|
||||
private String entered; // RIA ID typed on the Redeem tab
|
||||
|
||||
|
|
@ -91,10 +92,12 @@ final class AtmMenu extends Menu {
|
|||
// framed ID box
|
||||
for (int s : new int[]{28, 30}) put(s, Ui.pane(Material.YELLOW_STAINED_GLASS_PANE));
|
||||
if (dep) {
|
||||
put(29, issued == null ? Ui.item(Material.NAME_TAG, "<gold><b>Your new RIA ID", "<dark_gray>Appears here after you deposit")
|
||||
: Ui.glow(Ui.item(Material.NAME_TAG, "<gold><b>Your new RIA ID", "<white>" + issued, "<gray>Give it to anyone to collect the money",
|
||||
"<yellow>Click to show in chat")),
|
||||
c -> { if (issued != null) player.sendMessage(Ui.text("<gold>RIA ID: <click:copy_to_clipboard:'" + issued + "'><white><u>" + issued + "</u></click>")); });
|
||||
drawIssuedVoucher();
|
||||
if (!recoveredDeposit) load(backend().atmRecentDeposit(player), voucher -> {
|
||||
recoveredDeposit = true;
|
||||
issued = voucher.isEmpty() ? null : voucher;
|
||||
drawIssuedVoucher();
|
||||
});
|
||||
} else {
|
||||
put(29, Ui.item(Material.NAME_TAG, "<gold><b>Rihla reference", "<gray>Loading…"));
|
||||
load(backend().bankAccount(player), a -> put(29, Ui.item(Material.NAME_TAG, "<gold><b>Rihla reference",
|
||||
|
|
@ -102,6 +105,13 @@ final class AtmMenu extends Menu {
|
|||
}
|
||||
}
|
||||
|
||||
private void drawIssuedVoucher() {
|
||||
put(29, issued == null ? Ui.item(Material.NAME_TAG, "<gold><b>Your new RIA ID", "<dark_gray>Appears here after you deposit")
|
||||
: Ui.glow(Ui.item(Material.NAME_TAG, "<gold><b>Your new RIA ID", "<white>" + issued, "<gray>Give it to anyone to collect the money",
|
||||
"<yellow>Click to show in chat")),
|
||||
c -> { if (issued != null) player.sendMessage(Ui.text("<gold>RIA ID: <click:copy_to_clipboard:'" + issued + "'><white><u>" + issued + "</u></click>")); });
|
||||
}
|
||||
|
||||
private void drawRedeem() {
|
||||
put(4, Ui.glow(Ui.item(Material.LIGHTNING_ROD, "<aqua><b>Redeem an RIA ID", "<gray>1. Type the ID", "<gray>2. Pick Cash or To bank")));
|
||||
put(13, Ui.item(Material.WRITABLE_BOOK, entered == null ? "<yellow><b>Type RIA ID" : "<yellow><b>Change RIA ID",
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ public interface Backend {
|
|||
default CompletableFuture<Issued> atmCreateRia(Player p, List<DunemarkDenomination> pieces) { return na(); }
|
||||
/** ATM, tab 2. Look an RIA ID up so the menu can show the amount before payout. Return null/exceptional if unknown. */
|
||||
record Voucher(String riaId, long amountMinor, String fromName) {}
|
||||
default CompletableFuture<String> atmRecentDeposit(Player p) { return na(); }
|
||||
default CompletableFuture<Voucher> atmLookup(Player p, String riaId) { return na(); }
|
||||
/** ATM, tab 2. Pay the RIA ID out: toBank=false gives cash, toBank=true credits the player's bank account. One click, no confirmation. */
|
||||
default CompletableFuture<Result> atmRedeem(Player p, Voucher voucher, boolean toBank) { return na(); }
|
||||
|
|
|
|||
|
|
@ -108,6 +108,11 @@ final class JarvisBackend implements Backend, Listener {
|
|||
return cashAction(player,request).thenApply(JarvisBackend::cashResult);
|
||||
}
|
||||
|
||||
@Override public CompletableFuture<String> atmRecentDeposit(Player player) {
|
||||
UUID actor=player.getUniqueId();
|
||||
return remote(player,()->number(accepted(jarvis.requestRihla(actor,action("cash_recent_deposit"))),"voucher"));
|
||||
}
|
||||
|
||||
@Override public CompletableFuture<Voucher> atmLookup(Player player,String code) {
|
||||
UUID actor=player.getUniqueId();
|
||||
return remote(player,()->{
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff