var friends = []

function getNewFriendRatio() {
    return 0.2
}

function getNewFriend() {
    friends.push(Math.round(Math.random() * 2) + 1)
}

function getRandomFriend() {
    return Math.round(Math.random() * (friends.length - 1))
}

function changeFriendClosness(friend, diff) {
    newClosness = friends[friend] + diff;
    if(newClosness < 0) {
        newClosness = 0;
    }
    if(newClosness > 2) {
        newClosness = 2;
    }
    friends[friend] = newClosness;
}

function genFriendFeed() {
    var isNewFriendEvent = Math.random() < getNewFriendRatio();

    if(isNewFriendEvent) {
        genNewFriend();
    } else {
        currFriend = getRandomFriend()
        changeFriendClosness(currFriend, (Math.round(Math.random()) ? 1 : -1))
    }
}


var portraitStartX = 540;
var portraitStartY = 150;

function drawPersonPortrait(ctx, person) {
    for(p in person.parts) {
        ctx.drawImage(person.parts[p], portraitStartX, portraitStartY);
    }
}