added player actions class
This commit is contained in:
parent
f7f10c422c
commit
28a9054c0d
@ -36,6 +36,7 @@ require_once __DIR__ . '/Maps/Map.php';
|
|||||||
require_once __DIR__ . '/Maps/MapManager.php';
|
require_once __DIR__ . '/Maps/MapManager.php';
|
||||||
require_once __DIR__ . '/Maps/MapList.php';
|
require_once __DIR__ . '/Maps/MapList.php';
|
||||||
require_once __DIR__ . '/Players/PlayerManager.php';
|
require_once __DIR__ . '/Players/PlayerManager.php';
|
||||||
|
require_once __DIR__ . '/Players/PlayerActions.php';
|
||||||
require_once __DIR__ . '/Plugins/PluginManager.php';
|
require_once __DIR__ . '/Plugins/PluginManager.php';
|
||||||
require_once __DIR__ . '/Players/PlayerList.php';
|
require_once __DIR__ . '/Players/PlayerList.php';
|
||||||
require_once __DIR__ . '/Server/Server.php';
|
require_once __DIR__ . '/Server/Server.php';
|
||||||
|
59
application/core/Players/PlayerActions.php
Normal file
59
application/core/Players/PlayerActions.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ManiaControl\Players;
|
||||||
|
|
||||||
|
|
||||||
|
use ManiaControl\ManiaControl;
|
||||||
|
|
||||||
|
class PlayerActions {
|
||||||
|
/**
|
||||||
|
* Constants
|
||||||
|
*/
|
||||||
|
const BLUE_TEAM = 0;
|
||||||
|
const RED_TEAM = 1;
|
||||||
|
|
||||||
|
const SPECTATOR_USER_SELECTABLE = 0;
|
||||||
|
const SPECTATOR_SPECTATOR = 1;
|
||||||
|
const SPECTATOR_PLAYER = 2;
|
||||||
|
const SPECTATOR_BUT_KEEP_SELECTABLE = 3;
|
||||||
|
/**
|
||||||
|
* Private properties
|
||||||
|
*/
|
||||||
|
private $maniaControl = null;
|
||||||
|
|
||||||
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
|
$this->maniaControl = $maniaControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces a Player to a certain team
|
||||||
|
* @param $adminLogin
|
||||||
|
* @param $login
|
||||||
|
* @param $teamId
|
||||||
|
*/
|
||||||
|
public function forcePlayerToTeam($adminLogin, $login, $teamId){
|
||||||
|
$this->maniaControl->client->query('ForcePlayerTeam', $login, $teamId); //TODO bestätigung und chatnachricht
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces a Player to spectator
|
||||||
|
* @param $adminLogin
|
||||||
|
* @param $login
|
||||||
|
* @param int $spectatorState
|
||||||
|
*/
|
||||||
|
public function forcePlayerToSpectator($adminLogin, $login, $spectatorState = self::SPECTATOR_BUT_KEEP_SELECTABLE){
|
||||||
|
$this->maniaControl->client->query('ForceSpectator', $login, $spectatorState); //TODO bestätigung und chatnachricht
|
||||||
|
}
|
||||||
|
|
||||||
|
public function warnPlayer($adminLogin, $login, $message = ''){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function kickPlayer($adminLogin, $login, $message = ''){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function banPlayer($adminLogin, $login, $message = ''){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -477,7 +477,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$label->setY($y);
|
$label->setY($y);
|
||||||
$label->setStyle($style);
|
$label->setStyle($style);
|
||||||
$label->setTextSize($textSize);
|
$label->setTextSize($textSize);
|
||||||
$label->setText("Add Operator");
|
$label->setText("Add Moderator");
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
//render and display xml
|
//render and display xml
|
||||||
@ -511,29 +511,43 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
*/
|
*/
|
||||||
public function handleManialinkPageAnswer(array $callback){
|
public function handleManialinkPageAnswer(array $callback){
|
||||||
$actionId = $callback[1][2];
|
$actionId = $callback[1][2];
|
||||||
$forceBlue = (strpos($actionId, self::ACTION_FORCE_BLUE) === 0);
|
|
||||||
$forceRed = (strpos($actionId, self::ACTION_FORCE_RED) === 0);
|
|
||||||
$forceSpec = (strpos($actionId, self::ACTION_FORCE_SPEC) === 0);
|
|
||||||
$playerAdvanced = (strpos($actionId, self::ACTION_PLAYER_ADV) === 0);
|
|
||||||
|
|
||||||
if(!$forceBlue && !$forceRed && !$forceSpec && !$playerAdvanced)
|
|
||||||
return;
|
|
||||||
|
|
||||||
$actionArray = explode(".", $actionId);
|
$actionArray = explode(".", $actionId);
|
||||||
|
|
||||||
//TODO maybe with ids isntead of logins, lower network traffic
|
//TODO maybe with ids instead of logins, lower network traffic
|
||||||
if($forceBlue){
|
switch($actionArray[0].".".$actionArray[1]){
|
||||||
$this->maniaControl->client->query('ForcePlayerTeam', $actionArray[2], 0); //TODO bestätigung
|
case self::ACTION_FORCE_BLUE:
|
||||||
}else if($forceRed){
|
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($callback[1][1],$actionArray[2],playerActions::BLUE_TEAM);
|
||||||
$this->maniaControl->client->query('ForcePlayerTeam', $actionArray[2], 1); //TODO bestätigung
|
break;
|
||||||
}else if($forceSpec){
|
case self::ACTION_FORCE_RED:
|
||||||
$this->maniaControl->client->query('ForceSpectator', $actionArray[2], 3); //TODO bestätigung
|
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($callback[1][1],$actionArray[2],playerActions::RED_TEAM);
|
||||||
}else if($playerAdvanced){
|
break;
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($callback[1][1]);
|
case self::ACTION_FORCE_SPEC:
|
||||||
$this->advancedPlayerWidget($callback, $player, $actionArray[2]);
|
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($callback[1][1],$actionArray[2],playerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
||||||
|
break;
|
||||||
|
case self::ACTION_WARN_PLAYER:
|
||||||
|
$this->maniaControl->playerManager->playerActions->warnPlayer($callback[1][1],$actionArray[2]);
|
||||||
|
break;
|
||||||
|
case self::ACTION_KICK_PLAYER:
|
||||||
|
$this->maniaControl->playerManager->playerActions->kickPlayer($callback[1][1],$actionArray[2]);
|
||||||
|
break;
|
||||||
|
case self::ACTION_BAN_PLAYER:
|
||||||
|
$this->maniaControl->playerManager->playerActions->banPlayer($callback[1][1],$actionArray[2]);
|
||||||
|
break;
|
||||||
|
case self::ACTION_PLAYER_ADV:
|
||||||
|
$player = $this->maniaControl->playerManager->getPlayer($callback[1][1]);
|
||||||
|
$this->advancedPlayerWidget($callback, $player, $actionArray[2]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
$addMaster = (strpos($actionId, self::ACTION_ADD_AS_MASTER) === 0);
|
||||||
|
$addAdmin = (strpos($actionId, self::ACTION_ADD_AS_ADMIN) === 0);
|
||||||
|
$addModerator = (strpos($actionId, self::ACTION_ADD_AS_MOD) === 0);
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,6 +5,7 @@ namespace ManiaControl\Players;
|
|||||||
require_once __DIR__ . '/Player.php';
|
require_once __DIR__ . '/Player.php';
|
||||||
require_once __DIR__ . '/PlayerCommands.php';
|
require_once __DIR__ . '/PlayerCommands.php';
|
||||||
|
|
||||||
|
use FML\Controls\Quad;
|
||||||
use ManiaControl\Formatter;
|
use ManiaControl\Formatter;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
@ -24,7 +25,7 @@ class PlayerManager implements CallbackListener {
|
|||||||
const CB_PLAYERINFOCHANGED = 'PlayerManagerCallback.PlayerInfoChanged';
|
const CB_PLAYERINFOCHANGED = 'PlayerManagerCallback.PlayerInfoChanged';
|
||||||
const TABLE_PLAYERS = 'mc_players';
|
const TABLE_PLAYERS = 'mc_players';
|
||||||
const SETTING_JOIN_LEAVE_MESSAGES = 'Enable Join & Leave Messages';
|
const SETTING_JOIN_LEAVE_MESSAGES = 'Enable Join & Leave Messages';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private properties
|
* Private properties
|
||||||
*/
|
*/
|
||||||
@ -32,6 +33,7 @@ class PlayerManager implements CallbackListener {
|
|||||||
private $playerCommands = null;
|
private $playerCommands = null;
|
||||||
private $playerList = array();
|
private $playerList = array();
|
||||||
|
|
||||||
|
public $playerActions = null;
|
||||||
/**
|
/**
|
||||||
* Construct player manager
|
* Construct player manager
|
||||||
*
|
*
|
||||||
@ -42,7 +44,9 @@ class PlayerManager implements CallbackListener {
|
|||||||
$this->initTables();
|
$this->initTables();
|
||||||
|
|
||||||
$this->playerCommands = new PlayerCommands($maniaControl);
|
$this->playerCommands = new PlayerCommands($maniaControl);
|
||||||
|
|
||||||
|
$this->playerActions = new PlayerActions($maniaControl);
|
||||||
|
|
||||||
// Init settings
|
// Init settings
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES, true);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES, true);
|
||||||
|
|
||||||
@ -51,6 +55,7 @@ class PlayerManager implements CallbackListener {
|
|||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this, 'playerConnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this, 'playerConnect');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERDISCONNECT, $this, 'playerDisconnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERDISCONNECT, $this, 'playerDisconnect');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERINFOCHANGED, $this, 'playerInfoChanged');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERINFOCHANGED, $this, 'playerInfoChanged');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,7 +109,7 @@ class PlayerManager implements CallbackListener {
|
|||||||
$player = new Player($playerInfo);
|
$player = new Player($playerInfo);
|
||||||
$this->addPlayer($player);
|
$this->addPlayer($player);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger own callback
|
// Trigger own callback
|
||||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_ONINIT, array(self::CB_ONINIT));
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_ONINIT, array(self::CB_ONINIT));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user