Skip to content

Commit

Permalink
Add properties and string representations for many actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed Dec 7, 2016
1 parent e7a61a7 commit 31410a7
Show file tree
Hide file tree
Showing 25 changed files with 718 additions and 38 deletions.
30 changes: 29 additions & 1 deletion src/Model/Actions/AboutFaceFormationAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,21 @@ class AboutFaceFormationAction extends Action
*
* @var int
*/
const ID = 0x1a;
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 ...
Expand All @@ -26,4 +40,18 @@ 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
);
}
}
41 changes: 39 additions & 2 deletions src/Model/Actions/AddAttributeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
use RecAnalyst\RecordedGame;

/**
* Represents ...
* Represents an attribute addition, for example when cheating in more
* resources.
*/
class AddAttributeAction extends Action
{
Expand All @@ -14,7 +15,28 @@ class AddAttributeAction extends Action
*
* @var int
*/
const ID = 0x5;
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 ...
Expand All @@ -26,4 +48,19 @@ 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
);
}
}
41 changes: 40 additions & 1 deletion src/Model/Actions/AddWaypointAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,28 @@ class AddWaypointAction extends Action
*
* @var int
*/
const ID = 0xc;
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 ...
Expand All @@ -26,4 +47,22 @@ 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))
);
}
}
31 changes: 31 additions & 0 deletions src/Model/Actions/AttackGroundAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ class AttackGroundAction extends Action
*/
const ID = 0x6b;

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

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

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

/**
* Create a ...
*
Expand All @@ -26,4 +41,20 @@ public function __construct(RecordedGame $rec, $time)
{
parent::__construct($rec, $time);
}

/**
* 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)
);
}
}
35 changes: 34 additions & 1 deletion src/Model/Actions/AttackMoveAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,47 @@ class AttackMoveAction extends Action
*/
const ID = 0x21;

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

/**
* @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)
public function __construct(RecordedGame $rec, $time, $waypoints, $units)
{
parent::__construct($rec, $time);

$this->waypoints = $waypoints;
$this->units = $units;
}

/**
* Get a string representation of the action.
*
* @return string
*/
public function __toString()
{
return sprintf(
'AttackMove(tId=%d, waypoints[%d]={%s}, units[%d]={%s})',
count($this->waypoints),
implode(', ', array_map(function ($waypoint) {
return vsprintf('{%.2f, %.2f, %.2f}', $waypoint);
}, $this->waypoints)),
count($this->units),
implode(', ', $this->units)
);
}
}
33 changes: 30 additions & 3 deletions src/Model/Actions/AttackMoveTargetAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Represents ...
*/
class AttackMoveTargetAction extends Action
class AttackMoveTargetAction extends AttackMoveAction
{
/**
* The action ID.
Expand All @@ -16,14 +16,41 @@ class AttackMoveTargetAction extends Action
*/
const ID = 0x22;

// AttackMove(num=%d, tId=%d, waypoints[%d]={%s})
/**
* @var int
*/
public $targetId;

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

$this->targetId = $targetId;
}

/**
* Get a string representation of the action.
*
* @return string
*/
public function __toString()
{
parent::__construct($rec, $time);
return sprintf(
'AttackMove(tId=%d, waypoints[%d]={%s}, units[%d]={%s})',
$this->targetId,
count($this->waypoints),
implode(', ', array_map(function ($waypoint) {
return vsprintf('{%.2f, %.2f, %.2f}', $waypoint);
}, $this->waypoints)),
count($this->units),
implode(', ', $this->units)
);
}
}
26 changes: 25 additions & 1 deletion src/Model/Actions/AutoFormationsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ class AutoFormationsAction extends Action
*
* @var int
*/
const ID = 0x1d;
const ID = 0x1D;

/**
* @var int
*/
private $playerId;

/**
* @var bool
*/
private $enable;

/**
* Create a ...
Expand All @@ -26,4 +36,18 @@ public function __construct(RecordedGame $rec, $time)
{
parent::__construct($rec, $time);
}

/**
* Get a string representation of the action.
*
* @return string
*/
public function __toString()
{
return sprintf(
'AutoFormation(playerId=%d, enable=%s)',
$this->playerId,
$this->enable ? 'true' : 'false'
);
}
}
Loading

0 comments on commit 31410a7

Please sign in to comment.