getNationTypeList 변경

This commit is contained in:
2018-09-02 20:54:32 +09:00
parent 9dd1adacd2
commit 1a0914196f
23 changed files with 100 additions and 17 deletions
+3 -2
View File
@@ -90,8 +90,9 @@ $startYear = $gameStor->getValue('startyear');
<span class="input-group-text">국가 성향</span> <span class="input-group-text">국가 성향</span>
</div> </div>
<select class="custom-select form_nation_type" style="width:25ch;"> <select class="custom-select form_nation_type" style="width:25ch;">
<?php foreach(getNationTypeList() as $typeID => [$name,$pros,$cons]): ?> <?php foreach(getNationTypeList() as $typeID): ?>
<option value="<?=$typeID?>"><?=$name?> (<?=$pros?>, <?=$cons?>)</option> <?php $typeRealID = '\\sammo\\TriggerNationType\\'.$typeID ?>
<option value="<?=$typeID?>"><?=($typeRealID)::$name?> (<?=($typeRealID)::$pros?>, <?=($typeRealID)::$cons?>)</option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
<div class="input-group-prepend"> <div class="input-group-prepend">
+2
View File
@@ -20,6 +20,8 @@ function getNationLevelList():array{
} }
function getNationTypeList():array{ function getNationTypeList():array{
return GameConst::$availableNationType;
$table = [ $table = [
13=>['명가', '기술↑ 인구↑', '쌀수입↓ 수성↓'], 13=>['명가', '기술↑ 인구↑', '쌀수입↓ 수성↓'],
12=>['음양가', '내정↑ 인구↑', '기술↓ 전략↓'], 12=>['음양가', '내정↑ 인구↑', '기술↓ 전략↓'],
+19 -11
View File
@@ -14,7 +14,7 @@ use Constraint\Constraint;
* *
* @return int|float 계산된 능력치 * @return int|float 계산된 능력치
*/ */
function getGeneralLeadership(&$general, $withInjury, $withItem, $withStatAdjust, $useFloor = true){ function getGeneralLeadership($general, $withInjury, $withItem, $withStatAdjust, $useFloor = true){
if($general === null){ if($general === null){
return 0; return 0;
} }
@@ -57,7 +57,7 @@ function getGeneralLeadership(&$general, $withInjury, $withItem, $withStatAdjust
* *
* @return int|float 계산된 능력치 * @return int|float 계산된 능력치
*/ */
function getGeneralPower(&$general, $withInjury, $withItem, $withStatAdjust, $useFloor = true){ function getGeneralPower($general, $withInjury, $withItem, $withStatAdjust, $useFloor = true){
if($general === null){ if($general === null){
return 0; return 0;
} }
@@ -91,7 +91,7 @@ function getGeneralPower(&$general, $withInjury, $withItem, $withStatAdjust, $us
* *
* @return int|float 계산된 능력치 * @return int|float 계산된 능력치
*/ */
function getGeneralIntel(&$general, $withInjury, $withItem, $withStatAdjust, $useFloor = true){ function getGeneralIntel($general, $withInjury, $withItem, $withStatAdjust, $useFloor = true){
if($general === null){ if($general === null){
return 0; return 0;
} }
@@ -193,7 +193,7 @@ function CriticalScore($score, $type) {
return Util::round($score * $ratio); return Util::round($score * $ratio);
} }
function process_1(array $general, int $type){ function process_1(array $rawGeneral, int $type){
$db = DB::db(); $db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env'); $gameStor = KVStorage::getStorage($db, 'game_env');
@@ -212,11 +212,12 @@ function process_1(array $general, int $type){
[$startYear, $year, $month, $develCost] = $gameStor->getValuesAsArray(['startyear', 'year', 'month', 'develcost']); [$startYear, $year, $month, $develCost] = $gameStor->getValuesAsArray(['startyear', 'year', 'month', 'develcost']);
$city = $db->queryFirstRow('SELECT * FROM city WHERE city = %i', $general['city']); $general = new General($rawGeneral, $yera, $month);
$nation = getNationStaticInfo($general['nation']); $logger = $general->getLogger();
$lbonus = setLeadershipBonus($general, $nation['level']);
$logger = new ActionLogger($general['id'], $general['nation'], $year, $month);
$city = $db->queryFirstRow('SELECT * FROM city WHERE city = %i', $general->getCityID());
$constraints = [ $constraints = [
['NoNeutral'], ['NoNeutral'],
@@ -226,10 +227,10 @@ function process_1(array $general, int $type){
['ReqGeneralGold', $reqGold], ['ReqGeneralGold', $reqGold],
['RemainCityCapacity', [$cityKey, $actionName]] ['RemainCityCapacity', [$cityKey, $actionName]]
]; ];
$failReason =Constraint::testAll($constraints, [ $failReason = Constraint::testAll($constraints, [
'nation'=>$nation, 'nation'=>$general->getStaticNation(),
'city'=>$city, 'city'=>$city,
'general'=>$general, 'general'=>$general->getRaw(),
]); ]);
if($failReason !== null){ if($failReason !== null){
@@ -237,6 +238,13 @@ function process_1(array $general, int $type){
return; return;
} }
$trust = Util::valutFit($city['trust'], 50);
$score = getGeneralIntel($general, true, true, true, false);
$score *= $trust / 100;
$score *= getDomesticExpLevelBonus($general['explevel']);
$score *= Util::randRange(0.8, 1.2);
} }
function process_1_old(&$general, $type) { function process_1_old(&$general, $type) {
+2 -2
View File
@@ -172,8 +172,8 @@ abstract class Constraint{
return $this->reason; return $this->reason;
} }
public static function testAll(array $contraintPacks, array $input):?string{ public static function testAll(array $constraintPacks, array $input):?string{
foreach($contraintPacks as $constraintArgs){ foreach($constraintPacks as $constraintArgs){
if (!$constraintArgs){ if (!$constraintArgs){
continue; continue;
} }
+1 -1
View File
@@ -5,7 +5,7 @@ trait DefaultActionTrigger{
public function onPreTurnExecute(General $general, ?array $nation):array{ public function onPreTurnExecute(General $general, ?array $nation):array{
return []; return [];
} }
public function onCalcDomesticTurnScore(General $general, string $turnType, float $score, float $cost, float $successRate, float $failRate){ public function onCalcDomesticTurnScore(General $general, string $turnType, float $score, float $cost, float $successRate, float $failRate):array{
return [$score, $cost, $successRate, $failRate]; return [$score, $cost, $successRate, $failRate];
} }
+6
View File
@@ -93,4 +93,10 @@ class GameConstBase
/** @var int 초반 제한 기간 */ /** @var int 초반 제한 기간 */
public static $openingPartYear = 3; public static $openingPartYear = 3;
/** @var array 선택 가능한 국가 성향 */
public static $availableNationType = [
'che_명가', 'che_음양가', 'che_종횡가', 'che_불가', 'che_도적', 'che_오두미도', 'che_태평도', 'che_도가',
'che_묵가', 'che_덕가', 'che_병가', 'che_유가', 'che_법가'
];
} }
+29
View File
@@ -50,6 +50,22 @@ class General{
return $this->logActivatedSkill; return $this->logActivatedSkill;
} }
function hasActivatedSkill(string $skillName):bool{
return $this->activatedSkill[$skillName] ?? false;
}
function activateSkill(... $skillNames){
foreach($skillNames as $skillName){
$this->activatedSkill[$skillName] = true;
}
}
function deactivateSkill(... $skillNames){
foreach($skillNames as $skillName){
$this->activatedSkill[$skillName] = false;
}
}
function getName():string{ function getName():string{
return $this->raw['name']; return $this->raw['name'];
} }
@@ -70,6 +86,19 @@ class General{
return $this->logger; return $this->logger;
} }
//TODO: 장기적으로 General 클래스로 모두 옮겨와야함.
function getLeadership($withInjury = true, $withItem = true, $withStatAdjust = true, $useFloor = true):float{
return getGeneralLeadership($this->raw, $withInjury, $withItem, $withStatAdjust, $useFloor);
}
function getPower($withInjury = true, $withItem = true, $withStatAdjust = true, $useFloor = true):float{
return getGeneralPower($this->raw, $withInjury, $withItem, $withStatAdjust, $useFloor);
}
function getIntel($withInjury = true, $withItem = true, $withStatAdjust = true, $useFloor = true):float{
return getGeneralIntel($this->raw, $withInjury, $withItem, $withStatAdjust, $useFloor);
}
/** /**
* @param \MeekroDB $db * @param \MeekroDB $db
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace sammo\TriggerNationType;
use \sammo\iActionTrigger;
class che_유가 implements iActionTrigger{
use \sammo\DefaultActionTrigger;
static $id = 2;
static $name = '유가';
static $info = '';
static $pros = '내정↑ 민심↑';
static $cons = '쌀수입↓';
public function onCalcDomesticTurnScore(General $general, string $turnType, float $score, float $cost, float $successRate, float $failRate):array{
if($turnType == 'agri' || $turnType == 'comm'){
$score *= 1.1;
$cost *= 0.8;
}
return [$score, $cost, $successRate, $failRate];
}
}
@@ -1,6 +1,7 @@
<?php <?php
namespace sammo\TriggerNationType; namespace sammo\TriggerNationType;
use \sammo\iActionTrigger; use \sammo\iActionTrigger;
use \sammo\General;
class che_덕가 implements iActionTrigger{ class che_덕가 implements iActionTrigger{
use \sammo\DefaultActionTrigger; use \sammo\DefaultActionTrigger;
@@ -1,6 +1,7 @@
<?php <?php
namespace sammo\TriggerNationType; namespace sammo\TriggerNationType;
use \sammo\iActionTrigger; use \sammo\iActionTrigger;
use \sammo\General;
class che_도가 implements iActionTrigger{ class che_도가 implements iActionTrigger{
use \sammo\DefaultActionTrigger; use \sammo\DefaultActionTrigger;
@@ -1,6 +1,7 @@
<?php <?php
namespace sammo\TriggerNationType; namespace sammo\TriggerNationType;
use \sammo\iActionTrigger; use \sammo\iActionTrigger;
use \sammo\General;
class che_도적 implements iActionTrigger{ class che_도적 implements iActionTrigger{
use \sammo\DefaultActionTrigger; use \sammo\DefaultActionTrigger;
@@ -1,6 +1,7 @@
<?php <?php
namespace sammo\TriggerNationType; namespace sammo\TriggerNationType;
use \sammo\iActionTrigger; use \sammo\iActionTrigger;
use \sammo\General;
class che_명가 implements iActionTrigger{ class che_명가 implements iActionTrigger{
use \sammo\DefaultActionTrigger; use \sammo\DefaultActionTrigger;
@@ -1,6 +1,7 @@
<?php <?php
namespace sammo\TriggerNationType; namespace sammo\TriggerNationType;
use \sammo\iActionTrigger; use \sammo\iActionTrigger;
use \sammo\General;
class che_묵가 implements iActionTrigger{ class che_묵가 implements iActionTrigger{
use \sammo\DefaultActionTrigger; use \sammo\DefaultActionTrigger;
@@ -1,6 +1,7 @@
<?php <?php
namespace sammo\TriggerNationType; namespace sammo\TriggerNationType;
use \sammo\iActionTrigger; use \sammo\iActionTrigger;
use \sammo\General;
class che_법가 implements iActionTrigger{ class che_법가 implements iActionTrigger{
use \sammo\DefaultActionTrigger; use \sammo\DefaultActionTrigger;
@@ -1,6 +1,7 @@
<?php <?php
namespace sammo\TriggerNationType; namespace sammo\TriggerNationType;
use \sammo\iActionTrigger; use \sammo\iActionTrigger;
use \sammo\General;
class che_병가 implements iActionTrigger{ class che_병가 implements iActionTrigger{
use \sammo\DefaultActionTrigger; use \sammo\DefaultActionTrigger;
@@ -1,6 +1,7 @@
<?php <?php
namespace sammo\TriggerNationType; namespace sammo\TriggerNationType;
use \sammo\iActionTrigger; use \sammo\iActionTrigger;
use \sammo\General;
class che_불가 implements iActionTrigger{ class che_불가 implements iActionTrigger{
use \sammo\DefaultActionTrigger; use \sammo\DefaultActionTrigger;
@@ -1,6 +1,7 @@
<?php <?php
namespace sammo\TriggerNationType; namespace sammo\TriggerNationType;
use \sammo\iActionTrigger; use \sammo\iActionTrigger;
use \sammo\General;
class che_오두미도 implements iActionTrigger{ class che_오두미도 implements iActionTrigger{
use \sammo\DefaultActionTrigger; use \sammo\DefaultActionTrigger;
+2 -1
View File
@@ -1,6 +1,7 @@
<?php <?php
namespace sammo\TriggerNationType; namespace sammo\TriggerNationType;
use \sammo\iActionTrigger; use \sammo\iActionTrigger;
use \sammo\General;
class che_유가 implements iActionTrigger{ class che_유가 implements iActionTrigger{
use \sammo\DefaultActionTrigger; use \sammo\DefaultActionTrigger;
@@ -11,7 +12,7 @@ class che_유가 implements iActionTrigger{
static $pros = '내정↑ 민심↑'; static $pros = '내정↑ 민심↑';
static $cons = '쌀수입↓'; static $cons = '쌀수입↓';
public function onCalcDomesticTurnScore(General $general, string $turnType, float $score, float $cost, float $successRate, float $failRate){ public function onCalcDomesticTurnScore(General $general, string $turnType, float $score, float $cost, float $successRate, float $failRate):array{
if($turnType == 'agri' || $turnType == 'comm'){ if($turnType == 'agri' || $turnType == 'comm'){
$score *= 1.1; $score *= 1.1;
$cost *= 0.8; $cost *= 0.8;
@@ -1,6 +1,7 @@
<?php <?php
namespace sammo\TriggerNationType; namespace sammo\TriggerNationType;
use \sammo\iActionTrigger; use \sammo\iActionTrigger;
use \sammo\General;
class che_음양가 implements iActionTrigger{ class che_음양가 implements iActionTrigger{
use \sammo\DefaultActionTrigger; use \sammo\DefaultActionTrigger;
@@ -1,6 +1,7 @@
<?php <?php
namespace sammo\TriggerNationType; namespace sammo\TriggerNationType;
use \sammo\iActionTrigger; use \sammo\iActionTrigger;
use \sammo\General;
class che_종횡가 implements iActionTrigger{ class che_종횡가 implements iActionTrigger{
use \sammo\DefaultActionTrigger; use \sammo\DefaultActionTrigger;
@@ -1,6 +1,7 @@
<?php <?php
namespace sammo\TriggerNationType; namespace sammo\TriggerNationType;
use \sammo\iActionTrigger; use \sammo\iActionTrigger;
use \sammo\General;
class che_중립 implements iActionTrigger{ class che_중립 implements iActionTrigger{
use \sammo\DefaultActionTrigger; use \sammo\DefaultActionTrigger;
@@ -1,6 +1,7 @@
<?php <?php
namespace sammo\TriggerNationType; namespace sammo\TriggerNationType;
use \sammo\iActionTrigger; use \sammo\iActionTrigger;
use \sammo\General;
class che_태평도 implements iActionTrigger{ class che_태평도 implements iActionTrigger{
use \sammo\DefaultActionTrigger; use \sammo\DefaultActionTrigger;
+1
View File
@@ -9,6 +9,7 @@ interface iActionTrigger{
const PRIORITY_POST = 20000; const PRIORITY_POST = 20000;
const PRIORITY_FINAL = 10000; const PRIORITY_FINAL = 10000;
//TODO: 능력치는?
public function onPreTurnExecute(General $general, ?array $nation):array; public function onPreTurnExecute(General $general, ?array $nation):array;
public function onCalcDomesticTurnScore(General $general, string $turnType, float $score, float $cost, float $successRate, float $failRate):array; public function onCalcDomesticTurnScore(General $general, string $turnType, float $score, float $cost, float $successRate, float $failRate):array;