Class: Radventure::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/radventure/item.rb

Overview

Represents an ingame item

Examples:

Create new mundane item

bucket = Item.new('Bucket',
                  'Gear',
                  'A simple wooden bucket.',
                  'A simple wooden bucket capable of containing around 5L of fluids.',
                  0.05,
                  0.9)

Create new magical item, yet unknown

bag = Item.new('Leather Bag',
               'Unknown Item',
               'A small leather bag.',
               'A small beige leather bag with miscellaneous details.',
               2500,
               7,
               true,
               false,
               'Bag of Holding',
               'Wondrous item, uncommon',
               'This bag has an interior space considerably larger than its outside dimensions, roughly 2 feet in diameter at the mouth and 4 feet deep. The bag can hold up to 500 pounds, not exceeding a volume of 64 cubic feet. The bag weighs 15 pounds, regardless of its contents. Retrieving an item from the bag requires an action.\n\nIf the bag is overloaded, pierced, or torn, it ruptures and is destroyed, and its contents are scattered in the Astral Plane. If the bag is turned inside out, its contents spill forth, unharmed, but the bag must be put right before it can be used again.')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, short_desc, desc, value, weight, is_magic: false, is_known: true, true_name: nil, true_type: nil, true_desc: nil) ⇒ Item

Item constructor

Parameters:

  • name (String)

    The name of the item

  • type (String)

    The type (and subtype, where applicable) of the item

  • short_desc (String)

    The short description of the item

  • desc (String)

    The long description of the item

  • value (Float)

    The value (in gold pieces) of the item

  • weight (Float)

    The weight (in kilograms) of the item

  • is_magic (Boolean) (defaults to: false)

    Whether the item is magic or not

  • is_known (Boolean) (defaults to: true)

    Whether the item is known (as in the ‘Identify` spell) or not

  • true_name (String, nil) (defaults to: nil)

    The true name of the item

  • true_type (String, nil) (defaults to: nil)

    The true type (and possibly subtype) of the item

  • true_desc (String, nil) (defaults to: nil)

    The true long description of the item



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/radventure/item.rb', line 66

def initialize(name,
               type,
               short_desc,
               desc,
               value,
               weight,
               is_magic: false,
               is_known: true,
               true_name: nil,
               true_type: nil,
               true_desc: nil)
  @name       = name.strip
  @type       = type.strip
  @short_desc = short_desc.strip
  @desc       = desc.strip
  @value      = value.to_f
  @weight     = weight.to_f
  @is_magic   = is_magic ? true : false
  @is_known   = is_known ? true : false
  @true_name  = true_name.strip
  @true_type  = true_type.strip
  @true_desc  = true_desc.strip
end

Instance Attribute Details

#descString (readonly)

Returns The long description of the item.

Returns:

  • (String)

    The long description of the item



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/radventure/item.rb', line 48

class Item
  attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type,
              :true_desc

  # Item constructor
  #
  # @param name [String] The name of the item
  # @param type [String] The type (and subtype, where applicable) of the item
  # @param short_desc [String] The short description of the item
  # @param desc [String] The long description of the item
  # @param value [Float] The value (in gold pieces) of the item
  # @param weight [Float] The weight (in kilograms) of the item
  # @param is_magic [Boolean] Whether the item is magic or not
  # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not
  # @param true_name [String, nil] The true name of the item
  # @param true_type [String, nil] The true type (and possibly subtype) of the item
  # @param true_desc [String, nil] The true long description of the item
  # @return [Item] The Item object
  def initialize(name,
                 type,
                 short_desc,
                 desc,
                 value,
                 weight,
                 is_magic: false,
                 is_known: true,
                 true_name: nil,
                 true_type: nil,
                 true_desc: nil)
    @name       = name.strip
    @type       = type.strip
    @short_desc = short_desc.strip
    @desc       = desc.strip
    @value      = value.to_f
    @weight     = weight.to_f
    @is_magic   = is_magic ? true : false
    @is_known   = is_known ? true : false
    @true_name  = true_name.strip
    @true_type  = true_type.strip
    @true_desc  = true_desc.strip
  end
end

#is_knownBoolean (readonly)

Returns Whether the item is known (as in the ‘Identify` spell) or not.

