Sha256: 751f6965264bb6df639c00adc487eadccda8b7b8447402a86f7f06bdf7ae0763

Contents?: true

Size: 828 Bytes

Versions: 5

Compression:

Stored size: 828 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']
  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 >= 0
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
qwtf_discord_bot-2.1.2 lib/player.rb
qwtf_discord_bot-2.1.1 lib/player.rb
qwtf_discord_bot-2.1.0 lib/player.rb
qwtf_discord_bot-2.0.1 lib/player.rb
qwtf_discord_bot-2.0.0 lib/player.rb