1 | # Calcula el coste de un objeto |
||
2 | def calcular_coste(p) # p = objeto a calcular |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
3 | # Inicializamos |
||
4 | coste = 0 |
||
5 | eng = p[:engarces].split(',').sort.reverse |
||
6 | eng.each_with_index do |e, i| |
||
7 | # Coste de los engarces (joyas y runas = 4) |
||
8 | valor_calibre = [5, 10, 25, 50, 100, 250, 500] |
||
9 | # Avoid negative index values |
||
10 | coste += valor_calibre[e.to_i - i] if (e.to_i - i) >= 0 |
||
11 | end |
||
12 | # Reputacion |
||
13 | coste *= 0.9**p[:repu].to_i # Factor de Repu |
||
14 | coste.round # Redondea el coste sin decimales |
||
15 | end |
||
16 |