하야 추가
This commit is contained in:
@@ -1,385 +1,6 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
function process_29(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
$alllog = [];
|
||||
$history = [];
|
||||
$date = substr($general['turntime'],11,5);
|
||||
|
||||
$admin = $gameStor->getValues(['startyear','year','month','develcost','turnterm','scenario']);
|
||||
|
||||
$query = "select nation,name,level,gennum,scout from nation where nation='{$general['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$nation = MYDB_fetch_array($result);
|
||||
|
||||
$josaUn = JosaUtil::pick($nation['name'], '은');
|
||||
if($general['level'] == 0) {
|
||||
$log[] = "<C>●</>{$admin['month']}월:재야입니다. 인재탐색 실패. <1>$date</>";
|
||||
} elseif($nation['level'] <= 0) {
|
||||
$log[] = "<C>●</>{$admin['month']}월:방랑군입니다. 인재탐색 실패. <1>$date</>";
|
||||
} elseif($admin['year'] < $admin['startyear']+3 && $nation['gennum'] >= GameConst::$initialNationGenLimit) {
|
||||
$log[] = "<C>●</>{$admin['month']}월:현재 <D>{$nation['name']}</>{$josaUn} 탐색이 제한되고 있습니다. 인재탐색 실패.";
|
||||
} elseif($general['gold'] < $admin['develcost']) {
|
||||
$log[] = "<C>●</>{$admin['month']}월:자금이 모자랍니다. 인재탐색 실패. <1>$date</>";
|
||||
} else {
|
||||
$query = "select no from general where nation='{$general['nation']}' and npc<2";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$gencount = MYDB_num_rows($result);
|
||||
|
||||
$query = "select no from general where nation='{$general['nation']}' and npc=3";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$npccount = MYDB_num_rows($result);
|
||||
|
||||
$query = "select no from general where nation!='{$general['nation']}' and npc=3";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$otherNpccount = MYDB_num_rows($result);
|
||||
$otherNpccount = Util::round(sqrt($otherNpccount + 1)) - 1;
|
||||
|
||||
if($gencount <= 0) { $gencount = 1; }
|
||||
if($npccount <= 0) { $npccount = 1; }
|
||||
$criteria = $gencount * $npccount + $otherNpccount;
|
||||
|
||||
// 탐색 실패
|
||||
if(rand() % $criteria > 0) {
|
||||
$exp = 100;
|
||||
$ded = 70;
|
||||
switch(Util::choiceRandomUsingWeight([$general['leader'], $general['power'], $general['intel']])) {
|
||||
case 0: $general['leader2'] += 1; break;
|
||||
case 1: $general['power2'] += 1; break;
|
||||
case 2: $general['intel2'] += 1; break;
|
||||
}
|
||||
$log[] = "<C>●</>{$admin['month']}월:인재를 찾을 수 없었습니다. <1>$date</>";
|
||||
} else {
|
||||
// 탐색 성공
|
||||
$exp = 200;
|
||||
$ded = 300;
|
||||
switch(Util::choiceRandomUsingWeight([$general['leader'], $general['power'], $general['intel']])) {
|
||||
case 0: $general['leader2'] += 3; break;
|
||||
case 1: $general['power2'] += 3; break;
|
||||
case 2: $general['intel2'] += 3; break;
|
||||
}
|
||||
|
||||
$name = getRandGenName();
|
||||
$name = 'ⓜ'.$name;
|
||||
//중복장수 처리
|
||||
$query = "select no from general where name like '{$name}%'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$count = MYDB_num_rows($result);
|
||||
$count++;
|
||||
if($count > 1) {
|
||||
$name = "{$name}{$count}";
|
||||
}
|
||||
|
||||
if($nation['scout'] != 0) {
|
||||
$scoutType = "발견";
|
||||
$scoutLevel = 0;
|
||||
$scoutNation = 0;
|
||||
} else {
|
||||
$scoutType = "영입";
|
||||
$scoutLevel = 1;
|
||||
$scoutNation = $nation['nation'];
|
||||
}
|
||||
|
||||
$josaYi = JosaUtil::pick($general['name'], '이');
|
||||
$josaRa = JosaUtil::pick($name, '라');
|
||||
$log[] = "<C>●</>{$admin['month']}월:<Y>$name</>{$josaRa}는 <C>인재</>를 {$scoutType}하였습니다! <1>$date</>";
|
||||
$alllog[] = "<C>●</>{$admin['month']}월:<Y>{$general['name']}</>{$josaYi} <Y>$name</>{$josaRa}는 <C>인재</>를 {$scoutType}하였습니다!";
|
||||
pushGeneralHistory($general, "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y>$name</>{$josaRa}는 <C>인재</>를 {$scoutType}");
|
||||
|
||||
$query = "select max(leader+power+intel) as lpi, avg(dedication) as ded,avg(experience) as exp, avg(dex0) as dex0, avg(dex10) as dex10, avg(dex20) as dex20, avg(dex30) as dex30, avg(dex40) as dex40 from general where nation='{$general['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$avgGen = MYDB_fetch_array($result);
|
||||
|
||||
// 체섭시 무장 20%, 지장 20%, 무지장 60%
|
||||
// 마이너 무장 40%, 지장 40%, 무지장 20%
|
||||
$type = rand() % 10;
|
||||
if($admin['scenario'] < 100) {
|
||||
switch($type) {
|
||||
case 0: case 1:
|
||||
$leader = GameConst::$defaultStatMax - 10 + rand()%11;
|
||||
$intel = GameConst::$defaultStatMin + rand()%6;
|
||||
$power = GameConst::$defaultStatTotal - $leader - $intel;
|
||||
break;
|
||||
case 2: case 3:
|
||||
$leader = GameConst::$defaultStatMax - 10 + rand()%11;
|
||||
$power = GameConst::$defaultStatMin + rand()%6;
|
||||
$intel = GameConst::$defaultStatTotal - $leader - $power;
|
||||
break;
|
||||
case 4: case 5: case 6: case 7: case 8: case 9:
|
||||
$leader = GameConst::$defaultStatMin + rand()%6;
|
||||
$power = GameConst::$defaultStatMax - 10 + rand()%11;
|
||||
$intel = GameConst::$defaultStatTotal - $leader - $power;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch($type) {
|
||||
case 0: case 1: case 2: case 3:
|
||||
$leader = GameConst::$defaultStatMax - 10 + rand()%11;
|
||||
$intel = GameConst::$defaultStatMin + rand()%6;
|
||||
$power = GameConst::$defaultStatTotal - $leader - $intel;
|
||||
break;
|
||||
case 4: case 5: case 6: case 7:
|
||||
$leader = GameConst::$defaultStatMax - 10 + rand()%11;
|
||||
$power = GameConst::$defaultStatMin + rand()%6;
|
||||
$intel = GameConst::$defaultStatTotal - $leader - $power;
|
||||
break;
|
||||
case 8: case 9:
|
||||
$leader = GameConst::$defaultStatMin + rand()%6;
|
||||
$power = GameConst::$defaultStatMax - 10 + rand()%11;
|
||||
$intel = GameConst::$defaultStatTotal - $leader - $power;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 국내 최고능치 기준으로 랜덤성 스케일링
|
||||
if($avgGen['lpi'] > 210) {
|
||||
$leader = Util::round($leader * $avgGen['lpi'] / GameConst::$defaultStatTotal * (60+rand()%31)/100);
|
||||
$power = Util::round($power * $avgGen['lpi'] / GameConst::$defaultStatTotal * (60+rand()%31)/100);
|
||||
$intel = Util::round($intel * $avgGen['lpi'] / GameConst::$defaultStatTotal * (60+rand()%31)/100);
|
||||
} elseif($avgGen['lpi'] > 180) {
|
||||
$leader = Util::round($leader * $avgGen['lpi'] / GameConst::$defaultStatTotal * (75+rand()%21)/100);
|
||||
$power = Util::round($power * $avgGen['lpi'] / GameConst::$defaultStatTotal * (75+rand()%21)/100);
|
||||
$intel = Util::round($intel * $avgGen['lpi'] / GameConst::$defaultStatTotal * (75+rand()%21)/100);
|
||||
} else {
|
||||
$leader = Util::round($leader * $avgGen['lpi'] / GameConst::$defaultStatTotal * (90+rand()%11)/100);
|
||||
$power = Util::round($power * $avgGen['lpi'] / GameConst::$defaultStatTotal * (90+rand()%11)/100);
|
||||
$intel = Util::round($intel * $avgGen['lpi'] / GameConst::$defaultStatTotal * (90+rand()%11)/100);
|
||||
}
|
||||
$over1 = 0;
|
||||
$over2 = 0;
|
||||
$over3 = 0;
|
||||
// 너무 높은 능치는 다른 능치로 분산
|
||||
if($leader > 90) {
|
||||
$over1 = rand() % ($leader - 90) + 5;
|
||||
$leader -= $over1;
|
||||
}
|
||||
if($power > 90) {
|
||||
$over2 = rand() % ($power - 90) + 5;
|
||||
$power -= $over2;
|
||||
}
|
||||
if($intel > 90) {
|
||||
$over3 = rand() % ($intel - 90) + 5;
|
||||
$intel -= $over3;
|
||||
}
|
||||
// 낮은 능치쪽으로 합산
|
||||
if($type == 0) {
|
||||
$intel = $intel + $over1 + $over2 + $over3;
|
||||
} else {
|
||||
$power = $power + $over1 + $over2 + $over3;
|
||||
}
|
||||
// 너무 높은 능치는 제한
|
||||
if($leader > 95) {
|
||||
$leader = 95;
|
||||
}
|
||||
if($power > 95) {
|
||||
$power = 95;
|
||||
}
|
||||
if($intel > 95) {
|
||||
$intel = 95;
|
||||
}
|
||||
|
||||
//인재추가
|
||||
$npc = 3;
|
||||
$npccount = 10000 + $npcid;
|
||||
$affinity = rand() % 150 + 1;
|
||||
$picture = 'default.jpg';
|
||||
$turntime = getRandTurn($admin['turnterm']);
|
||||
$personal = rand() % 10;
|
||||
$bornyear = $admin['year'];
|
||||
$deadyear = $admin['year'] + 3;
|
||||
$age = 20;
|
||||
$specage = Util::round((80 - $age)/12) + $age;
|
||||
$specage2 = Util::round((80 - $age)/3) + $age;
|
||||
//$specage = $age + 1 + rand() % 3;
|
||||
//$specage2 = $age + 5 + rand() % 5;
|
||||
// 10년 ~ 50년
|
||||
$killturn = rand()%480 + 120;
|
||||
|
||||
$db->insert('general', [
|
||||
'npc'=>$npc,
|
||||
'npc_org'=>$npc,
|
||||
'affinity'=>$affinity,
|
||||
'name'=>$name,
|
||||
'picture'=>$picture,
|
||||
'nation'=>$scoutNation,
|
||||
'city'=>$general['city'],
|
||||
'leader'=>$leader,
|
||||
'power'=>$power,
|
||||
'intel'=>$intel,
|
||||
'experience'=>$experience,
|
||||
'dedication'=>$dedication,
|
||||
'level'=>$scoutLevel,
|
||||
'gold'=>100,
|
||||
'rice'=>100,
|
||||
'crew'=>0,
|
||||
'crewtype'=>GameUnitConst::DEFAULT_CREWTYPE,
|
||||
'train'=>0,
|
||||
'atmos'=>0,
|
||||
'tnmt'=>0,
|
||||
'weap'=>0,
|
||||
'book'=>0,
|
||||
'horse'=>0,
|
||||
'turntime'=>$turntime,
|
||||
'killturn'=>$killturn,
|
||||
'age'=>$age,
|
||||
'belong'=>1,
|
||||
'personal'=>$personal,
|
||||
'special'=>0,
|
||||
'specage'=>$specage,
|
||||
'special2'=>0,
|
||||
'specage2'=>$specage2,
|
||||
'npcmsg'=>'',
|
||||
'makelimit'=>0,
|
||||
'bornyear'=>$bornyear,
|
||||
'deadyear'=>$deadyear,
|
||||
'dex0'=>$avgGen['dex0'],
|
||||
'dex10'=>$avgGen['dex10'],
|
||||
'dex20'=>$avgGen['dex20'],
|
||||
'dex30'=>$avgGen['dex30'],
|
||||
'dex40'=>$avgGen['dex40'],
|
||||
]);
|
||||
|
||||
$npcid++;
|
||||
|
||||
$db->update('nation', [
|
||||
'gennum'=>$db->sqleval('gennum + 1'),
|
||||
], 'nation=%i', $general['nation']);
|
||||
|
||||
}
|
||||
|
||||
//기술로 가격
|
||||
$gold = $general['gold'] - $admin['develcost'];
|
||||
|
||||
// 성격 보정
|
||||
$exp = CharExperience($exp, $general['personal']);
|
||||
$ded = CharDedication($ded, $general['personal']);
|
||||
|
||||
// 자금 감소 // 경험치 상승 // 공헌도, 명성 상승
|
||||
$query = "update general set resturn='SUCCESS',term='0',gold='$gold',leader2='{$general['leader2']}',power2='{$general['power2']}',intel2='{$general['intel2']}',dedication=dedication+'$ded',experience=experience+'$exp' where no='{$general['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
|
||||
$log = checkAbility($general, $log);
|
||||
$log = uniqueItem($general, $log);
|
||||
}
|
||||
|
||||
pushGeneralPublicRecord($alllog, $admin['year'], $admin['month']);
|
||||
pushGenLog($general, $log);
|
||||
}
|
||||
|
||||
function process_45(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
$alllog = [];
|
||||
$history = [];
|
||||
$date = substr($general['turntime'],11,5);
|
||||
|
||||
$admin = $gameStor->getValues(['startyear', 'year', 'month']);
|
||||
|
||||
$query = "select name from nation where nation='{$general['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$nation = MYDB_fetch_array($result);
|
||||
|
||||
if($general['nation'] == 0) {
|
||||
$log[] = "<C>●</>{$admin['month']}월:재야입니다. 하야 실패. <1>$date</>";
|
||||
} elseif($admin['year'] < $admin['startyear']+3) {
|
||||
$log[] = "<C>●</>{$admin['month']}월:초반제한중 하야는 불가능합니다. 하야 실패. <1>$date</>";
|
||||
} elseif($general['level'] == 12) {
|
||||
$log[] = "<C>●</>{$admin['month']}월:군주입니다. 하야 실패. <1>$date</>";
|
||||
} else {
|
||||
|
||||
$query = "select no from diplomacy where me='{$general['nation']}' and state>='3' and state<='4'";
|
||||
$dipresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$dipcount1 = MYDB_num_rows($dipresult);
|
||||
|
||||
$query = "select no from diplomacy where me='{$general['nation']}' and state>='5' and state<='6'";
|
||||
$dipresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$dipcount2 = MYDB_num_rows($dipresult);
|
||||
|
||||
$gold = 0;
|
||||
$rice = 0;
|
||||
// 금쌀1000이상은 남김
|
||||
if($general['gold'] > 1000) {
|
||||
$gold = $general['gold'] - 1000;
|
||||
$general['gold'] = 1000;
|
||||
}
|
||||
if($general['rice'] > 1000) {
|
||||
$rice = $general['rice'] - 1000;
|
||||
$general['rice'] = 1000;
|
||||
}
|
||||
|
||||
if($dipcount1 > 0) {
|
||||
$josaYi = JosaUtil::pick($general['name'], '이');
|
||||
$josaUl = JosaUtil::pick($nation['name'], '을');
|
||||
$alllog[] = "<C>●</>{$admin['month']}월:<Y>{$general['name']}</>{$josaYi} 통합에 반대하며 <D><b>{$nation['name']}</b></>{$josaUl} <R>떠났</>습니다.";
|
||||
$log[] = "<C>●</>{$admin['month']}월:통합에 반대하며 <D><b>{$nation['name']}</b></>에서 떠났습니다. <1>$date</>";
|
||||
pushGeneralHistory($general, "<C>●</>{$admin['year']}년 {$admin['month']}월:통합에 반대하며 <D><b>{$nation['name']}</b></>{$josaUl} 떠남");
|
||||
|
||||
// 국적 바꾸고 등급 재야로
|
||||
$query = "update general set resturn='SUCCESS',belong=0,nation=0,level=0,makelimit='12',gold='{$general['gold']}',rice='{$general['rice']}' where no='{$general['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} elseif($dipcount2 > 0) {
|
||||
$josaYi = JosaUtil::pick($general['name'], '이');
|
||||
$josaUl = JosaUtil::pick($nation['name'], '을');
|
||||
$alllog[] = "<C>●</>{$admin['month']}월:<Y>{$general['name']}</>{$josaYi} 합병에 반대하며 <D><b>{$nation['name']}</b></>{$josaUl} <R>떠났</>습니다.";
|
||||
$log[] = "<C>●</>{$admin['month']}월:합병에 반대하며 <D><b>{$nation['name']}</b></>에서 떠났습니다. <1>$date</>";
|
||||
pushGeneralHistory($general, "<C>●</>{$admin['year']}년 {$admin['month']}월:합병에 반대하며 <D><b>{$nation['name']}</b></>{$josaUl} 떠남");
|
||||
|
||||
// 국적 바꾸고 등급 재야로
|
||||
$query = "update general set resturn='SUCCESS',belong=0,nation=0,level=0,makelimit='12',gold='{$general['gold']}',rice='{$general['rice']}' where no='{$general['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} else {
|
||||
$josaYi = JosaUtil::pick($general['name'], '이');
|
||||
$alllog[] = "<C>●</>{$admin['month']}월:<Y>{$general['name']}</>{$josaYi} <D><b>{$nation['name']}</b></>에서 <R>하야</>했습니다.";
|
||||
$log[] = "<C>●</>{$admin['month']}월:<D><b>{$nation['name']}</b></>에서 하야했습니다. <1>$date</>";
|
||||
pushGeneralHistory($general, "<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>에서 하야");
|
||||
|
||||
// 국적 바꾸고 등급 재야로 // 명성/공헌 N*10% 감소
|
||||
$query = "update general set resturn='SUCCESS',belong=0,betray=betray+1,nation=0,level=0,experience=experience*(1-0.1*betray),dedication=dedication*(1-0.1*betray),makelimit='12',gold='{$general['gold']}',rice='{$general['rice']}' where no='{$general['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
}
|
||||
|
||||
//도시의 태수, 군사, 시중직도 초기화
|
||||
$query = "update city set gen1='0' where gen1='{$general['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$query = "update city set gen2='0' where gen2='{$general['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$query = "update city set gen3='0' where gen3='{$general['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
|
||||
$query = "select no from troop where troop='{$general['troop']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$troop = MYDB_fetch_array($result);
|
||||
|
||||
//부대장일 경우
|
||||
if($troop['no'] == $general['no']) {
|
||||
// 모두 탈퇴
|
||||
$query = "update general set troop='0' where troop='{$general['troop']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
// 부대 삭제
|
||||
$query = "delete from troop where troop='{$general['troop']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} else {
|
||||
$query = "update general set troop='0' where no='{$general['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
}
|
||||
|
||||
$db->update('nation', [
|
||||
'gennum'=>$db->sqleval('gennum - 1'),
|
||||
'gold'=>$db->sqleval('gold + %i', $gold),
|
||||
'rice'=>$db->sqleval('rice + %i', $rice),
|
||||
], 'nation=%i', $general['nation']);
|
||||
}
|
||||
pushGeneralPublicRecord($alllog, $admin['year'], $admin['month']);
|
||||
pushGenLog($general, $log);
|
||||
}
|
||||
|
||||
function process_46(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
namespace sammo\GeneralCommand;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
LastTurn,
|
||||
Command
|
||||
};
|
||||
|
||||
|
||||
use function \sammo\{
|
||||
tryUniqueItemLottery
|
||||
};
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
use sammo\CityConst;
|
||||
|
||||
|
||||
|
||||
class che_임관 extends Command\GeneralCommand{
|
||||
static protected $actionName = '임관';
|
||||
|
||||
protected function argTest():bool{
|
||||
$this->arg = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
|
||||
$general = $this->generalObj;
|
||||
$env = $this->env;
|
||||
|
||||
$this->setNation();
|
||||
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$this->runnableConstraints=[
|
||||
['NotBeNeutral'],
|
||||
['NotOpeningPart', $relYear],
|
||||
['NotLord'],
|
||||
];
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->isRunnable()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$env = $this->env;
|
||||
|
||||
$general = $this->generalObj;
|
||||
$date = substr($general->getVar('turntime'),11,5);
|
||||
$generalName = $general->getName();
|
||||
$josaYi = JosaUtil::pick($generalName, '이');
|
||||
|
||||
$nationID = $this->nation['nation'];
|
||||
$nationName = $this->nation['name'];
|
||||
$josaUl = JosaUtil::pick($nationName, '을');
|
||||
|
||||
$dipState = Util::arrayGroupBy($db->query('SELECT no, state FROM diplomacy WHERE me = %i', $nationID), 'state');
|
||||
|
||||
$logger = $general->getLogger();
|
||||
|
||||
if(key_exists('3', $dipState) || key_exists('4', $dipState)){
|
||||
$logger->pushGeneralActionLog("통합에 반대하며 <D><b>{$nationName}</b></>에서 떠났습니다. <1>$date</>");
|
||||
$logger->pushGeneralHistoryLog("통합에 반대하며 <D><b>{$nationName}</b></>{$josaUl} 떠남");
|
||||
$logger->pushGlobalActionLog("{$generalName}</>{$josaYi} 통합에 반대하며 <D><b>{$nationName}</b></>{$josaUl} <R>떠났</>습니다.");
|
||||
}
|
||||
else if(key_exists('5', $dipState) || key_exists('6', $dipState)){
|
||||
$logger->pushGeneralActionLog("합병에 반대하며 <D><b>{$nationName}</b></>에서 떠났습니다. <1>$date</>");
|
||||
$logger->pushGeneralHistoryLog("합병에 반대하며 <D><b>{$nationName}</b></>{$josaUl} 떠남");
|
||||
$logger->pushGlobalActionLog("{$generalName}</>{$josaYi} 합병에 반대하며 <D><b>{$nationName}</b></>{$josaUl} <R>떠났</>습니다.");
|
||||
}
|
||||
else{
|
||||
$logger->pushGeneralActionLog("<D><b>{$nationName}</b></>에서 하야했습니다. <1>$date</>");
|
||||
$logger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>에서 하야");
|
||||
$logger->pushGlobalActionLog("{$generalName}</>{$josaYi} <D><b>{$nationName}</b></>에서 <R>하야</>했습니다.");
|
||||
$general->setVar('experience', $general->getVar('experience') * (1 - 0.1 * $general->getVar('betray')));
|
||||
$general->setVar('dedication', $general->getVar('dedication') * (1 - 0.1 * $general->getVar('betray')));
|
||||
$general->increaseVar('betray', 1);
|
||||
|
||||
}
|
||||
|
||||
$newGold = Util::valueFit($general->getVar('gold'), null, 1000);
|
||||
$newRice = Util::valueFit($general->getVar('rice'), null, 1000);
|
||||
|
||||
$lostGold = $general->getVar('gold') - $newGold;
|
||||
$lostRice = $general->getVar('rice') - $newRice;
|
||||
|
||||
$general->setVar('gold', $newGold);
|
||||
$general->setVar('rice', $newRice);
|
||||
|
||||
$db->update('nation', [
|
||||
'gold'=>$db->sqleval('gold + %i', $lostGold),
|
||||
'gold'=>$db->sqleval('gold + %i', $lostRice),
|
||||
'gennum'=>$db->sqleval('gennum - 1')
|
||||
], 'nation=%i', $nationID);
|
||||
|
||||
$general->setVar('nation', 0);
|
||||
$general->setVar('level', 0);
|
||||
$general->setVar('belong', 0);
|
||||
$general->setVar('makelimit', 12);
|
||||
|
||||
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Constraint;
|
||||
|
||||
class BeChief extends Constraint{
|
||||
const REQ_VALUES = Constraint::REQ_GENERAL;
|
||||
|
||||
public function checkInputValues(bool $throwExeception=true){
|
||||
if(!parent::checkInputValues($throwExeception) && !$throwException){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!key_exists('level', $this->general)){
|
||||
if(!$throwExeception){return false; }
|
||||
throw new \InvalidArgumentException("require level in general");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function test():bool{
|
||||
$this->checkInputValues();
|
||||
$this->tested = true;
|
||||
|
||||
if($this->general['level'] > 4){
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->reason = "수뇌가 아닙니다.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Constraint;
|
||||
|
||||
class BeLord extends Constraint{
|
||||
const REQ_VALUES = Constraint::REQ_GENERAL;
|
||||
|
||||
public function checkInputValues(bool $throwExeception=true){
|
||||
if(!parent::checkInputValues($throwExeception) && !$throwException){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!key_exists('level', $this->general)){
|
||||
if(!$throwExeception){return false; }
|
||||
throw new \InvalidArgumentException("require level in general");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function test():bool{
|
||||
$this->checkInputValues();
|
||||
$this->tested = true;
|
||||
|
||||
if($this->general['level'] != 12){
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->reason = "군주가 아닙니다.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Constraint;
|
||||
|
||||
class NotChief extends Constraint{
|
||||
const REQ_VALUES = Constraint::REQ_GENERAL;
|
||||
|
||||
public function checkInputValues(bool $throwExeception=true){
|
||||
if(!parent::checkInputValues($throwExeception) && !$throwException){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!key_exists('level', $this->general)){
|
||||
if(!$throwExeception){return false; }
|
||||
throw new \InvalidArgumentException("require level in general");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function test():bool{
|
||||
$this->checkInputValues();
|
||||
$this->tested = true;
|
||||
|
||||
if($this->general['level'] <= 4){
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->reason = "수뇌입니다.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Constraint;
|
||||
|
||||
class NotLord extends Constraint{
|
||||
const REQ_VALUES = Constraint::REQ_GENERAL;
|
||||
|
||||
public function checkInputValues(bool $throwExeception=true){
|
||||
if(!parent::checkInputValues($throwExeception) && !$throwException){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!key_exists('level', $this->general)){
|
||||
if(!$throwExeception){return false; }
|
||||
throw new \InvalidArgumentException("require level in general");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function test():bool{
|
||||
$this->checkInputValues();
|
||||
$this->tested = true;
|
||||
|
||||
if($this->general['level'] != 12){
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->reason = "군주입니다.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -540,7 +540,7 @@ class General implements iAction{
|
||||
'no', 'name', 'name2', 'picture', 'imgsvr', 'nation', 'nations', 'city', 'troop', 'injury', 'affinity',
|
||||
'leader', 'leader2', 'power', 'power2', 'intel', 'intel2', 'weap', 'book', 'horse', 'item',
|
||||
'experience', 'dedication', 'level', 'gold', 'rice', 'crew', 'crewtype', 'train', 'atmos', 'turntime',
|
||||
'makenation', 'makelimit', 'killturn', 'block', 'dedlevel', 'explevel', 'age', 'belong',
|
||||
'makelimit', 'killturn', 'block', 'dedlevel', 'explevel', 'age', 'belong',
|
||||
'personal', 'special', 'special2', 'term', 'mode', 'npc', 'npc_org', 'deadyear', 'npcmsg',
|
||||
'dex0', 'dex10', 'dex20', 'dex30', 'dex40',
|
||||
'warnum', 'killnum', 'deathnum', 'killcrew', 'deathcrew', 'recwar', 'last_turn'
|
||||
|
||||
@@ -52,7 +52,6 @@ CREATE TABLE `general` (
|
||||
`item` INT(2) NULL DEFAULT '0',
|
||||
`turntime` DATETIME(6) NULL DEFAULT NULL,
|
||||
`recwar` DATETIME(6) NULL DEFAULT NULL,
|
||||
`makenation` CHAR(255) NULL DEFAULT NULL,
|
||||
`makelimit` INT(2) NULL DEFAULT '0',
|
||||
`killturn` INT(3) NULL DEFAULT NULL,
|
||||
`lastconnect` DATETIME NULL DEFAULT NULL,
|
||||
|
||||
Reference in New Issue
Block a user