PHP code example of adnanmula / keyforge-game-log-parser
1. Go to this page and download the library: Download adnanmula/keyforge-game-log-parser library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
adnanmula / keyforge-game-log-parser example snippets
use AdnanMula\KeyforgeGameLogParser\Event\EventType;
use AdnanMula\KeyforgeGameLogParser\Parser\GameLogParser;
use AdnanMula\KeyforgeGameLogParser\Parser\ParseType;
$log = file_get_contents('path/to/log.txt');
$parser = new GameLogParser();
$game = $parser->execute($log, ParseType::PLAIN);
$winner = $game->winner()?->name;
$keysForged = $game->timeline()->filter(EventType::KEY_FORGED)->count();
$reapsByPlayer1 = $game->player1->timeline->filter(EventType::REAP)->count();
$firstCreatureUsedToReapByPlayer1 = $game->player1->timeline->filter(EventType::REAP)->at(0)->value;
use AdnanMula\KeyforgeGameLogParser\Parser\GameLogParser;
use AdnanMula\KeyforgeGameLogParser\Parser\ParseType;
$parser = new GameLogParser();
$plainString = '
Alice brings Deck A to The Crucible
Bob brings Deck B to The Crucible
...
';
// PLAIN
$game1 = $parser->execute($plainString, ParseType::PLAIN);
// ARRAY
$messages = [
'Alice brings Deck A to The Crucible',
'Bob brings Deck B to The Crucible',
// ...
];
$game2 = $parser->execute($messages, ParseType::ARRAY);
// HTML
$html = '<div class="message">Alice brings Deck A to The Crucible</div>...';
$game3 = $parser->execute($html, ParseType::HTML);
use AdnanMula\KeyforgeGameLogParser\Event\EventType;
// Checks declared across the whole game
$checks = $game->timeline()->filter(EventType::CHECK_DECLARED)->items();
// Player-specific timeline queries
$p1Checks = $game->player1->timeline->filter(EventType::CHECK_DECLARED)->items();
$p2Keys = $game->player2->timeline->filter(EventType::KEY_FORGED)->items();
$reapsAndFights = $game->player2->timeline->filter(EventType::REAP, EventType::FIGHT)->items();
etc...
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.