Update all plugins to conform to Rubocop.

This commit is contained in:
Major-
2015-08-27 18:17:58 +01:00
parent 424d2bda29
commit 8f3fd75b33
75 changed files with 1625 additions and 1537 deletions
+10 -7
View File
@@ -3,10 +3,11 @@ require 'java'
# A map of item ids to consumables.
CONSUMABLES = {}
# The id of the food consumption animation.
CONSUME_ANIMATION_ID = 829
# An item that can be consumed to produce a skill effect.
class Consumable
class Consumable
attr_reader :name, :id, :sound
def initialize(name, id, sound)
@@ -15,8 +16,8 @@ class Consumable
@sound = sound
end
def consume(player)
# Override to provide specific functionality.
def consume(_player)
# Override to provide specific functionality.
end
end
@@ -26,6 +27,7 @@ def append_consumable(consumable)
CONSUMABLES[consumable.id] = consumable
end
# An Action used for food consumption.
class ConsumeAction < Action
attr_reader :consumable
@@ -36,10 +38,11 @@ class ConsumeAction < Action
@executions = 0
end
def execute()
def execute
if @executions == 0
mob.inventory.reset(@slot)
@consumable.consume(mob)
mob.play_animation(Animation.new(CONSUME_ANIMATION_ID))
@executions += 1
else
@@ -48,9 +51,9 @@ class ConsumeAction < Action
end
def equals(other)
return (mob == other.mob && @consumable.id == other.consumable.id)
mob == other.mob && @consumable.id == other.consumable.id
end
end
# Intercepts the first item option message and consumes the consumable, if necessary.
@@ -61,4 +64,4 @@ on :message, :first_item_option do |player, message|
player.start_action(ConsumeAction.new(player, message.slot, consumable))
message.terminate
end
end
end
+183 -178
View File
@@ -6,10 +6,11 @@ java_import 'org.apollo.game.model.entity.Player'
private
# The id the of the sound made when eating food.
EAT_FOOD_SOUND = 317
# Represents an edible piece of food, such as bread or fish.
# TODO delay eating times
# TODO: delay eating times
class Food < Consumable
def initialize(name, id, restoration, replace)
@@ -21,221 +22,225 @@ class Food < Consumable
# Restore the appropriate amount of hitpoints when consumed.
def consume(player)
hitpoints = player.skill_set.skill(Skill::HITPOINTS)
new_curr = [ hitpoints.current_level + @restoration, hitpoints.maximum_level ].min
new_curr = [hitpoints.current_level + @restoration, hitpoints.maximum_level].min
player.inventory.add(@replace) unless (@replace == -1)
player.inventory.add(@replace) unless @replace == -1
player.send_message("You eat the #{name}.", true)
player.send_message("It heals some health.", true) if new_curr == hitpoints
player.send_message('It heals some health.', true) if new_curr == hitpoints
player.skill_set.set_skill(Skill::HITPOINTS, Skill.new(hitpoints.experience, new_curr, hitpoints.maximum_level))
skill = Skill.new(hitpoints.experience, new_curr, hitpoints.maximum_level)
player.skill_set.set_skill(Skill::HITPOINTS, skill)
end
end
# The default delay before a piece of food is eaten
DEFAULT_DELAY = 3
# Appends a food item to the list of consumables.
def food(hash)
raise 'Hash must contain a name, id, and a restoration value.' unless (hash.has_keys?(:name, :id, :restoration))
name = hash[:name]; id = hash[:id]; restoration = hash[:restoration]; replace = hash[:replace] || -1; @delay = hash[:delay] || 3
unless hash.has_keys?(:name, :id, :restoration)
fail 'Hash must contain a name, id, and a restoration value.'
end
name, id, restoration = hash[:name], hash[:id], hash[:restoration];
replace = hash[:replace] || -1
delay = hash[:delay] || DEFAULT_DELAY # TODO: ??
append_consumable(Food.new(name, id, restoration, replace))
end
# TODO special effects
food :name => :cooked_slimy_eel, :id => 3381, :restoration => 6 # this has a chance to heal 6 to 10 hp
food :name => :thin_snail_meat, :id => 3369, :restoration => 5 # this has a chance to heal 5 to 7 hp
food :name => :fat_snail_meat, :id => 3373, :restoration => 2 # this has a chance to heal 7 to 9 hp
food :name => :watermelon_slice, :id => 5984, :restoration => 0 # this heals 5% of player's life
food :name => :cooked_karambwan, :id => 3146, :restoration => 0 # poisons player(50)
food :name => :spider_on_stick, :id => 6297, :restoration => 7 # heals between 7 and 10
food :name => :spider_on_shaft, :id => 6299, :restoration => 7 # heals between 7 and 10
# TODO: special effects
food name: :cooked_slimy_eel, id: 3381, restoration: 6 # this has a chance to heal 6 to 10 hp
food name: :thin_snail_meat, id: 3369, restoration: 5 # this has a chance to heal 5 to 7 hp
food name: :fat_snail_meat, id: 3373, restoration: 2 # this has a chance to heal 7 to 9 hp
food name: :watermelon_slice, id: 5984, restoration: 0 # this heals 5% of player's life
food name: :cooked_karambwan, id: 3146, restoration: 0 # poisons player(50)
food name: :spider_on_stick, id: 6297, restoration: 7 # heals between 7 and 10
food name: :spider_on_shaft, id: 6299, restoration: 7 # heals between 7 and 10
# Meats/Fish
food :name => :anchovies, :id => 319, :restoration => 1
food :name => :crab_meat, :id => 7521, :restoration => 2, :replace => 7523
food :name => :crab_meat, :id => 7523, :restoration => 2, :replace => 7524
food :name => :crab_meat, :id => 7524, :restoration => 2, :replace => 7525
food :name => :crab_meat, :id => 7525, :restoration => 2, :replace => 7526
food :name => :crab_meat, :id => 7526, :restoration => 2
food :name => :shrimp, :id => 315, :restoration => 3
food :name => :sardine, :id => 325, :restoration => 3
food :name => :cooked_meat, :id => 2142, :restoration => 3
food :name => :cooked_chicken, :id => 2140, :restoration => 3
food :name => :ugthanki_meat, :id => 1861, :restoration => 3
food :name => :karambwanji, :id => 3151, :restoration => 3
food :name => :cooked_rabbit, :id => 3228, :restoration => 5
food :name => :herring, :id => 347, :restoration => 6
food :name => :trout, :id => 333, :restoration => 7
food :name => :cod, :id => 339, :restoration => 7
food :name => :mackeral, :id => 355, :restoration => 7
food :name => :roast_rabbit, :id => 7223, :restoration => 7
food :name => :pike, :id => 351, :restoration => 8
food :name => :lean_snail_meat, :id => 3371, :restoration => 8
food :name => :salmon, :id => 329, :restoration => 9
food :name => :tuna, :id => 361, :restoration => 10
food :name => :lobster, :id => 379, :restoration => 12
food :name => :bass, :id => 365, :restoration => 13
food :name => :swordfish, :id => 373, :restoration => 14
food :name => :cooked_jubbly, :id => 7568, :restoration => 15
food :name => :monkfish, :id => 7946, :restoration => 16
food :name => :cooked_karambwan, :id => 3144, :restoration => 18
food :name => :shark, :id => 385, :restoration => 20
food :name => :sea_turtle, :id => 397, :restoration => 21
food :name => :manta_ray, :id => 391, :restoration => 22
# Meats/Fish
food name: :anchovies, id: 319, restoration: 1
food name: :crab_meat, id: 7521, restoration: 2, replace: 7523
food name: :crab_meat, id: 7523, restoration: 2, replace: 7524
food name: :crab_meat, id: 7524, restoration: 2, replace: 7525
food name: :crab_meat, id: 7525, restoration: 2, replace: 7526
food name: :crab_meat, id: 7526, restoration: 2
food name: :shrimp, id: 315, restoration: 3
food name: :sardine, id: 325, restoration: 3
food name: :cooked_meat, id: 2142, restoration: 3
food name: :cooked_chicken, id: 2140, restoration: 3
food name: :ugthanki_meat, id: 1861, restoration: 3
food name: :karambwanji, id: 3151, restoration: 3
food name: :cooked_rabbit, id: 3228, restoration: 5
food name: :herring, id: 347, restoration: 6
food name: :trout, id: 333, restoration: 7
food name: :cod, id: 339, restoration: 7
food name: :mackeral, id: 355, restoration: 7
food name: :roast_rabbit, id: 7223, restoration: 7
food name: :pike, id: 351, restoration: 8
food name: :lean_snail_meat, id: 3371, restoration: 8
food name: :salmon, id: 329, restoration: 9
food name: :tuna, id: 361, restoration: 10
food name: :lobster, id: 379, restoration: 12
food name: :bass, id: 365, restoration: 13
food name: :swordfish, id: 373, restoration: 14
food name: :cooked_jubbly, id: 7568, restoration: 15
food name: :monkfish, id: 7946, restoration: 16
food name: :cooked_karambwan, id: 3144, restoration: 18
food name: :shark, id: 385, restoration: 20
food name: :sea_turtle, id: 397, restoration: 21
food name: :manta_ray, id: 391, restoration: 22
# Breads/Wraps
food :name => :bread, :id => 2309, :restoration => 5
food :name => :oomlie_wrap, :id => 2343, :restoration => 14
food :name => :ugthanki_kebab, :id => 1883, :restoration => 19
# Breads/Wraps
food name: :bread, id: 2309, restoration: 5
food name: :oomlie_wrap, id: 2343, restoration: 14
food name: :ugthanki_kebab, id: 1883, restoration: 19
# Fruits
food :name => :banana, :id => 1963, :restoration => 2
food :name => :sliced_banana, :id => 3162, :restoration => 2
food :name => :lemon, :id => 2102, :restoration => 2
food :name => :lemon_chunks, :id => 2104, :restoration => 2
food :name => :lemon_slices, :id => 2106, :restoration => 2
food :name => :lime, :id => 2120, :restoration => 2
food :name => :lime_chunks, :id => 2122, :restoration => 2
food :name => :lime_slices, :id => 2124, :restoration => 2
food :name => :strawberry, :id => 5504, :restoration => 5
food :name => :papaya_fruit, :id => 5972, :restoration => 8
food :name => :pineapple_chunks, :id => 2116, :restoration => 2
food :name => :pineapple_ring, :id => 2118, :restoration => 2
food :name => :orange, :id => 2108, :restoration => 2
food :name => :orange_rings, :id => 2110, :restoration => 2
food :name => :orange_slices, :id => 2112, :restoration => 2
# Fruits
food name: :banana, id: 1963, restoration: 2
food name: :sliced_banana, id: 3162, restoration: 2
food name: :lemon, id: 2102, restoration: 2
food name: :lemon_chunks, id: 2104, restoration: 2
food name: :lemon_slices, id: 2106, restoration: 2
food name: :lime, id: 2120, restoration: 2
food name: :lime_chunks, id: 2122, restoration: 2
food name: :lime_slices, id: 2124, restoration: 2
food name: :strawberry, id: 5504, restoration: 5
food name: :papaya_fruit, id: 5972, restoration: 8
food name: :pineapple_chunks, id: 2116, restoration: 2
food name: :pineapple_ring, id: 2118, restoration: 2
food name: :orange, id: 2108, restoration: 2
food name: :orange_rings, id: 2110, restoration: 2
food name: :orange_slices, id: 2112, restoration: 2
# Pies
# TODO: pie special effects (e.g. fish pie raises fishing level)
food name: :redberry_pie, id: 2325, restoration: 5, replace: 2333, delay: 1
food name: :redberry_pie, id: 2333, restoration: 5, delay: 1
# Pies
#TODO Special Effects on pies (i.e.fish pie raises fishing level)
food :name => :redberry_pie, :id => 2325, :restoration => 5, :replace => 2333, :delay => 1
food :name => :redberry_pie, :id => 2333, :restoration => 5, :delay => 1
food name: :meat_pie, id: 2327, restoration: 6, replace: 2331, delay: 1
food name: :meat_pie, id: 2331, restoration: 6, delay: 1
food :name => :meat_pie, :id => 2327, :restoration => 6, :replace => 2331, :delay => 1
food :name => :meat_pie, :id => 2331, :restoration => 6, :delay => 1
food name: :apple_pie, id: 2323, restoration: 7, replace: 2335, delay: 1
food name: :apple_pie, id: 2335, restoration: 7, delay: 1
food :name => :apple_pie, :id => 2323, :restoration => 7, :replace => 2335, :delay => 1
food :name => :apple_pie, :id => 2335, :restoration => 7, :delay => 1
food name: :fish_pie, id: 7188, restoration: 6, replace: 7190, delay: 1
food name: :fish_pie, id: 7190, restoration: 6, delay: 1
food :name => :fish_pie, :id => 7188, :restoration => 6, :replace => 7190, :delay => 1
food :name => :fish_pie, :id => 7190, :restoration => 6, :delay => 1
food name: :admiral_pie, id: 7198, restoration: 8, replace: 7200, delay: 1
food name: :admiral_pie, id: 7200, restoration: 8, delay: 1
food :name => :admiral_pie, :id => 7198, :restoration => 8, :replace => 7200, :delay => 1
food :name => :admiral_pie, :id => 7200, :restoration => 8, :delay => 1
food name: :wild_pie, id: 7208, restoration: 11, replace: 7210, delay: 1
food name: :wild_pie, id: 7210, restoration: 11, delay: 1
food :name => :wild_pie, :id => 7208, :restoration => 11, :replace => 7210, :delay => 1
food :name => :wild_pie, :id => 7210, :restoration => 11, :delay => 1
food name: :summer_pie, id: 7218, restoration: 11, replace: 7220, delay: 1
food name: :summer_pie, id: 7220, restoration: 11, delay: 1
food :name => :summer_pie, :id => 7218, :restoration => 11, :replace => 7220, :delay => 1
food :name => :summer_pie, :id => 7220, :restoration => 11, :delay => 1
# Stews
food name: :stew, id: 2003, restoration: 11
food name: :banana_stew, id: 4016, restoration: 11
food name: :curry, id: 2011, restoration: 19
# Stews
food :name => :stew, :id => 2003, :restoration => 11
food :name => :banana_stew, :id => 4016, :restoration => 11
food :name => :curry, :id => 2011, :restoration => 19
# Pizzas
food name: :plain_pizza, id: 2289, restoration: 7, replace: 2291
food name: :plain_pizza, id: 2291, restoration: 7
# Pizzas
food :name => :plain_pizza, :id => 2289, :restoration => 7, :replace => 2291
food :name => :plain_pizza, :id => 2291, :restoration => 7
food name: :meat_pizza, id: 2293, restoration: 8, replace: 2295
food name: :meat_pizza, id: 2295, restoration: 8
food :name => :meat_pizza, :id => 2293, :restoration => 8, :replace => 2295
food :name => :meat_pizza, :id => 2295, :restoration => 8
food name: :anchovy_pizza, id: 2297, restoration: 9, replace: 2299
food name: :anchovy_pizza, id: 2299, restoration: 9
food :name => :anchovy_pizza, :id => 2297, :restoration => 9, :replace => 2299
food :name => :anchovy_pizza, :id => 2299, :restoration => 9
food name: :pineapple_pizza, id: 2301, restoration: 11, replace: 2303
food name: :pineapple_pizza, id: 2303, restoration: 11
food :name => :pineapple_pizza, :id => 2301, :restoration => 11, :replace => 2303
food :name => :pineapple_pizza, :id => 2303, :restoration => 11
# Cakes
food name: :fishcake, id: 7530, restoration: 11
# Cakes
food :name => :fishcake, :id => 7530, :restoration => 11
food name: :cake, id: 1891, restoration: 4, replace: 1893
food name: :cake, id: 1893, restoration: 4, replace: 1895
food name: :cake, id: 1895, restoration: 4
food :name => :cake, :id => 1891, :restoration => 4, :replace => 1893
food :name => :cake, :id => 1893, :restoration => 4, :replace => 1895
food :name => :cake, :id => 1895, :restoration => 4
food name: :chocolate_cake, id: 1897, restoration: 5, replace: 1899
food name: :chocolate_cake, id: 1899, restoration: 5, replace: 1901
food name: :chocolate_cake, id: 1901, restoration: 5
food :name => :chocolate_cake, :id => 1897, :restoration => 5, :replace => 1899
food :name => :chocolate_cake, :id => 1899, :restoration => 5, :replace => 1901
food :name => :chocolate_cake, :id => 1901, :restoration => 5
# Wine
# TODO: Add to drinks.rb?
food name: :jug_of_wine, id: 1993, restoration: 11
# Wine
# Add to drinks.rb?
food :name => :jug_of_wine, :id => 1993, :restoration => 11
# Hot Drinks
# TODO: Add to drinks.rb?
food name: :nettle_tea, id: 4239, restoration: 3
food name: :nettle_tea, id: 4240, restoration: 3
# Hot Drinks
# Add to drinks.rb?
food :name => :nettle_tea, :id => 4239, :restoration => 3
food :name => :nettle_tea, :id => 4240, :restoration => 3
# Vegetables
food name: :potato, id: 1942, restoration: 1
food name: :spinach_roll, id: 1969, restoration: 2
food name: :baked_potato, id: 6701, restoration: 4
food name: :sweetcorn, id: 5988, restoration: 10
food name: :sweetcorn_bowl, id: 7088, restoration: 13
food name: :potato_with_butter, id: 6703, restoration: 14
food name: :chili_potato, id: 7054, restoration: 14
food name: :potato_with_cheese, id: 6705, restoration: 16
food name: :egg_potato, id: 7056, restoration: 16
food name: :mushroom_potato, id: 7058, restoration: 20
food name: :tuna_potato, id: 7060, restoration: 22
# Vegetables
food :name => :potato, :id => 1942, :restoration => 1
food :name => :spinach_roll, :id => 1969, :restoration => 2
food :name => :baked_potato, :id => 6701, :restoration => 4
food :name => :sweetcorn, :id => 5988, :restoration => 10
food :name => :sweetcorn_bowl, :id => 7088, :restoration => 13
food :name => :potato_with_butter, :id => 6703, :restoration => 14
food :name => :chili_potato, :id => 7054, :restoration => 14
food :name => :potato_with_cheese, :id => 6705, :restoration => 16
food :name => :egg_potato, :id => 7056, :restoration => 16
food :name => :mushroom_potato, :id => 7058, :restoration => 20
food :name => :tuna_potato, :id => 7060, :restoration => 22
# Dairy
food name: :cheese, id: 1985, restoration: 2
food name: :pot_of_cream, id: 2130, restoration: 1
# Dairy
food :name => :cheese, :id => 1985, :restoration => 2
food :name => :pot_of_cream, :id => 2130, :restoration => 1
# Gnome Food
food name: :toads_legs, id: 2152, restoration: 3
# Gnome Food
food :name => :toads_legs, :id => 2152, :restoration => 3
# Gnome Bowls
food name: :worm_hole, id: 2191, restoration: 12
food name: :worm_hole, id: 2233, restoration: 12
food name: :vegetable_ball, id: 2195, restoration: 12
food name: :vegetable_ball, id: 2235, restoration: 12
food name: :tangled_toads_legs, id: 2187, restoration: 15
food name: :tangled_toads_legs, id: 2231, restoration: 15
food name: :chocolate_bomb, id: 2185, restoration: 15
food name: :chocolate_bomb, id: 2229, restoration: 15
# Gnome Bowls
food :name => :worm_hole, :id => 2191, :restoration => 12
food :name => :worm_hole, :id => 2233, :restoration => 12
food :name => :vegetable_ball, :id => 2195, :restoration => 12
food :name => :vegetable_ball, :id => 2235, :restoration => 12
food :name => :tangled_toads_legs, :id => 2187, :restoration => 15
food :name => :tangled_toads_legs, :id => 2231, :restoration => 15
food :name => :chocolate_bomb, :id => 2185, :restoration => 15
food :name => :chocolate_bomb, :id => 2229, :restoration => 15
# Gnome Crunchies
food :name => :toad_crunchies, :id => 2217, :restoration => 7
food :name => :toad_crunchies, :id => 2243, :restoration => 7
food :name => :spicy_crunchies, :id => 2213, :restoration => 7
food :name => :spicy_crunchies, :id => 2241, :restoration => 7
food :name => :worm_crunchies, :id => 2205, :restoration => 8
food :name => :worm_crunchies, :id => 2237, :restoration => 8
food :name => :chocchip_crunchies, :id => 2209, :restoration => 7
food :name => :chocchip_crunchies, :id => 2239, :restoration => 7
# Gnome Battas
food :name => :fruit_batta, :id => 2225, :restoration => 11
food :name => :fruit_batta, :id => 2277, :restoration => 11
food :name => :toad_batta, :id => 2221, :restoration => 11
food :name => :toad_batta, :id => 2255, :restoration => 11
food :name => :worm_batta, :id => 2219, :restoration => 11
food :name => :worm_batta, :id => 2253, :restoration => 11
food :name => :vegetable_batta, :id => 2227, :restoration => 11
food :name => :vegetable_batta, :id => 2281, :restoration => 11
food :name => :cheese_tom_batta, :id => 2223, :restoration => 11
food :name => :cheese_tom_batta, :id => 2259, :restoration => 11
# Gnome Cocktails
# Make new drink.rb file for drinks? That way it's seperated from food and says You drink, instead of you eat :{name}.
food :name => :fruit_blast, :id => 2034, :restoration => 9
food :name => :fruit_blast, :id => 2084, :restoration => 9
food :name => :pineapple_punch, :id => 2036, :restoration => 9
food :name => :pineapple_punch, :id => 2048, :restoration => 9
food :name => :wizard_blizzard, :id => 2040, :restoration => 5 # -4attack,+5strength also
food :name => :wizard_blizzard, :id => 2054, :restoration => 5 # -4attack,+5strength also
food :name => :short_green_guy, :id => 2038, :restoration => 5 # -4attack,+5strength also
food :name => :short_green_guy, :id => 2080, :restoration => 5 # -4attack,+5strength also
food :name => :drunk_dragon, :id => 2032, :restoration => 5 # -4attack,+6strength also
food :name => :drunk_dragon, :id => 2092, :restoration => 5 # -4attack,+6strength also
food :name => :chocolate_saturday, :id => 2030, :restoration => 7 # -4attack,+6strength also
food :name => :chocolate_saturday, :id => 2074, :restoration => 7 # -4attack,+6strength also
food :name => :blurberry_special, :id => 2028, :restoration => 7 # -4attack,+6strength also
food :name => :blurberry_special, :id => 2064, :restoration => 7 # -4attack,+6strength also
# Misc
# Gnome Crunchies
food name: :toad_crunchies, id: 2217, restoration: 7
food name: :toad_crunchies, id: 2243, restoration: 7
food name: :spicy_crunchies, id: 2213, restoration: 7
food name: :spicy_crunchies, id: 2241, restoration: 7
food name: :worm_crunchies, id: 2205, restoration: 8
food name: :worm_crunchies, id: 2237, restoration: 8
food name: :chocchip_crunchies, id: 2209, restoration: 7
food name: :chocchip_crunchies, id: 2239, restoration: 7
# Gnome Battas
food name: :fruit_batta, id: 2225, restoration: 11
food name: :fruit_batta, id: 2277, restoration: 11
food name: :toad_batta, id: 2221, restoration: 11
food name: :toad_batta, id: 2255, restoration: 11
food name: :worm_batta, id: 2219, restoration: 11
food name: :worm_batta, id: 2253, restoration: 11
food name: :vegetable_batta, id: 2227, restoration: 11
food name: :vegetable_batta, id: 2281, restoration: 11
food name: :cheese_tom_batta, id: 2223, restoration: 11
food name: :cheese_tom_batta, id: 2259, restoration: 11
# Gnome Cocktails
# TODO: seperate from food, should say 'You drink' instead of 'You eat'.
food name: :fruit_blast, id: 2034, restoration: 9
food name: :fruit_blast, id: 2084, restoration: 9
food name: :pineapple_punch, id: 2036, restoration: 9
food name: :pineapple_punch, id: 2048, restoration: 9
food name: :wizard_blizzard, id: 2040, restoration: 5 # -4 attack, +5 strength also
food name: :wizard_blizzard, id: 2054, restoration: 5 # -4 attack, +5 strength also
food name: :short_green_guy, id: 2038, restoration: 5 # -4 attack, +5 strength also
food name: :short_green_guy, id: 2080, restoration: 5 # -4 attack, +5 strength also
food name: :drunk_dragon, id: 2032, restoration: 5 # -4 attack, +6 strength also
food name: :drunk_dragon, id: 2092, restoration: 5 # -4 attack, +6 strength also
food name: :chocolate_saturday, id: 2030, restoration: 7 # -4 attack, +6 strength also
food name: :chocolate_saturday, id: 2074, restoration: 7 # -4 attack, +6 strength also
food name: :blurberry_special, id: 2028, restoration: 7 # -4 attack, +6 strength also
food name: :blurberry_special, id: 2064, restoration: 7 # -4 attack, +6 strength also
+49 -33
View File
@@ -4,9 +4,10 @@ java_import 'org.apollo.game.model.entity.Skill'
private
# Contains potion-related constants.
module Constants
# The sound made when drinking a potion.
# The id of the sound made when drinking a potion.
DRINK_POTION_SOUND = 334
# The id of an empty vial.
@@ -25,10 +26,12 @@ class Potion < Consumable
def consume(player)
index = @doses.find_index(id) + 1
unless index == @doses.length # Consumable removes the previous potion for us, so we don't do it here.
if index != @doses.length # Consumable removes the old potion for us, so don't do it here.
player.inventory.add(@doses[index])
player.send_message("You drink some of your #{name} potion.", true)
player.send_message("You have #{ @doses.length - index } dose#{ "s" unless index == 3 } of potion left.", true)
player.send_message("You drink some of your #{name} potion.", true)
remaining = "You have #{@doses.length - index} dose#{'s' unless index == 3} of potion left."
player.send_message(remaining, true)
else
player.send_message('You drink the last of your potion.', true)
player.inventory.add(Constants::EMPTY_VIAL_ID)
@@ -37,7 +40,7 @@ class Potion < Consumable
drink(player)
end
def drink(player)
def drink(_player)
# Override to provide functionality
end
@@ -48,7 +51,7 @@ class BoostingPotion < Potion
def initialize(id, name, doses, skills, boost)
super(id, name, doses)
@skill_ids = skills.kind_of?(Array) ? skills : [ skills ]
@skill_ids = skills.is_a?(Array) ? skills : [skills]
@boost = boost
end
@@ -56,7 +59,7 @@ class BoostingPotion < Potion
@skill_ids.each do |id|
skill = player.skill_set.skill(id)
max = skill.maximum_level
level = [ skill.current_level, max ].min
level = [skill.current_level, max].min
new_current = @boost.call(max, level).floor
player.skill_set.set_skill(id, Skill.new(skill.experience, new_current, max))
@@ -65,17 +68,18 @@ class BoostingPotion < Potion
end
# Returns the parameters for the potion, as an array. Raises if any of the specified keys do not exist
# Returns the parameters for the potion, as an array. Fails if any of the specified keys do not
# exist.
def get_parameters(hash, keys)
raise "Hash must contain the following keys: #{ keys.join(", ") }." unless hash.has_keys?(*keys)
fail "Hash must contain the following keys: #{keys.join(', ')}." unless hash.has_keys?(*keys)
return keys.map {|key| hash[key] }
keys.map { |key| hash[key] }
end
# Appends a potion to the list of consumables.
def append_potion(hash)
def potion(hash)
class_name = 'Potion'
keys = [ :name, :doses ]
keys = [:name, :doses]
unless (hash.size == 2)
keys << :skills << :boost
@@ -83,36 +87,48 @@ def append_potion(hash)
end
parameters = get_parameters(hash, keys)
hash[:doses].each { |dose| append_consumable(Object.const_get(class_name).new(dose, *parameters)) }
doses = hash[:doses]
doses.each { |dose| append_consumable(Object.const_get(class_name).new(dose, *parameters)) }
end
# Some frequently-used boosts and skills
# Lambda parameters are | maximum_skill_level, current_skill_level |
basic_combat_boost = lambda { |max, level| level * 1.10 + 3 }
super_combat_boost = lambda { |max, level| level * 1.15 + 5 }
non_combat_boost = lambda { |max, level| level + 3 }
basic_combat_boost = ->(_, level) { level * 1.10 + 3 }
super_combat_boost = ->(_, level) { level * 1.15 + 5 }
non_combat_boost = ->(_, level) { level + 3 }
ATTACK, STRENGTH, DEFENCE = Skill::ATTACK, Skill::STRENGTH, Skill::DEFENCE
MAGIC, RANGED, PRAYER = Skill::MAGIC, Skill::RANGED, Skill::PRAYER
all_skills = (Skill::ATTACK..Skill::RUNECRAFT).to_a
combat_skills = [ Skill::ATTACK, Skill::STRENGTH, Skill::DEFENCE, Skill::MAGIC, Skill::RANGED ]
combat_skills = [ATTACK, STRENGTH, DEFENCE, MAGIC, RANGED]
# Boosting potions:
# Note that the order of the elements must be: :name, :doses, :skills, :boost.
append_potion :name => :attack, :doses => [ 2428, 121, 123, 125 ], :skills => Skill::ATTACK, :boost => basic_combat_boost
append_potion :name => :strength, :doses => [ 113, 115, 117, 119 ], :skills => Skill::STRENGTH, :boost => basic_combat_boost
append_potion :name => :defence, :doses => [ 2432, 133, 135, 137 ], :skills => Skill::DEFENCE, :boost => basic_combat_boost
potion name: :attack, doses: [2428, 121, 123, 125], skills: ATTACK, boost: basic_combat_boost
potion name: :strength, doses: [113, 115, 117, 119], skills: STRENGTH, boost: basic_combat_boost
potion name: :defence, doses: [2432, 133, 135, 137], skills: DEFENCE, boost: basic_combat_boost
append_potion :name => :agility, :doses => [ 3032, 3034, 3036, 3038 ], :skills => Skill::AGILITY, :boost => non_combat_boost
append_potion :name => :fishing, :doses => [ 2438, 151, 153, 155 ], :skills => Skill::FISHING, :boost => non_combat_boost
append_potion :name => :prayer, :doses => [ 2434, 139, 141, 143 ], :skills => Skill::PRAYER, :boost => lambda { |max, level| level / 4 + 7 }
potion name: :agility, doses: [3032, 3034, 3036, 3038], skills: Skill::AGILITY,
boost: non_combat_boost
potion name: :fishing, doses: [2438, 151, 153, 155], skills: Skill::FISHING,
boost: non_combat_boost
potion name: :prayer, doses: [2434, 139, 141, 143], skills: Skill::PRAYER,
boost: ->(_, level) { level / 4 + 7 }
append_potion :name => :restore, :doses => [ 2430, 127, 129, 131 ], :skills => combat_skills, :boost => lambda { |max, level| [ level * 1.3 + 10, max ].min }
append_potion :name => :super_restore, :doses => [ 3024, 3026, 3028, 3030 ], :skills => all_skills, :boost => lambda { |max, level| [ level * 1.25 + 8, max ].min }
potion name: :restore, doses: [2430, 127, 129, 131], skills: combat_skills,
boost: ->(_, level) { [level * 1.3 + 10, max].min }
potion name: :super_restore, doses: [3024, 3026, 3028, 3030], skills: all_skills,
boost: ->(_, level) { [level * 1.25 + 8, max].min }
append_potion :name => :super_attack, :doses => [ 2436, 145, 147, 149 ], :skills => Skill::ATTACK, :boost => super_combat_boost
append_potion :name => :super_strength, :doses => [ 2440, 157, 159, 161 ], :skills => Skill::STRENGTH, :boost => super_combat_boost
append_potion :name => :super_defence, :doses => [ 2442, 163, 165, 167 ], :skills => Skill::DEFENCE, :boost => super_combat_boost
append_potion :name => :ranging, :doses => [ 2444, 169, 171, 173 ], :skills => Skill::RANGED, :boost => lambda { |max, level| level * 1.10 + 4 }
append_potion :name => :magic, :doses => [ 3040, 3042, 3044, 3046 ], :skills => Skill::MAGIC, :boost => lambda { |max, level| level + 4 }
potion name: :super_attack, doses: [2436, 145, 147, 149], skills: ATTACK, boost: super_combat_boost
potion name: :super_strength, doses: [2440, 157, 159, 161], skills: STRENGTH,
boost: super_combat_boost
potion name: :super_defence, doses: [2442, 163, 165, 167], skills: DEFENCE,
boost: super_combat_boost
potion name: :ranging, doses: [2444, 169, 171, 173], skills: RANGED,
boost: ->(_, level) { level * 1.10 + 4 }
potion name: :magic, doses: [3040, 3042, 3044, 3046], skills: MAGIC,
boost: ->(_, level) { level + 4 }