AI턴 추가 구현

This commit is contained in:
2020-04-07 02:55:59 +09:00
parent 968655c9cd
commit 4e5caa7b8b
5 changed files with 572 additions and 242 deletions
+26
View File
@@ -1,6 +1,8 @@
<?php
namespace sammo;
use sammo\Command\GeneralCommand;
use sammo\WarUnitTrigger as WarUnitTrigger;
class General implements iAction{
@@ -266,6 +268,30 @@ class General implements iAction{
return GameUnitConst::byID($this->getVar('crewtype'));
}
function calcRecentWarTurn(int $turnTerm):int{
if(!$this->getVar('recent_war')){
return 12*1000;
}
$recwar = new \DateTimeImmutable($this->getVar('recent_war'));
$turnNow = new \DateTimeImmutable($this->getVar('turntime'));
$secDiff = TimeUtil::DateIntervalToSeconds($recwar->diff($turnNow));
if($secDiff <= 0){
return 0;
}
return intdiv($secDiff, 60 * $turnTerm);
}
function getReservedTurn(int $turnIdx, array $env):?GeneralCommand{
$db = DB::db();
$rawCmd = $db->queryFirstRow('SELECT * FROM general_turn WHERE general_id = %i AND turn_idx = %i', $this->getID(), $turnIdx);
if(!$rawCmd){
return null;
}
return buildGeneralCommandClass($rawCmd['action'], $this, $env, $rawCmd['arg']);
}
/**
* 장수의 스탯을 계산해옴
*