diff --git a/hwe/func_converter.php b/hwe/func_converter.php index 21ab9f17..2f82e843 100644 --- a/hwe/func_converter.php +++ b/hwe/func_converter.php @@ -359,7 +359,7 @@ function getWarUnitTriggerClass(string $type){ } function buildWarUnitTriggerClass(?string $type, WarUnit $unit, ?array $args = null):BaseWarUnitTrigger{ - $classPath = getNationCommandClass($type); + $classPath = getWarUnitTriggerClass($type); if(!$args){ return new $classPath($unit); } diff --git a/hwe/j_simulate_battle.php b/hwe/j_simulate_battle.php index 224daa6d..0274549c 100644 --- a/hwe/j_simulate_battle.php +++ b/hwe/j_simulate_battle.php @@ -31,8 +31,6 @@ if($query === null){ ]); } -LogText('simulate', $query); - $defaultCheck = [ 'required'=>[ 'attackerGeneral', 'attackerCity', 'attackerNation', diff --git a/hwe/js/battle_simulator.js b/hwe/js/battle_simulator.js index 1af0dd99..0d9196a4 100644 --- a/hwe/js/battle_simulator.js +++ b/hwe/js/battle_simulator.js @@ -769,7 +769,6 @@ jQuery(function($){ type:'post', url:'j_simulate_battle.php', dataType:'json', - contentType: "application/json", data:{ action:'reorder', query:JSON.stringify(data), diff --git a/hwe/lib.php b/hwe/lib.php index d7036ad0..63f3ca83 100644 --- a/hwe/lib.php +++ b/hwe/lib.php @@ -53,6 +53,6 @@ function MessageBox($str) function LogText($prefix, $variable) { - $text = sprintf('%s : %s'."\r\n", $prefix, var_export($variable, true)); + $text = sprintf('%s : %s'."\r\n", $prefix, TVarDumper::dump($variable)); file_put_contents(ROOT.'/d_log/dbg_logs.txt', $text, FILE_APPEND); } diff --git a/hwe/sammo/ActionSpecialWar/che_보병.php b/hwe/sammo/ActionSpecialWar/che_보병.php index b5802e18..f702b95a 100644 --- a/hwe/sammo/ActionSpecialWar/che_보병.php +++ b/hwe/sammo/ActionSpecialWar/che_보병.php @@ -29,8 +29,8 @@ class che_보병 extends \sammo\BaseSpecial{ public function getWarPowerMultiplier(WarUnit $unit):array{ if($unit->isAttacker()){ - return [0, 0.9]; + return [1, 0.9]; } - return [0, 0.8]; + return [1, 0.8]; } } \ No newline at end of file diff --git a/hwe/sammo/BaseWarUnitTrigger.php b/hwe/sammo/BaseWarUnitTrigger.php index 69b5ed66..8e7d980e 100644 --- a/hwe/sammo/BaseWarUnitTrigger.php +++ b/hwe/sammo/BaseWarUnitTrigger.php @@ -18,7 +18,13 @@ abstract class BaseWarUnitTrigger extends ObjectTrigger{ public function getUniqueID():string{ $priority = $this->priority; $fqn = static::class; - return "{$priority}_{$fqn}_{$this->raiseType}"; + if($this->object === null){ + $objID = ''; + } + else{ + $objID = spl_object_id($this->object); + } + return "{$priority}_{$fqn}_{$objID}_{$this->raiseType}"; } public function action(?array $env=null, $arg=null):?array{ @@ -53,7 +59,7 @@ abstract class BaseWarUnitTrigger extends ObjectTrigger{ $env['e_attacker'] = $isAttacker?$selfEnv:$opposeEnv; $env['e_defender'] = $isAttacker?$opposeEnv:$selfEnv; - if($callNextAction){ + if(!$callNextAction){ $env['stopNextAction'] = true; } diff --git a/hwe/sammo/ObjectTrigger.php b/hwe/sammo/ObjectTrigger.php index 9fab3fb7..32bef848 100644 --- a/hwe/sammo/ObjectTrigger.php +++ b/hwe/sammo/ObjectTrigger.php @@ -25,6 +25,12 @@ abstract class ObjectTrigger{ public function getUniqueID():string{ $priority = $this->priority; $fqn = static::class; - return "{$priority}_{$fqn}"; + if($this->object === null){ + $objID = ''; + } + else{ + $objID = spl_object_id($this->object); + } + return "{$priority}_{$fqn}_{$objID}"; } } \ No newline at end of file diff --git a/hwe/sammo/SpecialityHelper.php b/hwe/sammo/SpecialityHelper.php index 20f43671..ab6d005d 100644 --- a/hwe/sammo/SpecialityHelper.php +++ b/hwe/sammo/SpecialityHelper.php @@ -127,7 +127,7 @@ class SpecialityHelper{ } if(!$onlyAvailable){ - foreach(GameConst::$availableSpecialDomestic as $specialID){ + foreach(GameConst::$optionalSpecialDomestic as $specialID){ $specialObj = buildGeneralSpecialDomesticClass($specialID); $result[$specialID] = $specialObj; } @@ -140,18 +140,18 @@ class SpecialityHelper{ public static function getSpecialWarList(bool $onlyAvailable=true):array{ $result = []; if(!$onlyAvailable){ - $specialObj = buildGeneralSpecialDomesticClass(GameConst::$defaultSpecialDomestic); - $result[GameConst::$defaultSpecialDomestic] = $specialObj; + $specialObj = buildGeneralSpecialWarClass(GameConst::$defaultSpecialWar); + $result[GameConst::$defaultSpecialWar] = $specialObj; } - foreach(GameConst::$availableSpecialDomestic as $specialID){ - $specialObj = buildGeneralSpecialDomesticClass($specialID); + foreach(GameConst::$availableSpecialWar as $specialID){ + $specialObj = buildGeneralSpecialWarClass($specialID); $result[$specialID] = $specialObj; } if(!$onlyAvailable){ - foreach(GameConst::$availableSpecialDomestic as $specialID){ - $specialObj = buildGeneralSpecialDomesticClass($specialID); + foreach(GameConst::$optionalSpecialWar as $specialID){ + $specialObj = buildGeneralSpecialWarClass($specialID); $result[$specialID] = $specialObj; } } diff --git a/hwe/sammo/TriggerCaller.php b/hwe/sammo/TriggerCaller.php index ac9e506c..ab2650f1 100644 --- a/hwe/sammo/TriggerCaller.php +++ b/hwe/sammo/TriggerCaller.php @@ -119,7 +119,7 @@ abstract class TriggerCaller{ } function fire(?array $env = null, $arg = null):?array{ - foreach($this->triggerListByPriority as $subTriggerList){ + foreach($this->triggerListByPriority as $priority=>$subTriggerList){ /** @var ObjectTrigger[] $subTriggerList */ foreach($subTriggerList as $trigger){ $env = $trigger->action($env, $arg); diff --git a/hwe/sammo/WarUnitTrigger/che_격노발동.php b/hwe/sammo/WarUnitTrigger/che_격노발동.php index d6cc8129..e6f68544 100644 --- a/hwe/sammo/WarUnitTrigger/che_격노발동.php +++ b/hwe/sammo/WarUnitTrigger/che_격노발동.php @@ -7,6 +7,7 @@ use sammo\WarUnit; use sammo\GameUnitDetail; use sammo\Util; use sammo\ObjectTrigger; +use sammo\ActionLogger; class che_격노발동 extends BaseWarUnitTrigger{ protected $priority = ObjectTrigger::PRIORITY_POST + 600; diff --git a/hwe/sammo/WarUnitTrigger/che_계략발동.php b/hwe/sammo/WarUnitTrigger/che_계략발동.php index 00ed926b..dd73a342 100644 --- a/hwe/sammo/WarUnitTrigger/che_계략발동.php +++ b/hwe/sammo/WarUnitTrigger/che_계략발동.php @@ -7,6 +7,7 @@ use sammo\WarUnit; use sammo\GameUnitDetail; use sammo\Util; use sammo\ObjectTrigger; +use sammo\ActionLogger; class che_계략발동 extends BaseWarUnitTrigger{ protected $priority = ObjectTrigger::PRIORITY_POST + 100; @@ -28,7 +29,7 @@ class che_계략발동 extends BaseWarUnitTrigger{ $damage = $general->onCalcStat($general, 'warMagicFailDamage', $damage, $magic); $josaUl = \sammo\JosaUtil::pick($magic, '을'); - $general->pushGeneralBattleDetailLog("{$magic}{$josaUl} 성공했다!", ActionLogger::PLAIN); + $general->getLogger()->pushGeneralBattleDetailLog("{$magic}{$josaUl} 성공했다!", ActionLogger::PLAIN); $oppose->getLogger()->pushGeneralBattleDetailLog("{$magic}에 당했다!", ActionLogger::PLAIN); $self->multiplyWarPowerMultiply($damage); diff --git a/hwe/sammo/WarUnitTrigger/che_계략시도.php b/hwe/sammo/WarUnitTrigger/che_계략시도.php index fab2cb5f..5002c80d 100644 --- a/hwe/sammo/WarUnitTrigger/che_계략시도.php +++ b/hwe/sammo/WarUnitTrigger/che_계략시도.php @@ -6,6 +6,7 @@ use sammo\WarUnitCity; use sammo\WarUnit; use sammo\GameUnitDetail; use sammo\ObjectTrigger; +use sammo\Util; class che_계략시도 extends BaseWarUnitTrigger{ protected $priority = ObjectTrigger::PRIORITY_PRE + 300; @@ -49,7 +50,7 @@ class che_계략시도 extends BaseWarUnitTrigger{ $magicSuccessProb = 0.7; $magicSuccessProb = $general->onCalcStat($general, 'warMagicSuccessProb', $magicSuccessProb); - if($this->hasActivatedSkill('계략약화')){ + if($self->hasActivatedSkill('계략약화')){ $magicSuccessProb -= 0.1; //NOTE: 앞으로 이건 oppose의 onCalcStat에 들어가야하지 않을까? } diff --git a/hwe/sammo/WarUnitTrigger/che_계략실패.php b/hwe/sammo/WarUnitTrigger/che_계략실패.php index 68a2ce99..8d3c3793 100644 --- a/hwe/sammo/WarUnitTrigger/che_계략실패.php +++ b/hwe/sammo/WarUnitTrigger/che_계략실패.php @@ -7,6 +7,7 @@ use sammo\WarUnit; use sammo\GameUnitDetail; use sammo\Util; use sammo\ObjectTrigger; +use sammo\ActionLogger; class che_계략실패 extends BaseWarUnitTrigger{ protected $priority = ObjectTrigger::PRIORITY_POST + 200; @@ -28,7 +29,7 @@ class che_계략실패 extends BaseWarUnitTrigger{ $damage = $general->onCalcStat($general, 'warMagicFailDamage', $damage, $magic); $josaUl = \sammo\JosaUtil::pick($magic, '을'); - $general->pushGeneralBattleDetailLog("{$magic}{$josaUl} 실패했다!", ActionLogger::PLAIN); + $general->getLogger()->pushGeneralBattleDetailLog("{$magic}{$josaUl} 실패했다!", ActionLogger::PLAIN); $oppose->getLogger()->pushGeneralBattleDetailLog("{$magic}{$josaUl} 간파했다!", ActionLogger::PLAIN); $self->multiplyWarPowerMultiply(1/$damage); diff --git a/hwe/sammo/WarUnitTrigger/che_반계발동.php b/hwe/sammo/WarUnitTrigger/che_반계발동.php index 823a4682..2f4ef77a 100644 --- a/hwe/sammo/WarUnitTrigger/che_반계발동.php +++ b/hwe/sammo/WarUnitTrigger/che_반계발동.php @@ -7,6 +7,7 @@ use sammo\WarUnit; use sammo\GameUnitDetail; use sammo\Util; use sammo\ObjectTrigger; +use sammo\ActionLogger; class che_반계발동 extends BaseWarUnitTrigger{ protected $priority = ObjectTrigger::PRIORITY_POST + 150; @@ -23,7 +24,7 @@ class che_반계발동 extends BaseWarUnitTrigger{ $josaUl = \sammo\JosaUtil::pick($opposeMagic, '을'); - $general->pushGeneralBattleDetailLog("반계로 상대의 {$opposeMagic}{$josaUl} 되돌렸다!", ActionLogger::PLAIN); + $general->getLogger()->pushGeneralBattleDetailLog("반계로 상대의 {$opposeMagic}{$josaUl} 되돌렸다!", ActionLogger::PLAIN); $oppose->getLogger()->pushGeneralBattleDetailLog("{$opposeMagic}{$josaUl} 역으로 당했다!", ActionLogger::PLAIN); $self->multiplyWarPowerMultiply($damage); diff --git a/hwe/sammo/WarUnitTrigger/che_반계시도.php b/hwe/sammo/WarUnitTrigger/che_반계시도.php index e516a541..f94af653 100644 --- a/hwe/sammo/WarUnitTrigger/che_반계시도.php +++ b/hwe/sammo/WarUnitTrigger/che_반계시도.php @@ -5,6 +5,7 @@ use sammo\WarUnitGeneral; use sammo\WarUnitCity; use sammo\WarUnit; use sammo\GameUnitDetail; +use sammo\Util; use sammo\ObjectTrigger; class che_반계시도 extends BaseWarUnitTrigger{ diff --git a/hwe/sammo/WarUnitTrigger/che_위압발동.php b/hwe/sammo/WarUnitTrigger/che_위압발동.php index 6ec5e6f3..ce0dcce5 100644 --- a/hwe/sammo/WarUnitTrigger/che_위압발동.php +++ b/hwe/sammo/WarUnitTrigger/che_위압발동.php @@ -7,6 +7,7 @@ use sammo\WarUnit; use sammo\GameUnitDetail; use sammo\Util; use sammo\ObjectTrigger; +use sammo\ActionLogger; class che_위압발동 extends BaseWarUnitTrigger{ protected $priority = ObjectTrigger::PRIORITY_POST + 700; diff --git a/hwe/sammo/WarUnitTrigger/che_저격발동.php b/hwe/sammo/WarUnitTrigger/che_저격발동.php index 4d208750..26805880 100644 --- a/hwe/sammo/WarUnitTrigger/che_저격발동.php +++ b/hwe/sammo/WarUnitTrigger/che_저격발동.php @@ -7,6 +7,7 @@ use sammo\WarUnit; use sammo\GameUnitDetail; use sammo\Util; use sammo\ObjectTrigger; +use sammo\ActionLogger; class che_저격발동 extends BaseWarUnitTrigger{ protected $priority = ObjectTrigger::PRIORITY_POST + 100; diff --git a/hwe/sammo/WarUnitTrigger/che_저지발동.php b/hwe/sammo/WarUnitTrigger/che_저지발동.php index e0e79fe8..58e44c31 100644 --- a/hwe/sammo/WarUnitTrigger/che_저지발동.php +++ b/hwe/sammo/WarUnitTrigger/che_저지발동.php @@ -7,6 +7,7 @@ use sammo\WarUnit; use sammo\GameUnitDetail; use sammo\Util; use sammo\ObjectTrigger; +use sammo\ActionLogger; class che_저지발동 extends BaseWarUnitTrigger{ protected $priority = ObjectTrigger::PRIORITY_POST; //최우선 순위 @@ -24,8 +25,8 @@ class che_저지발동 extends BaseWarUnitTrigger{ $self->getLogger()->pushGeneralBattleDetailLog("상대를 저지했다!", ActionLogger::PLAIN); $oppose->getLogger()->pushGeneralBattleDetailLog("저지당했다!", ActionLogger::PLAIN); - $self->addDex($oppose->getCrewType(), $oppose->getWarPower() * 0.9); - $self->addDex($self->getCrewType(), $self->getWarPower() * 0.9); + $self->getGeneral()->addDex($oppose->getCrewType(), $oppose->getWarPower() * 0.9); + $self->getGeneral()->addDex($self->getCrewType(), $self->getWarPower() * 0.9); $self->setWarPowerMultiply(0); $oppose->setWarPowerMultiply(0); diff --git a/hwe/sammo/WarUnitTrigger/che_저지시도.php b/hwe/sammo/WarUnitTrigger/che_저지시도.php index 095a8963..2196b87e 100644 --- a/hwe/sammo/WarUnitTrigger/che_저지시도.php +++ b/hwe/sammo/WarUnitTrigger/che_저지시도.php @@ -5,6 +5,7 @@ use sammo\WarUnitGeneral; use sammo\WarUnitCity; use sammo\WarUnit; use sammo\GameUnitDetail; +use sammo\Util; use sammo\ObjectTrigger; class che_저지시도 extends BaseWarUnitTrigger{ diff --git a/hwe/sammo/WarUnitTrigger/che_전투치료발동.php b/hwe/sammo/WarUnitTrigger/che_전투치료발동.php index a5a537ee..cd95631c 100644 --- a/hwe/sammo/WarUnitTrigger/che_전투치료발동.php +++ b/hwe/sammo/WarUnitTrigger/che_전투치료발동.php @@ -7,6 +7,7 @@ use sammo\WarUnit; use sammo\GameUnitDetail; use sammo\Util; use sammo\ObjectTrigger; +use sammo\ActionLogger; class che_전투치료발동 extends BaseWarUnitTrigger{ protected $priority = ObjectTrigger::PRIORITY_POST + 300; @@ -24,7 +25,7 @@ class che_전투치료발동 extends BaseWarUnitTrigger{ $oppose->getLogger()->pushGeneralBattleDetailLog("상대가 치료했다!", ActionLogger::PLAIN); $self->getLogger()->pushGeneralBattleDetailLog("치료했다!", ActionLogger::PLAIN); - $oppose->getGeneral()->multiplyWarPowerMultiply(1/1.5); + $oppose->multiplyWarPowerMultiply(1/1.5); $this->processConsumableItem(); diff --git a/hwe/sammo/WarUnitTrigger/che_전투치료시도.php b/hwe/sammo/WarUnitTrigger/che_전투치료시도.php index 6730fec0..421b6478 100644 --- a/hwe/sammo/WarUnitTrigger/che_전투치료시도.php +++ b/hwe/sammo/WarUnitTrigger/che_전투치료시도.php @@ -5,6 +5,7 @@ use sammo\WarUnitGeneral; use sammo\WarUnitCity; use sammo\WarUnit; use sammo\GameUnitDetail; +use sammo\Util; use sammo\ObjectTrigger; class che_전투치료시도 extends BaseWarUnitTrigger{ diff --git a/hwe/sammo/WarUnitTrigger/che_필살발동.php b/hwe/sammo/WarUnitTrigger/che_필살발동.php index 96708b5a..f4c20efd 100644 --- a/hwe/sammo/WarUnitTrigger/che_필살발동.php +++ b/hwe/sammo/WarUnitTrigger/che_필살발동.php @@ -7,6 +7,7 @@ use sammo\WarUnit; use sammo\GameUnitDetail; use sammo\Util; use sammo\ObjectTrigger; +use sammo\ActionLogger; class che_필살발동 extends BaseWarUnitTrigger{ protected $priority = ObjectTrigger::PRIORITY_POST + 400; diff --git a/hwe/sammo/WarUnitTrigger/che_회피발동.php b/hwe/sammo/WarUnitTrigger/che_회피발동.php index 18991cbd..29c4ea80 100644 --- a/hwe/sammo/WarUnitTrigger/che_회피발동.php +++ b/hwe/sammo/WarUnitTrigger/che_회피발동.php @@ -7,6 +7,7 @@ use sammo\WarUnit; use sammo\GameUnitDetail; use sammo\Util; use sammo\ObjectTrigger; +use sammo\ActionLogger; class che_회피발동 extends BaseWarUnitTrigger{ protected $priority = ObjectTrigger::PRIORITY_POST + 500; diff --git a/hwe/sammo/WarUnitTrigger/che_회피시도.php b/hwe/sammo/WarUnitTrigger/che_회피시도.php index 512e68a9..0ea7136c 100644 --- a/hwe/sammo/WarUnitTrigger/che_회피시도.php +++ b/hwe/sammo/WarUnitTrigger/che_회피시도.php @@ -6,6 +6,7 @@ use sammo\WarUnitCity; use sammo\WarUnit; use sammo\GameUnitDetail; use sammo\ObjectTrigger; +use sammo\Util; class che_회피시도 extends BaseWarUnitTrigger{ protected $priority = ObjectTrigger::PRIORITY_PRE + 200; diff --git a/src/sammo/TVarDumper.php b/src/sammo/TVarDumper.php new file mode 100644 index 00000000..fd903c64 --- /dev/null +++ b/src/sammo/TVarDumper.php @@ -0,0 +1,129 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2013 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @package System.Util + */ + +/** + * TVarDumper class. + * + * TVarDumper is intended to replace the buggy PHP function var_dump and print_r. + * It can correctly identify the recursively referenced objects in a complex + * object structure. It also has a recursive depth control to avoid indefinite + * recursive display of some peculiar variables. + * + * TVarDumper can be used as follows, + * + * echo TVarDumper::dump($var); + * + * + * @author Qiang Xue + * @version $Id$ + * @package System.Util + * @since 3.0 + */ +class TVarDumper +{ + private static $_objects; + private static $_output; + private static $_depth; + + /** + * Converts a variable into a string representation. + * This method achieves the similar functionality as var_dump and print_r + * but is more robust when handling complex objects such as PRADO controls. + * @param mixed variable to be dumped + * @param integer maximum depth that the dumper should go into the variable. Defaults to 10. + * @return string the string representation of the variable + */ + public static function dump($var,$depth=10,$highlight=false) + { + self::$_output=''; + self::$_objects=array(); + self::$_depth=$depth; + self::dumpInternal($var,0); + if($highlight) + { + $result=highlight_string("/','',$result,1); + } + else + return self::$_output; + } + + private static function dumpInternal($var,$level) + { + switch(gettype($var)) + { + case 'boolean': + self::$_output.=$var?'true':'false'; + break; + case 'integer': + self::$_output.="$var"; + break; + case 'double': + self::$_output.="$var"; + break; + case 'string': + self::$_output.="'$var'"; + break; + case 'resource': + self::$_output.='{resource}'; + break; + case 'NULL': + self::$_output.="null"; + break; + case 'unknown type': + self::$_output.='{unknown}'; + break; + case 'array': + if(self::$_depth<=$level) + self::$_output.='array(...)'; + else if(empty($var)) + self::$_output.='array()'; + else + { + $keys=array_keys($var); + $spaces=str_repeat(' ',$level*4); + self::$_output.="array\n".$spaces.'('; + foreach($keys as $key) + { + self::$_output.="\n".$spaces." [$key] => "; + self::$_output.=self::dumpInternal($var[$key],$level+1); + } + self::$_output.="\n".$spaces.')'; + } + break; + case 'object': + if(($id=array_search($var,self::$_objects,true))!==false) + self::$_output.=get_class($var).'#'.($id+1).'(...)'; + else if(self::$_depth<=$level) + self::$_output.=get_class($var).'(...)'; + else + { + $id=array_push(self::$_objects,$var); + $className=get_class($var); + $members=(array)$var; + $keys=array_keys($members); + $spaces=str_repeat(' ',$level*4); + self::$_output.="$className#$id\n".$spaces.'('; + foreach($keys as $key) + { + $keyDisplay=strtr(trim($key),array("\0"=>':')); + self::$_output.="\n".$spaces." [$keyDisplay] => "; + self::$_output.=self::dumpInternal($members[$key],$level+1); + } + self::$_output.="\n".$spaces.')'; + } + break; + } + } +} +