| 1 | import { GroundType, groundDefinition } from "../definitions/tiles.js"; |
| 2 | |
| 3 | /** |
| 4 | * A* step cost into a path tile when preferring roads (out of combat). |
| 5 | * Slightly cheaper than grass so equal-ish routes favour the path without |
| 6 | * accepting long detours. |
| 7 | */ |
| 8 | export const PATH_GROUND_STEP_COST = 0.40; |
| 9 | |
| 10 | export function isPathGround (typeId) |
| 11 | { |
| 12 | return typeId === GroundType.path || !!groundDefinition(typeId)?.pathSurface; |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * @param {number} typeId |
| 17 | * @param {{ preferPaths?: boolean }} [options] |
| 18 | */ |
| 19 | export function stepCostForGround (typeId, { preferPaths = false } = {}) |
| 20 | { |
| 21 | if (preferPaths && isPathGround(typeId)) |
| 22 | { return PATH_GROUND_STEP_COST; } |
| 23 | return 1; |
| 24 | } |