aboutsummaryrefslogtreecommitdiff
path: root/src/sim/static/items.js
blob: a3e3eca76849df82c75c3646a27363dea738fbae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
tileMap = {
    0: Mountain,
    1: Forest,
    2: Town,
}

function getScout() {
    return { 
        id: 1, 
        text: "scout", 
        cost: 2, 
        callback: function (game) { 
            var type = tileMap[Math.floor(Math.random() * 3)]
            var tile = new type()
            messages.push(`Your scout found a ${tile.name}.`)

            var randX, randY
            do {
                randX = Math.floor(width * Math.random())
                randY = Math.floor(height * Math.random())
            } while(game.level[randX][randY] != undefined)
            game.level[randX][randY] = tile
        }
    }
}