mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 16:49:11 +00:00
Update all plugins to conform to Rubocop.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
GEMSTONES = {}
|
||||
|
||||
# A gemstone that can be received when mining.
|
||||
class Gemstone
|
||||
attr_reader :id, :chance
|
||||
|
||||
@@ -9,11 +10,11 @@ class Gemstone
|
||||
end
|
||||
end
|
||||
|
||||
def append_gem(gem)
|
||||
def gem(gem)
|
||||
GEMSTONES[gem.id] = gem
|
||||
end
|
||||
|
||||
append_gem(Gemstone.new(1623, 0)) # uncut sapphire
|
||||
append_gem(Gemstone.new(1605, 0)) # uncut emerald
|
||||
append_gem(Gemstone.new(1619, 0)) # uncut ruby
|
||||
append_gem(Gemstone.new(1617, 0)) # uncut diamond
|
||||
gem(Gemstone.new(1623, 0)) # uncut sapphire
|
||||
gem(Gemstone.new(1605, 0)) # uncut emerald
|
||||
gem(Gemstone.new(1619, 0)) # uncut ruby
|
||||
gem(Gemstone.new(1617, 0)) # uncut diamond
|
||||
|
||||
@@ -8,6 +8,7 @@ PROSPECT_PULSES = 3
|
||||
ORE_SIZE = 1
|
||||
|
||||
# TODO: finish implementing this
|
||||
# A `DistancedAction` for mining ore.
|
||||
class MiningAction < DistancedAction
|
||||
attr_reader :position, :ore, :counter, :started
|
||||
|
||||
@@ -21,9 +22,11 @@ class MiningAction < DistancedAction
|
||||
|
||||
def find_pickaxe
|
||||
weapon = mob.equipment.get(EquipmentConstants::WEAPON)
|
||||
PICKAXE_IDS.each { |id| return PICKAXES[id] if (!weapon.nil? && weapon.id == id) || mob.inventory.contains(id) }
|
||||
PICKAXE_IDS.each do |id|
|
||||
return PICKAXES[id] if (!weapon.nil? && weapon.id == id) || mob.inventory.contains(id)
|
||||
end
|
||||
|
||||
return nil
|
||||
nil
|
||||
end
|
||||
|
||||
# starts the mining animation, sets counters/flags and turns the mob to
|
||||
@@ -42,7 +45,7 @@ class MiningAction < DistancedAction
|
||||
mob.turn_to(@position)
|
||||
|
||||
# verify the mob can mine with their pickaxe
|
||||
unless (!pickaxe.nil? and level >= pickaxe.level)
|
||||
if pickaxe.nil? || level < pickaxe.level
|
||||
mob.send_message('You do not have a pickaxe for which you have the level to use.')
|
||||
stop
|
||||
return
|
||||
@@ -56,9 +59,7 @@ class MiningAction < DistancedAction
|
||||
end
|
||||
|
||||
# check if we need to kick start things
|
||||
unless @started
|
||||
start_mine(pickaxe)
|
||||
else
|
||||
if @started
|
||||
# count down and check if we can have a chance at some ore now
|
||||
if @counter == 0
|
||||
# TODO: calculate the chance that the player can actually get the rock
|
||||
@@ -73,16 +74,20 @@ class MiningAction < DistancedAction
|
||||
|
||||
stop
|
||||
end
|
||||
@counter -= 1
|
||||
end
|
||||
|
||||
@counter -= 1
|
||||
else
|
||||
start_mine(pickaxe)
|
||||
end
|
||||
end
|
||||
|
||||
def equals(other)
|
||||
return (get_class == other.get_class and @position == other.position and @ore == other.ore)
|
||||
get_class == other.get_class && @position == other.position && @ore == other.ore
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# A `DistancedAction` for a rock with no available ore.
|
||||
class ExpiredProspectingAction < DistancedAction
|
||||
attr_reader :position
|
||||
|
||||
@@ -96,11 +101,12 @@ class ExpiredProspectingAction < DistancedAction
|
||||
end
|
||||
|
||||
def equals(other)
|
||||
return (get_class == other.get_class and @position == other.position)
|
||||
get_class == other.get_class && @position == other.position
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# A `DistancedAction` for prospecting a rock.
|
||||
class ProspectingAction < DistancedAction
|
||||
attr_reader :position, :ore
|
||||
|
||||
@@ -112,22 +118,22 @@ class ProspectingAction < DistancedAction
|
||||
end
|
||||
|
||||
def executeAction
|
||||
unless @started
|
||||
@started = true
|
||||
|
||||
mob.send_message('You examine the rock for ores...')
|
||||
mob.turn_to(@position)
|
||||
else
|
||||
if @started
|
||||
ore_def = ItemDefinition.lookup(@ore.id)
|
||||
name = ore_def.name.sub(/ ore$/, '').downcase
|
||||
|
||||
mob.send_message("This rock contains #{name}.")
|
||||
stop
|
||||
else
|
||||
@started = true
|
||||
|
||||
mob.send_message('You examine the rock for ores...')
|
||||
mob.turn_to(@position)
|
||||
end
|
||||
end
|
||||
|
||||
def equals(other)
|
||||
return (get_class == other.get_class and @position == other.position and @ore == other.ore)
|
||||
get_class == other.get_class && @position == other.position && @ore == other.ore
|
||||
end
|
||||
|
||||
end
|
||||
@@ -135,9 +141,7 @@ end
|
||||
on :message, :first_object_action do |mob, message|
|
||||
ore = ORES[message.id]
|
||||
|
||||
unless ore.nil?
|
||||
mob.start_action(MiningAction.new(mob, message.position, ore))
|
||||
end
|
||||
mob.start_action(MiningAction.new(mob, message.position, ore)) unless ore.nil?
|
||||
end
|
||||
|
||||
on :message, :second_object_action do |mob, message|
|
||||
@@ -148,4 +152,4 @@ on :message, :second_object_action do |mob, message|
|
||||
elsif !EXPIRED_ORES[message.id].nil?
|
||||
mob.start_action(ExpiredProspectingAction.new(mob, message.position))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
ORES = {}
|
||||
EXPIRED_ORES = {}
|
||||
|
||||
# An ore that can be mined.
|
||||
class Ore
|
||||
attr_reader :id, :objects, :level, :exp, :respawn
|
||||
|
||||
@@ -27,70 +28,68 @@ def append_ore(ore)
|
||||
end
|
||||
|
||||
CLAY_OBJECTS = {
|
||||
2180 => 450 , 2109 => 451 , 14904 => 14896, 14905 => 14897
|
||||
2180 => 450, 2109 => 451, 14_904 => 14_896, 14_905 => 14_897
|
||||
}
|
||||
|
||||
COPPER_OBJECTS = {
|
||||
11960 => 11555, 11961 => 11556, 11962 => 11557, 11936 => 11552,
|
||||
11937 => 11553, 11938 => 11554, 2090 => 450 , 2091 => 451 ,
|
||||
14906 => 14898, 14907 => 14899, 14856 => 14832, 14857 => 14833,
|
||||
14858 => 14834
|
||||
11_960 => 11_555, 11_961 => 11_556, 11_962 => 11_557, 11_936 => 11_552,
|
||||
11_937 => 11_553, 11_938 => 11_554, 2090 => 450, 2091 => 451,
|
||||
14_906 => 14_898, 14_907 => 14_899, 14_856 => 14_832, 14_857 => 14_833,
|
||||
14_858 => 14_834
|
||||
}
|
||||
|
||||
TIN_OBJECTS = {
|
||||
11597 => 11555, 11958 => 11556, 11959 => 11557, 11933 => 11552,
|
||||
11934 => 11553, 11935 => 11554, 2094 => 450 , 2095 => 451 ,
|
||||
14092 => 14894, 14903 => 14895
|
||||
11_597 => 11_555, 11_958 => 11_556, 11_959 => 11_557, 11_933 => 11_552,
|
||||
11_934 => 11_553, 11_935 => 11_554, 2094 => 450, 2095 => 451,
|
||||
14_092 => 14_894, 14_903 => 14_895
|
||||
}
|
||||
|
||||
IRON_OBJECTS = {
|
||||
11954 => 11555, 11955 => 11556, 11956 => 11557, 2092 => 450 ,
|
||||
2093 => 451 , 14900 => 14892, 14901 => 14893, 14913 => 14915,
|
||||
14914 => 14916
|
||||
11_954 => 11_555, 11_955 => 11_556, 11_956 => 11_557, 2092 => 450,
|
||||
2093 => 451, 14_900 => 14_892, 14_901 => 14_893, 14_913 => 14_915,
|
||||
14_914 => 14_916
|
||||
}
|
||||
|
||||
COAL_OBJECTS = {
|
||||
11963 => 11555, 11964 => 11556, 11965 => 11557, 11930 => 11552,
|
||||
11931 => 11553, 11932 => 11554, 2096 => 450 , 2097 => 451 ,
|
||||
14850 => 14832, 14851 => 14833, 14852 => 14834
|
||||
11_963 => 11_555, 11_964 => 11_556, 11_965 => 11_557, 11_930 => 11_552,
|
||||
11_931 => 11_553, 11_932 => 11_554, 2096 => 450, 2097 => 451,
|
||||
14_850 => 14_832, 14_851 => 14_833, 14_852 => 14_834
|
||||
}
|
||||
|
||||
SILVER_OBJECTS = {
|
||||
11948 => 11555, 11949 => 11556, 11950 => 11557, 2100 => 450 ,
|
||||
2101 => 451
|
||||
11_948 => 11_555, 11_949 => 11_556, 11_950 => 11_557, 2100 => 450, 2101 => 451
|
||||
}
|
||||
|
||||
GOLD_OBJECTS = {
|
||||
11951 => 11555, 11952 => 11556, 11953 => 11557, 2098 => 450 ,
|
||||
2099 => 451
|
||||
11_951 => 11_555, 11_952 => 11_556, 11_953 => 11_557, 2098 => 450, 2099 => 451
|
||||
}
|
||||
|
||||
MITHRIL_OBJECTS = {
|
||||
11945 => 11555, 11946 => 11556, 11947 => 11557, 11942 => 11552,
|
||||
11943 => 11553, 11944 => 11554, 2102 => 450 , 2103 => 451 ,
|
||||
14853 => 14832, 14854 => 14833, 14855 => 14834
|
||||
11_945 => 11_555, 11_946 => 11_556, 11_947 => 11_557, 11_942 => 11_552,
|
||||
11_943 => 11_553, 11_944 => 11_554, 2102 => 450, 2103 => 451,
|
||||
14_853 => 14_832, 14_854 => 14_833, 14_855 => 14_834
|
||||
}
|
||||
|
||||
ADAMANT_OBJECTS = {
|
||||
11939 => 11552, 11940 => 11553, 11941 => 11554, 2104 => 450 ,
|
||||
2105 => 451 , 14862 => 14832, 14863 => 14833, 14864 => 14834
|
||||
11_939 => 11_552, 11_940 => 11_553, 11_941 => 11_554, 2104 => 450,
|
||||
2105 => 451, 14_862 => 14_832, 14_863 => 14_833, 14_864 => 14_834
|
||||
}
|
||||
|
||||
RUNITE_OBJECTS = {
|
||||
2106 => 450 , 2107 => 451 , 14859 => 14832, 14860 => 14833,
|
||||
14861 => 14834
|
||||
2106 => 450, 2107 => 451, 14_859 => 14_832, 14_860 => 14_833,
|
||||
14_861 => 14_834
|
||||
}
|
||||
|
||||
append_ore Ore.new(434, CLAY_OBJECTS, 1, 5, 3 ) # clay
|
||||
append_ore Ore.new(436, COPPER_OBJECTS, 1, 17.5, 6 ) # copper ore
|
||||
append_ore Ore.new(438, TIN_OBJECTS, 1, 17.5, 6 ) # tin ore
|
||||
append_ore Ore.new(440, IRON_OBJECTS, 15, 35, 16 ) # iron ore
|
||||
append_ore Ore.new(453, COAL_OBJECTS, 30, 50, 100 ) # coal
|
||||
append_ore Ore.new(444, GOLD_OBJECTS, 40, 65, 200 ) # gold ore
|
||||
append_ore Ore.new(442, SILVER_OBJECTS, 20, 40, 200 ) # silver ore
|
||||
append_ore Ore.new(447, MITHRIL_OBJECTS, 55, 80, 400 ) # mithril ore
|
||||
append_ore Ore.new(449, ADAMANT_OBJECTS, 70, 95, 800 ) # adamant ore
|
||||
append_ore Ore.new(451, RUNITE_OBJECTS, 85, 125, 2500) # runite ore
|
||||
append_ore Ore.new 434, CLAY_OBJECTS, 1, 5, 3 # clay
|
||||
append_ore Ore.new 436, COPPER_OBJECTS, 1, 17.5, 6 # copper ore
|
||||
append_ore Ore.new 438, TIN_OBJECTS, 1, 17.5, 6 # tin ore
|
||||
append_ore Ore.new 440, IRON_OBJECTS, 15, 35, 16 # iron ore
|
||||
append_ore Ore.new 453, COAL_OBJECTS, 30, 50, 100 # coal
|
||||
append_ore Ore.new 444, GOLD_OBJECTS, 40, 65, 200 # gold ore
|
||||
append_ore Ore.new 442, SILVER_OBJECTS, 20, 40, 200 # silver ore
|
||||
append_ore Ore.new 447, MITHRIL_OBJECTS, 55, 80, 400 # mithril ore
|
||||
append_ore Ore.new 449, ADAMANT_OBJECTS, 70, 95, 800 # adamant ore
|
||||
append_ore Ore.new 451, RUNITE_OBJECTS, 85, 125, 2500 # runite ore
|
||||
|
||||
# TODO: rune essence object id = 2491
|
||||
# level 1, exp 5, rune ess = 1436, pure ess = 7936
|
||||
# level 1, exp 5, rune ess = 1436, pure ess = 7936
|
||||
|
||||
@@ -5,6 +5,7 @@ java_import 'org.apollo.game.model.Animation'
|
||||
PICKAXES = {}
|
||||
PICKAXE_IDS = []
|
||||
|
||||
# A pickaxe that can be mined with.
|
||||
class Pickaxe
|
||||
attr_reader :id, :level, :animation, :pulses
|
||||
|
||||
@@ -29,4 +30,4 @@ append_pickaxe(Pickaxe.new(1273, 21, 629, 5)) # mithril pickaxe
|
||||
append_pickaxe(Pickaxe.new(1271, 31, 628, 4)) # adamant pickaxe
|
||||
append_pickaxe(Pickaxe.new(1275, 41, 624, 3)) # rune pickaxe
|
||||
|
||||
PICKAXE_IDS.reverse!
|
||||
PICKAXE_IDS.reverse!
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
# pulses down where appropriate.
|
||||
def respawn_pulses(base, players)
|
||||
base - players * base / ($world.player_repository.size * 2)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user