({ presetName, presetSize, goals })
| 440 | } |
| 441 | |
| 442 | function generateThangs ({ presetName, presetSize, goals }) { |
| 443 | presetName = (presetName || 'dungeon').toLowerCase() |
| 444 | presetName = { |
| 445 | grass: 'grassy', |
| 446 | volcano: 'glacier' |
| 447 | }[presetName] || presetName |
| 448 | const preset = presets[presetName] |
| 449 | presetSize = presetSizes[presetSize || 'small'] |
| 450 | const result = { thangs: [], rects: [], falseCount: 0, preset, presetSize } |
| 451 | generateFloor(result) |
| 452 | generateBorder(result) |
| 453 | generateDecorations(result) |
| 454 | if (!goals) { |
| 455 | return result.thangs |
| 456 | } |
| 457 | const killThangsGoal = _.find(goals, (goal) => goal.killThangs) |
| 458 | if (killThangsGoal) { |
| 459 | generateEnemies(result, killThangsGoal) |
| 460 | } |
| 461 | const getToLocationsGoal = _.find(goals, (goal) => goal.getToLocations) |
| 462 | if (getToLocationsGoal) { |
| 463 | generateGetToLocations(result, getToLocationsGoal) |
| 464 | } |
| 465 | const collectThangsGoal = _.find(goals, (goal) => goal.collectThangs) |
| 466 | if (collectThangsGoal) { |
| 467 | generateCollectThangs(result, collectThangsGoal) |
| 468 | } |
| 469 | const defendThangsGoal = _.find(goals, (goal) => goal.id === 'humans-survive') |
| 470 | if (defendThangsGoal) { |
| 471 | generateDefendThangs(result, defendThangsGoal) |
| 472 | } |
| 473 | return result.thangs |
| 474 | } |
| 475 | |
| 476 | function generateFloor (result) { |
| 477 | const floorSize = { x: result.preset.floorSize?.x || thangSizes.floorSize.x, y: result.preset.floorSize?.y || thangSizes.floorSize.y } |
no test coverage detected