averbraeck / housinggame-facilitator

Facilitator app for the housing game
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Approval and rejection of buying a house #14

Closed averbraeck closed 11 months ago

averbraeck commented 11 months ago

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.

averbraeck commented 11 months ago

The screens for approval and rejection have been created:

image

averbraeck commented 11 months ago

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.

averbraeck commented 11 months ago

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.

averbraeck commented 11 months ago

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);
        });
      }
averbraeck commented 11 months ago

The above script would have to be changed if comments are instead done using a popup window.

averbraeck commented 11 months ago

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.

averbraeck commented 11 months ago

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):

image

averbraeck commented 11 months ago

Pressing the "REJECT" button results in a draggable popup that allows for entering a comment before rejecting:

image

averbraeck commented 11 months ago

The transaction history for a house in a round is preserved in the database:

image

averbraeck commented 11 months ago

Approval / rejection popup is now 2-column:

image

averbraeck commented 11 months ago

Approval and rejection for the facilitator work as intended.