From c6cb3190cf0b818e26e28c0a792aa3132a7eb005 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sat, 17 Nov 2018 01:57:21 +0900 Subject: [PATCH] =?UTF-8?q?=EC=84=A0=EB=8F=99,=20=ED=83=88=EC=B7=A8,=20?= =?UTF-8?q?=ED=8C=8C=EA=B4=B4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .phan/config.php | 1 - hwe/func.php | 1 - hwe/func_process_sabotage.php | 575 ------------------------- hwe/sammo/Command/General/che_선동.php | 60 +++ hwe/sammo/Command/General/che_탈취.php | 97 +++++ hwe/sammo/Command/General/che_파괴.php | 60 +++ 6 files changed, 217 insertions(+), 577 deletions(-) delete mode 100644 hwe/func_process_sabotage.php create mode 100644 hwe/sammo/Command/General/che_선동.php create mode 100644 hwe/sammo/Command/General/che_탈취.php create mode 100644 hwe/sammo/Command/General/che_파괴.php diff --git a/.phan/config.php b/.phan/config.php index c4a0842b..b6e07ab5 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -30,7 +30,6 @@ return [ 'hwe/func_map.php', 'hwe/func_message.php', 'hwe/func_process_chief.php', - 'hwe/func_process_sabotage.php', 'hwe/func_process.php', 'hwe/func_string.php', 'hwe/func_template.php', diff --git a/hwe/func.php b/hwe/func.php index db89515c..86cd7096 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -4,7 +4,6 @@ namespace sammo; require_once 'process_war.php'; require_once 'func_gamerule.php'; require_once 'func_process.php'; -require_once 'func_process_sabotage.php'; require_once 'func_process_chief.php'; require_once 'func_tournament.php'; require_once 'func_auction.php'; diff --git a/hwe/func_process_sabotage.php b/hwe/func_process_sabotage.php deleted file mode 100644 index 8c93b906..00000000 --- a/hwe/func_process_sabotage.php +++ /dev/null @@ -1,575 +0,0 @@ -= 7){ - return '불가침국입니다.'; - } - return null; -} - -function process_33(&$general) { - $db = DB::db(); - $gameStor = KVStorage::getStorage($db, 'game_env'); - - $date = substr($general['turntime'],11,5); - $sabotageName = '탈취'; - $statType = 'power'; - - [$year, $month, $develCost] = $gameStor->getValuesAsArray(['year','month','develcost']); - $logger = new ActionLogger($general['no'], $general['nation'], $year, $month); - - $reqGold = $develCost * 5; - $reqRice = $develCost * 5; - - $srcCityID = $general['city']; - $destCityID = DecodeCommand($general['turn0'])[1]; - - $dist = searchDistance($srcCityID, 5, false); - $srcCity = $db->queryFirstRow('SELECT city,nation,supply FROM city WHERE city=%i', $srcCityID); - $destCity = $db->queryFirstRow('SELECT city,name,level,nation,secu,secu2,supply,agri,comm,def,wall,trust FROM city WHERE city=%i',$destCityID); - $destCityName = $destCity['name']??null; - - $srcNationID = $general['nation']; - $destNationID = $destCity['nation']; - - //탈취는 0까지 무제한 - - $srcNation = getNationStaticInfo($srcNationID); - $dipState = $db->queryFirstField('SELECT `state` FROM diplomacy WHERE me=%i AND you=%i', $srcNationID, $destNationID); - - $failReason = checkSabotageFailCondition($general, $srcCity, $destCity, $reqGold, $reqRice, $dipState); - if($failReason !== null){ - $logger->pushGeneralActionLog("{$failReason} {$sabotageName} 실패. <1>{$date}"); - return; - } - - $srcNation = getNationStaticInfo($srcNationID); - $destNation = getNationStaticInfo($destNationID); - - $generalList = $db->query('SELECT `no`,leader,horse,power,weap,intel,book,injury,level,special,special2 FROM general WHERE city=%i and nation=%i', $destCity['city'], $destCity['nation']); - - [ - $srcGenScore, - $srcSpecialScore, - $srcItemScore, - $srcNationScore, - ] = calcSabotageAttackScore($statType, $general, $srcNation); - - [ - $destGenScore, - $destCityScore, - $destSupplyScore - ] = calcSabotageDefendScore($statType, $generalList, $destCity, $destNation); - - $sabotageProb = ( - GameConst::$sabotageDefaultProb - + ($srcGenScore + $srcSpecialScore + $srcItemScore + $srcNationScore) - - ($destGenScore + $destCityScore + $destSupplyScore) - ); - - // 거리보정 - $sabotageProb /= Util::array_get($dist[$destCityID], 99); - - if(!Util::randBool($sabotageProb)){ - $josaYi = JosaUtil::pick($sabotageName, '이'); - $logger->pushGeneralActionLog("{$destCityName}에 {$sabotageName}{$josaYi} 실패했습니다. <1>$date"); - - $exp = Util::randRangeInt(1, 100); - $exp *= getCharExpMultiplier($general['personal']); - $ded = Util::randRangeInt(1, 70); - $ded *= getCharDedMultiplier($general['personal']); - - $general[$statType.'2'] += 1; - $general['gold'] -= $reqGold; - $general['rice'] -= $reqRice; - $db->update('general', [ - ($statType.'2') => $general[$statType.'2'], - 'resturn'=>'SUCCESS', - 'gold'=>$general['gold'], - 'rice'=>$general['rice'], - 'experience'=>$db->sqleval('experience + %i', Util::round($exp)), - 'dedication'=>$db->sqleval('dedication + %i', Util::round($ded)) - ], 'no=%i', $general['no']); - - checkAbilityEx($general['no'], $logger); - return; - } - - if($srcItemScore){ - $itemName = getItemName($general['item']); - $josaUl = JosaUtil::pick($itemName, '을'); - $logger->pushGeneralActionLog("{$itemName}{$josaUl} 사용!", ActionLogger::PLAIN); - $general['item'] = 0; - } - - $logger->pushGlobalActionLog("{$destCityName}에서 금과 쌀을 도둑맞았습니다."); - $josaYi = JosaUtil::pick($sabotageName, '이'); - $logger->pushGeneralActionLog("{$destCityName}에 {$sabotageName}{$josaYi} 성공했습니다. <1>$date"); - - // 탈취 최대 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($general['nation'] != 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', $srcNationID); - $general['gold'] += $gold - Util::round($gold * 0.7); - $general['rice'] += $rice - Util::round($rice * 0.7); - } else { - $general['gold'] += $gold; - $general['rice'] += $rice; - } - - $logger->pushGeneralActionLog("금{$gold} 쌀{$rice}을 획득했습니다.", ActionLogger::PLAIN); - - $exp = Util::randRangeInt(201, 300); - $exp *= getCharExpMultiplier($general['personal']); - $ded = Util::randRangeInt(141, 210); - $ded *= getCharDedMultiplier($general['personal']); - - $general[$statType.'2'] += 1; - $general['gold'] -= $reqGold; - $general['rice'] -= $reqRice; - $db->update('general', [ - 'firenum' => $db->sqleval('firenum + 1'), - ($statType.'2') => $general[$statType.'2'], - 'resturn'=>'SUCCESS', - 'gold'=>$general['gold'], - 'rice'=>$general['rice'], - 'item'=>$general['item'], - 'experience'=>$db->sqleval('experience + %i', Util::round($exp)), - 'dedication'=>$db->sqleval('dedication + %i', Util::round($ded)) - ], 'no=%i', $general['no']); - - checkAbilityEx($general['no'], $logger); -} - -function process_34(&$general) { - $db = DB::db(); - $gameStor = KVStorage::getStorage($db, 'game_env'); - - $date = substr($general['turntime'],11,5); - $sabotageName = '파괴'; - $statType = 'power'; - - [$year, $month, $develCost] = $gameStor->getValuesAsArray(['year','month','develcost']); - $logger = new ActionLogger($general['no'], $general['nation'], $year, $month); - - $reqGold = $develCost * 5; - $reqRice = $develCost * 5; - - $srcCityID = $general['city']; - $destCityID = DecodeCommand($general['turn0'])[1]; - - $dist = searchDistance($srcCityID, 5, false); - $srcCity = $db->queryFirstRow('SELECT city,nation,supply FROM city WHERE city=%i', $srcCityID); - $destCity = $db->queryFirstRow('SELECT city,name,level,nation,secu,secu2,supply,agri,comm,def,wall,trust FROM city WHERE city=%i',$destCityID); - $destCityName = $destCity['name']??null; - - $srcNationID = $general['nation']; - $destNationID = $destCity['nation']; - - $srcNation = getNationStaticInfo($srcNationID); - $dipState = $db->queryFirstField('SELECT `state` FROM diplomacy WHERE me=%i AND you=%i', $srcNationID, $destNationID); - - $failReason = checkSabotageFailCondition($general, $srcCity, $destCity, $reqGold, $reqRice, $dipState); - if($failReason !== null){ - $logger->pushGeneralActionLog("{$failReason} {$sabotageName} 실패. <1>{$date}"); - return; - } - - $srcNation = getNationStaticInfo($srcNationID); - $destNation = getNationStaticInfo($destNationID); - - $generalList = $db->query('SELECT `no`,leader,horse,power,weap,intel,book,injury,level,special,special2 FROM general WHERE city=%i and nation=%i', $destCity['city'], $destCity['nation']); - - [ - $srcGenScore, - $srcSpecialScore, - $srcItemScore, - $srcNationScore, - ] = calcSabotageAttackScore($statType, $general, $srcNation); - - [ - $destGenScore, - $destCityScore, - $destSupplyScore - ] = calcSabotageDefendScore($statType, $generalList, $destCity, $destNation); - - $sabotageProb = ( - GameConst::$sabotageDefaultProb - + ($srcGenScore + $srcSpecialScore + $srcItemScore + $srcNationScore) - - ($destGenScore + $destCityScore + $destSupplyScore) - ); - - // 거리보정 - $sabotageProb /= Util::array_get($dist[$destCityID], 99); - - if(!Util::randBool($sabotageProb)){ - $josaYi = JosaUtil::pick($sabotageName, '이'); - $logger->pushGeneralActionLog("{$destCityName}에 {$sabotageName}{$josaYi} 실패했습니다. <1>$date"); - - $exp = Util::randRangeInt(1, 100); - $exp *= getCharExpMultiplier($general['personal']); - $ded = Util::randRangeInt(1, 70); - $ded *= getCharDedMultiplier($general['personal']); - - $general[$statType.'2'] += 1; - $general['gold'] -= $reqGold; - $general['rice'] -= $reqRice; - $db->update('general', [ - ($statType.'2') => $general[$statType.'2'], - 'resturn'=>'SUCCESS', - 'gold'=>$general['gold'], - 'rice'=>$general['rice'], - 'experience'=>$db->sqleval('experience + %i', Util::round($exp)), - 'dedication'=>$db->sqleval('dedication + %i', Util::round($ded)) - ], 'no=%i', $general['no']); - - checkAbilityEx($general['no'], $logger); - return; - } - - if($srcItemScore){ - $itemName = getItemName($general['item']); - $josaUl = JosaUtil::pick($itemName, '을'); - $logger->pushGeneralActionLog("{$itemName}{$josaUl} 사용!", ActionLogger::PLAIN); - $general['item'] = 0; - } - - $logger->pushGlobalActionLog("누군가가 {$destCityName}의 성벽을 허물었습니다."); - $josaYi = JosaUtil::pick($sabotageName, '이'); - $logger->pushGeneralActionLog("{$destCityName}에 {$sabotageName}{$josaYi} 성공했습니다. <1>$date"); - - // 파괴 - $defAmount = Util::valueFit(Util::randRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax), null, $destCity['def'] - 100); - $wallAmount = Util::valueFit(Util::randRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax), null, $destCity['wall'] - 100); - 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); - - $injuryCount = SabotageInjury($destCityID); - - $logger->pushGeneralActionLog("도시의 수비가 {$defAmount}, 성벽이 {$wallAmount}만큼 감소하고, 장수 {$injuryCount}명이 부상 당했습니다.", ActionLogger::PLAIN); - - $exp = Util::randRangeInt(201, 300); - $exp *= getCharExpMultiplier($general['personal']); - $ded = Util::randRangeInt(141, 210); - $ded *= getCharDedMultiplier($general['personal']); - - $general[$statType.'2'] += 1; - $general['gold'] -= $reqGold; - $general['rice'] -= $reqRice; - $db->update('general', [ - 'firenum' => $db->sqleval('firenum + 1'), - ($statType.'2') => $general[$statType.'2'], - 'resturn'=>'SUCCESS', - 'gold'=>$general['gold'], - 'rice'=>$general['rice'], - 'item'=>$general['item'], - 'experience'=>$db->sqleval('experience + %i', Util::round($exp)), - 'dedication'=>$db->sqleval('dedication + %i', Util::round($ded)) - ], 'no=%i', $general['no']); - - checkAbilityEx($general['no'], $logger); -} - -function process_35(&$general) { - $db = DB::db(); - $gameStor = KVStorage::getStorage($db, 'game_env'); - - $date = substr($general['turntime'],11,5); - $sabotageName = '선동'; - $statType = 'leader'; - - [$year, $month, $develCost] = $gameStor->getValuesAsArray(['year','month','develcost']); - $logger = new ActionLogger($general['no'], $general['nation'], $year, $month); - - $reqGold = $develCost * 5; - $reqRice = $develCost * 5; - - $srcCityID = $general['city']; - $destCityID = DecodeCommand($general['turn0'])[1]; - - $dist = searchDistance($srcCityID, 5, false); - $srcCity = $db->queryFirstRow('SELECT city,nation,supply FROM city WHERE city=%i', $srcCityID); - $destCity = $db->queryFirstRow('SELECT city,name,level,nation,secu,secu2,supply,agri,comm,def,wall,trust FROM city WHERE city=%i',$destCityID); - $destCityName = $destCity['name']??null; - - $srcNationID = $general['nation']; - $destNationID = $destCity['nation']; - - $srcNation = getNationStaticInfo($srcNationID); - $dipState = $db->queryFirstField('SELECT `state` FROM diplomacy WHERE me=%i AND you=%i', $srcNationID, $destNationID); - - $lbonus = setLeadershipBonus($general, $srcNation['level']); - - $failReason = checkSabotageFailCondition($general, $srcCity, $destCity, $reqGold, $reqRice, $dipState); - if($failReason !== null){ - $logger->pushGeneralActionLog("{$failReason} {$sabotageName} 실패. <1>{$date}"); - return; - } - - $srcNation = getNationStaticInfo($srcNationID); - $destNation = getNationStaticInfo($destNationID); - - $generalList = $db->query('SELECT `no`,leader,horse,power,weap,intel,book,injury,level,special,special2 FROM general WHERE city=%i and nation=%i', $destCity['city'], $destCity['nation']); - [ - $srcGenScore, - $srcSpecialScore, - $srcItemScore, - $srcNationScore, - ] = calcSabotageAttackScore($statType, $general, $srcNation); - - [ - $destGenScore, - $destCityScore, - $destSupplyScore - ] = calcSabotageDefendScore($statType, $generalList, $destCity, $destNation); - - $sabotageProb = ( - GameConst::$sabotageDefaultProb - + ($srcGenScore + $srcSpecialScore + $srcItemScore + $srcNationScore) - - ($destGenScore + $destCityScore + $destSupplyScore) - ); - - // 거리보정 - $sabotageProb /= Util::array_get($dist[$destCityID], 99); - - if(!Util::randBool($sabotageProb)){ - $josaYi = JosaUtil::pick($sabotageName, '이'); - $logger->pushGeneralActionLog("{$destCityName}에 {$sabotageName}{$josaYi} 실패했습니다. <1>$date"); - - $exp = Util::randRangeInt(1, 100); - $exp *= getCharExpMultiplier($general['personal']); - $ded = Util::randRangeInt(1, 70); - $ded *= getCharDedMultiplier($general['personal']); - - $general[$statType.'2'] += 1; - $general['gold'] -= $reqGold; - $general['rice'] -= $reqRice; - $db->update('general', [ - ($statType.'2') => $general[$statType.'2'], - 'resturn'=>'SUCCESS', - 'gold'=>$general['gold'], - 'rice'=>$general['rice'], - 'experience'=>$db->sqleval('experience + %i', Util::round($exp)), - 'dedication'=>$db->sqleval('dedication + %i', Util::round($ded)) - ], 'no=%i', $general['no']); - - checkAbilityEx($general['no'], $logger); - return; - } - - if($srcItemScore){ - $itemName = getItemName($general['item']); - $josaUl = JosaUtil::pick($itemName, '을'); - $logger->pushGeneralActionLog("{$itemName}{$josaUl} 사용!", ActionLogger::PLAIN); - $general['item'] = 0; - } - - $logger->pushGlobalActionLog("{$destCityName}의 백성들이 동요하고 있습니다."); - $josaYi = JosaUtil::pick($sabotageName, '이'); - $logger->pushGeneralActionLog("{$destCityName}에 {$sabotageName}{$josaYi} 성공했습니다. <1>$date"); - - // 선동 최대 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); - - $injuryCount = SabotageInjury($destCityID); - - $logger->pushGeneralActionLog("도시의 치안이 {$secuAmount}, 민심이 ".round($trustAmount, 1)."만큼 감소하고, 장수 {$injuryCount}명이 부상 당했습니다.", ActionLogger::PLAIN); - - $exp = Util::randRangeInt(201, 300); - $exp *= getCharExpMultiplier($general['personal']); - $ded = Util::randRangeInt(141, 210); - $ded *= getCharDedMultiplier($general['personal']); - - $general[$statType.'2'] += 1; - $general['gold'] -= $reqGold; - $general['rice'] -= $reqRice; - $db->update('general', [ - 'firenum' => $db->sqleval('firenum + 1'), - ($statType.'2') => $general[$statType.'2'], - 'resturn'=>'SUCCESS', - 'gold'=>$general['gold'], - 'rice'=>$general['rice'], - 'item'=>$general['item'], - 'experience'=>$db->sqleval('experience + %i', Util::round($exp)), - 'dedication'=>$db->sqleval('dedication + %i', Util::round($ded)) - ], 'no=%i', $general['no']); - - checkAbilityEx($general['no'], $logger); -} diff --git a/hwe/sammo/Command/General/che_선동.php b/hwe/sammo/Command/General/che_선동.php new file mode 100644 index 00000000..cdbe0c69 --- /dev/null +++ b/hwe/sammo/Command/General/che_선동.php @@ -0,0 +1,60 @@ +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("{$destCityName}의 백성들이 동요하고 있습니다."); + $josaYi = JosaUtil::pick($commandName, '이'); + $logger->pushGeneralActionLog("{$destCityName}에 {$commandName}{$josaYi} 성공했습니다. <1>$date"); + + $logger->pushGeneralActionLog( + "도시의 치안이 {$secuAmountText}, 민심이 {$trustAmountText}만큼 감소하고, 장수 {$injuryCount}명이 부상 당했습니다.", + ActionLogger::PLAIN + ); + } + +} \ No newline at end of file diff --git a/hwe/sammo/Command/General/che_탈취.php b/hwe/sammo/Command/General/che_탈취.php new file mode 100644 index 00000000..185db8dd --- /dev/null +++ b/hwe/sammo/Command/General/che_탈취.php @@ -0,0 +1,97 @@ +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("{$destCityName}에서 금과 쌀을 도둑맞았습니다."); + $josaYi = JosaUtil::pick($commandName, '이'); + $logger->pushGeneralActionLog("{$destCityName}에 {$commandName}{$josaYi} 성공했습니다. <1>$date"); + + $logger->pushGeneralActionLog("금{$goldText} 쌀{$riceText}을 획득했습니다.", ActionLogger::PLAIN); + } + +} \ No newline at end of file diff --git a/hwe/sammo/Command/General/che_파괴.php b/hwe/sammo/Command/General/che_파괴.php new file mode 100644 index 00000000..f9034953 --- /dev/null +++ b/hwe/sammo/Command/General/che_파괴.php @@ -0,0 +1,60 @@ +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("누군가가 {$destCityName}의 성벽을 허물었습니다."); + $josaYi = JosaUtil::pick($commandName, '이'); + $logger->pushGeneralActionLog("{$destCityName}에 {$commandName}{$josaYi} 성공했습니다. <1>$date"); + + $logger->pushGeneralActionLog( + "도시의 수비가 {$defAmountText}, 성벽이 {$wallAmountText}만큼 감소하고, 장수 {$injuryCount}명이 부상 당했습니다.", + ActionLogger::PLAIN + ); + } + +} \ No newline at end of file