턴 변경을 합리적으로 변경
This commit is contained in:
@@ -118,7 +118,7 @@ foreach(GameConst::$generalPoolAllowOption as $allowOption){
|
|||||||
$builder->setOwner($userID);
|
$builder->setOwner($userID);
|
||||||
$builder->setKillturn(5);
|
$builder->setKillturn(5);
|
||||||
$builder->setNPCType(0);
|
$builder->setNPCType(0);
|
||||||
$builder->setAuxVar('next_change', TimeUtil::nowAddDays(1));
|
$builder->setAuxVar('next_change', TimeUtil::nowAddMinutes(24 * $env['turnterm']));
|
||||||
$builder->fillRemainSpecAsZero($env);
|
$builder->fillRemainSpecAsZero($env);
|
||||||
$builder->build($env);
|
$builder->build($env);
|
||||||
$generalID = $builder->getGeneralID();
|
$generalID = $builder->getGeneralID();
|
||||||
|
|||||||
@@ -36,8 +36,9 @@ list(
|
|||||||
$year,
|
$year,
|
||||||
$month,
|
$month,
|
||||||
$maxgeneral,
|
$maxgeneral,
|
||||||
$npcmode
|
$npcmode,
|
||||||
) = $gameStor->getValuesAsArray(['year', 'month', 'maxgeneral', 'npcmode']);
|
$turnterm
|
||||||
|
) = $gameStor->getValuesAsArray(['year', 'month', 'maxgeneral', 'npcmode', 'turnterm']);
|
||||||
|
|
||||||
if($npcmode!=2){
|
if($npcmode!=2){
|
||||||
Json::die([
|
Json::die([
|
||||||
@@ -128,7 +129,7 @@ if(key_exists('specialDomestic', $info)){
|
|||||||
if(key_exists('specialWar', $info)){
|
if(key_exists('specialWar', $info)){
|
||||||
$generalObj->updateVar('special2', $info['specialWar']);
|
$generalObj->updateVar('special2', $info['specialWar']);
|
||||||
}
|
}
|
||||||
$generalObj->setAuxVar('next_change', TimeUtil::nowAddDays(1));
|
$generalObj->setAuxVar('next_change', TimeUtil::nowAddMinutes(24 * $turnterm));
|
||||||
|
|
||||||
$userNick = $ownerInfo['name'];
|
$userNick = $ownerInfo['name'];
|
||||||
$josaYi = JosaUtil::pick($userNick, '이');
|
$josaYi = JosaUtil::pick($userNick, '이');
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use sammo\Json;
|
|||||||
use sammo\Util;
|
use sammo\Util;
|
||||||
|
|
||||||
abstract class AbsFromUserPool extends AbsGeneralPool{
|
abstract class AbsFromUserPool extends AbsGeneralPool{
|
||||||
static $valid_seconds = 3600*24;
|
|
||||||
|
|
||||||
public function occupyGeneralName(): bool
|
public function occupyGeneralName(): bool
|
||||||
{
|
{
|
||||||
@@ -45,9 +44,9 @@ abstract class AbsFromUserPool extends AbsGeneralPool{
|
|||||||
throw new \RuntimeException('pool 부족');
|
throw new \RuntimeException('pool 부족');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$result = [];
|
$result = [];
|
||||||
$validUntil = $oNow->add(new \DateInterval(sprintf('PT%dS', static::$valid_seconds)));
|
$validUntil = TimeUtil::nowAddMinutes(24 * $gameStor->turnterm);
|
||||||
$validUntilText = $validUntil->format('Y-m-d H:i:s');
|
|
||||||
while(count($result) < $pickCnt){
|
while(count($result) < $pickCnt){
|
||||||
$cand = Util::choiceRandomUsingWeightPair($pool);
|
$cand = Util::choiceRandomUsingWeightPair($pool);
|
||||||
$poolID = $cand['id'];
|
$poolID = $cand['id'];
|
||||||
@@ -60,12 +59,12 @@ abstract class AbsFromUserPool extends AbsGeneralPool{
|
|||||||
//하나씩 한다.
|
//하나씩 한다.
|
||||||
$db->update('select_pool', [
|
$db->update('select_pool', [
|
||||||
'owner'=>$owner,
|
'owner'=>$owner,
|
||||||
'reserved_until'=>$validUntilText,
|
'reserved_until'=>$validUntil,
|
||||||
], 'id = %i AND reserved_until IS NULL AND owner IS NULL and general_id IS NULL', $poolID);
|
], 'id = %i AND reserved_until IS NULL AND owner IS NULL and general_id IS NULL', $poolID);
|
||||||
if($db->affectedRows()==0){
|
if($db->affectedRows()==0){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$result[$poolID] = new static($db, $candInfo, $validUntilText);
|
$result[$poolID] = new static($db, $candInfo, $validUntil);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_values($result);
|
return array_values($result);
|
||||||
|
|||||||
Reference in New Issue
Block a user