Class: Char

Inherits:
Object
  • Object
show all
Defined in:
lib/Olib/character/char.rb

Constant Summary collapse

@@silvers =
0
@@routines =
{}

Class Method Summary collapse

Class Method Details

.deplete_wealth(silvers) ⇒ Object



77
78
79
# File 'lib/Olib/character/char.rb', line 77

def Char.deplete_wealth(silvers)
  @@silvers = @@silvers - silvers
end

.deposit(amt) ⇒ Object



58
59
60
61
62
63
64
65
66
# File 'lib/Olib/character/char.rb', line 58

def Char.deposit(amt)
  wealth
  if wealth >= amt
    Go2.bank
    fput "unhide" if invisible? || hidden?
    fput "deposit #{amt}"
  end
  return self
end

.deposit_allObject



50
51
52
53
54
55
56
# File 'lib/Olib/character/char.rb', line 50

def Char.deposit_all
  Go2.bank
  fput "unhide" if invisible? || hidden?
  fput "deposit all"
  @@silvers = 0
  return self
end

.fwi_teleporterObject



17
18
19
# File 'lib/Olib/character/char.rb', line 17

def Char.fwi_teleporter
  Vars.teleporter || Vars.mapdb_fwi_trinket
end

.hideObject



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/Olib/character/char.rb', line 5

def Char.hide
  while not hiding?
    waitrt?
    if @@routines[:hiding]
      @@routines[:hiding].call
    else
      fput 'hide'
    end
  end
  Char
end

.hiding_routine(procedure) ⇒ Object



25
26
27
28
# File 'lib/Olib/character/char.rb', line 25

def Char.hiding_routine(procedure)
  @@routines[:hiding] = procedure
  Char
end

.leftObject



30
31
32
# File 'lib/Olib/character/char.rb', line 30

def Char.left
  GameObj.left_hand.name == "Empty" ? nil : Olib::Item.new(GameObj.left_hand)
end

.rightObject



34
35
36
# File 'lib/Olib/character/char.rb', line 34

def Char.right
  GameObj.right_hand.name == "Empty" ? nil : Olib::Item.new(GameObj.right_hand)
end

.shareObject

naive share does not check if you’re actually in a group or not



70
71
72
73
74
75
# File 'lib/Olib/character/char.rb', line 70

def Char.share
  wealth
  fput "share #{@silvers}"
  wealth
  self
end

.smart_wealthObject



81
82
83
84
# File 'lib/Olib/character/char.rb', line 81

def Char.smart_wealth
  return @@silvers if @@silvers 
  Char.wealth
end

.unhideObject



86
87
88
89
# File 'lib/Olib/character/char.rb', line 86

def Char.unhide
  fput 'unhide' if Spell[916].active? or hidden?
  self
end

.visible?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/Olib/character/char.rb', line 21

def Char.visible?
  hiding? || invisible?
end

.wealthObject



99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/Olib/character/char.rb', line 99

def Char.wealth
  fput "info"
  while(line=get)
    next    if line =~ /^\s*Name\:|^\s*Gender\:|^\s*Normal \(Bonus\)|^\s*Strength \(STR\)\:|^\s*Constitution \(CON\)\:|^\s*Dexterity \(DEX\)\:|^\s*Agility \(AGI\)\:|^\s*Discipline \(DIS\)\:|^\s*Aura \(AUR\)\:|^\s*Logic \(LOG\)\:|^\s*Intuition \(INT\)\:|^\s*Wisdom \(WIS\)\:|^\s*Influence \(INF\)\:/
    if line =~ /^\s*Mana\:\s+\-?[0-9]+\s+Silver\:\s+([0-9]+)/
      @@silvers= $1.to_i
      break
    end
    sleep 0.1
  end
  @@silvers
end

.withdraw(amount) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/Olib/character/char.rb', line 38

def Char.withdraw(amount)
  Go2.bank
  result = Olib.do "withdraw #{amount} silvers", /I'm sorry|hands you/
  if result =~ /I'm sorry/ 
    Go2.origin
    echo "Unable to withdraw the amount requested for this script to run from your bank account"
    exit
  end
  wealth
  return self
end