Returns:

  • (Boolean)

    Whether the item is known (as in the ‘Identify` spell) or not



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/radventure/item.rb', line 48

class Item
  attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type,
              :true_desc

  # Item constructor
  #
  # @param name [String] The name of the item
  # @param type [String] The type (and subtype, where applicable) of the item
  # @param short_desc [String] The short description of the item
  # @param desc [String] The long description of the item
  # @param value [Float] The value (in gold pieces) of the item
  # @param weight [Float] The weight (in kilograms) of the item
  # @param is_magic [Boolean] Whether the item is magic or not
  # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not
  # @param true_name [String, nil] The true name of the item
  # @param true_type [String, nil] The true type (and possibly subtype) of the item
  # @param true_desc [String, nil] The true long description of the item
  # @return [Item] The Item object
  def initialize(name,
                 type,
                 short_desc,
                 desc,
                 value,
                 weight,
                 is_magic: false,
                 is_known: true,
                 true_name: nil,
                 true_type: nil,
                 true_desc: nil)
    @name       = name.strip
    @type       = type.strip
    @short_desc = short_desc.strip
    @desc       = desc.strip
    @value      = value.to_f
    @weight     = weight.to_f
    @is_magic   = is_magic ? true : false
    @is_known   = is_known ? true : false
    @true_name  = true_name.strip
    @true_type  = true_type.strip
    @true_desc  = true_desc.strip
  end
end

#is_magicBoolean (readonly)

Returns Whether the item is magic or not.

Returns:

  • (Boolean)

    Whether the item is magic or not



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/radventure/item.rb', line 48

class Item
  attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type,
              :true_desc

  # Item constructor
  #
  # @param name [String] The name of the item
  # @param type [String] The type (and subtype, where applicable) of the item
  # @param short_desc [String] The short description of the item
  # @param desc [String] The long description of the item
  # @param value [Float] The value (in gold pieces) of the item
  # @param weight [Float] The weight (in kilograms) of the item
  # @param is_magic [Boolean] Whether the item is magic or not
  # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not
  # @param true_name [String, nil] The true name of the item
  # @param true_type [String, nil] The true type (and possibly subtype) of the item
  # @param true_desc [String, nil] The true long description of the item
  # @return [Item] The Item object
  def initialize(name,
                 type,
                 short_desc,
                 desc,
                 value,
                 weight,
                 is_magic: false,
                 is_known: true,
                 true_name: nil,
                 true_type: nil,
                 true_desc: nil)
    @name       = name.strip
    @type       = type.strip
    @short_desc = short_desc.strip
    @desc       = desc.strip
    @value      = value.to_f
    @weight     = weight.to_f
    @is_magic   = is_magic ? true : false
    @is_known   = is_known ? true : false
    @true_name  = true_name.strip
    @true_type  = true_type.strip
    @true_desc  = true_desc.strip
  end
end

#nameString (readonly)

Returns The name of the item.

Returns:

  • (String)

    The name of the item



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/radventure/item.rb', line 48

class Item
  attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type,
              :true_desc

  # Item constructor
  #
  # @param name [String] The name of the item
  # @param type [String] The type (and subtype, where applicable) of the item
  # @param short_desc [String] The short description of the item
  # @param desc [String] The long description of the item
  # @param value [Float] The value (in gold pieces) of the item
  # @param weight [Float] The weight (in kilograms) of the item
  # @param is_magic [Boolean] Whether the item is magic or not
  # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not
  # @param true_name [String, nil] The true name of the item
  # @param true_type [String, nil] The true type (and possibly subtype) of the item
  # @param true_desc [String, nil] The true long description of the item
  # @return [Item] The Item object
  def initialize(name,
                 type,
                 short_desc,
                 desc,
                 value,
                 weight,
                 is_magic: false,
                 is_known: true,
                 true_name: nil,
                 true_type: nil,
                 true_desc: nil)
    @name       = name.strip
    @type       = type.strip
    @short_desc = short_desc.strip
    @desc       = desc.strip
    @value      = value.to_f
    @weight     = weight.to_f
    @is_magic   = is_magic ? true : false
    @is_known   = is_known ? true : false
    @true_name  = true_name.strip
    @true_type  = true_type.strip
    @true_desc  = true_desc.strip
  end
end

#short_descString (readonly)

Returns The short description of the item.

Returns:

  • (String)

    The short description of the item



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/radventure/item.rb', line 48

class Item
  attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type,
              :true_desc

  # Item constructor
  #
  # @param name [String] The name of the item
  # @param type [String] The type (and subtype, where applicable) of the item
  # @param short_desc [String] The short description of the item
  # @param desc [String] The long description of the item
  # @param value [Float] The value (in gold pieces) of the item
  # @param weight [Float] The weight (in kilograms) of the item
  # @param is_magic [Boolean] Whether the item is magic or not
  # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not
  # @param true_name [String, nil] The true name of the item
  # @param true_type [String, nil] The true type (and possibly subtype) of the item
  # @param true_desc [String, nil] The true long description of the item
  # @return [Item] The Item object
  def initialize(name,
                 type,
                 short_desc,
                 desc,
                 value,
                 weight,
                 is_magic: false,
                 is_known: true,
                 true_name: nil,
                 true_type: nil,
                 true_desc: nil)
    @name       = name.strip
    @type       = type.strip
    @short_desc = short_desc.strip
    @desc       = desc.strip
    @value      = value.to_f
    @weight     = weight.to_f
    @is_magic   = is_magic ? true : false
    @is_known   = is_known ? true : false
    @true_name  = true_name.strip
    @true_type  = true_type.strip
    @true_desc  = true_desc.strip
  end
end

#true_descString? (readonly)

Returns The true long description of the item.

Returns:

  • (String, nil)

    The true long description of the item



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/radventure/item.rb', line 48

class Item
  attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type,
              :true_desc

  # Item constructor
  #
  # @param name [String] The name of the item
  # @param type [String] The type (and subtype, where applicable) of the item
  # @param short_desc [String] The short description of the item
  # @param desc [String] The long description of the item
  # @param value [Float] The value (in gold pieces) of the item
  # @param weight [Float] The weight (in kilograms) of the item
  # @param is_magic [Boolean] Whether the item is magic or not
  # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not
  # @param true_name [String, nil] The true name of the item
  # @param true_type [String, nil] The true type (and possibly subtype) of the item
  # @param true_desc [String, nil] The true long description of the item
  # @return [Item] The Item object
  def initialize(name,
                 type,
                 short_desc,
                 desc,
                 value,
                 weight,
                 is_magic: false,
                 is_known: true,
                 true_name: nil,
                 true_type: nil,
                 true_desc: nil)
    @name       = name.strip
    @type       = type.strip
    @short_desc = short_desc.strip
    @desc       = desc.strip
    @value      = value.to_f
    @weight     = weight.to_f
    @is_magic   = is_magic ? true : false
    @is_known   = is_known ? true : false
    @true_name  = true_name.strip
    @true_type  = true_type.strip
    @true_desc  = true_desc.strip
  end
end

#true_nameString? (readonly)

Returns The true name of the item.

Returns:

  • (String, nil)

    The true name of the item



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/radventure/item.rb', line 48

class Item
  attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type,
              :true_desc

  # Item constructor
  #
  # @param name [String] The name of the item
  # @param type [String] The type (and subtype, where applicable) of the item
  # @param short_desc [String] The short description of the item
  # @param desc [String] The long description of the item
  # @param value [Float] The value (in gold pieces) of the item
  # @param weight [Float] The weight (in kilograms) of the item
  # @param is_magic [Boolean] Whether the item is magic or not
  # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not
  # @param true_name [String, nil] The true name of the item
  # @param true_type [String, nil] The true type (and possibly subtype) of the item
  # @param true_desc [String, nil] The true long description of the item
  # @return [Item] The Item object
  def initialize(name,
                 type,
                 short_desc,
                 desc,
                 value,
                 weight,
                 is_magic: false,
                 is_known: true,
                 true_name: nil,
                 true_type: nil,
                 true_desc: nil)
    @name       = name.strip
    @type       = type.strip
    @short_desc = short_desc.strip
    @desc       = desc.strip
    @value      = value.to_f
    @weight     = weight.to_f
    @is_magic   = is_magic ? true : false
    @is_known   = is_known ? true : false
    @true_name  = true_name.strip
    @true_type  = true_type.strip
    @true_desc  = true_desc.strip
  end
end

#true_typeString? (readonly)

Returns The true type (and possibly subtype) of the item.

Returns:

  • (String, nil)

    The true type (and possibly subtype) of the item



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/radventure/item.rb', line 48

class Item
  attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type,
              :true_desc

  # Item constructor
  #
  # @param name [String] The name of the item
  # @param type [String] The type (and subtype, where applicable) of the item
  # @param short_desc [String] The short description of the item
  # @param desc [String] The long description of the item
  # @param value [Float] The value (in gold pieces) of the item
  # @param weight [Float] The weight (in kilograms) of the item
  # @param is_magic [Boolean] Whether the item is magic or not
  # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not
  # @param true_name [String, nil] The true name of the item
  # @param true_type [String, nil] The true type (and possibly subtype) of the item
  # @param true_desc [String, nil] The true long description of the item
  # @return [Item] The Item object
  def initialize(name,
                 type,
                 short_desc,
                 desc,
                 value,
                 weight,
                 is_magic: false,
                 is_known: true,
                 true_name: nil,
                 true_type: nil,
                 true_desc: nil)
    @name       = name.strip
    @type       = type.strip
    @short_desc = short_desc.strip
    @desc       = desc.strip
    @value      = value.to_f
    @weight     = weight.to_f
    @is_magic   = is_magic ? true : false
    @is_known   = is_known ? true : false
    @true_name  = true_name.strip
    @true_type  = true_type.strip
    @true_desc  = true_desc.strip
  end
end

#typeString (readonly)

Returns The type (and subtype, where applicable) of the item.

Returns:

  • (String)

    The type (and subtype, where applicable) of the item



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/radventure/item.rb', line 48

class Item
  attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type,
              :true_desc

  # Item constructor
  #
  # @param name [String] The name of the item
  # @param type [String] The type (and subtype, where applicable) of the item
  # @param short_desc [String] The short description of the item
  # @param desc [String] The long description of the item
  # @param value [Float] The value (in gold pieces) of the item
  # @param weight [Float] The weight (in kilograms) of the item
  # @param is_magic [Boolean] Whether the item is magic or not
  # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not
  # @param true_name [String, nil] The true name of the item
  # @param true_type [String, nil] The true type (and possibly subtype) of the item
  # @param true_desc [String, nil] The true long description of the item
  # @return [Item] The Item object
  def initialize(name,
                 type,
                 short_desc,
                 desc,
                 value,
                 weight,
                 is_magic: false,
                 is_known: true,
                 true_name: nil,
                 true_type: nil,
                 true_desc: nil)
    @name       = name.strip
    @type       = type.strip
    @short_desc = short_desc.strip
    @desc       = desc.strip
    @value      = value.to_f
    @weight     = weight.to_f
    @is_magic   = is_magic ? true : false
    @is_known   = is_known ? true : false
    @true_name  = true_name.strip
    @true_type  = true_type.strip
    @true_desc  = true_desc.strip
  end
end

#valueFloat (readonly)

Returns The value (in gold pieces) of the item.

Returns:

  • (Float)

    The value (in gold pieces) of the item



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/radventure/item.rb', line 48

class Item
  attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type,
              :true_desc

  # Item constructor
  #
  # @param name [String] The name of the item
  # @param type [String] The type (and subtype, where applicable) of the item
  # @param short_desc [String] The short description of the item
  # @param desc [String] The long description of the item
  # @param value [Float] The value (in gold pieces) of the item
  # @param weight [Float] The weight (in kilograms) of the item
  # @param is_magic [Boolean] Whether the item is magic or not
  # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not
  # @param true_name [String, nil] The true name of the item
  # @param true_type [String, nil] The true type (and possibly subtype) of the item
  # @param true_desc [String, nil] The true long description of the item
  # @return [Item] The Item object
  def initialize(name,
                 type,
                 short_desc,
                 desc,
                 value,
                 weight,
                 is_magic: false,
                 is_known: true,
                 true_name: nil,
                 true_type: nil,
                 true_desc: nil)
    @name       = name.strip
    @type       = type.strip
    @short_desc = short_desc.strip
    @desc       = desc.strip
    @value      = value.to_f
    @weight     = weight.to_f
    @is_magic   = is_magic ? true : false
    @is_known   = is_known ? true : false
    @true_name  = true_name.strip
    @true_type  = true_type.strip
    @true_desc  = true_desc.strip
  end
end

#weightFloat (readonly)

Returns The weight (in kilograms) of the item.

Returns:

  • (Float)

    The weight (in kilograms) of the item



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/radventure/item.rb', line 48

class Item
  attr_reader :name, :type, :short_desc, :desc, :value, :weight, :is_magic, :is_known, :true_name, :true_type,
              :true_desc

  # Item constructor
  #
  # @param name [String] The name of the item
  # @param type [String] The type (and subtype, where applicable) of the item
  # @param short_desc [String] The short description of the item
  # @param desc [String] The long description of the item
  # @param value [Float] The value (in gold pieces) of the item
  # @param weight [Float] The weight (in kilograms) of the item
  # @param is_magic [Boolean] Whether the item is magic or not
  # @param is_known [Boolean] Whether the item is known (as in the `Identify` spell) or not
  # @param true_name [String, nil] The true name of the item
  # @param true_type [String, nil] The true type (and possibly subtype) of the item
  # @param true_desc [String, nil] The true long description of the item
  # @return [Item] The Item object
  def initialize(name,
                 type,
                 short_desc,
                 desc,
                 value,
                 weight,
                 is_magic: false,
                 is_known: true,
                 true_name: nil,
                 true_type: nil,
                 true_desc: nil)
    @name       = name.strip
    @type       = type.strip
    @short_desc = short_desc.strip
    @desc       = desc.strip
    @value      = value.to_f
    @weight     = weight.to_f
    @is_magic   = is_magic ? true : false
    @is_known   = is_known ? true : false
    @true_name  = true_name.strip
    @true_type  = true_type.strip
    @true_desc  = true_desc.strip
  end
end