javascript – Calcular lucro e Pagante

calculo_loots function (balanceEk, balanceEd, balanceMs, balanceRp) {

var ekBalance = parseInt ($ (& # 39; + balanceEk + & # 39;)) html ()),
edBalance = parseInt ($ (& # 39; + balanceEd + & # 39;)) html ()),
msBalance = parseInt ($ (& # 39; + balanceMs + & # 39;)) html ()),
rpBalance = parseInt ($ (& # 39; + balanceRp + & # 39;). html ()),
allBalance = ekBalance + edBalance + msBalance + rpBalance,
impression


var countbalance = 0

// Verificar quantidade de player

if (ekBalance! = 0) {
countbalance ++
} if (edBalance! = 0) {
countbalance ++
} if (msBalance! = 0) {
countbalance ++
} if (rpBalance! = 0) {
countbalance ++
}

// Verificar quem tem more

var profit = allBalance / countbalance

ekBalance = profit - ekBalance
edBalance = profit - edBalance
msBalance = profit - msBalance
rpBalance = profit - rpBalance

var listBalance = {Profit :: profit}

if (ekBalance == Math.min (ekBalance, edBalance, msBalance, rpBalance)) {
listBalance['pagante'] = & # 39; EK & # 39;
} other {
listBalance['EK'] = ekBalance
}

if (edBalance == Math.min (ekBalance, edBalance, msBalance, rpBalance)) {
listBalance['pagante'] = & # 39; ED & # 39;
} other {
listBalance['ED'] = edBalance
}

if (msBalance == Math.min (ekBalance, edBalance, msBalance, rpBalance)) {
listBalance['pagante'] = & # 39; MS & # 39;
} other {
listBalance['MS'] = msBalance
}

if (rpBalance == Math.min (ekBalance, edBalance, msBalance, rpBalance)) {
listBalance['pagante'] = & # 39; RP & # 39;
} other {
listBalance['RP'] = rpBalance
}


back to listBalance


}