MCPcopy Create free account
hub / github.com/codecombat/codecombat / generateThangs

Function generateThangs

app/lib/terrain-generation.js:442–474  ·  view source on GitHub ↗
({ presetName, presetSize, goals })

Source from the content-addressed store, hash-verified

440}
441
442function 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
476function generateFloor (result) {
477 const floorSize = { x: result.preset.floorSize?.x || thangSizes.floorSize.x, y: result.preset.floorSize?.y || thangSizes.floorSize.y }

Callers 1

onGenerateMethod · 0.85

Calls 7

generateFloorFunction · 0.85
generateBorderFunction · 0.85
generateDecorationsFunction · 0.85
generateEnemiesFunction · 0.85
generateGetToLocationsFunction · 0.85
generateCollectThangsFunction · 0.85
generateDefendThangsFunction · 0.85

Tested by

no test coverage detected