Class: Conreality::Player

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

Overview

Represents a Conreality player.

Constant Summary collapse

TABLE =
:object_player
KEY =
:uuid

Constants inherited from Database::Row

Database::Row::SCHEMA

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

Methods inherited from Database::Row

attr_accessor, attr_reader, attr_wrapper, attr_writer, #get, #key, key_attr, #set!, table_name

Constructor Details

#initialize(client, uuid) ⇒ Player

Returns a new instance of Player.

Parameters:

  • client (Client)
  • uuid (#to_s)

42
43
44
# File 'lib/conreality/player.rb', line 42

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

Instance Attribute Details

#avatarBinary

The player's avatar image.

Returns:


30
31
32
# File 'lib/conreality/player.rb', line 30

def avatar
  @avatar
end

#ip_addrString

The player's IPv4/IPv6 address.

Returns:

  • (String)

24
25
26
# File 'lib/conreality/player.rb', line 24

def ip_addr
  @ip_addr
end

#languageString

The player's primary language.

Returns:

  • (String)

37
38
39
# File 'lib/conreality/player.rb', line 37

def language
  @language
end

#nameString

The player's full name.

Returns:

  • (String)

18
19
20
# File 'lib/conreality/player.rb', line 18

def name
  @name
end

#nickString

The player's nickname.

Returns:

  • (String)

12
13
14
# File 'lib/conreality/player.rb', line 12

def nick
  @nick
end

Instance Method Details

#cameraCamera?

Returns the bodycam, if any, of this player.

Returns:


60
61
62
# File 'lib/conreality/player.rb', line 60

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

#deregister!

This method returns an undefined value.

Deregisters this player from the game.


68
69
70
# File 'lib/conreality/player.rb', line 68

def deregister!
  # TODO
end

#has_camera?Boolean

Checks whether this player has a bodycam.

Returns:

  • (Boolean)

50
51
52
53
54
# File 'lib/conreality/player.rb', line 50

def has_camera?
  @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