Skip to content
Open
625 changes: 578 additions & 47 deletions src/Analyzers/BodyAnalyzer.php

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions src/Model/Actions/AboutFaceFormationAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace RecAnalyst\Model\Actions;

use RecAnalyst\RecordedGame;

/**
* Represents ...
*/
class AboutFaceFormationAction extends Action
{
/**
* The action ID.
*
* @var int
*/
const ID = 0x1A;

/**
* ID of the player that is executing this action.
*
* @var int
*/
public $playerId;

/**
* Formation this action applies to.
*
* @var int
*/
public $formationId;

/**
* Create a ...
*
* @param \RecAnalyst\RecordedGame $rec Recorded game instance.
* @param int $time Recorded game instance.
*/
public function __construct(RecordedGame $rec, $time)
{
parent::__construct($rec, $time);
}

/**
* Get a string representation of the action.
*
* @return string
*/
public function __toString()
{
return sprintf(
'AboutFaceFormation(playerId=%d, formationId=%d)',
$this->playerId,
$this->formationId
);
}
}
53 changes: 53 additions & 0 deletions src/Model/Actions/Action.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace RecAnalyst\Model\Actions;

use RecAnalyst\RecordedGame;
use RecAnalyst\Utils;

abstract class Action
{
/**
* Recorded game the action belongs to.
*
* @var \RecAnalyst\RecordedGame
*/
protected $rec;

/**
* Time since the start of the game at which the action occurred,
* in milliseconds.
*
* @var int
*/
public $time;

/**
* Create a player action.
*
* @param \RecAnalyst\RecordedGame $rec Recorded game instance.
* @param int $time Time in milliseconds when the action occurred.
*/
public function __construct(RecordedGame $rec, $time)
{
$this->rec = $rec;
$this->time = $time;
}

public function __toString()
{
$className = get_class($this);
$className = substr($className, strrpos($className, '\\') + 1);
$string = '[' . Utils::formatGameTime($this->time) . '] ' . $className;
foreach ($this as $k => $v) {
if ($k === 'rec' || $k === 'time') continue;
$string .= ' ' . $k . '=';
if (is_array($v)) {
$string .= implode(',', $v);
} else {
$string .= $v;
}
}
return $string;
}
}
66 changes: 66 additions & 0 deletions src/Model/Actions/AddAttributeAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace RecAnalyst\Model\Actions;

use RecAnalyst\RecordedGame;

/**
* Represents an attribute addition, for example when cheating in more
* resources.
*/
class AddAttributeAction extends Action
{
/**
* The action ID.
*
* @var int
*/
const ID = 0x05;

/**
* Player the action applies to.
*
* @var int
*/
public $playerId;

/**
* Attribute number.
*
* @var int
*/
public $attribute;

/**
* Amount of $attribute to add.
*
* @var int
*/
public $amount;

/**
* Create a ...
*
* @param \RecAnalyst\RecordedGame $rec Recorded game instance.
* @param int $time Recorded game instance.
*/
public function __construct(RecordedGame $rec, $time)
{
parent::__construct($rec, $time);
}

/**
* Get a string representation of the action.
*
* @return string
*/
public function __toString()
{
return sprintf(
'AddAttribute(playerId=%d, attribute=%d, amount=%d)',
$this->playerId,
$this->attribute,
$this->amount
);
}
}
68 changes: 68 additions & 0 deletions src/Model/Actions/AddWaypointAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace RecAnalyst\Model\Actions;

use RecAnalyst\RecordedGame;

/**
* Represents ...
*/
class AddWaypointAction extends Action
{
/**
* The action ID.
*
* @var int
*/
const ID = 0x0C;

/**
* ID of the player that is adding a waypoint.
*
* @var int
*/
public $playerId;

/**
* [TODO]
*
* @var int
*/
public $recipient;

/**
* Waypoint locations. An array of [$x, $y, $z] locations.
*
* @var int[][]
*/
public $waypoints = [];

/**
* Create a ...
*
* @param \RecAnalyst\RecordedGame $rec Recorded game instance.
* @param int $time Recorded game instance.
*/
public function __construct(RecordedGame $rec, $time)
{
parent::__construct($rec, $time);
}

/**
* Get a string representation of the action.
*
* @return string
*/
public function __toString()
{
return sprintf(
'AddWaypoint(playerId=%d, recipient=%d, waypoints[%d]={%s})',
$this->playerId,
$this->recipient,
count($this->waypoints),
implode(', ', array_map(function ($waypoint) {
return vsprintf('{%.2f, %.2f, %.2f}', $waypoint);
}, $this->waypoints))
);
}
}
60 changes: 60 additions & 0 deletions src/Model/Actions/AiOrderAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace RecAnalyst\Model\Actions;

use RecAnalyst\RecordedGame;

/**
* Represents ...
*/
class AiOrderAction extends Action
{
/**
* The action ID.
*
* @var int
*/
const ID = 0xa;

// AIOrder(num=%d, pId=%d, issuer=%d, recipient=%d, order=%d, pri=%d,
// tId=%d, tOwner=%d, tPos=%.10f,%.10f,%.10f, range=%.10f,
// immediate=%d, front=%d)
private $num;
private $playerId;
private $issuer;
private $recipient;
private $order;
private $priority;
private $tId;
private $tOwner;
private $tPosition;
private $range;
private $immediate;
private $front;

/**
* Create a ...
*
* @param \RecAnalyst\RecordedGame $rec Recorded game instance.
* @param int $time Recorded game instance.
*/
public function __construct(RecordedGame $rec, $time)
{
parent::__construct($rec, $time);
}

/**
* Get a string representation of the action.
*
* @return string
*/
public function __toString()
{
return sprintf(
'AiOrder(playerId=%d, attribute=%d, amount=%d)',
$this->playerId,
$this->attribute,
$this->amount
);
}
}
64 changes: 64 additions & 0 deletions src/Model/Actions/AttackGroundAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace RecAnalyst\Model\Actions;

use RecAnalyst\RecordedGame;

/**
* Represents ...
*/
class AttackGroundAction extends Action
{
/**
* The action ID.
*
* @var int
*/
const ID = 0x6b;

/**
* @var float
*/
public $x;

/**
* @var float
*/
public $y;

/**
* @var int[]
*/
public $units;

/**
* Create a ...
*
* @param \RecAnalyst\RecordedGame $rec Recorded game instance.
* @param int $time Recorded game instance.
*/
public function __construct(RecordedGame $rec, $time, $x, $y, $units)
{
parent::__construct($rec, $time);

$this->x = $x;
$this->y = $y;
$this->units = $units;
}

/**
* Get a string representation of the action.
*
* @return string
*/
public function __toString()
{
return sprintf(
'AttackGround(x=%.2f, y=%.2f, units[%d]={%s})',
$this->x,
$this->y,
count($this->units),
implode(', ', $this->units)
);
}
}
Loading