턴 변경을 합리적으로 변경

This commit is contained in:
2020-12-31 08:09:23 +09:00
parent b2cca3687a
commit a33539e75f
3 changed files with 9 additions and 9 deletions
+1 -1
View File
@@ -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();
+4 -3
View File
@@ -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, '이');
+4 -5
View File
@@ -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);