class Rules::ActionTurn

Action turn Characters can perform non attack actions, with modifier

Public Class Methods

new(sheet, skill) click to toggle source

If the character has a bonus in he skill, it is added to the modifiers Note that in these simple set of rules, no character ever has a bonus,

because it was not included in the character creation Questionnaire.

A bonus can be given using the set command.

# File data/rpg-prompt/rules_default.rb, line 207
def initialize(sheet, skill)
  @sheet = sheet
  unless @skill_sym
    @skill_sym = Message.skill_symbol(skill)
    @@skill_hash = RulesHashes::SkillHash.new
  end
  @skill_bonus = @sheet[@skill_sym] ? @sheet[@skill_sym] : 0
end
skill?(skill) click to toggle source

checks if the skill has been defined in RulesHashes

# File data/rpg-prompt/rules_default.rb, line 217
def self.skill?(skill)
  unless @skill_sym
    @skill_sym = Message.skill_symbol(skill)
    @@skill_hash = RulesHashes::SkillHash.new
  end
  @@skill_hash.key?(@skill_sym)
end

Public Instance Methods

action_table_result(roll) click to toggle source

Checks for the result in the ActionTable

# File data/rpg-prompt/rules_default.rb, line 254
def action_table_result(roll)
  r = truncate_val(roll)
  @@action_table = RulesHashes::ActionTable.new
  action_result = :failure
  @@action_table.each do |ar, l|
    if (r >= l[0]) && (r < l[1])
      action_result = ar
    end
  end
  action_result
end
mod_roll(roll) click to toggle source

Helper method for resolve. It prompts the modifier

# File data/rpg-prompt/rules_default.rb, line 267
def mod_roll(roll)
  r = roll + @modifier
  Message.help(:skill_roll, {r: r, roll: roll, modifier: @modifier})
  r
end
process_options(options, command_mod) click to toggle source

In these simple set of rules, only a basic difficulty rule is included

# File data/rpg-prompt/rules_default.rb, line 226
def process_options(options, command_mod)
  @modifier = command_mod
  @no_action = false
  options.each do |option|
    c = option[0]
    option[0] = ' '
    case c
    when 'c' #check
      @no_action = true
    when 'e' #easy
      @modifier += 3
    when 'm' #medium
      @modifier += 0
    when 'h' #hard
      @modifier -= 3
    end
  end
  @modifier += @skill_bonus
  return @no_action, @modifier
end
resolve() click to toggle source

Rresolves the action, with the options from process_options

# File data/rpg-prompt/rules_default.rb, line 274
def resolve
  roll = Dice.prompt_roll(:d10)
  action_result = action_table_result(mod_roll(roll))
  Message.skill_word(action_result)
end
truncate_val(v) click to toggle source

Helper method for action_table_result. It guarantees in range

# File data/rpg-prompt/rules_default.rb, line 248
def truncate_val(v)
  v = (v > 500) ? 500 : v
  v = (v < -500) ? -500 : v
end