Update battle log when ignoring something (#784)

This commit is contained in:
QuiteQuiet
2016-11-02 21:06:10 +01:00
committed by Guangcong Luo
parent bdff3a3eb2
commit 0159762959
3 changed files with 48 additions and 5 deletions

View File

@@ -524,18 +524,21 @@ var Pokemon = (function () {
this.baseAbility = ability;
}
};
Pokemon.prototype.htmlName = function () {
return '<span class="battle-nickname' + (this.side.n === 0 ? '' : '-foe') + '" title="' + this.species + '">' + Tools.escapeHTML(this.name) + '</span>';
};
Pokemon.prototype.getName = function (shortName) {
if (this.side.n === 0) {
return Tools.escapeHTML(this.name);
return this.htmlName();
} else {
return (shortName ? "Opposing " : "The opposing ") + (this.side.battle.ignoreOpponent || this.side.battle.ignoreNicks ? this.species : Tools.escapeHTML(this.name));
return (shortName ? "Opposing " : "The opposing ") + this.htmlName();
}
};
Pokemon.prototype.getLowerName = function (shortName) {
if (this.side.n === 0) {
return Tools.escapeHTML(this.name);
return this.htmlName();
} else {
return (shortName ? "opposing " : "the opposing ") + (this.side.battle.ignoreOpponent || this.side.battle.ignoreNicks ? this.species : Tools.escapeHTML(this.name));
return (shortName ? "opposing " : "the opposing ") + this.htmlName();
}
};
Pokemon.prototype.getTitle = function () {
@@ -553,7 +556,7 @@ var Pokemon = (function () {
if (plaintext) {
name += ' (' + this.species + ')';
} else {
name += ' <small>(' + this.species + ')</small>';
name = '<span class="battle-nickname' + (this.side && this.side.n === 0 ? '' : '-foe') + '" title="' + this.species + '">' + name + ' <small>(' + this.species + ')</small>' + '</span>';
}
}
if (plaintext) {
@@ -2474,6 +2477,11 @@ var Battle = (function () {
if (this.mySide) this.mySide.reset();
if (this.yourSide) this.yourSide.reset();
if (this.ignoreNicks) {
var $log = $('.battle-log .inner');
if ($log.length) $log.addClass('hidenicks');
}
// activity queue state
this.animationDelay = 0;
this.multiHitMove = null;

View File

@@ -1120,6 +1120,13 @@
toggleIgnoreSpects: function (e) {
this.battle.ignoreSpects = !!e.currentTarget.checked;
this.battle.add('Spectators ' + (this.battle.ignoreSpects ? '' : 'no longer ') + 'ignored.');
var $messages = $('.battle-log').find('.chat').not('small:contains(\u2605)');
if (!$messages.length) return;
if (this.battle.ignoreSpects) {
$messages.hide();
} else {
$messages.show();
}
},
toggleIgnoreNicks: function (e) {
this.battle.ignoreNicks = !!e.currentTarget.checked;
@@ -1127,13 +1134,32 @@
this.battle.add('Nicknames ' + (this.battle.ignoreNicks ? '' : 'no longer ') + 'ignored.');
this.toggleNicknames(this.battle.mySide);
this.toggleNicknames(this.battle.yourSide);
var $log = $('.battle-log .inner');
if (!$log.length) return;
if (this.battle.ignoreNicks) {
$log.addClass('hidenicks');
} else {
$log.removeClass('hidenicks');
}
},
toggleIgnoreOpponent: function (e) {
this.battle.ignoreOpponent = !!e.currentTarget.checked;
this.battle.add('Opponent ' + (this.battle.ignoreOpponent ? '' : 'no longer ') + 'ignored.');
var $log = $('.battle-log .inner');
var $messages = $log.find('.chatmessage-' + this.battle.yourSide.id);
if (!$messages.length) return;
if (this.battle.ignoreOpponent) {
$messages.hide();
$log.addClass('hidenicks');
} else {
$messages.show();
$log.removeClass('hidenicks');
}
},
toggleNicknames: function (side) {
for (var i = 0; i < side.active.length; i++) {
if (!side.active[i]) continue;
side.active[i].statbarElem.html(side.getStatbarHTML(side.active[i], true));
side.updateStatbar(side.active[i], true, true);
}

View File

@@ -906,3 +906,12 @@ button.subtle {
button.subtle:hover {
text-decoration: underline;
}
.hidenicks span.battle-nickname,
.hidenicks span.battle-nickname-foe {
font-size: 0;
}
.hidenicks span.battle-nickname::before,
.hidenicks span.battle-nickname-foe::before{
content: attr(title);
font-size: 9pt;
}