mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 08:39:17 +00:00
Fix mining; rename to skill-mining.
This commit is contained in:
@@ -10,8 +10,8 @@ ORE_SIZE = 1
|
|||||||
class MiningAction < DistancedAction
|
class MiningAction < DistancedAction
|
||||||
attr_reader :position, :ore, :counter, :started
|
attr_reader :position, :ore, :counter, :started
|
||||||
|
|
||||||
def initialize(character, position, ore)
|
def initialize(player, position, ore)
|
||||||
super 0, true, character, position, ORE_SIZE
|
super 0, true, player, position, ORE_SIZE
|
||||||
@position = position
|
@position = position
|
||||||
@ore = ore
|
@ore = ore
|
||||||
@started = false
|
@started = false
|
||||||
@@ -20,12 +20,12 @@ class MiningAction < DistancedAction
|
|||||||
|
|
||||||
def find_pickaxe
|
def find_pickaxe
|
||||||
PICKAXE_IDS.each do |id|
|
PICKAXE_IDS.each do |id|
|
||||||
weapon = character.equipment.get EquipmentConstants::WEAPON
|
weapon = player.equipment.get EquipmentConstants::WEAPON
|
||||||
if weapon.id == id
|
if weapon.id == id
|
||||||
return PICKAXES[id]
|
return PICKAXES[id]
|
||||||
end
|
end
|
||||||
|
|
||||||
if character.inventory.contains id
|
if player.inventory.contains id
|
||||||
return PICKAXES[id]
|
return PICKAXES[id]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -33,31 +33,31 @@ class MiningAction < DistancedAction
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# starts the mining animation, sets counters/flags and turns the character to
|
# starts the mining animation, sets counters/flags and turns the player to
|
||||||
# the ore
|
# the ore
|
||||||
def start_mine(pickaxe)
|
def start_mine(pickaxe)
|
||||||
@started = true
|
@started = true
|
||||||
character.send_message "You swing your pick at the rock."
|
player.send_message "You swing your pick at the rock."
|
||||||
character.turn_to @position
|
player.turn_to @position
|
||||||
character.play_animation pickaxe.animation
|
player.play_animation pickaxe.animation
|
||||||
@counter = pickaxe.pulses
|
@counter = pickaxe.pulses
|
||||||
end
|
end
|
||||||
|
|
||||||
def executeAction
|
def executeAction
|
||||||
skills = character.skill_set
|
skills = player.skill_set
|
||||||
level = skills.get_skill(Skill::MINING).current_level
|
level = skills.get_skill(Skill::MINING).current_level
|
||||||
pickaxe = find_pickaxe
|
pickaxe = find_pickaxe
|
||||||
|
|
||||||
# verify the player can mine with their pickaxe
|
# verify the player can mine with their pickaxe
|
||||||
if not (pickaxe != nil and level >= pickaxe.level)
|
if not (pickaxe != nil and level >= pickaxe.level)
|
||||||
character.send_message "You do not have a pickaxe for which you have the level to use."
|
player.send_message "You do not have a pickaxe for which you have the level to use."
|
||||||
stop
|
stop
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
# verify the player can mine the ore
|
# verify the player can mine the ore
|
||||||
if ore.level > level
|
if ore.level > level
|
||||||
character.send_message "You do not have the required level to mine this rock."
|
player.send_message "You do not have the required level to mine this rock."
|
||||||
stop
|
stop
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -70,11 +70,11 @@ class MiningAction < DistancedAction
|
|||||||
if @counter == 0
|
if @counter == 0
|
||||||
# TODO: calculate the chance that the player can actually get the rock
|
# TODO: calculate the chance that the player can actually get the rock
|
||||||
|
|
||||||
if character.inventory.add ore.id
|
if player.inventory.add ore.id
|
||||||
ore_def = ItemDefinition.lookup @ore.id # TODO: split off into some method
|
ore_def = ItemDefinition.lookup @ore.id # TODO: split off into some method
|
||||||
name = ore_def.name.sub(/ ore$/, "").downcase
|
name = ore_def.name.sub(/ ore$/, "").downcase
|
||||||
|
|
||||||
character.send_message "You manage to mine some #{name}."
|
player.send_message "You manage to mine some #{name}."
|
||||||
skills.add_experience Skill::MINING, ore.exp
|
skills.add_experience Skill::MINING, ore.exp
|
||||||
# TODO: expire the rock
|
# TODO: expire the rock
|
||||||
end
|
end
|
||||||
@@ -94,12 +94,12 @@ end
|
|||||||
class ExpiredProspectingAction < DistancedAction
|
class ExpiredProspectingAction < DistancedAction
|
||||||
attr_reader :position
|
attr_reader :position
|
||||||
|
|
||||||
def initialize(character, position)
|
def initialize(player, position)
|
||||||
super 0, true, character, position, ORE_SIZE
|
super 0, true, player, position, ORE_SIZE
|
||||||
end
|
end
|
||||||
|
|
||||||
def executeAction
|
def executeAction
|
||||||
character.send_message "There is currently no ore available in this rock."
|
player.send_message "There is currently no ore available in this rock."
|
||||||
stop
|
stop
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -112,8 +112,8 @@ end
|
|||||||
class ProspectingAction < DistancedAction
|
class ProspectingAction < DistancedAction
|
||||||
attr_reader :position, :ore
|
attr_reader :position, :ore
|
||||||
|
|
||||||
def initialize(character, position, ore)
|
def initialize(player, position, ore)
|
||||||
super PROSPECT_PULSES, true, character, position, ORE_SIZE
|
super PROSPECT_PULSES, true, player, position, ORE_SIZE
|
||||||
@position = position
|
@position = position
|
||||||
@ore = ore
|
@ore = ore
|
||||||
@started = false
|
@started = false
|
||||||
@@ -123,13 +123,13 @@ class ProspectingAction < DistancedAction
|
|||||||
if not @started
|
if not @started
|
||||||
@started = true
|
@started = true
|
||||||
|
|
||||||
character.send_message "You examine the rock for ores..."
|
player.send_message "You examine the rock for ores..."
|
||||||
character.turn_to @position
|
player.turn_to @position
|
||||||
else
|
else
|
||||||
ore_def = ItemDefinition.lookup @ore.id
|
ore_def = ItemDefinition.lookup @ore.id
|
||||||
name = ore_def.name.sub(/ ore$/, "").downcase
|
name = ore_def.name.sub(/ ore$/, "").downcase
|
||||||
|
|
||||||
character.send_message "This rock contains #{name}."
|
player.send_message "This rock contains #{name}."
|
||||||
|
|
||||||
stop
|
stop
|
||||||
end
|
end
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<plugin>
|
<plugin>
|
||||||
<id>mining</id>
|
<id>skill-mining</id>
|
||||||
<version>1</version>
|
<version>1</version>
|
||||||
<name>Mining</name>
|
<name>Mining</name>
|
||||||
<description>Adds the mining skill.</description>
|
<description>Adds the mining skill.</description>
|
||||||
Reference in New Issue
Block a user