Closed averbraeck closed 11 months ago
The screens for approval and rejection have been created:
Warnings still have to be built in for players who cannot afford their house, for a double buy of the same house, or for a bid that is not equal to the market value of the house.
Since it is difficult to fill the comment field when the screen is being refreshed every 5 seconds, and since there is little room to show to the facilitator whether the player can afford the house, a popup-screen to fill the comment might help.
This is the script that was used to reload the buy/sell tables:
$(document).ready(function() {
reloadTables();
});
function reloadTables() {
// store input values before reloading
var comments = new Array();
var ids = new Array();
$(".buy-comment").map(
function() {
comments.push($(this).val());
ids.push($(this).attr('id'));
});
var active = document.activeElement;
console.log("comments: " + comments + ", ids: " + ids);
$.post("/housinggame-facilitator/reload-tables", {
reloadTables : 'true'
}, function(data, status) {
var tableDiv = document
.getElementById("facilitator-tables");
tableDiv.innerHTML = data;
// return input values after relaoding
for (let i = 0; i < ids.length; i++) {
$("#" + ids[i]).val(comments[i]);
}
active.focus();
setTimeout(reloadTables, 5000);
});
}
The above script would have to be changed if comments are instead done using a popup window.
The approveBuy
and rejectBuy
scripts are as follows at the moment:
function approveBuy(playerCode, transactionId) {
var $comment=$("#comment-" + playerCode).val();
$.post("/housinggame-facilitator/approve-buy", {
playerCode : JSON.stringify(playerCode),
transactionId : JSON.stringify(transactionId),
comment: JSON.stringify($comment),
approve: 'APPROVE'
});
}
function rejectBuy(playerCode, transactionId) {
var $comment=$("#comment-" + playerCode).val();
$.post("/housinggame-facilitator/approve-buy", {
playerCode : JSON.stringify(playerCode),
transactionId : JSON.stringify(transactionId),
comment: JSON.stringify($comment),
approve: 'REJECT'
});
}
Instead of immediately approving, the script should show a popup with the exact situation for the player on which the approval can be based. By the way, when a house is sold twice, the 'approve' button should not be functional.
Error messages are now displayed when a house transaction is either impossible (APPROVE button greyed out), or not wise for the player (APPROVE still possible):
Pressing the "REJECT" button results in a draggable popup that allows for entering a comment before rejecting:
The transaction history for a house in a round is preserved in the database:
Approval / rejection popup is now 2-column:
Approval and rejection for the facilitator work as intended.
The facilitator now approves or rejects buying of a house. The table to do so has to be implemented, with the appropriate buttons and the communication to the players' app.