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

Function generateEnemies

app/lib/terrain-generation.js:638–658  ·  view source on GitHub ↗
(result, defeatThangsGoal)

Source from the content-addressed store, hash-verified

636}
637
638function generateEnemies (result, defeatThangsGoal) {
639 let i
640 for (i = 0; i < Math.ceil(Math.random() * 8);) {
641 const enemy = {
642 id: getRandomThang(['Crab Monster Junior']),
643 pos: getRandomPosition(result),
644 margin: 0
645 }
646 if (result.falseCount === 99) {
647 result.falseCount = 0
648 break
649 }
650 if (addThang(result, enemy)) {
651 ++i
652 }
653 }
654 if (!i) {
655 console.log("Couldn't find space for an enemy; removing defeatThangsGoal")
656 result.goals = _.without(result.goals, defeatThangsGoal)
657 }
658}
659
660function generateGetToLocations (result, getToLocationsGoal) {
661 while (true) {

Callers 1

generateThangsFunction · 0.85

Calls 4

getRandomThangFunction · 0.85
getRandomPositionFunction · 0.85
addThangFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected