Skip to content

Commit

Permalink
Merge branch 'release/0.5.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
ta2edchimp committed Oct 2, 2015
2 parents 50b0c05 + da6017b commit 5dd62a6
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 39 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Release 0.5.3

- c703842 Versionbump
- a9ea146 Merge branch 'feature/damage-overview' into develop
- d486d36 Display damage overview, closes #9
- a25fed2 Adding damage statistics.
- 19fd6a1 Added an index for each possible query to speed things up a bit when saving battle reports, closes #87
- 163c088 Bugfix... darn
- 747b46d Merge branch 'release/0.5.2' into develop

# Release 0.5.2

- 04f9292 Versionbump.
Expand Down
24 changes: 23 additions & 1 deletion classes/BattleParty.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ public function load($brID = 0, $toBeEdited = false) {

// Fetch team members
$team = $db->query(
"select distinct c.*, ifnull(cc.corporationName, 'Unknown') as corporationName, " .
"select distinct c.*, " .
"ifnull((select sum(brDamageDealt) from brDamageComposition where brDealingCombatantID = c.brCombatantID), 0) as damageDealt, " .
"ifnull(cc.corporationName, 'Unknown') as corporationName, " .
"ifnull(a.allianceName, '') as allianceName, t.typeName as shipTypeName, t.mass as shipTypeMass, " .
"bpg.battlePartyGroupName as shipGroup, bpg.battlePartyGroupOrderKey as shipGroupOrderKey, " .
"(select videoID from brVideos where videoPoVCombatantID = c.brCombatantID order by videoID limit 1) as assignedFootage " .
Expand Down Expand Up @@ -239,6 +241,13 @@ public function saveAdditionalData() {
foreach ($this->members as $combatant)
$combatant->saveAdditionalData();
}

public function getMembersByDamageDealt() {
$memberList = $this->members;
usort($memberList, 'BattleParty::membersByDamageSorter');

return $memberList;
}

public function toArray() {

Expand All @@ -258,5 +267,18 @@ public function toJSON() {

return json_encode($this->toArray());
}

public static function membersByDamageSorter($a, $b) {

if ($a->damageDealt == $b->damageDealt) {
if ($a->damageTaken == $b->damageTaken)
return 0;

return $a->damageTaken > $b->damageTaken ? -1 : 1;
}

return $a->damageDealt > $b->damageDealt ? -1 : 1;

}

}
5 changes: 3 additions & 2 deletions classes/Combatant.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ class Combatant {
public $priceTag = 0.0;

public $damageTaken = 0.0;
public $damageDealt = 0.0;
public $damageComposition = null;

public $assignedFootage = 0;

private $hasBeenRemoved = false;

private $requiredProps = array("characterID", "characterName", "corporationID", "corporationName", "allianceID", "allianceName", "shipTypeID");
private $availableProps = array("brCombatantID", "brHidden", "brDeleted", "brTeam", "brBattlePartyID", "brManuallyAdded", "characterID", "characterName", "corporationID", "corporationName", "allianceID", "allianceName", "shipTypeID", "shipTypeName", "shipTypeMass", "shipGroup", "shipGroupOrderKey", "shipIsPod", "brCyno", "died", "killID", "killTime", "priceTag", "assignedFootage", "damageTaken", "damageComposition");
private $availableProps = array("brCombatantID", "brHidden", "brDeleted", "brTeam", "brBattlePartyID", "brManuallyAdded", "characterID", "characterName", "corporationID", "corporationName", "allianceID", "allianceName", "shipTypeID", "shipTypeName", "shipTypeMass", "shipGroup", "shipGroupOrderKey", "shipIsPod", "brCyno", "died", "killID", "killTime", "priceTag", "assignedFootage", "damageTaken", "damageDealt", "damageComposition");

public function __construct($props, $killID = "") {

Expand Down Expand Up @@ -96,7 +97,7 @@ public function __construct($props, $killID = "") {
$this->shipTypeName = "Unknown";
if ($this->shipIsPod === null)
$this->shipIsPod = Item::isCapsule($this->shipTypeID);


if (!empty($killID)) {
$this->died = true;
Expand Down
4 changes: 2 additions & 2 deletions classes/Kill.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public static function fromImport(stdClass $kill = null) {
$attacker->damageComposition = array();

$attacker->damageComposition[] = array(
receiver => $victim,
amount => $atk->damageDone
"receiver" => $victim,
"amount" => $atk->damageDone
);
}

Expand Down
4 changes: 3 additions & 1 deletion database/brDamageComposition.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ CREATE TABLE `brDamageComposition` (
`brReceivingCombatantID` int(11) NOT NULL DEFAULT '0',
`brDealingCombatantID` int(11) NOT NULL DEFAULT '0',
`brDamageDealt` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`brDamageCompositionID`)
PRIMARY KEY (`brDamageCompositionID`),
KEY `brDamageComposition_IX_brReceivingCombatantID` (`brReceivingCombatantID`),
KEY `brDamageComposition_IX_brDealingCombatantID` (`brDealingCombatantID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

define('BR_VERSION', '0.5.2');
define('BR_VERSION', '0.5.3');

require_once('vendor/autoload.php');

Expand Down
44 changes: 44 additions & 0 deletions public/themes/default/components/brCombatant.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{% if combatant is defined %}
{% if not combatantDetailMode is defined or combatantDetailMode == 'normal' or combatantDetailMode == '' or (combatantDetailMode == 'damage' and (combatant.damageTaken > 0 or combatant.damageDealt > 0)) %}
<tr class="combatant{% if combatant.died %} danger{% endif %}{% if combatant.brHidden %} hidden-on-br{% endif %}" data-combatant-id="{{ combatant.brCombatantID }}" data-kill-id="{{ combatant.killID }}" data-character-id="{{ combatant.characterID }}">
<td>
<div class="ship-icon-container">
<img src="//image.eveonline.com/InventoryType/{{ combatant.shipTypeID }}_64.png">
{% if (combatant.shipGroup is defined and combatant.shipGroup != 'DPS') or combatant.brCyno == true %}
<div class="ship-type-icon">
{% if combatant.brCyno == true %}
<span class="glyphicon glyphicon-asterisk" title="Had a Cynosural Field Generator fitted."></span>
{% endif %}
{% if combatant.shipGroup is defined and combatant.shipGroup != 'DPS' %}
<span class="glyphicon {% if combatant.shipGroup == 'Capital' %}glyphicon-tower{% elseif combatant.shipGroup == 'Logistics' %}glyphicon-heart{% elseif combatant.shipGroup == 'Ewar' %}glyphicon-flash{% endif %}" title="{{ combatant.shipGroup }}"></span>
{% endif %}
</div>
{% endif %}
</div>
</td>
<td style="width:100%" class="hidden-xxs">
<div class="combatant-details">
{% if combatant.characterName != '' %}<strong>{{ combatant.characterName }}</strong><br>{% endif %}
{% if not combatantDetailMode is defined or combatantDetailMode == 'normal' or combatantDetailMode == '' %}
<small>{{ combatant.corporationName }}
{% if combatant.allianceID > 0 %}<br>{{ combatant.allianceName }}{% endif %}</small><br>
{% endif %}
{{ combatant.shipTypeName }}<br>
{% if not combatantDetailMode is defined or combatantDetailMode == 'normal' or combatantDetailMode == '' and combatant.priceTag > 0 %}
({{ (combatant.priceTag / 1000000)|number_format(2, '.', ',') }} million ISK)
{% else %}
&nbsp;
{% endif %}
{% if combatantDetailMode is defined and combatantDetailMode == 'damage' %}
{% if combatant.damageDealt > 0 %}<br>{{ combatant.damageDealt|number_format(0, '.', ',') }} dmg dealt{% endif %}
{% if combatant.damageTaken > 0 %}<br>{{ combatant.damageTaken|number_format(0, '.', ',') }} dmg taken{% endif %}
{% elseif BR_PAGE_SHOW == true and combatant.assignedFootage > 0 %}
<div class="combatant-info-container"><a href="#footage-panel-{{ combatant.assignedFootage }}" class="footage">
<span class="glyphicon glyphicon-facetime-video"></span></a>
</div>
{% endif %}
</div>
</td>
</tr>
{% endif %}
{% endif %}
32 changes: 1 addition & 31 deletions public/themes/default/components/teamList.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,7 @@ <h4 class="list-group-item-heading text-center">{{ currentTeamName }}</h4>
<table id="battlereport-{{ currentTeamID }}" class="table table-striped table-hover battlereport-combatants">
<tbody>
{% for combatant in currentTeam.members %}
<tr class="combatant{% if combatant.died %} danger{% endif %}{% if combatant.brHidden %} hidden-on-br{% endif %}" data-combatant-id="{{ combatant.brCombatantID }}" data-kill-id="{{ combatant.killID }}" data-character-id="{{ combatant.characterID }}">
<td>
<div class="ship-icon-container">
<img src="//image.eveonline.com/InventoryType/{{ combatant.shipTypeID }}_64.png">
{% if (combatant.shipGroup is defined and combatant.shipGroup != 'DPS') or combatant.brCyno == true %}
<div class="ship-type-icon">
{% if combatant.brCyno == true %}
<span class="glyphicon glyphicon-asterisk" title="Had a Cynosural Field Generator fitted."></span>
{% endif %}
{% if combatant.shipGroup is defined and combatant.shipGroup != 'DPS' %}
<span class="glyphicon {% if combatant.shipGroup == 'Capital' %}glyphicon-tower{% elseif combatant.shipGroup == 'Logistics' %}glyphicon-heart{% elseif combatant.shipGroup == 'Ewar' %}glyphicon-flash{% endif %}" title="{{ combatant.shipGroup }}"></span>
{% endif %}
</div>
{% endif %}
</div>
</td>
<td style="width:100%" class="hidden-xxs">
<div class="combatant-details">
{% if combatant.characterName != '' %}<strong>{{ combatant.characterName }}</strong><br>{% endif %}
<small>{{ combatant.corporationName }}
{% if combatant.allianceID > 0 %}<br>{{ combatant.allianceName }}{% endif %}</small><br>
{{ combatant.shipTypeName }}<br>
{% if combatant.priceTag > 0 %}({{ (combatant.priceTag / 1000000)|number_format(2, '.', ',') }} million ISK){% else %}&nbsp;{% endif %}
{% if BR_PAGE_SHOW == true and combatant.assignedFootage > 0 %}
<div class="combatant-info-container"><a href="#footage-panel-{{ combatant.assignedFootage }}" class="footage">
<span class="glyphicon glyphicon-facetime-video"></span></a>
</div>
{% endif %}
</div>
</td>
</tr>
{% include 'components/brCombatant.html' %}
{% endfor %}
</tbody>
{% if BR_CAN_APPEND_COMBATANTS == true %}
Expand Down
64 changes: 64 additions & 0 deletions public/themes/default/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ <h1>
<div style="float:right">
<a href="/show/{{ battleReport.battleReportID }}" class="btn btn-xs btn-primary"{% if battleReportDetail != 'overview' %} style="opacity:.5"{% endif %}><span class="glyphicon glyphicon-menu-hamburger"></span></a>
<a href="/show/{{ battleReport.battleReportID }}/timeline" class="btn btn-xs btn-primary"{% if battleReportDetail != 'timeline' %} style="opacity:.5"{% endif %}><span class="glyphicon glyphicon-time"></span></a>
<a href="/show/{{ battleReport.battleReportID }}/damage" class="btn btn-xs btn-primary"{% if battleReportDetail != 'damage' %} style="opacity:.5"{% endif %}><span class="glyphicon glyphicon-dashboard"></span></a>
{% if BR_COMMENTS_ENABLED == true %}
<a href="/show/{{ battleReport.battleReportID }}/comments" class="btn btn-xs btn-primary"{% if battleReportDetail != 'comments' %} style="opacity:.5"{% endif %}><span class="glyphicon glyphicon-comment"></span>{% if battleReport.commentCount > 0 %} <span class="badge">{{ battleReport.commentCount }}</span>{% endif %}</a>
{% endif %}
Expand Down Expand Up @@ -63,6 +64,69 @@ <h3 class="panel-title">{{ battleReportDetailTitle }}</h3>
{% endif %}
</div>
</div>
{% elseif battleReportDetail == 'damage' %}
{% set combatantDetailMode = 'damage' %}
<div class="panel-body">
{% if battleReport.teamC.members|length > 0 %}
{% set colClsName = 'col-xs-4' %}
{% else %}
{% set colClsName = 'col-xs-6' %}
{% endif %}
<div class="row">
<div class="{{ colClsName }}">
<h4 class="list-group-item-heading text-center">Team A</h4>
<p class="text-center">
<small>{{ battleReport.teamA.brDamageDealt|number_format(0, '.', ',') }} dmg dealt<br>
{{ battleReport.teamA.brDamageReceived|number_format(0, '.', ',') }} dmg taken</small></p>
</div>
<div class="{{ colClsName }}">
<h4 class="list-group-item-heading text-center">Team B</h4>
<p class="text-center">
<small>{{ battleReport.teamB.brDamageDealt|number_format(0, '.', ',') }} dmg dealt<br>
{{ battleReport.teamB.brDamageReceived|number_format(0, '.', ',') }} dmg taken</small></p>
</div>
{% if battleReport.teamC.members|length > 0 %}
<div class="{{ colClsName }}">
<h4 class="list-group-item-heading text-center">Team C</h4>
<p class="text-center">
<small>{{ battleReport.teamC.brDamageDealt|number_format(0, '.', ',') }} dmg dealt<br>
{{ battleReport.teamC.brDamageReceived|number_format(0, '.', ',') }} dmg taken</small></p>
</div>
{% endif %}
</div>
<div class="row">
<div class="{{ colClsName }}">
<table id="battlereport-{{ currentTeamID }}" class="table table-striped table-hover battlereport-combatants">
<tbody>
{% for combatant in battleReport.teamA.getMembersByDamageDealt() %}
{% include 'components/brCombatant.html' %}
{% endfor %}
</tbody>
</table>
</div>
<div class="{{ colClsName }}">
<table id="battlereport-{{ currentTeamID }}" class="table table-striped table-hover battlereport-combatants">
<tbody>
{% for combatant in battleReport.teamB.getMembersByDamageDealt() %}
{% include 'components/brCombatant.html' %}
{% endfor %}
</tbody>
</table>
</div>
{% if battleReport.teamC.members|length > 0 %}
<div class="{{ colClsName }}">
<table id="battlereport-{{ currentTeamID }}" class="table table-striped table-hover battlereport-combatants">
<tbody>
{% for combatant in battleReport.teamC.getMembersByDamageDealt() %}
{% include 'components/brCombatant.html' %}
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
</div>
{% set combatantDetailMode = '' %}
{% elseif battleReportDetail == 'timeline' %}
<div class="panel-body">
<div class="row">
Expand Down
2 changes: 1 addition & 1 deletion views/show.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

$battleReportDetailTitle = "Battle Overview";

$availableDetails = array("timeline");
$availableDetails = array("timeline", "damage");
if (BR_COMMENTS_ENABLED === true)
$availableDetails[] = "comments";
if (!empty($battleReportDetail)) {
Expand Down

0 comments on commit 5dd62a6

Please sign in to comment.