fix: phan 메시지에 따라 수정
- array에 +=를 phan 알아듣기 쉽게 array_merge로 - Util::array_get이 더 이상 필요없으므로 null coalescing - array로 tuple류를 반환하는 함수에 index를 포함하도록 변경 - php intelephense에게는 현재 무효 - getPost 일부 값에 int 지정 - 아이템에 id property를 없앴으므로 관련 코드 제거 - enum은 array key로 사용할 수 없으므로 \Ds\Map으로 변경 - KakaoKey PhanRedefineClass 에러 우회
This commit is contained in:
@@ -173,7 +173,7 @@ $serverID = $emperior['server_id'] ?? ($emperior['serverID'] ?? null);
|
|||||||
if (!$nation['nation'] ?? null) {
|
if (!$nation['nation'] ?? null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$nation += Json::decode($nation['data']);
|
$nation = array_merge(Json::decode($nation['data']), $nation);
|
||||||
|
|
||||||
/** @var array $nation */
|
/** @var array $nation */
|
||||||
$nation['typeName'] = getNationType($nation['type']);
|
$nation['typeName'] = getNationType($nation['type']);
|
||||||
@@ -201,7 +201,7 @@ $serverID = $emperior['server_id'] ?? ($emperior['serverID'] ?? null);
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (key_exists('aux', $nation) && !is_array($nation['aux'])) {
|
if (key_exists('aux', $nation) && !is_array($nation['aux'])) {
|
||||||
$nation += Json::decode($nation['aux']);
|
$nation = array_merge(Json::decode($nation['aux']), $nation);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $templates->render('oldNation', $nation);
|
echo $templates->render('oldNation', $nation);
|
||||||
|
|||||||
@@ -110,7 +110,8 @@ if ($scenarioIdx && key_exists($scenarioIdx, $scenarioList[$seasonIdx] ?? [])) {
|
|||||||
|
|
||||||
$hallResult = array_map(function ($general) use ($typeValue, $ownerNameList) {
|
$hallResult = array_map(function ($general) use ($typeValue, $ownerNameList) {
|
||||||
$aux = Json::decode($general['aux']);
|
$aux = Json::decode($general['aux']);
|
||||||
$general += $aux;
|
/** @var array $general */
|
||||||
|
$general = array_merge($aux, $general);
|
||||||
|
|
||||||
if (key_exists($general['owner'], $ownerNameList)) {
|
if (key_exists($general['owner'], $ownerNameList)) {
|
||||||
$general['ownerName'] = $ownerNameList[$general['owner']];
|
$general['ownerName'] = $ownerNameList[$general['owner']];
|
||||||
@@ -118,10 +119,11 @@ if ($scenarioIdx && key_exists($scenarioIdx, $scenarioList[$seasonIdx] ?? [])) {
|
|||||||
|
|
||||||
if (!key_exists('bgColor', $general)) {
|
if (!key_exists('bgColor', $general)) {
|
||||||
if (!key_exists('color', $general)) {
|
if (!key_exists('color', $general)) {
|
||||||
$general['bgColor'] = GameConst::$basecolor4;
|
$color = GameConst::$basecolor4;
|
||||||
} else {
|
} else {
|
||||||
$general['bgColor'] = $general['color'];
|
$color = $general['color'];
|
||||||
}
|
}
|
||||||
|
$general['bgColor'] = $color;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!key_exists('fgColor', $general)) {
|
if (!key_exists('fgColor', $general)) {
|
||||||
|
|||||||
+4
-3
@@ -882,9 +882,9 @@ function generalInfo2(General $generalObj)
|
|||||||
</table>";
|
</table>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOnlineNum()
|
function getOnlineNum(): int
|
||||||
{
|
{
|
||||||
return KVStorage::getStorage(DB::db(), 'game_env')->online;
|
return KVStorage::getStorage(DB::db(), 'game_env')->getValue('online') ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onlinegen(General $general)
|
function onlinegen(General $general)
|
||||||
@@ -1075,6 +1075,7 @@ function updateTraffic()
|
|||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$admin = $gameStor->getValues(['year', 'month', 'refresh', 'maxonline', 'maxrefresh']);
|
$admin = $gameStor->getValues(['year', 'month', 'refresh', 'maxonline', 'maxrefresh']);
|
||||||
|
/** @var array{year:int,month:int,refresh:int,maxonline:int,maxrefresh:int} $admin */
|
||||||
|
|
||||||
//최다갱신자
|
//최다갱신자
|
||||||
$user = $db->queryFirstRow('select name,refresh from general order by refresh desc limit 1');
|
$user = $db->queryFirstRow('select name,refresh from general order by refresh desc limit 1');
|
||||||
@@ -2248,7 +2249,7 @@ function calcCityDistance(int $from, int $to, ?array $linkNationList): ?int
|
|||||||
* @param $from 기준 도시 코드
|
* @param $from 기준 도시 코드
|
||||||
* @param $to 대상 도시 코드
|
* @param $to 대상 도시 코드
|
||||||
* @param $linkNationList 경로에 해당하는 국가 리스트
|
* @param $linkNationList 경로에 해당하는 국가 리스트
|
||||||
* @return array $dist=>[cityID, $nation] 배열 가장 앞이 가장 가까움
|
* @return array<int,array{int,int}[]> $dist=>[cityID, $nation] 배열 가장 앞이 가장 가까움
|
||||||
*/
|
*/
|
||||||
function searchDistanceListToDest(int $from, int $to, array $linkNationList)
|
function searchDistanceListToDest(int $from, int $to, array $linkNationList)
|
||||||
{
|
{
|
||||||
|
|||||||
+5
-5
@@ -8,11 +8,11 @@ class MapRequest{
|
|||||||
public $neutralView;
|
public $neutralView;
|
||||||
public $showMe;
|
public $showMe;
|
||||||
function __construct($obj){
|
function __construct($obj){
|
||||||
$this->serverID = Util::array_get($obj['serverID'], null);
|
$this->serverID = $obj['serverID'] ?? null;
|
||||||
$this->year = Util::array_get($obj['year']);
|
$this->year = $obj['year'] ?? null;
|
||||||
$this->month = Util::array_get($obj['month']);
|
$this->month = $obj['month'] ?? null;
|
||||||
$this->aux = Util::array_get($obj['aux'],[]);
|
$this->aux = $obj['aux'] ?? [];
|
||||||
$this->neutralView = Util::array_get($obj['neutralView'], false);
|
$this->neutralView = $obj['neutralView'] ?? false;
|
||||||
$this->showMe = $obj['showMe'];
|
$this->showMe = $obj['showMe'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ function getTournament(int $tnmt)
|
|||||||
][$tnmt] ?? "TOURNAMENT_TYPE_ERR_{$tnmt}";
|
][$tnmt] ?? "TOURNAMENT_TYPE_ERR_{$tnmt}";
|
||||||
}
|
}
|
||||||
|
|
||||||
function printRow($k, $npc, $name, $abil, $tgame, $win, $draw, $lose, $gd, $gl, $prmt)
|
function printRow(int $k, int $npc, string $name, $abil, $tgame, $win, $draw, $lose, $gd, $gl, $prmt)
|
||||||
{
|
{
|
||||||
$k += 1;
|
$k += 1;
|
||||||
if ($prmt > 0) {
|
if ($prmt > 0) {
|
||||||
@@ -588,7 +588,10 @@ function fillLowGenAll($tnmt_type)
|
|||||||
//7 8강
|
//7 8강
|
||||||
//8 4강
|
//8 4강
|
||||||
//9 결승
|
//9 결승
|
||||||
function getTwo($tournament, $phase)
|
/**
|
||||||
|
* @return array{0:int,1:int}
|
||||||
|
*/
|
||||||
|
function getTwo(int $tournament, int $phase): array
|
||||||
{
|
{
|
||||||
$cand = [];
|
$cand = [];
|
||||||
switch ($tournament) {
|
switch ($tournament) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ include "func.php";
|
|||||||
|
|
||||||
WebUtil::requireAJAX();
|
WebUtil::requireAJAX();
|
||||||
|
|
||||||
|
/** @var int|null */
|
||||||
$pick = Util::getPost('pick', 'int');
|
$pick = Util::getPost('pick', 'int');
|
||||||
|
|
||||||
if(!$pick){
|
if(!$pick){
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ $loader->addClassMap((function () {
|
|||||||
|
|
||||||
|
|
||||||
//디버그용 매크로
|
//디버그용 매크로
|
||||||
ini_set("session.cache_expire", 10080); // minutes
|
ini_set("session.cache_expire", "10080"); // minutes
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ class GetConst extends \sammo\BaseAPI
|
|||||||
|
|
||||||
public function genConstData()
|
public function genConstData()
|
||||||
{
|
{
|
||||||
|
/** @var array<string,array{0:string,1:string[],2?:int> */
|
||||||
$gameConstKeys = [
|
$gameConstKeys = [
|
||||||
'nationType' => [
|
'nationType' => [
|
||||||
'\sammo\buildNationTypeClass',
|
'\sammo\buildNationTypeClass',
|
||||||
|
|||||||
@@ -15,10 +15,6 @@ class BaseItem implements iAction{
|
|||||||
protected $buyable = false;
|
protected $buyable = false;
|
||||||
protected $reqSecu = 0;
|
protected $reqSecu = 0;
|
||||||
|
|
||||||
function getID(){
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getRawName(){
|
function getRawName(){
|
||||||
return $this->rawName;
|
return $this->rawName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class BaseStatItem extends BaseItem{
|
|||||||
protected $rawName = '노기';
|
protected $rawName = '노기';
|
||||||
protected $consumable = false;
|
protected $consumable = false;
|
||||||
protected $buyable = true;
|
protected $buyable = true;
|
||||||
|
|
||||||
protected const ITEM_TYPE = [
|
protected const ITEM_TYPE = [
|
||||||
'명마'=>['통솔', 'leadership'],
|
'명마'=>['통솔', 'leadership'],
|
||||||
'무기'=>['무력', 'strength'],
|
'무기'=>['무력', 'strength'],
|
||||||
@@ -27,7 +27,6 @@ class BaseStatItem extends BaseItem{
|
|||||||
$this->rawName = $nameTokens[$tokenLen-1];
|
$this->rawName = $nameTokens[$tokenLen-1];
|
||||||
[$this->statNick, $this->statType] = static::ITEM_TYPE[$nameTokens[$tokenLen-3]];
|
[$this->statNick, $this->statType] = static::ITEM_TYPE[$nameTokens[$tokenLen-3]];
|
||||||
|
|
||||||
$this->id = $this->statValue;
|
|
||||||
$this->name = sprintf('%s(+%d)',$this->rawName, $this->statValue);
|
$this->name = sprintf('%s(+%d)',$this->rawName, $this->statValue);
|
||||||
$this->info = sprintf('%s +%d', $this->statNick, $this->statValue);
|
$this->info = sprintf('%s +%d', $this->statNick, $this->statValue);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use Ds\Map;
|
||||||
use sammo\DTO\BettingInfo;
|
use sammo\DTO\BettingInfo;
|
||||||
use sammo\DTO\BettingItem;
|
use sammo\DTO\BettingItem;
|
||||||
use sammo\Enums\RankColumn;
|
use sammo\Enums\RankColumn;
|
||||||
@@ -346,12 +347,13 @@ class Betting
|
|||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
if ($this->info->reqInheritancePoint) {
|
if ($this->info->reqInheritancePoint) {
|
||||||
/** @var UserLogger[] */
|
/** @var Map<int,UserLogger> */
|
||||||
$loggers = [];
|
$loggers = new Map();
|
||||||
foreach ($rewardList as $rewardItem) {
|
foreach ($rewardList as $rewardItem) {
|
||||||
if ($rewardItem['userID'] === null) {
|
if ($rewardItem['userID'] === null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
/** @var int */
|
||||||
$userID = $rewardItem['userID'];
|
$userID = $rewardItem['userID'];
|
||||||
$amount = $rewardItem['amount'];
|
$amount = $rewardItem['amount'];
|
||||||
|
|
||||||
@@ -373,7 +375,7 @@ class Betting
|
|||||||
$partialText = "베팅 부분 당첨({$matchPoint}/{$selectCnt})";
|
$partialText = "베팅 부분 당첨({$matchPoint}/{$selectCnt})";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key_exists($userID, $loggers)) {
|
if ($loggers->hasKey($userID)) {
|
||||||
$userLogger = $loggers[$userID];
|
$userLogger = $loggers[$userID];
|
||||||
} else {
|
} else {
|
||||||
$userLogger = new UserLogger($userID);
|
$userLogger = new UserLogger($userID);
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ use function \sammo\getTechAbil;
|
|||||||
use function sammo\getTechLevel;
|
use function sammo\getTechLevel;
|
||||||
|
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
use sammo\MustNotBeReachedException;
|
||||||
|
|
||||||
|
|
||||||
class che_징병 extends Command\GeneralCommand
|
class che_징병 extends Command\GeneralCommand
|
||||||
{
|
{
|
||||||
@@ -98,6 +97,9 @@ class che_징병 extends Command\GeneralCommand
|
|||||||
$maxCrew = $leadership * 100;
|
$maxCrew = $leadership * 100;
|
||||||
|
|
||||||
$reqCrewType = GameUnitConst::byID($this->arg['crewType']);
|
$reqCrewType = GameUnitConst::byID($this->arg['crewType']);
|
||||||
|
if($reqCrewType === null){
|
||||||
|
throw new MustNotBeReachedException();
|
||||||
|
}
|
||||||
if ($reqCrewType->id == $currCrewType->id) {
|
if ($reqCrewType->id == $currCrewType->id) {
|
||||||
$maxCrew -= $general->getVar('crew');
|
$maxCrew -= $general->getVar('crew');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,6 +158,8 @@ class che_출병 extends Command\GeneralCommand
|
|||||||
|
|
||||||
$candidateCities = [];
|
$candidateCities = [];
|
||||||
|
|
||||||
|
$currDist = 999;
|
||||||
|
|
||||||
$minDist = Util::array_first_key($distanceList);
|
$minDist = Util::array_first_key($distanceList);
|
||||||
do {
|
do {
|
||||||
//1: 최단 거리 도시 중 공격 대상이 있는가 확인
|
//1: 최단 거리 도시 중 공격 대상이 있는가 확인
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ class RaiseInvader extends \sammo\Event\Action
|
|||||||
->setNPCType(9)
|
->setNPCType(9)
|
||||||
->setStat(Util::toInt($specAvg * 1.8), Util::toInt($specAvg * 1.8), Util::toInt($specAvg * 1.2))
|
->setStat(Util::toInt($specAvg * 1.8), Util::toInt($specAvg * 1.8), Util::toInt($specAvg * 1.2))
|
||||||
->setAffinity(999)
|
->setAffinity(999)
|
||||||
->setExpDed($exp * 1.2, null)
|
->setExpDed(Util::toInt($exp * 1.2), null)
|
||||||
->setGoldRice(99999, 99999);
|
->setGoldRice(99999, 99999);
|
||||||
$ruler->build($env);
|
$ruler->build($env);
|
||||||
|
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ class General implements iAction
|
|||||||
* @param bool $withStatAdjust 능력치간 보정 사용 여부
|
* @param bool $withStatAdjust 능력치간 보정 사용 여부
|
||||||
* @param bool $useFloor 내림 사용 여부, false시 float 값을 반환할 수도 있음
|
* @param bool $useFloor 내림 사용 여부, false시 float 값을 반환할 수도 있음
|
||||||
*
|
*
|
||||||
* @return int|float 계산된 능력치
|
* @return float 계산된 능력치
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected function getStatValue(string $statName, $withInjury = true, $withIActionObj = true, $withStatAdjust = true, $useFloor = true): float
|
protected function getStatValue(string $statName, $withInjury = true, $withIActionObj = true, $withStatAdjust = true, $useFloor = true): float
|
||||||
@@ -1130,7 +1130,7 @@ class General implements iAction
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ?int[] $generalIDList
|
* @param ?int[] $generalIDList
|
||||||
* @param null|string|RankColumn[] $column
|
* @param null|array<string|RankColumn> $column
|
||||||
* @param int $constructMode
|
* @param int $constructMode
|
||||||
* @return \sammo\General[]
|
* @return \sammo\General[]
|
||||||
* @throws MustNotBeReachedException
|
* @throws MustNotBeReachedException
|
||||||
|
|||||||
+16
-14
@@ -11,12 +11,9 @@ class GeneralAI
|
|||||||
{
|
{
|
||||||
/** @var General */
|
/** @var General */
|
||||||
protected $general;
|
protected $general;
|
||||||
/** @var array */
|
protected array $city;
|
||||||
protected $city;
|
protected array $nation;
|
||||||
/** @var array */
|
protected int $genType;
|
||||||
protected $nation;
|
|
||||||
/** @var int */
|
|
||||||
protected $genType;
|
|
||||||
|
|
||||||
/** @var AutorunGeneralPolicy */
|
/** @var AutorunGeneralPolicy */
|
||||||
protected $generalPolicy;
|
protected $generalPolicy;
|
||||||
@@ -90,13 +87,12 @@ class GeneralAI
|
|||||||
$this->env = $gameStor->getAll(true);
|
$this->env = $gameStor->getAll(true);
|
||||||
$this->baseDevelCost = $this->env['develcost'] * 12;
|
$this->baseDevelCost = $this->env['develcost'] * 12;
|
||||||
$this->general = $general;
|
$this->general = $general;
|
||||||
if ($general->getRawCity() === null) {
|
$city = $general->getRawCity();
|
||||||
|
if ($city === null) {
|
||||||
$city = $db->queryFirstRow('SELECT * FROM city WHERE city = %i', $general->getCityID());
|
$city = $db->queryFirstRow('SELECT * FROM city WHERE city = %i', $general->getCityID());
|
||||||
$general->setRawCity($city);
|
$general->setRawCity($city);
|
||||||
$this->city = $city;
|
|
||||||
} else {
|
|
||||||
$this->city = $general->getRawCity();
|
|
||||||
}
|
}
|
||||||
|
$this->city = $city;
|
||||||
|
|
||||||
$this->nation = $db->queryFirstRow(
|
$this->nation = $db->queryFirstRow(
|
||||||
'SELECT nation,name,color,capital,capset,gennum,gold,rice,bill,rate,rate_tmp,scout,war,strategic_cmd_limit,surlimit,tech,power,level,chief_set,type,aux FROM nation WHERE nation = %i',
|
'SELECT nation,name,color,capital,capset,gennum,gold,rice,bill,rate,rate_tmp,scout,war,strategic_cmd_limit,surlimit,tech,power,level,chief_set,type,aux FROM nation WHERE nation = %i',
|
||||||
@@ -866,7 +862,7 @@ class GeneralAI
|
|||||||
|
|
||||||
$userGenerals = $this->userCivilGenerals;
|
$userGenerals = $this->userCivilGenerals;
|
||||||
if (in_array($this->dipState, [self::d평화, self::d선포])) {
|
if (in_array($this->dipState, [self::d평화, self::d선포])) {
|
||||||
$userGenerals += $this->userWarGenerals;
|
$userGenerals = array_merge($this->userWarGenerals, $userGenerals);
|
||||||
}
|
}
|
||||||
|
|
||||||
$generalCandidates = [];
|
$generalCandidates = [];
|
||||||
@@ -1142,7 +1138,7 @@ class GeneralAI
|
|||||||
|
|
||||||
$npcGenerals = $this->npcCivilGenerals;
|
$npcGenerals = $this->npcCivilGenerals;
|
||||||
if (in_array($this->dipState, [self::d평화, self::d선포])) {
|
if (in_array($this->dipState, [self::d평화, self::d선포])) {
|
||||||
$npcGenerals += $this->npcWarGenerals;
|
$npcGenerals = array_merge($this->npcWarGenerals, $npcGenerals);
|
||||||
}
|
}
|
||||||
|
|
||||||
$generalCandidates = [];
|
$generalCandidates = [];
|
||||||
@@ -3826,16 +3822,23 @@ class GeneralAI
|
|||||||
|
|
||||||
|
|
||||||
$picked = false;
|
$picked = false;
|
||||||
|
|
||||||
|
/** @var General|null */
|
||||||
|
$randGeneral = null;
|
||||||
foreach (Util::range(5) as $idx) {
|
foreach (Util::range(5) as $idx) {
|
||||||
|
|
||||||
/** @var General */
|
/** @var General */
|
||||||
if ($this->npcWarGenerals) {
|
if ($this->npcWarGenerals) {
|
||||||
|
/** @var General */
|
||||||
$randGeneral = Util::choiceRandom($this->npcWarGenerals);
|
$randGeneral = Util::choiceRandom($this->npcWarGenerals);
|
||||||
} else if ($this->npcCivilGenerals) {
|
} else if ($this->npcCivilGenerals) {
|
||||||
|
/** @var General */
|
||||||
$randGeneral = Util::choiceRandom($this->npcCivilGenerals);
|
$randGeneral = Util::choiceRandom($this->npcCivilGenerals);
|
||||||
} else if ($this->userWarGenerals) {
|
} else if ($this->userWarGenerals) {
|
||||||
|
/** @var General */
|
||||||
$randGeneral = Util::choiceRandom($this->userWarGenerals);
|
$randGeneral = Util::choiceRandom($this->userWarGenerals);
|
||||||
} else if ($this->userCivilGenerals) {
|
} else if ($this->userCivilGenerals) {
|
||||||
|
/** @var General */
|
||||||
$randGeneral = Util::choiceRandom($this->userCivilGenerals);
|
$randGeneral = Util::choiceRandom($this->userCivilGenerals);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@@ -3863,11 +3866,10 @@ class GeneralAI
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$picked || !$randGeneral) {
|
if (!$picked || $randGeneral === null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var General $randGeneral */
|
|
||||||
$randGeneral->setVar('officer_level', $chiefLevel);
|
$randGeneral->setVar('officer_level', $chiefLevel);
|
||||||
$randGeneral->setVar('officer_city', 0);
|
$randGeneral->setVar('officer_city', 0);
|
||||||
$randGeneral->applyDB($db);
|
$randGeneral->applyDB($db);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class che_도시치료 extends BaseGeneralTrigger{
|
|||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
|
/** @var array{int,string,string}[] $patients */
|
||||||
$patients = $db->queryAllLists(
|
$patients = $db->queryAllLists(
|
||||||
'SELECT no,name,nation FROM general WHERE city=%i AND injury > 10 AND no != %i',
|
'SELECT no,name,nation FROM general WHERE city=%i AND injury > 10 AND no != %i',
|
||||||
$general->getCityID(),
|
$general->getCityID(),
|
||||||
@@ -39,6 +40,7 @@ class che_도시치료 extends BaseGeneralTrigger{
|
|||||||
|
|
||||||
$cureList = [];
|
$cureList = [];
|
||||||
|
|
||||||
|
/** @var string|null */
|
||||||
$curedPatientName = null;
|
$curedPatientName = null;
|
||||||
foreach($patients as [$patientID, $patientName, $patientNationID]){
|
foreach($patients as [$patientID, $patientName, $patientNationID]){
|
||||||
if (!Util::randBool(0.5)) {
|
if (!Util::randBool(0.5)) {
|
||||||
@@ -56,6 +58,10 @@ class che_도시치료 extends BaseGeneralTrigger{
|
|||||||
return $env;
|
return $env;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($curedPatientName === null){
|
||||||
|
throw new \sammo\MustNotBeReachedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(count($cureList) == 1){
|
if(count($cureList) == 1){
|
||||||
$josaUl = JosaUtil::pick($curedPatientName, "을");
|
$josaUl = JosaUtil::pick($curedPatientName, "을");
|
||||||
|
|||||||
@@ -285,14 +285,13 @@ class InheritancePointManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: 굳이 merge, apply, clean 3단계를 거쳐야 할 이유가 없음
|
//FIXME: 굳이 merge, apply, clean 3단계를 거쳐야 할 이유가 없음
|
||||||
/** @var array[InheritanceKey]float */
|
/** @var Map<InheritanceKey,float> */
|
||||||
$rebirthDegraded = [
|
$rebirthDegraded = new Map();
|
||||||
InheritanceKey::dex => 0.5,
|
$rebirthDegraded[InheritanceKey::dex] = 0.5;
|
||||||
];
|
|
||||||
|
|
||||||
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$userID}");
|
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$userID}");
|
||||||
$totalPoint = 0;
|
$totalPoint = 0;
|
||||||
/** @var array[InheritanceKey][float, string|float] */
|
/** @var array<string,array{0:float,1:string|float}> */
|
||||||
$allPoints = $inheritStor->getAll();
|
$allPoints = $inheritStor->getAll();
|
||||||
if (!$allPoints || count($allPoints) == 0) {
|
if (!$allPoints || count($allPoints) == 0) {
|
||||||
//비었으므로 리셋 안함
|
//비었으므로 리셋 안함
|
||||||
@@ -309,7 +308,7 @@ class InheritancePointManager
|
|||||||
|
|
||||||
foreach ($allPoints as $rKey => [$value,]) {
|
foreach ($allPoints as $rKey => [$value,]) {
|
||||||
$key = InheritanceKey::from($rKey);
|
$key = InheritanceKey::from($rKey);
|
||||||
if ($isRebirth && key_exists($key, $rebirthDegraded)) {
|
if ($isRebirth && $rebirthDegraded->hasKey($key)) {
|
||||||
$value *= $rebirthDegraded[$key];
|
$value *= $rebirthDegraded[$key];
|
||||||
}
|
}
|
||||||
$keyText = $this->getInheritancePointType($key)->info;
|
$keyText = $this->getInheritancePointType($key)->info;
|
||||||
|
|||||||
@@ -375,9 +375,9 @@ class Scenario{
|
|||||||
'npcNeutral_cnt'=>count($this->getNPCneutral()),
|
'npcNeutral_cnt'=>count($this->getNPCneutral()),
|
||||||
'nation'=>array_map(function($nation) use ($nationGeneralCnt, $nationGeneralExCnt, $nationGeneralNeutralCnt){
|
'nation'=>array_map(function($nation) use ($nationGeneralCnt, $nationGeneralExCnt, $nationGeneralNeutralCnt){
|
||||||
$brief = $nation->getBrief();
|
$brief = $nation->getBrief();
|
||||||
$brief['generals'] = Util::array_get($nationGeneralCnt[$nation->getID()], 0);
|
$brief['generals'] = $nationGeneralCnt[$nation->getID()] ?? 0;
|
||||||
$brief['generalsEx'] = Util::array_get($nationGeneralExCnt[$nation->getID()], 0);
|
$brief['generalsEx'] = $nationGeneralExCnt[$nation->getID()] ?? 0;
|
||||||
$brief['generalsNeutral'] = Util::array_get($nationGeneralNeutralCnt[$nation->getID()], 0);
|
$brief['generalsNeutral'] = $nationGeneralNeutralCnt[$nation->getID()] ?? 0;
|
||||||
|
|
||||||
return $brief;
|
return $brief;
|
||||||
},$this->getNation())
|
},$this->getNation())
|
||||||
|
|||||||
@@ -25,15 +25,15 @@ class Nation{
|
|||||||
private $generals = [];
|
private $generals = [];
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
int $id = null,
|
int $id = null,
|
||||||
string $name = '국가',
|
string $name = '국가',
|
||||||
string $color = '#000000',
|
string $color = '#000000',
|
||||||
int $gold = 0,
|
int $gold = 0,
|
||||||
int $rice = 2000,
|
int $rice = 2000,
|
||||||
string $infoText = '국가 설명',
|
string $infoText = '국가 설명',
|
||||||
int $tech = 0,
|
int $tech = 0,
|
||||||
?string $type = null,
|
?string $type = null,
|
||||||
int $nationLevel = 0,
|
int $nationLevel = 0,
|
||||||
array $cities = []
|
array $cities = []
|
||||||
){
|
){
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
@@ -47,7 +47,7 @@ class Nation{
|
|||||||
$this->nationLevel = $nationLevel;
|
$this->nationLevel = $nationLevel;
|
||||||
$this->cities = $cities;
|
$this->cities = $cities;
|
||||||
|
|
||||||
if(count($cities)){
|
if(count($this->cities)){
|
||||||
$this->capital = $this->cities[0];
|
$this->capital = $this->cities[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ class Nation{
|
|||||||
else{
|
else{
|
||||||
$capital = 0;
|
$capital = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->type === null){
|
if($this->type === null){
|
||||||
$type = Util::choiceRandom(GameConst::$availableNationType);
|
$type = Util::choiceRandom(GameConst::$availableNationType);
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ class Nation{
|
|||||||
|
|
||||||
$nationStor->scout_msg = $this->infoText;
|
$nationStor->scout_msg = $this->infoText;
|
||||||
|
|
||||||
|
|
||||||
$diplomacy = [];
|
$diplomacy = [];
|
||||||
foreach($otherNations as $nation){
|
foreach($otherNations as $nation){
|
||||||
$diplomacy[] = [
|
$diplomacy[] = [
|
||||||
@@ -143,7 +143,7 @@ class Nation{
|
|||||||
if(count($diplomacy) > 0){
|
if(count($diplomacy) > 0){
|
||||||
$db->insert('diplomacy', $diplomacy);
|
$db->insert('diplomacy', $diplomacy);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addGeneral(GeneralBuilder $general){
|
public function addGeneral(GeneralBuilder $general){
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace kakao;
|
namespace kakao;
|
||||||
|
|
||||||
if (class_exists('\\kakao\\KakaoKey') === false) {
|
class KakaoKeyNull
|
||||||
// @suppress PhanRedefineClass
|
{
|
||||||
class KakaoKey
|
const REST_KEY = '';
|
||||||
{
|
const ADMIN_KEY = '';
|
||||||
const REST_KEY = '';
|
const REDIRECT_URI = '';
|
||||||
const ADMIN_KEY = '';
|
}
|
||||||
const REDIRECT_URI = '';
|
|
||||||
}
|
if (!class_exists('\\kakao\\KakaoKey')) {
|
||||||
|
class_alias('\\kakao\\KakaoKeyNull', '\\kakao\\KakaoKey');
|
||||||
}
|
}
|
||||||
//https://devtalk.kakao.com/t/php-rest-api/14602/3
|
//https://devtalk.kakao.com/t/php-rest-api/14602/3
|
||||||
//header('Content-Type: application/json; charset=utf-8');
|
//header('Content-Type: application/json; charset=utf-8');
|
||||||
@@ -46,7 +48,7 @@ class Story_Path
|
|||||||
|
|
||||||
class Talk_Path
|
class Talk_Path
|
||||||
{
|
{
|
||||||
public static $TALK_PROFILE= "/v1/api/talk/profile";
|
public static $TALK_PROFILE = "/v1/api/talk/profile";
|
||||||
public static $TALK_TO_ME = "/v2/api/talk/memo/send";
|
public static $TALK_TO_ME = "/v2/api/talk/memo/send";
|
||||||
public static $TALK_TO_ME_DEFAULT = "/v2/api/talk/memo/default/send";
|
public static $TALK_TO_ME_DEFAULT = "/v2/api/talk/memo/default/send";
|
||||||
}
|
}
|
||||||
@@ -77,12 +79,12 @@ class Kakao_REST_API_Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
self::$admin_apis = array(
|
self::$admin_apis = array(
|
||||||
User_Management_Path::$USER_IDS,
|
User_Management_Path::$USER_IDS,
|
||||||
Push_Notification_Path::$REGISTER,
|
Push_Notification_Path::$REGISTER,
|
||||||
Push_Notification_Path::$TOKENS,
|
Push_Notification_Path::$TOKENS,
|
||||||
Push_Notification_Path::$DEREGISTER,
|
Push_Notification_Path::$DEREGISTER,
|
||||||
Push_Notification_Path::$SEND
|
Push_Notification_Path::$SEND
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function request($api_path, $params = '', $http_method = 'GET')
|
public function request($api_path, $params = '', $http_method = 'GET')
|
||||||
@@ -94,7 +96,7 @@ class Kakao_REST_API_Helper
|
|||||||
$requestUrl = ($api_path == '/oauth/token' ? self::$OAUTH_HOST : self::$API_HOST) . $api_path;
|
$requestUrl = ($api_path == '/oauth/token' ? self::$OAUTH_HOST : self::$API_HOST) . $api_path;
|
||||||
|
|
||||||
if (($http_method == 'GET' || $http_method == 'DELETE') && !empty($params)) {
|
if (($http_method == 'GET' || $http_method == 'DELETE') && !empty($params)) {
|
||||||
$requestUrl .= '?'.$params;
|
$requestUrl .= '?' . $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
$opts = [
|
$opts = [
|
||||||
@@ -167,25 +169,25 @@ class Kakao_REST_API_Helper
|
|||||||
{
|
{
|
||||||
$this->AUTHORIZATION_CODE = $authorization_code;
|
$this->AUTHORIZATION_CODE = $authorization_code;
|
||||||
$params = [
|
$params = [
|
||||||
'grant_type'=>'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
'client_id'=>$this->REST_KEY,
|
'client_id' => $this->REST_KEY,
|
||||||
'redirect_uri'=>$this->REDIRECT_URI,
|
'redirect_uri' => $this->REDIRECT_URI,
|
||||||
'code'=>$this->AUTHORIZATION_CODE
|
'code' => $this->AUTHORIZATION_CODE
|
||||||
];
|
];
|
||||||
$result = $this->_create_or_refresh_access_token($params);
|
$result = $this->_create_or_refresh_access_token($params);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function refresh_access_token($refresh_token)
|
public function refresh_access_token($refresh_token)
|
||||||
{
|
{
|
||||||
$params = [
|
$params = [
|
||||||
'grant_type'=>'refresh_token',
|
'grant_type' => 'refresh_token',
|
||||||
'client_id'=>$this->REST_KEY,
|
'client_id' => $this->REST_KEY,
|
||||||
'refresh_token'=>$refresh_token
|
'refresh_token' => $refresh_token
|
||||||
];
|
];
|
||||||
$result = $this->_create_or_refresh_access_token($params);
|
$result = $this->_create_or_refresh_access_token($params);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,11 +214,11 @@ class Kakao_REST_API_Helper
|
|||||||
public function meWithEmail()
|
public function meWithEmail()
|
||||||
{
|
{
|
||||||
$params = [
|
$params = [
|
||||||
'property_keys'=>'['.
|
'property_keys' => '[' .
|
||||||
'"id",'.
|
'"id",' .
|
||||||
'"kakao_account.has_email","kakao_account.email",'.
|
'"kakao_account.has_email","kakao_account.email",' .
|
||||||
'"kakao_account.is_email_valid","kakao_account.is_email_verified"'.
|
'"kakao_account.is_email_valid","kakao_account.is_email_verified"' .
|
||||||
']'
|
']'
|
||||||
];
|
];
|
||||||
return $this->request(User_Management_Path::$ME);
|
return $this->request(User_Management_Path::$ME);
|
||||||
}
|
}
|
||||||
@@ -257,8 +259,8 @@ class Kakao_REST_API_Helper
|
|||||||
public function talk_to_me_default($req)
|
public function talk_to_me_default($req)
|
||||||
{
|
{
|
||||||
$params = [
|
$params = [
|
||||||
'template_object' => json_encode($req)
|
'template_object' => json_encode($req)
|
||||||
];
|
];
|
||||||
return $this->request(Talk_Path::$TALK_TO_ME_DEFAULT, $params, 'POST');
|
return $this->request(Talk_Path::$TALK_TO_ME_DEFAULT, $params, 'POST');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,7 +271,7 @@ class Kakao_REST_API_Helper
|
|||||||
|
|
||||||
|
|
||||||
private $REST_KEY = KakaoKey::REST_KEY; // 디벨로퍼스의 앱 설정에서 확인할 수 있습니다.
|
private $REST_KEY = KakaoKey::REST_KEY; // 디벨로퍼스의 앱 설정에서 확인할 수 있습니다.
|
||||||
private $REDIRECT_URI = KakaoKey::REDIRECT_URI; // 설정에 등록한 사이트 도메인 + redirect uri
|
private $REDIRECT_URI = KakaoKey::REDIRECT_URI; // 설정에 등록한 사이트 도메인 + redirect uri
|
||||||
private $AUTHORIZATION_CODE = ''; // 동의를 한 후 발급되는 code
|
private $AUTHORIZATION_CODE = ''; // 동의를 한 후 발급되는 code
|
||||||
private $REFRESH_TOKEN = '';
|
private $REFRESH_TOKEN = '';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user