honor()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 15
rs 9.65
1
# frozen_string_literal: true
2
3
# Honor calculator, based on char lvl owned by player.
4
def honor(jugador)
5
  honor = 0 # Initialize by 0
6
7
  heros.each do |h|
8
    # Increase honor for each player lvl
9
    honor += h.nivel if h.jugador == jugador
10
    # ONLY for MB players
11
    unless ciudad?(jugador).empty?
12
      # Increase honor for each MB player lvl/3
13
      honor += (h.nivel / 3).to_i if h.ciudad == ciudad?(jugador).first['name']
14
    end
15
  end
16
17
  honor
18
end
19