Class: Conreality::Player

Inherits:
Object
  • Object
show all
Defined in:
lib/conreality/player.rb

Overview

Represents a Conreality player.

Constant Summary collapse

TABLE =
:object_player
KEY =
:uuid

Instance Attribute Summary collapse

Attributes inherited from Object

#color, #group, #label, #mass, #orientation, #position, #radius, #theater, #type, #uuid

Instance Method Summary collapse

Methods inherited from Object

#as_asset, #as_camera, #as_player, #inspect, #is_asset?, #is_camera?, #is_player?, #is_target?, #send_message

Constructor Details

#initialize(session, uuid) ⇒ Player

Returns a new instance of Player.

Parameters:



44
45
46
# File 'lib/conreality/player.rb', line 44

def initialize(session, uuid)
  super(session, uuid)
end

Instance Attribute Details

#avatarBinary

The player’s avatar image.

Returns:



32
33
34
# File 'lib/conreality/player.rb', line 32

def avatar
  @avatar
end

#ip_addrString

The player’s IPv4/IPv6 address.

Returns:

  • (String)


26
27
28
# File 'lib/conreality/player.rb', line 26

def ip_addr
  @ip_addr
end

#languageString

The player’s primary language.

Returns:

  • (String)


39
40
41
# File 'lib/conreality/player.rb', line 39

def language
  @language
end

#nameString

The player’s full name.

Returns:

  • (String)


20
21
22
# File 'lib/conreality/player.rb', line 20

def name
  @name
end

#nickString

The player’s nickname.

Returns:

  • (String)


14
15
16
# File 'lib/conreality/player.rb', line 14

def nick
  @nick
end

Instance Method Details

#cameraCamera?

Returns the bodycam, if any, of this player.

Returns:



62
63
64
# File 'lib/conreality/player.rb', line 62

def camera
  self.has_camera? ? self.as_camera : nil
end

#deregister!void

This method returns an undefined value.

Deregisters this player from the game.



70
71
72
# File 'lib/conreality/player.rb', line 70

def deregister!
  # TODO
end

#has_camera?Boolean

Checks whether this player has a bodycam.

Returns:

  • (Boolean)


52
53
54
55
56
# File 'lib/conreality/player.rb', line 52

def has_camera?
  @session.client.exec_with_params("SELECT COUNT(*) FROM #{q(Database::SCHEMA)}.#{q(:camera)} WHERE #{q(:uuid)} = $1 LIMIT 1", self.key) do |result|
    !!result.num_tuples.nonzero?
  end
end