#!/usr/bin/ruby # args: (any order) # updateall=> maj tous les file_Trolls file_* # refresh=> update le cache # profil => affiche le profil # vue => affiche la vue # nozero => vire le niveau 0 # nogogo => vire les gowaps # split => affiche separement monstres/trolls/lieux # dmax42 => distmax 42 # misc # formule de seuil de niveau en pi: s = 0 ; (0..50).each { |d| s += 10*(d+2) ; puts s } (20 50 90 140 200..) # formule de gain d'xp au kill: 11 + lvl + 3*(difflvl) +1 si sortilege -1 si potion # fichier mountycreds.rb: # def mountycreds # ['login', 'passrestreint'] # end require 'mountycreds' require 'libmhsp' class MHElem attr_accessor :d @@lastx = @@lasty = @@lastn = 1 def to_s if @x == @@lastx and @y == @@lasty and @n == @@lastn s = " (#@id)" # "(1) en 000,000 000: ( else s = "(#@d) en %3d,%3d %3d: (#@id)" % [@x, @y, @n] @@lastx = @x @@lasty = @y @@lastn = @n end if @lvl s << ' ' s << (@race ? @race[0] : 'l.') s << @lvl.to_s end s << " #@nom" if @nom s << " (#@guilde)" if @guilde s end def <=>(other) [:d, :n, :x, :y, :id].each { |f| diff = (send(f) <=> other.send(f)) return diff unless diff == 0 } (@cat + @nom) <=> (other.cat + other.nom) end end def show_profil l, p, pr = mountycreds val = MHInfo.get_spprofil(l, pr).chomp.split(';') dla = val.delete_at(7) lbl = %w{mat x y n pv pvmax pa datq desq ddeg dreg vue arm mm rm} val.zip(lbl).each { |v, l| puts "%4s: #{v.to_i}" % l } dla =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/ dla_t = Time.mktime($1, $2, $3, $4, $5, $6) delay = dla_t.to_i - Time.now.to_i puts "dla: #{dla} (dans #{delay/3600}h#{delay/3600 % 60}m#{delay%60})" end def show_vue l, p, pr = mountycreds v = MHVueSP.new v.update MHInfo.get_spvue(l, pr) v.parse src = v.cat['TROLLS'].find { |t| t.id.to_s == l or t.nom == l } if ARGV.include? 'split' v.cat else { 'ALL' => v.cat.values.flatten } end.each { |k, v| v.each { |e| # calcule la distance p/r au troll if src e.d = [:x, :y, :n].map { |f| (src.send(f).to_i - e.send(f).to_i).abs }.inject { |a, b| a > b ? a : b } else e.n.to_i end } # traite les arguments de ligne de commande v.delete_if { |e| e.n == '0' } if ARGV.include? 'nozero' v.delete_if { |e| e.cat == 'MONSTRES' and e.nom =~ /gowap/i } if ARGV.include? 'nogogo' dmax = nil v.delete_if { |e| e.d > dmax rescue false } if dmax = ARGV.inject(500) { |a, e| e =~ /dmax(\d+)/ ? $1.to_i : a } puts "#{k}:", v.sort, '' unless v.empty? } end MHInfo.update_cache if ARGV.include? 'updateall' show_vue if ARGV.include? 'vue' show_profil if ARGV.include? 'profil'