Sha256: 1349f23b93f633eb5a5f43fdb1230e6be5f50498d0661ab15f6ba73189bcda9f

Contents?: true

Size: 863 Bytes

Versions: 66

Compression:

Stored size: 863 Bytes

Contents

class Player
  PLAYER_CLASSES = {
    'sco' => 'scout',
    'sni' => 'sniper',
    'sol' => 'soldier',
    'dem' => 'demoman',
    'med' => 'medic',
    'pyr' => 'pyro',
    'hwg' => 'hwguy',
    'spy' => 'spy',
    'eng' => 'engineer'
  }.freeze

  def initialize(data)
    @data = data
  end

  def name
    @data['name']
  end

  def score
    @data['score']
  end

  def to_row
    "#{emoji}#{name}"
  end

  def team
    return 'spec' if !valid_score? || @data['team'].empty? || @data['team'] == 'observe'

    @data['team']
  end

  def player_class
    short_class && PLAYER_CLASSES[short_class]
  end

  private

  def emoji
    Emoji.for(team: team.to_s, player_class: player_class)
  end

  def short_class
    skin.split('_').last && skin.split('_').last[0, 3]
  end

  def skin
    @data['skin']
  end

  def valid_score?
    score != -9999
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
qwtf_discord_bot-6.3.1 lib/player.rb
qwtf_discord_bot-6.3.0 lib/player.rb
qwtf_discord_bot-6.2.2 lib/player.rb
qwtf_discord_bot-6.2.1 lib/player.rb
qwtf_discord_bot-6.2.0 lib/player.rb
qwtf_discord_bot-6.1.5 lib/player.rb
qwtf_discord_bot-6.1.4 lib/player.rb
qwtf_discord_bot-6.1.3 lib/player.rb
qwtf_discord_bot-6.1.2 lib/player.rb
qwtf_discord_bot-6.1.1 lib/player.rb
qwtf_discord_bot-6.1.0 lib/player.rb
qwtf_discord_bot-6.0.4 lib/player.rb
qwtf_discord_bot-6.0.3 lib/player.rb
qwtf_discord_bot-6.0.2 lib/player.rb
qwtf_discord_bot-6.0.1 lib/player.rb
qwtf_discord_bot-5.5.26 lib/player.rb
qwtf_discord_bot-5.5.25 lib/player.rb
qwtf_discord_bot-5.5.24 lib/player.rb
qwtf_discord_bot-5.5.23 lib/player.rb
qwtf_discord_bot-5.5.22 lib/player.rb