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