/** * Handles the event. * * @param array $matches * * @return void */ public function handle($matches) { $this->player = Player::where('steam_id', $matches[3])->where('map_id', $this->map->id)->first(); $message = $matches[5]; if (is_null($this->player)) { return; } $handle = ['Planted_The_Bomb', 'Defused_The_Bomb']; $key = array_search($message, $handle); if ($key !== false) { $func = 'handle'; $func .= ucwords(camel_case($handle[$key])); $this->{$func}(); } }
/** * Handles the event. * * @param array $matches * * @return void */ public function handle($matches) { $attacker = Player::where('steam_id', $matches[3])->where('map_id', $this->map->id)->first(); $attacked = Player::where('steam_id', $matches[7])->where('map_id', $this->map->id)->first(); if (is_null($attacker) || is_null($attacked)) { return; } ++$attacker->assists; $attacker->save(); $re = new RoundEvent(); $re->map_id = $this->map->id; $re->current_round = $this->map->score_a + $this->map->score_b + 1; $re->type = 'assisted_in_killing'; $re->data = ['attacker' => $attacker->id, 'attacked' => $attacked->id]; $re->save(); }
/** * Handles the event. * * @param array $matches * * @return void */ public function handle($matches) { $attacker = Player::where('steam_id', $matches[3])->where('map_id', $this->map->id)->first(); $attacked = Player::where('steam_id', $matches[10])->where('map_id', $this->map->id)->first(); if (is_null($attacker) || is_null($attacked)) { return; } ++$attacker->kills; ++$attacked->deaths; $re = new RoundEvent(); $re->map_id = $this->map->id; $re->current_round = $this->map->score_a + $this->map->score_b + 1; $re->type = 'kill'; $re->data = ['attacker' => $attacker->id, 'attacker_location' => $matches[5] . ' ' . $matches[6] . ' ' . $matches[7], 'attacked' => $attacked->id, 'attacked_location' => $matches[12] . ' ' . $matches[13] . ' ' . $matches[14], 'weapon' => $matches[15]]; $re->save(); if (Str::contains($matches[16], 'headshot')) { ++$attacker->headshots; } $attacker->save(); $attacked->save(); }