Class: Char
- Inherits:
-
Object
- Object
- Char
- Defined in:
- lib/Olib/character/char.rb
Defined Under Namespace
Classes: Duration
Constant Summary collapse
- EMPATH =
"Empath"- INJURIES =
Wounds.singleton_methods .map(&:to_s) .select do |m| m.downcase == m && m !~ /_/ end.map(&:to_sym)
- @@silvers =
0- @@routines =
{}
- @@aiming =
nil
Class Method Summary collapse
- .aim(location) ⇒ Object
- .arm ⇒ Object
- .deplete_wealth(silvers) ⇒ Object
- .deposit(amt) ⇒ Object
- .deposit_all ⇒ Object
- .empty_hands ⇒ Object
- .fwi_teleporter ⇒ Object
- .hide ⇒ Object
- .hiding_routine(procedure) ⇒ Object
- .in_town? ⇒ Boolean
- .left ⇒ Object
- .right ⇒ Object
-
.share ⇒ Object
naive share does not check if you’re actually in a group or not.
- .smart_wealth ⇒ Object
- .spell(num) ⇒ Object
- .stand ⇒ Object
- .swap ⇒ Object
- .total_wound_severity ⇒ Object
- .unarm ⇒ Object
- .unhide ⇒ Object
- .visible? ⇒ Boolean
- .wealth ⇒ Object
- .withdraw(amount) ⇒ Object
- .wounded? ⇒ Boolean
Class Method Details
.aim(location) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/Olib/character/char.rb', line 58 def Char.aim(location) unless @@aiming == location fput "aim #{location}" @@aiming = location end self end |
.arm ⇒ Object
24 25 26 27 |
# File 'lib/Olib/character/char.rb', line 24 def Char.arm fput "gird" self end |
.deplete_wealth(silvers) ⇒ Object
130 131 132 |
# File 'lib/Olib/character/char.rb', line 130 def Char.deplete_wealth(silvers) #@@silvers = @@silvers - silvers end |
.deposit(amt) ⇒ Object
111 112 113 114 115 116 117 118 119 |
# File 'lib/Olib/character/char.rb', line 111 def Char.deposit(amt) wealth if wealth >= amt Go2.bank fput "unhide" if invisible? || hidden? fput "deposit #{amt}" end return self end |
.deposit_all ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/Olib/character/char.rb', line 103 def Char.deposit_all Go2.bank fput "unhide" if invisible? || hidden? fput "deposit all" @@silvers = 0 return self end |
.empty_hands ⇒ Object
174 175 176 177 178 179 180 181 182 |
# File 'lib/Olib/character/char.rb', line 174 def Char.empty_hands hands = [Char.left, Char.right].compact hands.each do |hand| Containers.Lootsack.add hand end yield hands.each(&:take) end |
.fwi_teleporter ⇒ Object
66 67 68 |
# File 'lib/Olib/character/char.rb', line 66 def Char.fwi_teleporter Vars.teleporter || Vars.mapdb_fwi_trinket end |
.hide ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/Olib/character/char.rb', line 12 def Char.hide while not hiding? waitrt? if @@routines[:hiding] @@routines[:hiding].call else fput 'hide' end end Char end |
.hiding_routine(procedure) ⇒ Object
74 75 76 77 |
# File 'lib/Olib/character/char.rb', line 74 def Char.hiding_routine(procedure) @@routines[:hiding] = procedure Char end |
.in_town? ⇒ Boolean
79 80 81 |
# File 'lib/Olib/character/char.rb', line 79 def Char.in_town? Room.current.location =~ /the Adventurer's Guild|kharam|teras|landing|sol|icemule trace|mist|vaalor|illistim|rest|cysaegir|logoth/i end |
.left ⇒ Object
83 84 85 |
# File 'lib/Olib/character/char.rb', line 83 def Char.left GameObj.left_hand.name == "Empty" ? nil : Olib::Item.new(GameObj.left_hand) end |
.right ⇒ Object
87 88 89 |
# File 'lib/Olib/character/char.rb', line 87 def Char.right GameObj.right_hand.name == "Empty" ? nil : Olib::Item.new(GameObj.right_hand) end |
.share ⇒ Object
naive share does not check if you’re actually in a group or not
123 124 125 126 127 128 |
# File 'lib/Olib/character/char.rb', line 123 def Char.share wealth fput "share #{@silvers}" wealth self end |
.smart_wealth ⇒ Object
134 135 136 137 |
# File 'lib/Olib/character/char.rb', line 134 def Char.smart_wealth return @@silvers if @@silvers Char.wealth end |
.spell(num) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/Olib/character/char.rb', line 47 def Char.spell(num) hour, minutes, seconds = Spell[num].remaining.split(":").map(&:to_f) total_seconds = seconds + (minutes * 60.00) + (hour * 60.00 * 60.00) Duration.new( total_seconds, total_seconds/60, total_seconds/60/60, ) end |
.stand ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/Olib/character/char.rb', line 39 def Char.stand unless standing? fput "stand" waitrt? end self end |
.swap ⇒ Object
34 35 36 37 |
# File 'lib/Olib/character/char.rb', line 34 def Char.swap fput "swap" self end |
.total_wound_severity ⇒ Object
165 166 167 168 |
# File 'lib/Olib/character/char.rb', line 165 def Char.total_wound_severity INJURIES .reduce(0) do |sum, method| sum + Wounds.send(method) end end |
.unarm ⇒ Object
29 30 31 32 |
# File 'lib/Olib/character/char.rb', line 29 def Char.unarm fput "store both" self end |
.unhide ⇒ Object
139 140 141 142 |
# File 'lib/Olib/character/char.rb', line 139 def Char.unhide fput 'unhide' if Spell[916].active? or hidden? self end |
.visible? ⇒ Boolean
70 71 72 |
# File 'lib/Olib/character/char.rb', line 70 def Char.visible? hiding? || invisible? end |
.wealth ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/Olib/character/char.rb', line 152 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
91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/Olib/character/char.rb', line 91 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 |
.wounded? ⇒ Boolean
170 171 172 |
# File 'lib/Olib/character/char.rb', line 170 def Char.wounded? total_wound_severity.gt(0) end |