TankGameOrg / engine

1 stars 2 forks source link

Shoot die roll #84

Closed ryan3r closed 1 week ago

ryan3r commented 2 months ago

As a UI developer I would like to know how many dice to roll when shooting any player So that I can roll the dice or let users preform the rolls themselves Ideally without perceptible lag

Current implementation

The version config provides a function that generates pairs of targets and dice (number and type) to roll. That data is sent to the frontend and the shoot action displays the targeting interface and dice based on the selected player.

Log entry

Shooting the wall gets a hit entry but not a hit_roll since no dice were rolled.

{
  "subject": "Lena",
  "action": "shoot",
  "target": "D11",
  "hit": true,
  "timestamp": 84000
}

Shooting a player gets a hit roll entry containing the values of the dice that were rolled based on the roll the UI also sets the hit field.

{
    "subject": "Lena",
    "action": "shoot",
    "target": "C9",
    "hit_roll": {
        "type": "die-roll",
        "manual": true,
        "roll": [
            true,
            true
        ]
    },
    "hit": true,
    "timestamp": 88800
}

My suggestion is to generate the pairs (target and applicable dice) in the engine and provide them through the possible actions api and update the shoot rule to use the hit_roll field (if applicable) instead of hit.