Sha256: df972038703eefdd1fc3f36842ac204e7846b516bd99468886ae5a16e36bbc4c

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

Contents

module Gamefic
  module World
    module Players
      include Gamefic::World::Entities
      include Gamefic::World::Commands

      # An array of entities that are currently connected to users.
      #
      # @return [Array<Gamefic::Actor>]
      def players
        @players ||= []
      end

      def player_class cls = nil
        STDERR.puts "Modifying player_class this way is deprecated. Use set_player_class instead" unless cls.nil?
        @player_class = cls unless cls.nil?
        @player_class ||= Gamefic::Actor
      end

      # @param cls [Class]
      def set_player_class cls
        unless cls < Gamefic::Active && cls <= Gamefic::Entity
          raise ArgumentError, "Player class must be an active entity"
        end
        @player_class = cls
      end

      # Make a character that a player will control on introduction.
      #
      # @return [Gamefic::Actor]
      def make_player_character
        cast player_class, name: 'yourself', synonyms: 'self myself you me', proper_named: true
      end
      alias get_player_character make_player_character
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gamefic-2.4.0 lib/gamefic/world/players.rb
gamefic-2.3.0 lib/gamefic/world/players.rb
gamefic-2.2.3 lib/gamefic/world/players.rb
gamefic-2.2.2 lib/gamefic/world/players.rb
gamefic-2.2.1 lib/gamefic/world/players.rb
gamefic-2.2.0 lib/gamefic/world/players.rb
gamefic-2.1.1 lib/gamefic/world/players.rb
gamefic-2.1.0 lib/gamefic/world/players.rb
gamefic-2.0.3 lib/gamefic/world/players.rb