averbraeck / housinggame-facilitator

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

Calculate satisfaction rating per round or one-time #30

Closed averbraeck closed 5 months ago

averbraeck commented 5 months ago

See https://github.com/averbraeck/housinggame-common/issues/23. The satisfaction rating for a house below/above the required rating can be applied every round, or one-time only when buying.

averbraeck commented 5 months ago

The following code snippet has been added to ApproveRejectStayServlet when the staying is approved by the facilitator:

if (data.getScenarioParameters().getSatisfactionHouseRatingPerRound() != 0)
{
    HousegroupRecord hgr = SqlUtils.readRecordFromId(data, Tables.HOUSEGROUP, transaction.getHousegroupId());
    HouseRecord house = SqlUtils.readRecordFromId(data, Tables.HOUSE, hgr.getHouseId());
    int phr = prr.getPreferredHouseRating();
    int hr = house.getRating();
    prr.setSatisfactionHouseRatingDelta(hr - phr);
    prr.setPersonalSatisfaction(prr.getPersonalSatisfaction() + hr - phr);
    prr.setFinalHousegroupId(hgr.getId());
}
averbraeck commented 5 months ago

Completed.