| @@ 19-60 (lines=42) @@ | ||
| 16 | end |
|
| 17 | ||
| 18 | # TODO: Conflictive method |
|
| 19 | def resistencia(elemento) # I'm sorry for this... |
|
| 20 | total = 0 # Initialize default returns 0 |
|
| 21 | regex = /vs #{Regexp.quote(elemento)}/ # looks for "+N vs #{elemento}" |
|
| 22 | reg2x = /vs todas las resistencias/ |
|
| 23 | ||
| 24 | %w(proteccions baratijas armour).each do |i| |
|
| 25 | next unless send(i) # ask for item-type |
|
| 26 | send(i).each do |item| |
|
| 27 | if item.enchanted? |
|
| 28 | item.enchants.each do |e| |
|
| 29 | texto = enchant(e)[:descripcion] # takes description |
|
| 30 | if m = (regex =~ texto) # if positive (TODO: tune up this) |
|
| 31 | bono = texto[m.to_i - 2].to_i # add the bonificator |
|
| 32 | # puts "#{elemento}, #{item.name},magia: #{texto}" |
|
| 33 | total += bono |
|
| 34 | end |
|
| 35 | next unless m = (reg2x =~ texto) # if positive (TODO: tune up this) |
|
| 36 | bono = texto[m.to_i - 2].to_i # add the bonificator |
|
| 37 | # puts "+1 todas las resistencias" |
|
| 38 | total += bono |
|
| 39 | end |
|
| 40 | end |
|
| 41 | next unless item.engarzado? |
|
| 42 | %w(gemas joyas runas).each do |engarce| |
|
| 43 | next unless eng = item.send(engarce) |
|
| 44 | eng.each do |id| |
|
| 45 | texto = send(engarce[0..-2], id).fits[item.fits] # takes description |
|
| 46 | if m = (regex =~ texto) # if positive (TODO: tune up this) |
|
| 47 | # puts "#{elemento}, #{item.name},#{engarce} #{texto}" |
|
| 48 | bono = texto[m.to_i - 2].to_i # add the bonificator |
|
| 49 | total += bono |
|
| 50 | end |
|
| 51 | next unless m = (reg2x =~ texto) # if positive (TODO: tune up this) |
|
| 52 | bono = texto[m.to_i - 2].to_i # add the bonificator |
|
| 53 | # puts "+1 todas las resistencias" |
|
| 54 | total += bono |
|
| 55 | end |
|
| 56 | end |
|
| 57 | end |
|
| 58 | end |
|
| 59 | total |
|
| 60 | end |
|
| 61 | ||
| 62 | # Custom meta-methods created by each item: |
|
| 63 | (fields[0] + fields[1] + fields[2]).each do |f| |
|
| @@ 21-62 (lines=42) @@ | ||
| 18 | end |
|
| 19 | ||
| 20 | # TODO: Conflictive method |
|
| 21 | def resistencia(elemento) # I'm sorry for this... |
|
| 22 | total = 0 # Initialize default returns 0 |
|
| 23 | regex = /vs #{Regexp.quote(elemento)}/ # looks for "+N vs #{elemento}" |
|
| 24 | reg2x = /vs todas las resistencias/ |
|
| 25 | ||
| 26 | %w(proteccions baratijas armour).each do |i| |
|
| 27 | next unless send(i) # ask for item-type |
|
| 28 | send(i).each do |item| |
|
| 29 | if item.enchanted? |
|
| 30 | item.enchants.each do |e| |
|
| 31 | texto = enchant(e)[:descripcion] # takes description |
|
| 32 | if m = (regex =~ texto) # if positive (TODO: tune up this) |
|
| 33 | bono = texto[m.to_i - 2].to_i # add the bonificator |
|
| 34 | # puts "#{elemento}, #{item.name},magia: #{texto}" |
|
| 35 | total += bono |
|
| 36 | end |
|
| 37 | next unless m = (reg2x =~ texto) # if positive (TODO: tune up this) |
|
| 38 | bono = texto[m.to_i - 2].to_i # add the bonificator |
|
| 39 | # puts "+1 todas las resistencias" |
|
| 40 | total += bono |
|
| 41 | end |
|
| 42 | end |
|
| 43 | next unless item.engarzado? |
|
| 44 | %w(gemas joyas runas).each do |engarce| |
|
| 45 | next unless eng = item.send(engarce) |
|
| 46 | eng.each do |id| |
|
| 47 | texto = send(engarce[0..-2], id).fits[item.fits] # takes description |
|
| 48 | if m = (regex =~ texto) # if positive (TODO: tune up this) |
|
| 49 | # puts "#{elemento}, #{item.name},#{engarce} #{texto}" |
|
| 50 | bono = texto[m.to_i - 2].to_i # add the bonificator |
|
| 51 | total += bono |
|
| 52 | end |
|
| 53 | next unless m = (reg2x =~ texto) # if positive (TODO: tune up this) |
|
| 54 | bono = texto[m.to_i - 2].to_i # add the bonificator |
|
| 55 | # puts "+1 todas las resistencias" |
|
| 56 | total += bono |
|
| 57 | end |
|
| 58 | end |
|
| 59 | end |
|
| 60 | end |
|
| 61 | total |
|
| 62 | end |
|
| 63 | ||
| 64 | # Custom meta-methods created by each item: |
|
| 65 | (fields[0] + fields[1] + fields[2]).each do |f| |
|