새 금쌀 구매 로직
This commit is contained in:
+95
-72
@@ -2145,97 +2145,120 @@ class GeneralAI
|
|||||||
protected function do금쌀구매(): ?GeneralCommand
|
protected function do금쌀구매(): ?GeneralCommand
|
||||||
{
|
{
|
||||||
$general = $this->general;
|
$general = $this->general;
|
||||||
$avgAmount = ($general->getVar('gold') + $general->getVar('rice'))/2;
|
|
||||||
|
|
||||||
if($this->city['trade'] === null && !$this->generalPolicy->can상인무시){
|
if($this->city['trade'] === null && !$this->generalPolicy->can상인무시){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($avgAmount < $this->baseDevelCost){
|
$kill = $general->getRankVar('killcrew') + 50000;
|
||||||
|
$death = $general->getRankVar('deathcrew') + 50000;
|
||||||
|
$deathRate = $death/$kill;
|
||||||
|
|
||||||
|
$absGold = $general->getVar('gold');
|
||||||
|
$absRice = $general->getVar('rice');
|
||||||
|
|
||||||
|
$relGold = $absGold;
|
||||||
|
$relRice = $absRice * $deathRate;
|
||||||
|
|
||||||
|
if($absGold + $absRice < $this->baseDevelCost * 2){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->dipState !== self::d평화 && ($this->genType & self::t통솔장)){
|
$crewType = $general->getCrewTypeObj();
|
||||||
$crewType = $general->getCrewTypeObj();
|
if($this->generalPolicy->can모병){
|
||||||
if($this->generalPolicy->can모병){
|
$costCmd = buildGeneralCommandClass('che_모병', $general, $this->env, [
|
||||||
$costCmd = buildGeneralCommandClass('che_모병', $general, $this->env, [
|
'crewType'=>$crewType->id,
|
||||||
'crewType'=>$crewType->id,
|
'amount'=>$this->fullLeadership*100
|
||||||
'amount'=>$this->fullLeadership*100
|
]);
|
||||||
]);
|
}
|
||||||
}
|
else{
|
||||||
else{
|
$costCmd = buildGeneralCommandClass('che_징병', $general, $this->env, [
|
||||||
$costCmd = buildGeneralCommandClass('che_징병', $general, $this->env, [
|
'crewType'=>$crewType->id,
|
||||||
'crewType'=>$crewType->id,
|
'amount'=>$this->fullLeadership*100
|
||||||
'amount'=>$this->fullLeadership*100
|
]);
|
||||||
]);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$goldCost = $costCmd->getCost()[0];
|
$goldCost = $costCmd->getCost()[0];
|
||||||
$riceCost = $crewType->riceWithTech(
|
$riceCost = $crewType->riceWithTech(
|
||||||
$this->nation['tech'],
|
$this->nation['tech'],
|
||||||
$this->fullLeadership*100 *
|
$this->fullLeadership*100
|
||||||
$general->getRankVar('killcrew')/max($general->getRankVar('deathcrew'),1)
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if($avgAmount * 2 > $goldCost + $riceCost){
|
if(($relGold + $relRice) * 1.5 <= $goldCost + $riceCost){
|
||||||
if ($general->getVar('rice') < $riceCost * 2 && $general->getVar('gold') >= $goldCost * 4) {
|
return null;
|
||||||
//1:1
|
}
|
||||||
$amount = Util::valueFit(Util::toInt($general->getVar('gold') - $avgAmount), 100, GameConst::$maxResourceActionAmount);
|
|
||||||
if($amount >= $this->nationPolicy->minimumResourceActionAmount){
|
$tryBuying = false;
|
||||||
$cmd = buildGeneralCommandClass('che_군량매매', $general, $this->env,
|
if ($this->generalPolicy->can상인무시){
|
||||||
[
|
if($relRice * 1.5 < $relGold && $relRice < $riceCost * 2)
|
||||||
'buyRice' => true,
|
{
|
||||||
'amount' => $amount
|
$tryBuying = true;
|
||||||
]
|
}
|
||||||
);
|
else if($relRice * 2 < $relGold)
|
||||||
if($cmd->hasFullConditionMet()){
|
{
|
||||||
return $cmd;
|
$tryBuying = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
else{
|
||||||
if ($general->getVar('gold') < $goldCost && $general->getVar('rice') >= $riceCost * 2) {
|
if($relRice * 2 < $relGold && $relRice < $riceCost * 3)
|
||||||
$avgAmount = ($general->getVar('gold') + $general->getVar('rice'))/2;
|
{
|
||||||
$amount = Util::valueFit(Util::toInt($general->getVar('rice') - $avgAmount), 100, GameConst::$maxResourceActionAmount);
|
$tryBuying = true;
|
||||||
if($amount >= $this->nationPolicy->minimumResourceActionAmount){
|
}
|
||||||
$cmd = buildGeneralCommandClass('che_군량매매', $general, $this->env,
|
}
|
||||||
[
|
|
||||||
'buyRice' => false,
|
if ($tryBuying) {
|
||||||
'amount' => $amount
|
//1:1
|
||||||
]
|
$amount = Util::valueFit(Util::toInt(($relGold - $relRice) / (1 + $deathRate)), 100, GameConst::$maxResourceActionAmount);
|
||||||
);
|
if($amount >= $this->nationPolicy->minimumResourceActionAmount){
|
||||||
if($cmd->hasFullConditionMet()){
|
$cmd = buildGeneralCommandClass('che_군량매매', $general, $this->env,
|
||||||
return $cmd;
|
[
|
||||||
}
|
'buyRice' => true,
|
||||||
}
|
'amount' => $amount
|
||||||
|
]
|
||||||
|
);
|
||||||
|
if($cmd->hasFullConditionMet()){
|
||||||
|
return $cmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($general->getVar('rice') < $this->baseDevelCost && $general->getVar('gold') >= $this->baseDevelCost * 3) {
|
$trySelling = false;
|
||||||
$cmd = buildGeneralCommandClass('che_군량매매', $general, $this->env,
|
if ($this->generalPolicy->can상인무시){
|
||||||
[
|
if($relGold * 1.5 < $relRice && $relGold < $goldCost * 2)
|
||||||
'buyRice' => true,
|
{
|
||||||
'amount' => Util::valueFit(Util::toInt($general->getVar('gold') - $avgAmount), 100, GameConst::$maxResourceActionAmount)
|
$trySelling = true;
|
||||||
]
|
}
|
||||||
);
|
else if($relGold * 2 < $relRice)
|
||||||
if($cmd->hasFullConditionMet()){
|
{
|
||||||
return $cmd;
|
$trySelling = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if($relGold * 2 < $relRice && $relGold < $goldCost * 3)
|
||||||
|
{
|
||||||
|
$trySelling = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($general->getVar('gold') < $this->baseDevelCost && $general->getVar('rice') >= $this->baseDevelCost * 3) {
|
|
||||||
$avgAmount = ($general->getVar('gold') + $general->getVar('rice'))/2;
|
if ($trySelling) {
|
||||||
$cmd = buildGeneralCommandClass('che_군량매매', $general, $this->env,
|
$amount = Util::valueFit(Util::toInt(($relRice - $relGold) / (1 + $deathRate)), 100, GameConst::$maxResourceActionAmount);
|
||||||
[
|
if($amount >= $this->nationPolicy->minimumResourceActionAmount){
|
||||||
'buyRice' => false,
|
$cmd = buildGeneralCommandClass('che_군량매매', $general, $this->env,
|
||||||
'amount' => Util::valueFit(Util::toInt($general->getVar('rice') - $avgAmount), 100, GameConst::$maxResourceActionAmount)
|
[
|
||||||
]
|
'buyRice' => false,
|
||||||
);
|
'amount' => $amount
|
||||||
if($cmd->hasFullConditionMet()){
|
]
|
||||||
return $cmd;
|
);
|
||||||
|
if($cmd->hasFullConditionMet()){
|
||||||
|
return $cmd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user