Method: CEML::Cast#affinity

Defined in:
lib/ceml/models/cast.rb

#affinity(role, guy) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/ceml/models/cast.rb', line 22

def affinity role, guy
  casted_count = @castings[role.name].size
  needed =  [role.range.min - casted_count, 0].max
  allowed = [role.range.max - casted_count, 0].max

  return [-1, -1, -1 ] unless role.tagspec =~ guy and allowed > 0
  [ role.tagspec.with.size, -needed, -allowed ]
end