Skip to content

Commit

Permalink
Few fixes and changes
Browse files Browse the repository at this point in the history
  • Loading branch information
GodMod committed Feb 28, 2020
1 parent 7f5423a commit b97705b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
1 change: 0 additions & 1 deletion admin/import.php
Expand Up @@ -98,7 +98,6 @@ public function display($messages=array(), $blnImportFinished=false) {
$this->tpl->assign_vars(array(
'EVENTS' => (new hdropdown('event', array('options' => $events)))->output(),
'ITEMPOOLS' => (new hdropdown('itempool', array('options' => $itempools)))->output(),
'S_LAYOUT_WARNING' => ($this->pdh->get_eqdkp_base_layout($this->config->get('eqdkp_layout')) != 'monolith') ? true : false,
));

$this->core->set_vars(array(
Expand Down
35 changes: 26 additions & 9 deletions includes/monolith_parser.class.php
Expand Up @@ -30,6 +30,10 @@ public function __construct() {
}

public function parse($strDKPTable, $strLootHistory, $strDKPHistory, $intEventID, $intItempoolID){
if($this->config->get('dkp_easymode')){
$intItempoolID = $this->pdh->get('event', 'def_itempool', array($intEventID));
}

if ($objLog = simplexml_load_string($strDKPTable)){
//Build itemList
$blnRaidItemList = false;
Expand Down Expand Up @@ -80,21 +84,25 @@ public function parse($strDKPTable, $strLootHistory, $strDKPHistory, $intEventID
//Adjustments
$intLastDKPImport = $this->config->get('last_dkpimport', 'monolithimport');
if(!$intLastDKPImport) $intLastDKPImport = 0;

$intNewLastDKPImport = $intLastDKPImport;

$objDKPHistory = simplexml_load_string($strDKPHistory);
foreach($objDKPHistory->historyentry as $objAdj){
$strPlayers = (string)$objAdj->playerstring;
$arrPlayers = explode(',', $strPlayers);

$strValues = (string)$objAdj->dkp;
$arrValues = explode(',', $strValues);

$fltValue = (float)$objAdj->dkp;
$time = (int)$objAdj->timestamp;
$strReason = (string)$objAdj->reason;

if($time > $intNewLastDKPImport) $intNewLastDKPImport = $time;
if($time <= $intLastDKPImport) continue;

foreach($arrPlayers as $strPlayer){
foreach($arrPlayers as $k => $strPlayer){
if(!strlen($strPlayer)) continue;

list($membername, $servername) = explode('-', $strPlayer);
Expand All @@ -109,15 +117,22 @@ function($m) { return $m[1].' '.$m[2]; },
$strServername = (isset($servername) && strlen($servername)) ? trim($servername) : $this->config->get('servername');

$strFullMembername = $strMembername.'-'.unsanitize($strServername);
$strValue = (count($arrValues)>1) ? $arrValues[$k] : $fltValue;

if(strpos($strValue, '%') !== false){
continue;
}

$value = (float)$strValue;

//create adjustment
$arrAdjustment[$fltValue][] = array(
'value' => $fltValue,
$arrAdjustment[$value.'__'.$strReason][] = array(
'value' => $value,
'member_name'=> $strFullMembername,
'reason'=> $strReason,
);
if(!isset($arrAdjMemberList[$strFullMembername])) $arrAdjMemberList[$strFullMembername] = 0;
$arrAdjMemberList[$strFullMembername] += $fltValue;
$arrAdjMemberList[$strFullMembername] += $value;
}

}
Expand Down Expand Up @@ -171,15 +186,16 @@ function($m) { return $m[1].' '.$m[2]; },

if ($floatAdjustement != 0){
//create adjustment
$arrAdjustment[$floatAdjustement][] = array(
$strReason = 'MonolithDKP Import '.$strCurrentTime;
$arrAdjustment[$floatAdjustement.'__'.$strReason][] = array(
'value' => $floatAdjustement,
'member'=> $intMemberID,
'reason'=> 'MonolithDKP Import '.$strCurrentTime,
'reason'=> $strReason,
);
}

$arrMember[] = $intMemberID;
}
}

//Create raid with value 0
$raid_upd = $this->pdh->put('raid', 'add_raid', array($intTime, $arrMember, $intEventID, 'MonolithDKP Import '.$strCurrentTime, 0));
Expand All @@ -188,9 +204,10 @@ function($m) { return $m[1].' '.$m[2]; },
//Add Adjustments

foreach ($arrAdjustment as $val => $a){
if($val == 0) continue;
$arrMembers = array();
foreach($a as $adj){
if($adj['value'] == 0) continue;

if(!isset($adj['member'])){
$arrMembername = explode("-", $adj['member_name']);
$strBuyerName = trim($arrMembername[0]);
Expand All @@ -203,7 +220,7 @@ function($m) { return $m[1].' '.$m[2]; },
$arrMembers[] = $adj['member'];
}
}

$adj_upd[] = $this->pdh->put('adjustment', 'add_adjustment', array($adj['value'], $adj['reason'], $arrMembers, $intEventID, $raid_upd, $intTime));
}

Expand Down
2 changes: 1 addition & 1 deletion monolithimport_plugin_class.php
Expand Up @@ -26,7 +26,7 @@
class monolithimport extends plugin_generic {

public $vstatus = 'Stable';
public $version = '1.0.0';
public $version = '1.0.1';

protected static $apiLevel = 23;

Expand Down

0 comments on commit b97705b

Please sign in to comment.