<?php

/**
 * 大乱斗使用公共车池车辆
 */

namespace Game\Controller\Activity\Scuffle;

use Framework\Define\ErrorDefine;
use Framework\MVC\ControllerBase;
use Framework\Network\SendMessage;
use Game\Logic\Activity\ScuffleLogic;
use Game\Protobuf\CGReplacePublicPoolCar;
use Game\Protobuf\GCReplacePublicPoolCar;
use Game\Protobuf\PacketId;

class CG_ReplacePublicPoolCar extends ControllerBase
{
    use ScuffleLogic;

    private GCReplacePublicPoolCar $sendMessage;

    public function __construct()
    {
        $this->message = new CGReplacePublicPoolCar();
        $this->sendMessage = new GCReplacePublicPoolCar();
    }

    public function run(): int
    {
        $this->sendMessage->setCode(
            $this->playerUsePublicPoolCar(
                $this->message->getIndex(),
                $this->message->getCarTplId()
            ));
        SendMessage::getInstance()->sendClient(PacketId::GC_ReplacePublicPoolCar, $this->sendMessage);
        return ErrorDefine::SUCCESS;
    }
}
