선동, 탈취, 파괴 구현
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
namespace sammo\GeneralCommand;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
Command
|
||||
};
|
||||
|
||||
class che_선동 extends che_화계{
|
||||
static protected $actionName = '선동';
|
||||
|
||||
static protected $statType = 'leader';
|
||||
static protected $injuryGeneral = true;
|
||||
|
||||
protected function affectDestCity(int $injuryCount){
|
||||
$general = $this->generalObj;
|
||||
$date = substr($general->getVar('turntime'),11,5);
|
||||
|
||||
$logger = $general->getLogger();
|
||||
|
||||
$destCity = $this->destCity;
|
||||
|
||||
$destCityName = $destCity['name'];
|
||||
$destCityID = $destCity['city'];
|
||||
|
||||
$commandName = $this->getName();
|
||||
|
||||
// 선동 최대 10
|
||||
$secuAmount = Util::valueFit(Util::randRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax), null, $destCity['secu']);
|
||||
$trustAmount = Util::valueFit(
|
||||
Util::randRange(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax) / 50,
|
||||
null,
|
||||
$destCity['trust']
|
||||
);
|
||||
$destCity['secu'] -= $secuAmount;
|
||||
$destCity['trust'] -= $trustAmount;
|
||||
|
||||
$db->update('city', [
|
||||
'state'=>32,
|
||||
'secu'=>$destCity['secu'],
|
||||
'trust'=>$destCity['trust']
|
||||
], 'city=%i', $destCityID);
|
||||
|
||||
$secuAmountText = number_format($secuAmount);
|
||||
$trustAmountText = number_format($trustAmount, 1);
|
||||
|
||||
$logger->pushGlobalActionLog("<G><b>{$destCityName}</b></>의 백성들이 동요하고 있습니다.");
|
||||
$josaYi = JosaUtil::pick($commandName, '이');
|
||||
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>에 {$commandName}{$josaYi} 성공했습니다. <1>$date</>");
|
||||
|
||||
$logger->pushGeneralActionLog(
|
||||
"도시의 치안이 <C>{$secuAmountText}</>, 민심이 <C>{$trustAmountText}</>만큼 감소하고, 장수 <C>{$injuryCount}</>명이 부상 당했습니다.",
|
||||
ActionLogger::PLAIN
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
namespace sammo\GeneralCommand;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
Command
|
||||
};
|
||||
|
||||
class che_탈취 extends che_화계{
|
||||
static protected $actionName = '탈취';
|
||||
|
||||
static protected $statType = 'power';
|
||||
static protected $injuryGeneral = false;
|
||||
|
||||
protected function affectDestCity(int $injuryCount){
|
||||
$general = $this->generalObj;
|
||||
$nationID = $general->getNationID();
|
||||
$date = substr($general->getVar('turntime'),11,5);
|
||||
|
||||
$logger = $general->getLogger();
|
||||
|
||||
$destCity = $this->destCity;
|
||||
|
||||
$destCityName = $destCity['name'];
|
||||
$destCityID = $destCity['city'];
|
||||
|
||||
$commandName = $this->getName();
|
||||
|
||||
// 탈취 최대 400 * 8
|
||||
$gold = Util::randRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax) * $destCity['level'];
|
||||
$rice = Util::randRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax) * $destCity['level'];
|
||||
|
||||
if($destCity['supply']){
|
||||
[$destNationGold, $destNationRice] = $db->queryFirstList('SELECT gold,rice FROM nation WHERE nation=%i', $destNationID);
|
||||
|
||||
$destNationGold -= $gold;
|
||||
$destNationRice -= $rice;
|
||||
|
||||
if($destNationGold < GameConst::$minNationalGold) {
|
||||
$gold += $destNationGold - GameConst::$minNationalGold;
|
||||
$destNationGold = GameConst::$minNationalGold;
|
||||
}
|
||||
if($destNationRice < GameConst::$minNationalRice) {
|
||||
$rice += $destNationRice - GameConst::$minNationalRice;
|
||||
$destNationRice = GameConst::$minNationalRice;
|
||||
}
|
||||
|
||||
$db->update('nation', [
|
||||
'gold'=>$destNationGold,
|
||||
'rice'=>$destNationRice
|
||||
], 'nation=%i', $destNationID);
|
||||
$db->update('city', [
|
||||
'state'=>34
|
||||
], 'city=%i', $destCityID);
|
||||
}
|
||||
else{
|
||||
$db->update('city', [
|
||||
'comm'=>Util::valueFit($destCity['comm'] - $gold / 12, 0),
|
||||
'agri'=>Util::valueFit($destCity['agri'] - $rice / 12, 0),
|
||||
'state'=>34
|
||||
], 'city=%i', $destCityID);
|
||||
}
|
||||
|
||||
// 본국으로 일부 회수, 재야이면 본인이 전량 소유
|
||||
if($nationID != 0) {
|
||||
$db->update('nation', [
|
||||
'gold' => $db->sqleval('gold + %i', Util::round($gold * 0.7)),
|
||||
'rice' => $db->sqleval('rice + %i', Util::round($rice * 0.7))
|
||||
], 'nation=%i', $nationID);
|
||||
$general->increaseVar('gold', $gold - Util::round($gold * 0.7));
|
||||
$general->increaseVar('rice', $rice - Util::round($rice * 0.7));
|
||||
} else {
|
||||
$general->increaseVar('gold', $gold);
|
||||
$general->increaseVar('rice', $rice);
|
||||
}
|
||||
|
||||
$db->update('city', [
|
||||
'state'=>32,
|
||||
'agri'=>$destCity['agri'],
|
||||
'comm'=>$destCity['comm']
|
||||
], 'city=%i', $destCityID);
|
||||
|
||||
$goldText = number_format($gold);
|
||||
$riceText = number_format($rice);
|
||||
|
||||
$josaYi = JosaUtil::pick($destCityName, '이');
|
||||
$logger->pushGlobalActionLog("<G><b>{$destCityName}</b></>에서 금과 쌀을 도둑맞았습니다.");
|
||||
$josaYi = JosaUtil::pick($commandName, '이');
|
||||
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>에 {$commandName}{$josaYi} 성공했습니다. <1>$date</>");
|
||||
|
||||
$logger->pushGeneralActionLog("금<C>{$goldText}</> 쌀<C>{$riceText}</>을 획득했습니다.", ActionLogger::PLAIN);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
namespace sammo\GeneralCommand;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
Command
|
||||
};
|
||||
|
||||
class che_파괴 extends che_화계{
|
||||
static protected $actionName = '파괴';
|
||||
|
||||
static protected $statType = 'power';
|
||||
static protected $injuryGeneral = true;
|
||||
|
||||
protected function affectDestCity(int $injuryCount){
|
||||
$general = $this->generalObj;
|
||||
$date = substr($general->getVar('turntime'),11,5);
|
||||
|
||||
$logger = $general->getLogger();
|
||||
|
||||
$destCity = $this->destCity;
|
||||
|
||||
$destCityName = $destCity['name'];
|
||||
$destCityID = $destCity['city'];
|
||||
|
||||
$commandName = $this->getName();
|
||||
|
||||
// 파괴
|
||||
$defAmount = Util::valueFit(Util::randRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax), null, $destCity['def']);
|
||||
$wallAmount = Util::valueFit(Util::randRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax), null, $destCity['wall']);
|
||||
if($defAmount < 0){ $defAmount = 0; }
|
||||
if($wallAmount < 0){ $wallAmount = 0; }
|
||||
|
||||
$destCity['def'] -= $defAmount;
|
||||
$destCity['wall'] -= $wallAmount;
|
||||
|
||||
$db->update('city', [
|
||||
'state'=>32,
|
||||
'def'=>$destCity['def'],
|
||||
'wall'=>$destCity['wall']
|
||||
], 'city=%i', $destCityID);
|
||||
|
||||
$defAmountText = number_format($defAmount);
|
||||
$wallAmountText = number_format($wallAmount);
|
||||
|
||||
$josaYi = JosaUtil::pick($destCityName, '이');
|
||||
$logger->pushGlobalActionLog("누군가가 <G><b>{$destCityName}</b></>의 성벽을 허물었습니다.");
|
||||
$josaYi = JosaUtil::pick($commandName, '이');
|
||||
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>에 {$commandName}{$josaYi} 성공했습니다. <1>$date</>");
|
||||
|
||||
$logger->pushGeneralActionLog(
|
||||
"도시의 수비가 <C>{$defAmountText}</>, 성벽이 <C>{$wallAmountText}</>만큼 감소하고, 장수 <C>{$injuryCount}</>명이 부상 당했습니다.",
|
||||
ActionLogger::PLAIN
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user