Sha256: c868288f2e0760b87429986904f360d590a9105a5ce44b5b95481a384298c711

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

module Fonte
  module Parsers
    grammar L4D2Player
      include Word
      include Number
      include SourcePlayer

      rule l4d2_player
        source_player "<" character:l4d2_character ">" "<" status:l4d2_player_status ">" "<" l4d2_life ">" "<" l4d2_position ">" "<" area:l4d2_area ">" {
          def nickname
            source_player.nickname
          end

          def uid
            source_player.uid
          end

          def steam_id
            source_player.steam_id
          end

          def team
            source_player.team
          end

          def life
            l4d2_life.value[:life]
          end

          def blood
            l4d2_life.value[:blood]
          end

          def position
            l4d2_position.position
          end

          def angle
            l4d2_position.angle
          end

          def value
            source_player.value
          end
        }
      end

      rule l4d2_character
        (![<>] character)* {
          def value
            text_value
          end
        }
      end

      rule l4d2_player_status
        (![<>] character)* {
          def value
            text_value
          end
        }
      end

      rule l4d2_life
        l4d2_life_blood / "0" {
          def value
            { :life => 0, :blood => 0 }
          end
        }
      end

      rule l4d2_life_blood
        life:integer "+" blood:integer {
          def value
            { :life => life.value, :blood => blood.value }
          end
        }
      end

      rule l4d2_position
        "setpos_exact" SPACE position:coordinates ";" SPACE "setang" SPACE angle:coordinates
      end

      rule l4d2_area
        "Area" SPACE integer {
          def value
            integer.value
          end
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fonte-0.2.0 lib/fonte/parsers/l4d2_player.treetop