2020-07-29 15:31:44 +02:00
#!/usr/bin/php
< ? php
$listEncounters = array (
## The Dread Fortress
'Nefra, Who Bars the Way {3266533082005504}' , 'Gate Commander Draxus {3273924720721920}' , 'Grob\'thok, Who Feeds the Forge {3273929015689216}' , 'Corruptor Zero {3273933310656512}' , 'Dread Master Brontes {3273937605623808}' ,
## Eternity Vault
'Soa {2289823159156736}' ,
## Assation
'The Writhing Horror {2938874321960960}' , 'Heirad {2938002443599872}' , 'Ciphas {2938011033534464}' , 'Kel\'sara {2938006738567168}' , 'Operator IX {2942606648541184}' , 'Kephess the Undying {2937620191510528}' , 'The Terror From Beyond {2978340776443904}' ,
##
'The Eyeless {3328380611067904}' ,
## Toborro
'Golden Fury {3232800408862720}' , 'Golden Fury {3232817588731904}' ,
## The False Emperor
'Tregg the Destroyer {1690314444111872}' , 'Jindo Krey {770959514533888}' , 'HK-47 {770955219566592}' , 'Chondrus Berani {1690331623981056}' , 'Sith Entity {1695962326106112}' , 'Forsaken Sith Lord {781830076760064}' , 'Darth Malgus {770963809501184}' ,
## Battle of Rishi
'Marko Ka {3533564083699712}' , 'Rarrook {3533559788732416}' , 'Lord Vodd {3533585558536192}' , 'Shield Squadron Unit 1 {3533594148470784}' , 'Darth Yun {4257506591244288}' ,
## Objective Meridian
'Commander Aster {4258021987319808}' , 'Darth Malgus {4257502296276992}' ,
## Heart of Ruin
'Colossal Monolith {3541140406009856}' ,
##
'Toxxun {3340011382505472}' ,
## Mutated Geonosian Queen
'Mutated Geonosian Queen {4197299739688960}'
);
$dmgTypes = array ( 'energy' , 'elemental' , 'kinetic' , 'internal' );
$instTypes = array ( 'Story' , 'Veteran' , 'Master' );
$zoneNames = array (
# Planet zones
'Corellia' , 'Coruscant' , 'CZ-198' , 'Rishi' , 'Taris' , 'Tatooine' , 'Voss' , 'Yavin 4' , 'Ziost' ,
# Instances zones
'Lair of the Eyeless' , 'Toborro\'s Palace Courtyard' , 'The False Emperor' , 'Battle of Rishi' , 'Objective Meridian' , 'Hive of the Mountain Queen'
);
class loadFile
{
// Declare properties
public $filename = " " ;
public $handle = null ;
// Constructor
public function __construct (){
// echo 'The class "' . __CLASS__ . '" was initiated!<br>';
$this -> fileName = " " ;
$this -> handle = null ;
}
// Destructor
public function __destruct (){
// echo 'The class "' . __CLASS__ . '" was destroyed.<br>';
}
// Method to get the filename
public function getFileName (){
return $this -> fileName ;
}
// Method to set the filename
public function setFileName ( $filename ){
$this -> fileName = $filename ;
}
// Method to get the handle content
public function getHandle (){
// TODO Check file exists
2020-08-01 06:54:12 +02:00
$this -> handle = fopen ( $this -> fileName , " r " );
2020-07-29 15:31:44 +02:00
return $this -> handle ;
}
}
class LogEvent
{
// Properties declaration
public $event = " " ;
// public $date = "";
// public $source = "";
// public $target = "";
// public $ability = "";
// public $effect = "";
// public $value = 0;
// public $threat = 0;
// Constructor
public function __construct ()
{
// echo 'The class "' . __CLASS__ . '" was initiated!<br>';
$this -> event = " " ;
// $this->date = $date;
// $this->source = $source;
// $this->target = $target;
// $this->ability = $ability;
// $this->effect = $effect;
// $this->value = $value;
// $this->threat = $threat;
}
// Destructor
public function __destruct (){
// echo 'The class "' . __CLASS__ . '" was destroyed.<br>';
}
// Method to set the event
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>
2020-08-01 06:54:12 +02:00
// $isMatching = preg_match_all('/[\[<\(]([^\[<\(\]>\)]*)[\]>\)]/m', $logEvent, $this->event, PREG_SET_ORDER, 0);
$isMatching = preg_match_all ( '/[\[<\(]([^\[<\]>]*)[\]>\)]/m' , $logEvent , $this -> event , PREG_SET_ORDER , 0 );
2020-07-29 15:31:44 +02:00
return $this -> event ;
}
}
$handlecontent = new loadFile ;
2020-08-01 06:54:12 +02:00
$handlecontent -> setFileName ( " combat_2020-07-29_20_28_31_201102.txt " );
2020-07-29 15:31:44 +02:00
$handleresult = $handlecontent -> getHandle ();
if ( $handleresult ) {
2020-08-01 06:54:12 +02:00
$totalAmount = 0 ; $totalThreat = 0 ; $stateCombat = False ; $totalHitCrit = 0 ; $arraySource = array (); $combatRef = 0 ;
2020-07-29 15:31:44 +02:00
while (( $line = fgets ( $handleresult )) !== false ) {
$log = new LogEvent ;
$log = $log -> arrayEvent ( $line );
2020-08-01 06:54:12 +02:00
// 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 ];
}
2020-07-29 15:31:44 +02:00
2020-08-01 06:54:12 +02:00
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 ;
}
2020-07-29 15:31:44 +02:00
}
2020-08-01 06:54:12 +02:00
print_r ( $arraySource );
2020-07-29 15:31:44 +02:00
} else {
echo " Error while loading file handle ! " ;
}
?>