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.

54 lines
1.3 KiB
PHTML

4 years ago
<?php
namespace Base\Tool;
2 years ago
use Base\Tool\GameResource\TzjClient;
4 years ago
/**
* 游戏资源接口
*/
class GameResource
{
private $client;
private $game;
private $clientMap = [
2 years ago
6 => TzjClient::class, // 天之禁2(安卓版)
7 => TzjClient::class, // 天之禁2(苹果版)
4 years ago
];
public function __construct($game)
{
$this->game = $game;
3 years ago
$this->client = $this->createClient($game);
4 years ago
}
3 years ago
private function createClient($game)
4 years ago
{
$clientClass = '';
3 years ago
$gameId = intval($game['id']);
4 years ago
if (isset($this->clientMap[$gameId])) {
$clientClass = $this->clientMap[$gameId];
} else {
throw new \Exception('游戏资源客户端未配置');
}
3 years ago
return new $clientClass($game);
4 years ago
}
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);
}
}