stat 관련 데이터 수정
This commit is contained in:
+8
-123
@@ -3,130 +3,18 @@ namespace sammo;
|
||||
|
||||
use Constraint\Constraint;
|
||||
|
||||
/**
|
||||
* 장수의 통솔을 받아옴
|
||||
*
|
||||
* @param array $general 장수 정보, leader, injury, lbonus, horse 사용
|
||||
* @param bool $withInjury 부상값 사용 여부
|
||||
* @param bool $withItem 아이템 적용 여부
|
||||
* @param bool $withStatAdjust 추가 능력치 보정 사용 여부
|
||||
* @param bool $useFloor 내림 사용 여부, false시 float 값을 반환할 수도 있음
|
||||
*
|
||||
* @return int|float 계산된 능력치
|
||||
*/
|
||||
function getGeneralLeadership($general, $withInjury, $withItem, $withStatAdjust, $useFloor = true){
|
||||
if($general === null){
|
||||
return 0;
|
||||
}
|
||||
$leadership = $general['leader'];
|
||||
if($withInjury){
|
||||
$leadership *= (100 - $general['injury']) / 100;
|
||||
}
|
||||
|
||||
if($withStatAdjust){
|
||||
if($general['special2'] == 72){
|
||||
$leadership *= 1.15;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($general['lbonus'])){
|
||||
$leadership += $general['lbonus'];
|
||||
}
|
||||
|
||||
if($withItem){
|
||||
$leadership += getHorseEff($general['horse']);
|
||||
}
|
||||
|
||||
//$withStatAdjust는 통솔에서 미사용
|
||||
|
||||
if($useFloor){
|
||||
return intval($leadership);
|
||||
}
|
||||
return $leadership;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 장수의 무력을 받아옴
|
||||
*
|
||||
* @param array $general 장수 정보, power, injury, weap 사용
|
||||
* @param bool $withInjury 부상값 사용 여부
|
||||
* @param bool $withItem 아이템 적용 여부
|
||||
* @param bool $withStatAdjust 추가 능력치 보정 사용 여부
|
||||
* @param bool $useFloor 내림 사용 여부, false시 float 값을 반환할 수도 있음
|
||||
*
|
||||
* @return int|float 계산된 능력치
|
||||
*/
|
||||
function getGeneralPower($general, $withInjury, $withItem, $withStatAdjust, $useFloor = true){
|
||||
if($general === null){
|
||||
return 0;
|
||||
}
|
||||
$power = $general['power'];
|
||||
if($withInjury){
|
||||
$power *= (100 - $general['injury']) / 100;
|
||||
}
|
||||
|
||||
if($withItem){
|
||||
$power += getWeapEff($general['weap']);
|
||||
}
|
||||
|
||||
if($withStatAdjust){
|
||||
$power += Util::round(getGeneralIntel($general, $withInjury, $withItem, false, false) / 4);
|
||||
}
|
||||
|
||||
if($useFloor){
|
||||
return intval($power);
|
||||
}
|
||||
return $power;
|
||||
}
|
||||
|
||||
/**
|
||||
* 장수의 지력을 받아옴
|
||||
*
|
||||
* @param array $general 장수 정보, intel, injury, book 사용
|
||||
* @param bool $withInjury 부상값 사용 여부
|
||||
* @param bool $withItem 아이템 적용 여부
|
||||
* @param bool $withStatAdjust 추가 능력치 보정 사용 여부
|
||||
* @param bool $useFloor 내림 사용 여부, false시 float 값을 반환할 수도 있음
|
||||
*
|
||||
* @return int|float 계산된 능력치
|
||||
*/
|
||||
function getGeneralIntel($general, $withInjury, $withItem, $withStatAdjust, $useFloor = true){
|
||||
if($general === null){
|
||||
return 0;
|
||||
}
|
||||
|
||||
$intel = $general['intel'];
|
||||
if($withInjury){
|
||||
$intel *= (100 - $general['injury']) / 100;
|
||||
}
|
||||
|
||||
if($withItem){
|
||||
$intel += getBookEff($general['book']);
|
||||
}
|
||||
|
||||
if($withStatAdjust){
|
||||
$intel += Util::round(getGeneralPower($general, $withInjury, $withItem, false, false) / 4);
|
||||
}
|
||||
|
||||
if($useFloor){
|
||||
return intval($intel);
|
||||
}
|
||||
return $intel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 내정 커맨드 사용시 성공 확률 계산
|
||||
*
|
||||
* @param array $general 장수 정보
|
||||
* @param int|string $type 내정 커맨드 타입, 0|'leader' = 통솔 기반, 1|'power' = 무력 기반, 2|'intel' = 지력 기반
|
||||
* @param string $type 내정 커맨드 타입, 'leader' = 통솔 기반, 'power' = 무력 기반, 'intel' = 지력 기반
|
||||
*
|
||||
* @return array 계산된 실패, 성공 확률 ('success' => 성공 확률, 'fail' => 실패 확률)
|
||||
*/
|
||||
function CriticalRatioDomestic($general, $type) {
|
||||
$leader = getGeneralLeadership($general, false, true, true, false);
|
||||
$power = getGeneralPower($general, false, true, true, false);
|
||||
$intel = getGeneralIntel($general, false, true, true, false);
|
||||
function CriticalRatioDomestic(General $general, string $type) {
|
||||
$leader = $general->getLeadership(false, true, true, false);
|
||||
$power = $general->getPower(false, true, true, false);
|
||||
$intel = $general->getIntel(false, true, true, false);
|
||||
|
||||
$avg = ($leader+$power+$intel) / 3;
|
||||
/*
|
||||
@@ -142,12 +30,9 @@ function CriticalRatioDomestic($general, $type) {
|
||||
505050(50%,50%), 107070(50%,50%)
|
||||
*/
|
||||
switch($type) {
|
||||
case 'leader':
|
||||
case 0: $ratio = $avg / $leader; break;
|
||||
case 'power':
|
||||
case 1: $ratio = $avg / $power; break;
|
||||
case 'intel':
|
||||
case 2: $ratio = $avg / $intel; break;
|
||||
case 'leader': $ratio = $avg / $leader; break;
|
||||
case 'power': $ratio = $avg / $power; break;
|
||||
case 'intel': $ratio = $avg / $intel; break;
|
||||
default:
|
||||
throw new MustNotBeReachedException();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class che_징병 implements iAction{
|
||||
}
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'rawLeadership'){
|
||||
if($statName === 'leadership'){
|
||||
return $value *= 1.15;
|
||||
}
|
||||
return $value;
|
||||
|
||||
@@ -65,7 +65,7 @@ class che_기술연구 extends che_상업투자{
|
||||
|
||||
$score = Util::valueFit($this->calcBaseScore(), 1);
|
||||
|
||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general->getRaw(), static::$statKey);
|
||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
||||
if($trust < 80){
|
||||
$successRatio *= $trust / 80;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ class che_상업투자 extends Command\GeneralCommand{
|
||||
|
||||
$score = Util::valueFit($this->calcBaseScore(), 1);
|
||||
|
||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general->getRaw(), static::$statKey);
|
||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
||||
if($trust < 80){
|
||||
$successRatio *= $trust / 80;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ class che_정착장려 extends Command\GeneralCommand{
|
||||
|
||||
$score = Util::valueFit($this->calcBaseScore(), 1);
|
||||
|
||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general->getRaw(), static::$statKey);
|
||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
||||
$successRatio = $general->onCalcDomestic(static::$cityKey, 'success', $successRatio);
|
||||
$failRatio = $general->onCalcDomestic(static::$cityKey, 'fail', $failRatio);
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ class che_주민선정 extends Command\GeneralCommand{
|
||||
|
||||
$score = Util::valueFit($this->calcBaseScore(), 1);
|
||||
|
||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general->getRaw(), static::$statKey);
|
||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
||||
$successRatio = $general->onCalcDomestic(static::$cityKey, 'success', $successRatio);
|
||||
$failRatio = $general->onCalcDomestic(static::$cityKey, 'fail', $failRatio);
|
||||
|
||||
|
||||
+60
-4
@@ -10,6 +10,9 @@ class General implements iAction{
|
||||
* @var iAction $nationType
|
||||
* @var iAction $levelObj
|
||||
* @var iAction $specialDomesticObj
|
||||
* @var iAction $specialWarObj
|
||||
* @var iAction $personalityObj
|
||||
* @var iAction[] $itemObjs
|
||||
*/
|
||||
|
||||
protected $raw = [];
|
||||
@@ -195,17 +198,70 @@ class General implements iAction{
|
||||
return GameUnitConst::byID($this->getVar('crewtype'));
|
||||
}
|
||||
|
||||
//TODO: 장기적으로 General 클래스로 모두 옮겨와야함.
|
||||
/**
|
||||
* 장수의 스탯을 계산해옴
|
||||
*
|
||||
* @param string $statName 스탯값, leadership, power, intel 가능
|
||||
* @param bool $withInjury 부상값 사용 여부
|
||||
* @param bool $withItem 아이템 적용 여부
|
||||
* @param bool $withStatAdjust 추가 능력치 보정 사용 여부
|
||||
* @param bool $useFloor 내림 사용 여부, false시 float 값을 반환할 수도 있음
|
||||
*
|
||||
* @return int|float 계산된 능력치
|
||||
*/
|
||||
|
||||
protected function getStatValue(string $statName, $withInjury = true, $withItem = true, $withStatAdjust = true, $useFloor = true):float{
|
||||
$statValue = $this->getVar($statName);
|
||||
|
||||
if($withInjury){
|
||||
$statValue *= (100 - $this->getVar('injury')) / 100;
|
||||
}
|
||||
|
||||
if($withStatAdjust){
|
||||
if($statName === 'power'){
|
||||
$statValue *= Util::round($this->getStatValue('intel', $withInjury, $withItem, false, false) / 4);
|
||||
}
|
||||
else if($statName === 'intel'){
|
||||
$statValue *= Util::round($this->getStatValue('power', $withInjury, $withItem, false, false) / 4);
|
||||
}
|
||||
}
|
||||
|
||||
foreach([
|
||||
$this->nationType,
|
||||
$this->levelObj,
|
||||
$this->specialDomesticObj,
|
||||
$this->specialWarObj,
|
||||
$this->personalityObj
|
||||
] as $actionObj){
|
||||
if($actionObj !== null){
|
||||
$statValue = $actionObj->onCalcStat($this, $statName, $statValue);
|
||||
}
|
||||
}
|
||||
|
||||
if($withItem){
|
||||
foreach($this->itemObjs as $actionObj){
|
||||
if($actionObj !== null){
|
||||
$statValue = $actionObj->onCalcStat($this, $statName, $statValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($useFloor){
|
||||
return Util::toInt($statValue);
|
||||
}
|
||||
return $statValue;
|
||||
}
|
||||
|
||||
function getLeadership($withInjury = true, $withItem = true, $withStatAdjust = true, $useFloor = true):float{
|
||||
return getGeneralLeadership($this->raw, $withInjury, $withItem, $withStatAdjust, $useFloor);
|
||||
return $this->getStatValue('leadership', $withInjury, $withItem, $withStatAdjust, $useFloor);
|
||||
}
|
||||
|
||||
function getPower($withInjury = true, $withItem = true, $withStatAdjust = true, $useFloor = true):float{
|
||||
return getGeneralPower($this->raw, $withInjury, $withItem, $withStatAdjust, $useFloor);
|
||||
return $this->getStatValue('power', $withInjury, $withItem, $withStatAdjust, $useFloor);
|
||||
}
|
||||
|
||||
function getIntel($withInjury = true, $withItem = true, $withStatAdjust = true, $useFloor = true):float{
|
||||
return getGeneralIntel($this->raw, $withInjury, $withItem, $withStatAdjust, $useFloor);
|
||||
return $this->getStatValue('intel', $withInjury, $withItem, $withStatAdjust, $useFloor);
|
||||
}
|
||||
|
||||
function addDex(GameUnitDetail $crewType, float $exp, bool $affectTrainAtmos=false){
|
||||
|
||||
@@ -319,9 +319,6 @@ class NPC{
|
||||
'crewtype'=>GameUnitConst::DEFAULT_CREWTYPE,
|
||||
'train'=>0,
|
||||
'atmos'=>0,
|
||||
'weap'=>0,
|
||||
'book'=>0,
|
||||
'horse'=>0,
|
||||
'turntime'=>$turntime,
|
||||
'killturn'=>$killturn,
|
||||
'age'=>$age,
|
||||
|
||||
@@ -512,7 +512,7 @@ class WarUnitGeneral extends WarUnit{
|
||||
|
||||
//계략
|
||||
if($crewType->magicCoef){
|
||||
$magicRatio = getGeneralIntel($this->raw, true, true, true, false) / 100;
|
||||
$magicRatio = $this->getGeneral()->getIntel(true, true, true, false) / 100;
|
||||
$magicRatio *= $crewType->magicCoef;
|
||||
|
||||
if($specialWar == 41){
|
||||
|
||||
Reference in New Issue
Block a user