feat: Global/GetMap, Global/GetCachedMap 추가
- 지도를 가져오는 코드 - GetCahcedMap에서는 600초 단위 캐싱 - history 필드에 최근 10건 표시
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\API\Global;
|
||||
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\MapRequest;
|
||||
use sammo\Validator;
|
||||
|
||||
use function sammo\getWorldMap;
|
||||
|
||||
class GetMap extends \sammo\BaseAPI
|
||||
{
|
||||
public function validateArgs(): ?string
|
||||
{
|
||||
$v = new Validator($this->args);
|
||||
$v->rule('boolean', 'neutralView')
|
||||
->rule('boolean', 'showMe');
|
||||
if (!$v->validate()) {
|
||||
return $v->errorStr();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getRequiredSessionMode(): int
|
||||
{
|
||||
return static::REQ_LOGIN | static::REQ_READ_ONLY;
|
||||
}
|
||||
|
||||
public function launch(Session $session, ?DateTimeInterface $modifiedSince, ?string $reqEtag)
|
||||
{
|
||||
return getWorldMap(new MapRequest([
|
||||
'neutralView' => !!($this->args['neutralView'] ?? false),
|
||||
'showMe' => !!($this->args['showMe'] ?? false),
|
||||
]));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user