averbraeck / housinggame-facilitator

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

Rolling dice for damage calculation needs to be implemented #10

Closed averbraeck closed 10 months ago

averbraeck commented 11 months ago

The data entry is already there, but the damage calculation for players with a house has not yet been done.

averbraeck commented 10 months ago

The following test has been taken from the documentation in the game:

Calculation of flood damage

The flood damage for all players in a group is calculated by the facilitator app for that group. When the facilitator enters the dice rolls and presses "ROLL DICE, SHOW DAMAGE", the calculation takes place. At the same time, the players can open the "SHOW DAMAGE" menu on their mobile phone to get a detailed assessment of the damage to their house in the current round.

1. Calculation of the protection level of the house

[!WARNING]
We need to decide whether NewsEffects are calculated when the news is effective (changing the values in the database for the game play) or when the values are used (looping over the NewsEffects till the current round, and applying the changes. Since most news effects do not have a field that can be updated in the database (e.g., tax discounts, living bonus, moving changes, etc.), the news effect calculation takes place where it is applied, and news effects are not changing any fields in the database.

2. Calculation of the damage

3. See if one-time-only measures are used

4. Calculate the cost and satisfaction penalty for the user

[!WARNING] Satisfaction penalties can lead to negative satisfaction. The ScenarioParameters indicate whether negative satisfaction for the player is allowed or not. This has to be taken into account in the calculation.

[!NOTE] Flood damage impacts the personal satisfaction. It is not something that is bought or sold with the house, such as the positive psychological effect of having applied measures to the house.

5. Apply damage reduction to the house

[!WARNING] Damage reductions also need to be calculated for houses that have not yet been sold. This is difficult for houses that are not yet on the market. We have to see how to proceed here...

averbraeck commented 10 months ago

The extra fields have been added to the database, see https://github.com/averbraeck/housinggame-common/issues/21

averbraeck commented 10 months ago

The dice roll has been implemented. processing is a tremendously long piece of code... The results of a dice roll 8, 8 for a test group (Table6) is as follows:

image

The results will be analyzed below.

averbraeck commented 10 months ago

Flood penalties and costs have also transferred to the players:

image

averbraeck commented 10 months ago

It looks like the flood table calculations are correct. The player table, however, does not show the correct flood penalty -- the numbers shown per player are not the sum of the damage numbers in the flood table. Let's check the costs:

Player t6p1 owns house D01. This house sustained 2 rain damage points, costing 4 k. Player t6p5 owns house U04. This house sustained 1 river damage point, costing 4 k.

The database has the following values for player t6p1, which is correct: image

The database has the following values for player t6p5, which is correct: image

averbraeck commented 10 months ago

One error was caused by not storing the pluvial and fluvial house protection with the HouseGroup after buying measures. This has been corrected.

The calculation of the satisfaction points is actually correct: image

There is a 1-point fixed fluvial satisfaction penalty if the area gets flooded plus a 1-point penalty per damage point if the house sustains fluvial damage. For the house above, this adds to 2 points.

averbraeck commented 10 months ago

The NewsEffects are taken into account in the community protection calculations. E.g., in round 3, the protection changes:

image

This leads in the flood table for round 3 and beyond to:

image

averbraeck commented 10 months ago

Calculations are complete, with the exception of depleting the resources for one-time measures, in case they had to be used.