mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 16:49:11 +00:00
Update all plugins to conform to Rubocop.
This commit is contained in:
@@ -4,6 +4,7 @@ java_import 'org.apollo.game.model.entity.Player'
|
||||
java_import 'org.apollo.game.message.impl.SetWidgetTextMessage'
|
||||
java_import 'org.apollo.game.message.impl.OpenOverlayMessage'
|
||||
|
||||
declare_attribute(:wilderness_level, 0, :transient)
|
||||
|
||||
# Constants constants related to the wilderness
|
||||
module WildernessConstants
|
||||
@@ -16,47 +17,50 @@ module WildernessConstants
|
||||
|
||||
end
|
||||
|
||||
declare_attribute(:wilderness_level, 0, :transient)
|
||||
|
||||
# Determines the wilderness level for the specified player's position
|
||||
def wilderness_level(player)
|
||||
return ((player.position.y - 3520) / 8).ceil
|
||||
((player.position.y - 3520) / 8).ceil
|
||||
end
|
||||
|
||||
area_action :wilderness_level do
|
||||
|
||||
on_entry do |player|
|
||||
on_entry do |player|
|
||||
player.wilderness_level = wilderness_level(player)
|
||||
player.interface_set.open_overlay(WildernessConstants::OVERLAY_INTERFACE_ID)
|
||||
player.send(SetWidgetTextMessage.new(WildernessConstants::LEVEL_STRING_ID, "Level: #{player.wilderness_level}"))
|
||||
|
||||
id = WildernessConstants::LEVEL_STRING_ID
|
||||
player.send(SetWidgetTextMessage.new(id, "Level: #{player.wilderness_level}"))
|
||||
show_action(player, ATTACK_ACTION)
|
||||
end
|
||||
|
||||
while_in do |player|
|
||||
current = player.wilderness_level
|
||||
updated = wilderness_level(player)
|
||||
if (current != updated)
|
||||
player.wilderness_level = updated
|
||||
player.send(SetWidgetTextMessage.new(WildernessConstants::LEVEL_STRING_ID, "Level: #{player.wilderness_level}"))
|
||||
|
||||
if current != updated
|
||||
player.wilderness_level = updated
|
||||
|
||||
id = WildernessConstants::LEVEL_STRING_ID
|
||||
player.send(SetWidgetTextMessage.new(id, "Level: #{player.wilderness_level}"))
|
||||
end
|
||||
end
|
||||
|
||||
on_exit do |player|
|
||||
player.wilderness_level = 0
|
||||
player.interface_set.close()
|
||||
player.interface_set.close
|
||||
|
||||
player.send(OpenOverlayMessage.new(-1))
|
||||
hide_action(player, ATTACK_ACTION)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Monkey patch the existing player class to add method of checking whether or not a player is within the wilderness
|
||||
# Monkey patch the existing player class to add method of checking whether or not a player is
|
||||
# within the wilderness
|
||||
class Player
|
||||
|
||||
def in_wilderness
|
||||
self.wilderness_level > 0
|
||||
wilderness_level > 0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
area :name => :wilderness, :coordinates => [ 2945, 3522, 3390, 3972, 0 ], :actions => :wilderness_level
|
||||
area name: :wilderness, coordinates: [2945, 3522, 3390, 3972, 0], actions: :wilderness_level
|
||||
|
||||
Reference in New Issue
Block a user