<?php

/**
 * 按注册流程,创建消息
 */

namespace Tool\MakeLocustRequestFile\Script;

require_once __DIR__ . '/../../../Library/AutoLoad.php';

use Tool\MakeLocustRequestFile\Config\Config;
use Tool\MakeLocustRequestFile\Model\Login;
use Tool\MakeLocustRequestFile\Util\PlayerData;
use Tool\MakeLocustRequestFile\Util\TxtUtil;

class MakeLoginProcessData
{
    //生成数据
    public function makeLoginProcessData(int $idx)
    {
        $playerData = array();
        $playerData[PlayerData::KEY_PLAYER_ID] = $idx;
        $playerData[PlayerData::KEY_ACCOUNT] = $idx;
        $playerData[PlayerData::KEY_DEFAULT_CAR_UID] = 0;
        $playerData[PlayerData::KEY_DEFAULT_CAR_ID] = Config::CREATE_DEFAULT_CAR_ID;
        PlayerData::getInstance()->clearPlayerData($playerData);
        $config = new Config();
        $loginModelName = $config->getModelName(Config::MODEL_LOGIN);
        /**
         * @var Login $loginModel
         */
        $loginModel = new $loginModelName();
        $data = array();
        $loginModel->getRegisetProcessData($data);
        $txtUtil = new TxtUtil();
        $txtUtil->writeTxtFile($idx, $data);
    }
}

////测试
//$make = new MakeLoginProcessData();
//$make->makeLoginProcessData(1);
