added classname to billdata

This commit is contained in:
kremsy 2015-07-10 22:56:27 +02:00
parent ef7ddc0de2
commit 8a29489285
4 changed files with 19 additions and 5 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false"> <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false">
<file url="file://$PROJECT_DIR$/plugins/kremsy/SlotMachine.php" charset="windows-1252" />
<file url="PROJECT" charset="UTF-8" /> <file url="PROJECT" charset="UTF-8" />
</component> </component>
</project> </project>

View File

@ -17,6 +17,7 @@
- added some missing PHP Docs - added some missing PHP Docs
- added some depency libraries as they are used by the Socket Handler - added some depency libraries as they are used by the Socket Handler
- added additional Callback which gets triggered on ManiaControl Restart - added additional Callback which gets triggered on ManiaControl Restart
- added class name to the BillData object
- updated some depency libraries - updated some depency libraries
#Bug Fixes #Bug Fixes

View File

@ -22,10 +22,12 @@ class BillData {
public $amount = 0; public $amount = 0;
public $creationTime = -1; public $creationTime = -1;
public $message = ""; public $message = "";
public $class = "";
/** /**
* Construct new Bill Data Model * Construct new Bill Data Model
* *
* @param string $class
* @param callable $function * @param callable $function
* @param Player|string $player * @param Player|string $player
* @param int $amount * @param int $amount
@ -33,7 +35,8 @@ class BillData {
* @param string $receiverLogin * @param string $receiverLogin
* @param string $message * @param string $message
*/ */
public function __construct(callable $function, $player, $amount, $pay = false, $receiverLogin = null, $message = '') { public function __construct($class, callable $function, $player, $amount, $pay = false, $receiverLogin = null, $message = '') {
$this->class = $class;
$this->function = $function; $this->function = $function;
$this->player = $player; $this->player = $player;
$this->amount = $amount; $this->amount = $amount;

View File

@ -58,16 +58,21 @@ class BillManager implements CallbackListener {
* @return bool * @return bool
*/ */
public function sendBill(callable $function, Player $player, $amount, $message, $receiver = '') { public function sendBill(callable $function, Player $player, $amount, $message, $receiver = '') {
//Get the Caller Class
$backTrace = debug_backtrace();
$class = $backTrace[1]['class'];
try { try {
$billId = $this->maniaControl->getClient()->sendBill($player->login, intval($amount), $message, $receiver); $billId = $this->maniaControl->getClient()->sendBill($player->login, intval($amount), $message, $receiver);
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
//TODO better error handling, maybe call the user func with ERROR_WHILE_TRANSACTION //TODO better error handling, maybe call the user func with ERROR_WHILE_TRANSACTION
return false; return false;
} }
$this->openBills[$billId] = new BillData($function, $player, $amount, false, $receiver, $message); $this->openBills[$billId] = new BillData($class, $function, $player, $amount, false, $receiver, $message);
return true; return true;
} }
/** /**
* Send planets from the server to a player * Send planets from the server to a player
* *
@ -78,12 +83,17 @@ class BillManager implements CallbackListener {
* @return bool * @return bool
*/ */
public function sendPlanets(callable $function, $receiverLogin, $amount, $message) { public function sendPlanets(callable $function, $receiverLogin, $amount, $message) {
//Get the Caller Class
$backTrace = debug_backtrace();
$class = $backTrace[1]['class'];
try { try {
$billId = $this->maniaControl->getClient()->pay($receiverLogin, intval($amount), $message); $billId = $this->maniaControl->getClient()->pay($receiverLogin, intval($amount), $message);
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
return false; return false;
} }
$this->openBills[$billId] = new BillData($function, $receiverLogin, $amount, true, $receiverLogin, $message);
$this->openBills[$billId] = new BillData($class, $function, $receiverLogin, $amount, true, $receiverLogin, $message);
return true; return true;
} }