You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.0 KiB
PHP
68 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Base\Tool;
|
|
|
|
use GuzzleHttp\Client;
|
|
use GuzzleHttp\Exception\RequestException;
|
|
|
|
use Base\Tool\GameResource\YzchzbClient;
|
|
use Base\Tool\GameResource\LsxxClient;
|
|
use Base\Tool\GameResource\JtxcClient;
|
|
use Base\Tool\GameResource\JxjClient;
|
|
|
|
/**
|
|
* 游戏资源接口
|
|
*/
|
|
class GameResource
|
|
{
|
|
private $client;
|
|
private $game;
|
|
|
|
private $clientMap = [
|
|
191 => LeyouClient::class, // 九天仙尘(安卓版)
|
|
192 => LeyouClient::class, // 九天仙尘(苹果版)
|
|
229 => YzchzbClient::class, // 远征手游之楚汉争霸(安卓版)
|
|
230 => YzchzbClient::class, // 远征手游之楚汉争霸(苹果版)
|
|
231 => LsxxClient::class, // 乱世枭雄(安卓版)
|
|
232 => LsxxClient::class, // 乱世枭雄(苹果版)
|
|
239 => LeyouClient::class, // 剑仙诀(安卓版)
|
|
240 => LeyouClient::class, // 剑仙诀(苹果版)
|
|
247 => LeyouClient::class, // 剑破长空(安卓版)
|
|
248 => LeyouClient::class, // 剑破长空(苹果版)
|
|
];
|
|
|
|
public function __construct($game)
|
|
{
|
|
$this->game = $game;
|
|
$this->client = $this->createClient();
|
|
}
|
|
|
|
private function createClient()
|
|
{
|
|
$clientClass = '';
|
|
$gameId = intval($this->game['id']);
|
|
if (isset($this->clientMap[$gameId])) {
|
|
$clientClass = $this->clientMap[$gameId];
|
|
} else {
|
|
throw new \Exception('游戏资源客户端未配置');
|
|
}
|
|
return new $clientClass();
|
|
}
|
|
|
|
public function getResourceTypes()
|
|
{
|
|
$deviceType = $this->game['sdk_version'] == 1 ? 'andriod' : 'ios';
|
|
return $this->client->getResourceTypes($deviceType);
|
|
}
|
|
|
|
public function getResources($typeId = null)
|
|
{
|
|
$deviceType = $this->game['sdk_version'] == 1 ? 'andriod' : 'ios';
|
|
return $this->client->getResources($typeId, $deviceType);
|
|
}
|
|
|
|
public function apply($order, $role)
|
|
{
|
|
return $this->client->apply($order, $role);
|
|
}
|
|
} |