Sha256: 100e11d3fb43bcc766c75cb396af5ef0418f3081140a52797a69339810d5e29a

Contents?: true

Size: 540 Bytes

Versions: 4

Compression:

Stored size: 540 Bytes

Contents

require_relative 'world_object'

module Woyo

class Character < WorldObject

  attributes :description, name: lambda { |this| this.id.to_s.capitalize }

  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

4 entries across 4 versions & 1 rubygems

Version Path
woyo-world-0.0.6 lib/woyo/world/character.rb
woyo-world-0.0.5 lib/woyo/world/character.rb
woyo-world-0.0.4 lib/woyo/world/character.rb
woyo-world-0.0.3 lib/woyo/world/character.rb