Implemented entering combat detection. Fixed issue with combats number. Added start and end for each combat

This commit is contained in:
Rooty 2020-08-01 06:54:12 +02:00
parent ac0a1370d4
commit da62c0094a

View File

@ -67,37 +67,11 @@
// Method to get the handle content
public function getHandle(){
// TODO Check file exists
$this->handle = fopen($this->fileName, "r");
// if($this->handle) {
// while (($line = fgets($this->handle)) !== false) {
// echo $line;
// }
// fclose($this->handle);
// } else {
// $this->handle = False;
// }
$this->handle = fopen($this->fileName, "r");
return $this->handle;
}
}
// class Event:
// regex = r'[\[<\(]([^\[<\(\]>\)]*)[\]>\)]'
// def __init__(self, x):
// data = re.findall(Event.regex, x)
// data.append('')
// self.to_string = ' '.join(data)
//
// dateandtime = datetime.strptime(list(sys.argv[1].split("_"))[1]+" "+data[0], '%Y-%m-%d %H:%M:%S.%f')
//
// self.date = dateandtime
// self.source = Entity(data[1])
// self.target = Entity(data[2])
// self.ability = Ability(data[3])
// self.effect = Effect(data[4])
// self.value = Value(data[5])
// self.threat = Threat(data[6])
class LogEvent
{
// Properties declaration
@ -133,40 +107,75 @@
public function arrayEvent($logEvent){
// [23:40:42.150] [@Comendatore] [Combat Training Target MK-10 {2816257300627456}:133000004817] [Ion Pulse {2199843594305536}] [ApplyEffect {836045448945477}: Damage {836045448945501}] (7659* elemental {836045448940875}) <19146>
// [date] [src] [target] [ability] [effect] (value) <threat>
$isMatching = preg_match_all('/[\[<\(]([^\[<\(\]>\)]*)[\]>\)]/m', $logEvent, $this->event, PREG_SET_ORDER, 0);
// $isMatching = preg_match_all('/[\[<\(]([^\[<\(\]>\)]*)[\]>\)]/m', $logEvent, $this->event, PREG_SET_ORDER, 0);
$isMatching = preg_match_all('/[\[<\(]([^\[<\]>]*)[\]>\)]/m', $logEvent, $this->event, PREG_SET_ORDER, 0);
return $this->event;
}
}
// $handle = fopen("combat_2020-06-11_18_06_42_493608.txt", "r");
$handlecontent = new loadFile;
$handlecontent->setFileName("combat_2020-07-25_22_39_58_532658.txt");
$handlecontent->setFileName("combat_2020-07-29_20_28_31_201102.txt");
$handleresult = $handlecontent->getHandle();
if($handleresult) {
$totalAmount=0;$totalThreat=0;
$totalAmount=0;$totalThreat=0;$stateCombat = False;$totalHitCrit=0;$arraySource=array();$combatRef=0;
while (($line = fgets($handleresult)) !== false) {
$log = new LogEvent;
$log = $log->arrayEvent($line);
if( array_key_exists(6, $log) );
// print_r($log);
$logDate = $log[0][1];
$logSource = $log[1][1];
$logTarget = $log[2][1];
$logAbility = $log[3][1];
$logEffect = $log[4][1];
$logValue = (isset($log[5][1]) && ($log[5][1] != 0))?$log[5][1]:null;
$logThreat = isset($log[6][1])?$log[6][1]:null;
print("Date : ".$logDate." Source : ".$logSource." Target : ".$logTarget." Ability : ".$logAbility." Effect : ".$logEffect." Amount : ".$logValue." Menace : ".$logThreat."\n");
#TODO
// Start CCombat detection
// if( $log[1][1]
// Combat detection
if( strstr($log[4][1],'EnterCombat') )
{
$stateCombat = True;
$combatRef++;
$encounter=explode(" (", $log[5][1]);
$arraySource[$combatRef]["encounter"] = $encounter[0];
$arraySource[$combatRef]["startCombatDate"] = $log[0][1];
} elseif ( strstr($log[4][1],'ExitCombat') )
{
$stateCombat = False;
$arraySource[$combatRef]["endCombatDate"] = $log[0][1];
}
$totalAmount+=$logValue;$totalThreat+=$logThreat;
if( $stateCombat )
{
$logDate = $log[0][1];
$logSource = $log[1][1];
$logTarget = $log[2][1];
$logAbility = $log[3][1];
$logEffect = $log[4][1];
$logValue = (isset($log[5][1]) && ($log[5][1] != ''))?explode(" ", $log[5][1]):0;
$logThreat = isset($log[6][1])?$log[6][1]:0;
// On traire les valeurs renvoyées dans $logValue (ex: 519* energy {836045448940874})
if( is_array($logValue) )
{
$logAmount = $logValue[0];
$logDmgType = isset($logValue[1])?$logValue[1]:0;
$logDmgId = isset($logValue[2])?$logValue[2]:0;
} else {
$logAmount = $logValue;
}
// On incrémente le nombre de coups critiques si c'est un critique
if (strstr($logAmount, '*'))
{
$hitCrit = True;
$logAmount = str_replace('*','',$logAmount);
} else {
$hitCrit = False;
}
// On construit le tableau final seulement si la source est un joueur ou un boss
$arraySource[$combatRef][$log[1][1]][$log[0][1]]["source"]["target"] = $logTarget;
$arraySource[$combatRef][$log[1][1]][$log[0][1]]["source"]["ability"] = $logAbility;
$arraySource[$combatRef][$log[1][1]][$log[0][1]]["source"]["dmgType"] = $logDmgType;
$arraySource[$combatRef][$log[1][1]][$log[0][1]]["source"]["dmgDone"] = $logAmount;
$arraySource[$combatRef][$log[1][1]][$log[0][1]]["source"]["hitCritDone"] = $hitCrit;
$arraySource[$combatRef][$log[1][1]][$log[0][1]]["source"]["threatDone"] = $logThreat;
}
}
print("Total Damages : ".$totalAmount."\n");
print("Total Menace : ".$totalThreat."\n");
print_r($arraySource);
} else {
echo "Error while loading file handle !";
}