턴 버그 수정, 아이템 관련 구 코드 수정

This commit is contained in:
2019-10-06 01:45:50 +09:00
parent 44f0e78086
commit 2006845ff7
14 changed files with 41 additions and 795 deletions
+7 -7
View File
@@ -216,7 +216,7 @@ switch($btn) {
break;
case "무기지급":
if($item == 0) {
if($item == 'None') {
$text = "무기 회수!";
}
else {
@@ -240,7 +240,7 @@ switch($btn) {
}
break;
case "책지급":
if($item == 0) {
if($item == 'None') {
$text = "책 회수!";
}
else {
@@ -252,7 +252,7 @@ switch($btn) {
$msg->send(true);
}
if($item == 0){
if($item == 'None'){
$db->update('general', [
'book'=>'None'
], '`no` IN %li', $genlist);
@@ -264,7 +264,7 @@ switch($btn) {
}
break;
case "말지급":
if($item == 0) {
if($item == 'None') {
$text = "말 회수!";
}
else {
@@ -276,7 +276,7 @@ switch($btn) {
$msg->send(true);
}
if($item == 0){
if($item == 'None'){
$db->update('general', [
'horse'=>'None'
], '`no` IN %li', $genlist);
@@ -288,7 +288,7 @@ switch($btn) {
}
break;
case "도구지급":
if($item == 0) {
if($item == 'None') {
$text = "특수도구 회수!";
}
else {
@@ -300,7 +300,7 @@ switch($btn) {
$msg->send(true);
}
if($item == 0){
if($item == 'None'){
$db->update('general', [
'item'=>'None'
], '`no` IN %li', $genlist);
+3 -138
View File
@@ -1144,16 +1144,17 @@ function checkDelay() {
//지연 해야할 밀린 턴 횟수
$iter = intdiv($timeMinDiff, $term);
if($iter > $threshold) {
$minute = ($iter - $threshold) * $term;
$minute = $iter * $term;
$newTurntime = $turntime->add(new \DateInterval("PT{$minute}M"));
$newNextTurntime = $turntime->add(new \DateInterval("PT{$term}M"));
$gameStor->turntime = $newTurntime->format('Y-m-d H:i:s');
$gameStor->starttime = (new \DateTimeImmutable($gameStor->starttime))
->add(new \DateInterval("PT{$minute}M"))
->format('Y-m-d H:i:s');
$db->update('general', [
'turntime'=> $db->sqleval('DATE_ADD(turntime, INTERVAL %i MINUTE)', $minute)
], true);
], 'turntime<=DATE_ADD(turntime, INTERVAL %i MINUTE)', $term);
$db->update('auction', [
'expire'=> $db->sqleval('DATE_ADD(expire, INTERVAL %i MINUTE)', $minute)
], true);
@@ -1516,142 +1517,6 @@ function tryUniqueItemLottery(General $general, string $acquireType='아이템')
return true;
}
function uniqueItem($general, $log, $vote=0) {
//TODO: uniqueItem 을 쓰는 경우를 모두 제거.
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$alllog = [];
$history = [];
$occupied = [];
$item = [];
if($general['npc'] >= 2) { return $log; }
if($general['weapon'] > 6 || $general['book'] > 6 || $general['horse'] > 6 || $general['item'] > 6) { return $log; }
$admin = $gameStor->getValues(['year', 'month', 'scenario']);
$query = "select count(*) as cnt from general where npc<2";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gen = MYDB_fetch_array($result);
if($admin['scenario'] < 100) { $prob = $gen['cnt'] * 5; } // 5~6개월에 하나씩 등장
else { $prob = $gen['cnt']; } // 1~2개월에 하나씩 등장
if($vote == 1) { $prob = Util::round($gen['cnt'] * 0.7 / 3); } // 투표율 70%, 투표 한번에 2~3개 등장
elseif($vote == 2) { $prob = Util::round($gen['cnt'] / 10 / 2); } // 랜임시 2개(10%) 등장(200명중 20명 랜임시도?)
elseif($vote == 3) { $prob = Util::round($gen['cnt'] / 10 / 4); } // 건국시 4개(20%) 등장(200명시 20국 정도 됨)
if($prob < 3) { $prob = 3; }
//아이템 습득 상황
if(rand() % $prob == 0) {
//셋중 선택
$selGroup = [
20 - $db->queryFirstField('SELECT count(*) from general where weapon > 6'),
20 - $db->queryFirstField('SELECT count(*) from general where book > 6'),
20 - $db->queryFirstField('SELECT count(*) from general where horse > 6'),
20 - $db->queryFirstField('SELECT count(*) from general where item > 6')
];
$sel = Util::choiceRandomUsingWeight($selGroup);
switch($sel) {
case 0: $type = "weapon"; break;
case 1: $type = "book"; break;
case 2: $type = "horse"; break;
case 3: $type = "item"; break;
}
$query = "select no,{$type} from general where {$type}>6";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$count = MYDB_num_rows($result);
if($count < 20) {
for($i=0; $i < $count; $i++) {
$gen = MYDB_fetch_array($result);
$occupied[$gen[$type]] = 1;
}
for($i=7; $i <= 26; $i++) {
if(!Util::array_get($occupied[$i])) {
$item[] = $i;
}
}
$it = $item[rand() % count($item)]??0;
$query = "update general set {$type}='$it' where no='{$general['no']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$nation = getNationStaticInfo($general['nation']);
switch($sel) {
case 0:
$josaUl = JosaUtil::pick(getItemName($it), '을');
$josaYi = JosaUtil::pick($general['name'], '이');
$log[] = "<C>●</><C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
$alllog[0] = "<C>●</>{$admin['month']}월:<Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
pushGeneralHistory($general, "<C>●</>{$admin['year']}년 {$admin['month']}월:<C>".getItemName($it)."</>{$josaUl} 습득");
if($vote == 0) {
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【아이템】</b></><D><b>{$nation['name']}</b></>의 <Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
} elseif($vote == 1) {
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【설문상품】</b></><D><b>{$nation['name']}</b></>의 <Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
} elseif($vote == 2) {
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【랜덤임관상품】</b></><D><b>{$nation['name']}</b></>의 <Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
} elseif($vote == 3) {
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【건국상품】</b></><D><b>{$nation['name']}</b></>의 <Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
}
break;
case 1:
$josaUl = JosaUtil::pick(getItemName($it), '을');
$josaYi = JosaUtil::pick($general['name'], '이');
$log[] = "<C>●</><C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
$alllog[0] = "<C>●</>{$admin['month']}월:<Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
pushGeneralHistory($general, "<C>●</>{$admin['year']}년 {$admin['month']}월:<C>".getItemName($it)."</>{$josaUl} 습득");
if($vote == 0) {
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【아이템】</b></><D><b>{$nation['name']}</b></>의 <Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
} elseif($vote == 1) {
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【설문상품】</b></><D><b>{$nation['name']}</b></>의 <Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
} elseif($vote == 2) {
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【랜덤임관상품】</b></><D><b>{$nation['name']}</b></>의 <Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
} elseif($vote == 3) {
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【건국상품】</b></><D><b>{$nation['name']}</b></>의 <Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
}
break;
case 2:
$josaUl = JosaUtil::pick(getItemName($it), '을');
$josaYi = JosaUtil::pick($general['name'], '이');
$log[] = "<C>●</><C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
$alllog[0] = "<C>●</>{$admin['month']}월:<Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
pushGeneralHistory($general, "<C>●</>{$admin['year']}년 {$admin['month']}월:<C>".getItemName($it)."</>{$josaUl} 습득");
if($vote == 0) {
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【아이템】</b></><D><b>{$nation['name']}</b></>의 <Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
} elseif($vote == 1) {
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【설문상품】</b></><D><b>{$nation['name']}</b></>의 <Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
} elseif($vote == 2) {
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【랜덤임관상품】</b></><D><b>{$nation['name']}</b></>의 <Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
} elseif($vote == 3) {
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【건국상품】</b></><D><b>{$nation['name']}</b></>의 <Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
}
break;
case 3:
$josaUl = JosaUtil::pick(getItemName($it), '을');
$josaYi = JosaUtil::pick($general['name'], '이');
$log[] = "<C>●</><C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
$alllog[0] = "<C>●</>{$admin['month']}월:<Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
pushGeneralHistory($general, "<C>●</>{$admin['year']}년 {$admin['month']}월:<C>".getItemName($it)."</>{$josaUl} 습득");
if($vote == 0) {
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【아이템】</b></><D><b>{$nation['name']}</b></>의 <Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
} elseif($vote == 1) {
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【설문상품】</b></><D><b>{$nation['name']}</b></>의 <Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
} elseif($vote == 2) {
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【랜덤임관상품】</b></><D><b>{$nation['name']}</b></>의 <Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
} elseif($vote == 3) {
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【건국상품】</b></><D><b>{$nation['name']}</b></>의 <Y>{$general['name']}</>{$josaYi} <C>".getItemName($it)."</>{$josaUl} 습득했습니다!";
}
break;
}
pushGeneralPublicRecord($alllog, $admin['year'], $admin['month']);
pushWorldHistory($history, $admin['year'], $admin['month']);
}
}
return $log;
}
function checkDedication($general, $log) {
$db = DB::db();
$connect=$db->get();
-18
View File
@@ -99,7 +99,6 @@ function getNationType(?string $type) {
$nationClass = buildNationTypeClass($type);
$text = $nationClass->getName();
$text = join(' ', StringUtil::splitString($text));
$cache[$type] = $text;
return $text;
}
@@ -629,23 +628,6 @@ function isConsumable(?string $item) : bool{
return $itemClass->isConsumable();
}
function getItemInfo(?string $item):?array{
if($item === null){
return ['-', null];
}
$itemClass = buildItemClass($item);
return [$itemClass->getName(), $itemClass->getInfo()];
}
function getItemCost(?string $item) : int {
if($item === null){
return 0;
}
$itemClass = buildItemClass($item);
return $itemClass->getCost();
}
function getNameColor(int $npcType):?string{
if($npcType >= 2){
return 'cyan';
-12
View File
@@ -105,18 +105,6 @@ function displaySpecialDomesticInfo(?string $type):string{
]);
}
function displayItemInfo(?string $type):string{
[$text, $info] = getItemInfo($type);
$templates = new \League\Plates\Engine(__dir__.'/templates');
return $templates->render('tooltip', [
'text'=>$text,
'info'=>$info,
]);
}
function allButton() {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
+1 -1
View File
@@ -93,7 +93,7 @@ $weight = [];
foreach($db->query('SELECT `no`, `name`, leadership, strength, intel, nation, imgsvr, picture, personal, special, special2 FROM general WHERE npc=2') as $general){
$general['special'] = buildGeneralSpecialDomesticClass($general['special'])->getName();
$general['special2'] = buildGeneralSpecialWarClass($general['special2'])->getName();
$general['personal'] = (getPersonalityClass($general['personal']));
$general['personal'] = buildPersonalityClass($general['personal'])->getName();
$general['nation'] = getNationStaticInfo($general['nation'])['name'];
$candidates[$general['no']] = $general + ['keepCnt'=>KEEP_CNT];
$allStat = $general['leadership'] + $general['strength'] + $general['intel'];
+5 -5
View File
@@ -111,18 +111,18 @@ $generalCheck = [
'between'=>[
['train', [40, GameConst::$maxTrainByWar]],
['atmos', [40, GameConst::$maxAtmosByWar]],
['book', [0, 26]],
['weapon', [0, 26]],
['horse', [0, 26]],
['item', [0, 26]],
['explevel', [0, 300]],
['injury', [0, 80]],
['level', [1, 12]]
],
'in'=>[
['personal', array_keys(getCharacterList())],
['special2', array_merge(array_keys(SpecialityConst::WAR), [0])],
['special2', array_merge(array_keys(SpecialityConst::WAR), ['None'])],
['crewtype', array_keys(GameUnitConst::all())],
['horse', array_keys(GameConst::$allItems['horse'])],
['weapon', array_keys(GameConst::$allItems['weapon'])],
['book', array_keys(GameConst::$allItems['book'])],
['item', array_keys(GameConst::$allItems['item'])],
]
];
+1 -1
View File
@@ -172,7 +172,7 @@ if ($genius) {
]);
} else {
$specage2 = Util::valueFit(Util::round((GameConst::$retirementYear - $age)/4 - $relYear / 2), 3) + $age;
$special2 = 0;
$special2 = GameConst::$defaultSpecialWar;
}
//내특
$specage = Util::valueFit(Util::round((GameConst::$retirementYear - $age)/12 - $relYear / 2), 3) + $age;
+2 -2
View File
@@ -213,7 +213,7 @@ function processWar_NG(
$logger = $attacker->getLogger();
$attacker->useBattleInitItem();
//$attacker->useBattleInitItem();
$date = $attacker->getGeneral()->getTurnTime(General::TURNTIME_HM);
@@ -286,7 +286,7 @@ function processWar_NG(
$logger->pushGeneralActionLog("{$attackerCrewTypeName}{$josaRo} 성벽을 <M>공격</>합니다.", ActionLogger::PLAIN);
}
$defender->useBattleInitItem();
//$defender->useBattleInitItem();
$attacker->setOppose($defender);
$defender->setOppose($attacker);
@@ -15,9 +15,6 @@ use \sammo\{
use function \sammo\{
tryUniqueItemLottery,
getItemCost,
getItemInfo,
getItemName
};
use \sammo\Constraint\Constraint;
+9 -11
View File
@@ -15,8 +15,6 @@ use \sammo\{
use function \sammo\{
tryUniqueItemLottery,
getItemCost,
getItemInfo,
getItemName,
buildItemClass
};
@@ -80,8 +78,8 @@ class che_장비매매 extends Command\GeneralCommand{
ConstraintHelper::ReqGeneralRice($reqRice),
];
if($itemCode == 0){
$this->runnableConstraints[] = ConstraintHelper::ReqGeneralValue($itemType, $itemTypeName, '>=', 1);
if($itemCode === 'None'){
$this->runnableConstraints[] = ConstraintHelper::ReqGeneralValue($itemType, $itemTypeName, '!=', 'None');
}
else if($itemCode == $general->getVar($itemType)){
$this->runnableConstraints[] = ConstraintHelper::AlwaysFail('이미 가지고 있습니다.');
@@ -98,8 +96,9 @@ class che_장비매매 extends Command\GeneralCommand{
}
$itemCode = $this->arg['itemCode'];
$itemObj = buildItemClass($itemCode);
$reqGold = getItemCost($itemCode);
$reqGold = $itemObj->getCost();
return [$reqGold, 0];
}
@@ -124,17 +123,16 @@ class che_장비매매 extends Command\GeneralCommand{
$itemType = $this->arg['itemType'];
$itemCode = $this->arg['itemCode'];
if($itemCode == 'None'){
if($itemCode === 'None'){
$buying = false;
$itemCode = $general->getVar($itemType);
$cost = getItemCost($itemCode);
}
else{
$buying = true;
$cost = $this->getCost()[0];
}
$itemName = getItemName($itemCode);
$itemObj = buildItemClass($itemCode);
$cost = $itemObj->getCost();
$itemName = $itemObj->getName();
$josaUl = JosaUtil::pick($itemName, '을');
@@ -148,7 +146,7 @@ class che_장비매매 extends Command\GeneralCommand{
else{
$logger->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 판매했습니다. <1>$date</>");
$general->increaseVarWithLimit('gold', $cost / 2);
$general->setVar($itemType, 0);
$general->deleteItem($itemType);
}
$exp = 10;
+10 -1
View File
@@ -101,8 +101,17 @@ class General implements iAction{
][$short]($this->getVar('turntime'));
}
function setItem(string $itemKey='item', ?string $itemCode){
if($itemCode === null){
$this->deleteItem($itemKey);
}
$this->setVar($itemKey, $itemCode);
$this->itemObjs[$itemKey] = buildItemClass($itemCode);
}
function deleteItem(string $itemKey='item'){
$this->setVar($itemKey, 0);
$this->setVar($itemKey, 'None');
$this->itemObjs[$itemKey] = new ActionItem\None();
}
+1 -1
View File
@@ -403,7 +403,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
// 현재시간의 월턴시간 이후 분단위 장수 처리
[$executionOver, $currentTurn] = static::executeGeneralCommandUntil(
$nextTurn, $limitActionTime, $gameStor->year, $gameStor->month
$date, $limitActionTime, $gameStor->year, $gameStor->month
);
if($currentTurn !== null){
-16
View File
@@ -300,27 +300,11 @@ class WarUnit{
throw new NotInheritedMethodException();
}
function useBattleInitItem():bool{
return false;
}
function beginPhase():void{
$this->clearActivatedSkill();
$this->computeWarPower();
}
function checkBattleBeginSkill(){
yield true;
}
function checkBattleBeginItem():bool{
return false;
}
function applyBattleBeginSkillAndItem():bool{
return false;
}
function hasActivatedSkill(string $skillName):bool{
return $this->activatedSkill[$skillName] ?? false;
}
+2 -579
View File
@@ -198,163 +198,6 @@ class WarUnitGeneral extends WarUnit{
return [$warPower,$opposeWarPowerMultiply];
}
///전투 개시 시에 작동하여 1회에만 작동하는 아이템, 자체적인 Consumable을 처리하지 않는 경우에만
function useBattleInitItem():bool{
$general = $this->getGeneral();
$item = $general->getItem();
if($item === null){
return false;
}
if(!$item->isConsumable()){
return false;
}
if(!$item->isValidTurnItem('Battle', 'NonHandledConsumable')){
return false;
}
$itemName = $item->getName();
$josaUl = JosaUtil::pick($itemName, '을');
$this->getLogger()->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 사용!", ActionLogger::PLAIN);
return true;
$itemActivated = false;
$itemConsumed = false;
$itemName = getItemName($item);
$general = $this->general;
if($item == 3){
//탁주 사용
$this->addAtmos(3);
$itemActivated = true;
$itemConsumed = true;
}
else if($item >= 14 && $item <= 16){
//의적주, 두강주, 보령압주 사용
$this->addAtmosBonus(5);
$itemActivated = true;
}
else if($item >= 19 && $item <= 20){
//춘화첩, 초선화 사용
$this->addAtmosBonus(7);
$itemActivated = true;
}
else if($item == 4){
//청주 사용
$this->addTrain(3);
$itemActivated = true;
$itemConsumed = true;
}
else if($item >= 12 && $item <= 13){
//과실주, 이강주 사용
$this->addTrainBonus(5);
$itemActivated = true;
}
else if($item >= 18 && $item <= 18){
//철벽서, 단결도 사용
$this->addTrainBonus(7);
$itemActivated = true;
}
return $itemActivated;
}
///전투 개시 시에 작동하여 매 장수마다 작동하는 스킬
function checkBattleBeginSkill(){
$oppose = $this->getOppose();
$specialWar = $this->getSpecialWar();
if(
$this->getCrewType()->armType == GameUnitConst::T_SIEGE &&
$oppose->getCrewType()->armType == GameUnitConst::T_CASTLE
){
$this->activateSkill('부상무효');
}
yield true;
if($specialWar == 62){
$oppose->activateSkill('저격불가');
$this->activateSkill('부상무효');
}
yield true;
if (
$specialWar == 70 &&
$this->oppose instanceof WarUnitGeneral &&
!$this->hasActivatedSkill('저격') &&
!$this->hasActivatedSkill('저격불가') &&
Util::randBool(1/3)
) {
$this->activateSkill('저격');
}
yield true;
}
///전투 개시 시에 작동하여 매 장수마다 작동하는 아이템
function checkBattleBeginItem():bool{
$item = $this->getItem();
$oppose = $this->getOppose();
if(!$item){
return false;
}
$itemActivated = false;
$itemConsumed = false;
$itemName = getItemName($item);
if(
$item == 2 &&
$this->oppose instanceof WarUnitGeneral &&
!$this->hasActivatedSkill('저격') &&
!$this->hasActivatedSkill('저격불가') &&
Util::randBool(1/5)
){
//수극
$itemActivated = true;
$itemConsumed = true;
$this->activateSkill('저격', '수극');
}
if($itemConsumed){
//NOTE: 소비 아이템은 하나인가?, 1회용인가?
$this->general->updateVar('item', 0);
$josaUl = JosaUtil::pick($itemName, '을');
$this->getLogger()->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 사용!", ActionLogger::PLAIN);
}
return $itemActivated;
}
function applyBattleBeginSkillAndItem():bool{
$result = false;
$oppose = $this->getOppose();
$general = $this->general;
if($oppose->hasActivatedSkill('저격')){
$result = true;
$oppose->getLogger()->pushGeneralActionLog("상대를 <C>저격</>했다!", ActionLogger::PLAIN);
$oppose->getLogger()->pushGeneralBattleDetailLog("상대를 <C>저격</>했다!", ActionLogger::PLAIN);
$this->getLogger()->pushGeneralActionLog("상대에게 <R>저격</>당했다!", ActionLogger::PLAIN);
$this->getLogger()->pushGeneralBattleDetailLog("상대에게 <R>저격</>당했다!", ActionLogger::PLAIN);
if($oppose->hasActivatedSkill('수극')){
$general->increaseVarWithLimit('injury', Util::randRangeInt(20, 40), null, 80);
}
else{
$general->increaseVarWithLimit('injury', Util::randRangeInt(20, 60), null, 80);
}
}
return $result;
}
function getHP():int{
return $this->general->getVar('crew');
}
@@ -427,420 +270,6 @@ class WarUnitGeneral extends WarUnit{
return $this->killed;
}
function checkPreActiveSkill(){
$activated = false;
$oppose = $this->getOppose();
$specialWar = $this->getSpecialWar();
$item = $this->getItem();
$crewType = $this->getCrewType();
if($specialWar == 62){
$oppose->activateSkill('필살불가');
$oppose->activateSkill('위압불가');
$oppose->activateSkill('격노불가');
$oppose->activateSkill('계략약화');
}
yield true;
if($specialWar == 45){
$oppose->activateSkill('계략약화');
}
yield true;
if(
$specialWar == 63 &&
$this->getPhase() == 0 &&
$this->getHP() >= 1000 &&
$this->getComputedAtmos() >= 90 &&
$this->getComputedTrain() >= 90 &&
!$this->hasActivatedSkill('위압불가')
){
$this->activateSkill('위압');
}
yield true;
if($specialWar == 60){
$oppose->activateSkill('회피불가');
}
yield true;
}
function checkActiveSkill(){
$oppose = $this->getOppose();
$specialWar = $this->getSpecialWar();
$item = $this->getItem();
$crewType = $this->getCrewType();
if(
!$this->hasActivatedSkill('특수') &&
!$this->hasActivatedSkill('저지불가') &&
!$this->isAttacker &&
$crewType->name == '목우'
){
//XXX: 병종에 특수 스킬이 달려있도록 설정해야함
$ratio = $this->getComputedAtmos() + $this->getComputedTrain();
if(Util::randBool($ratio / 400)){
$this->activateSkill('특수', '저지');
}
}
yield true;
if(
!$this->hasActivatedSkill('특수') &&
!$this->hasActivatedSkill('필살불가') &&
Util::randBool($this->getComputedCriticalRatio())
){
$this->activateSkill('특수', '필살시도', '필살');
}
yield true;
if(
!$this->hasActivatedSkill('특수') &&
!$this->hasActivatedSkill('회피불가') &&
Util::randBool($this->getComputedAvoidRatio())
){
$this->activateSkill('특수', '회피시도', '회피');
}
yield true;
//계략
if($crewType->magicCoef){
$magicRatio = $this->getGeneral()->getIntel(true, true, true, false) / 100;
$magicRatio *= $crewType->magicCoef;
if($specialWar == 41){
$magicRatio += 0.2;
}
if(Util::randBool($magicRatio)){
$magicSuccessRatio = 0.7;
if($specialWar == 40){
$magicSuccessRatio += 0.2;
}
if($specialWar == 41){
$magicSuccessRatio += 0.2;
}
if($specialWar == 42){
$magicSuccessRatio += 0.1;
}
if($specialWar == 44){
$magicSuccessRatio += 1;
}
if($this->hasActivatedSkill('계략약화')){
$magicSuccessRatio -= 0.1;
}
if($oppose instanceof WarUnitCity){
$magic = Util::choiceRandom(['급습', '위보', '혼란']);
}
else{
$magic = Util::choiceRandom(['위보', '매복', '반목', '화계', '혼란']);
}
$this->activateSkill('계략시도', $magic);
if(Util::randBool($magicSuccessRatio)){
$this->activateSkill('계략');
}
else{
$this->activateSkill('계략실패');
}
}
}
yield true;
//의술
if($specialWar == 73 && Util::randBool(0.2)){
$this->activateSkill('치료');
}
yield true;
}
function checkPostActiveSkill(){
$activated = false;
$oppose = $this->getOppose();
$specialWar = $this->getSpecialWar();
$item = $this->getItem();
$crewType = $this->getCrewType();
if(
$specialWar == 74 &&
$oppose->hasActivatedSkill('필살') &&
!$this->hasActivatedSkill('격노불가')
){
if($this->isAttacker){
if(Util::randBool(1/3)){
$this->activateSkill('진노', '격노');
$activated = true;
}
else if(Util::randBool(1/4)){
$this->activateSkill('격노');
$activated = true;
}
}
else{
if(Util::randBool(1/2)){
$this->activateSkill('격노');
$activated = true;
}
}
}
yield true;
if(
$specialWar == 74 &&
$oppose->hasActivatedSkill('회피') &&
!$this->hasActivatedSkill('격노불가')
){
if($this->isAttacker){
if(Util::randBool(1/3)){
$this->activateSkill('진노', '격노');
$oppose->deactivateSkill('회피');
$activated = true;
}
else if(Util::randBool(1/4)){
$this->activateSkill('격노');
$oppose->deactivateSkill('회피');
$activated = true;
}
}
else{
if(Util::randBool(1/2)){
$this->activateSkill('격노');
$oppose->deactivateSkill('회피');
$activated = true;
}
}
}
yield true;
if(
($item == 23 || $item == 24) &&
!$this->hasActivatedSkill('치료') &&
Util::randBool(0.2)
){
$this->activateSkill('치료');
$activated = true;
}
yield true;
//계략
if(
$specialWar == 45 &&
$oppose->hasActivatedSkill('계략') &&
Util::randBool(0.4)
){
$this->activateSkill('반계');
$oppose->deactivateSkill('계략');
$activated = true;
}
yield true;
if(
$specialWar == 42 &&
$this->hasActivatedSkill('계략')
){
$this->warPowerMultiply *= 1.3;
}
yield true;
if(
$specialWar == 43 &&
$this->hasActivatedSkill('계략')
){
$this->warPowerMultiply *= 1.5;
}
yield true;
}
function applyActiveSkill(){
$oppose = $this->getOppose();
$crewType = $this->getCrewType();
$specialWar = $this->getSpecialWar();
$thisLogger = $this->getLogger();
$opposeLogger = $oppose->getLogger();
if($this->hasActivatedSkill('저지')){
$this->addDex($oppose->getCrewType(), $oppose->getWarPower() * 0.9);
$this->addDex($this->getCrewType(), $this->getWarPower() * 0.9);
$this->setWarPowerMultiply(0);
$oppose->setWarPowerMultiply(0);
$thisLogger->pushGeneralBattleDetailLog('상대를 <C>저지</>했다!</>');
$opposeLogger->pushGeneralBattleDetailLog('저지</>당했다!</>');
//저지는 특수함.
return;
}
yield true;
//계략 세트
if($this->hasActivatedSkill('계략')){
$tableToGeneral = [
'위보'=>1.2,
'매복'=>1.4,
'반목'=>1.6,
'화계'=>1.8,
'혼란'=>2.0
];
$tableToCity = [
'급습'=>1.2,
'위보'=>1.4,
'혼란'=>1.6
];
if($specialWar == 45){
$tableToGeneral['반목'] *= 2;
}
if($oppose instanceof WarUnitCity){
$table = $tableToCity;
}
else{
$table = $tableToGeneral;
}
foreach($table as $skillKey => $skillMultiply){
if($this->hasActivatedSkill($skillKey)){
$josaUl = \sammo\JosaUtil::pick($skillKey, '을');
$thisLogger->pushGeneralBattleDetailLog("<D>{$skillKey}</>{$josaUl} <C>성공</>했다!");
$opposeLogger->pushGeneralBattleDetailLog("<D>{$skillKey}</>에 당했다!");
$this->multiplyWarPowerMultiply($skillMultiply);
break;
}
}
}
yield true;
//반계 세트
if($this->hasActivatedSkill('반계')){
$table = [
'위보'=>1.2,
'매복'=>1.4,
'반목'=>1.6,
'화계'=>1.8,
'혼란'=>2.0
];
foreach($table as $skillKey => $skillMultiply){
if($oppose->hasActivatedSkill($skillKey)){
$josaUl = \sammo\JosaUtil::pick($skillKey, '을');
$thisLogger->pushGeneralBattleDetailLog("<C>반계</>로 상대의 <D>{$skillKey}</>{$josaUl} 되돌렸다!");
$opposeLogger->pushGeneralBattleDetailLog("<D>{$skillKey}</>{$josaUl} <R>역으로</> 당했다!");
$this->multiplyWarPowerMultiply($skillMultiply);
break;
}
}
}
yield true;
//계략 실패 세트
if($this->hasActivatedSkill('계략실패')){
$tableToGeneral = [
'위보'=>1.1,
'매복'=>1.2,
'반목'=>1.3,
'화계'=>1.4,
'혼란'=>1.5
];
$tableToCity = [
'급습'=>1.1,
'위보'=>1.2,
'혼란'=>1.3
];
if($oppose instanceof WarUnitCity){
$table = $tableToCity;
}
else{
$table = $tableToGeneral;
}
foreach($table as $skillKey => $skillMultiply){
if($this->hasActivatedSkill($skillKey)){
$josaUl = \sammo\JosaUtil::pick($skillKey, '을');
$thisLogger->pushGeneralBattleDetailLog("<D>{$skillKey}</>{$josaUl} <R>실패</>했다!");
$opposeLogger->pushGeneralBattleDetailLog("<D>{$skillKey}</>{$josaUl} 간파했다!");
$this->multiplyWarPowerMultiply(1/$skillMultiply);
$oppose->multiplyWarPowerMultiply($skillMultiply);
break;
}
}
}
yield true;
if($this->hasActivatedSkill('치료')){
$thisLogger->pushGeneralBattleDetailLog("<C>치료</>했다!</>");
$oppose->multiplyWarPowerMultiply(1/1.5);
}
yield true;
if($this->hasActivatedSkill('필살')){
$thisLogger->pushGeneralBattleDetailLog('<C>필살</>공격!</>');
$opposeLogger->pushGeneralBattleDetailLog('상대의 <R>필살</>공격!</>');
$this->multiplyWarPowerMultiply($this->criticalDamage());
}
yield true;
if($this->hasActivatedSkill('회피')){
$thisLogger->pushGeneralBattleDetailLog('<C>회피</>했다!</>');
$opposeLogger->pushGeneralBattleDetailLog('상대가 <R>회피</>했다!</>');
$oppose->multiplyWarPowerMultiply(0.2);
}
yield true;
if($this->hasActivatedSkill('진노')){
if($oppose->hasActivatedSkill('필살')){
$thisLogger->pushGeneralBattleDetailLog('상대의 필살 공격에 <C>진노</>했다!</>');
$opposeLogger->pushGeneralBattleDetailLog('필살 공격에 상대가 <R>진노</>했다!</>');
}
else if($oppose->hasActivatedSkill('회피시도')){
$thisLogger->pushGeneralBattleDetailLog('상대의 회피 시도에 <C>진노</>했다!</>');
$opposeLogger->pushGeneralBattleDetailLog('회피 시도에 상대가 <R>진노</>했다!</>');
}
$this->bonusPhase += 1;
$this->multiplyWarPowerMultiply($this->criticalDamage());
}
else if($this->hasActivatedSkill('격노')){
if($oppose->hasActivatedSkill('필살')){
$thisLogger->pushGeneralBattleDetailLog('상대의 필살 공격에 <C>격노</>했다!</>');
$opposeLogger->pushGeneralBattleDetailLog('필살 공격에 상대가 <R>격노</>했다!</>');
}
else if($oppose->hasActivatedSkill('회피시도')){
$thisLogger->pushGeneralBattleDetailLog('상대의 회피 시도에 <C>격노</>했다!</>');
$opposeLogger->pushGeneralBattleDetailLog('회피 시도에 상대가 <R>격노</>했다!</>');
}
$this->multiplyWarPowerMultiply($this->criticalDamage());
}
yield true;
if($this->hasActivatedSkill('위압')){
$thisLogger->pushGeneralBattleDetailLog('상대에게 <C>위압</>을 줬다!</>');
$opposeLogger->pushGeneralBattleDetailLog('상대에게 <R>위압</>받았다!</>');
$oppose->setWarPowerMultiply(0);
}
yield true;
}
function tryWound():bool{
$general = $this->general;
if($this->hasActivatedSkillOnLog('부상무효')){
@@ -895,15 +324,9 @@ class WarUnitGeneral extends WarUnit{
* @param \MeekroDB $db
*/
function applyDB($db):bool{
$updateVals = $this->getUpdatedValues();
if(!$updateVals){
return false;
}
$db->update('general', $updateVals, 'no=%i', $this->raw['no']);
$affected = $this->getGeneral()->applyDB($db);
$this->getLogger()->flush();
return $db->affectedRows() > 0;
return $affected;
}
}