Sha256: 1f98cd0a2e25651053c379206c340f16dfe0cc35fc864db7522e075a798ea92a

Contents?: true

Size: 582 Bytes

Versions: 3

Compression:

Stored size: 582 Bytes

Contents

require_relative 'world_object'

module Woyo

class Character < WorldObject

  def initialize_object
    super
    attributes :description, name: lambda { |this| this.id.to_s.capitalize }
  end

  def world
    @world ||= context if context.is_a? World
  end

  def location
    @location ||= context if context.is_a? Location
  end

  def me
    self
  end

  def go way_or_id
    id = way_or_id.kind_of?(Way) ? way_or_id.id : way_or_id
    way = @location.ways[id]
    @location.characters.delete me.id
    @location = way.to
    @location.characters[me.id] = me
  end

end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
woyo-world-0.0.9 lib/woyo/world/character.rb
woyo-world-0.0.8 lib/woyo/world/character.rb
woyo-world-0.0.7 lib/woyo/world/character.rb