Add option to ignore opponents

Ignores chat messages from an opponent and causes their Pokemon to display
species instead of nicknames
This commit is contained in:
sirDonovan
2015-05-05 18:18:34 -05:00
parent bac6343d8a
commit 6a8ea3fb9b
2 changed files with 13 additions and 7 deletions

View File

@@ -520,14 +520,14 @@ var Pokemon = (function () {
if (this.side.n === 0) {
return Tools.escapeHTML(this.name);
} else {
return "The opposing " + Tools.escapeHTML(this.name);
return "The opposing " + (this.side.battle.ignoreOpponent ? this.species : Tools.escapeHTML(this.name));
}
};
Pokemon.prototype.getLowerName = function () {
if (this.side.n === 0) {
return Tools.escapeHTML(this.name);
} else {
return "the opposing " + Tools.escapeHTML(this.name);
return "the opposing " + (this.side.battle.ignoreOpponent ? this.species : Tools.escapeHTML(this.name));
}
};
Pokemon.prototype.getTitle = function () {
@@ -540,8 +540,8 @@ var Pokemon = (function () {
return titlestring;
};
Pokemon.prototype.getFullName = function (plaintext) {
var name = Tools.escapeHTML(this.name);
if (this.name !== this.species) {
var name = this.side.n && this.side.battle.ignoreOpponent ? this.species : Tools.escapeHTML(this.name);
if (name !== this.species) {
if (plaintext) {
name += ' (' + this.species + ')';
} else {
@@ -1550,7 +1550,7 @@ var Side = (function () {
var gender = '';
if (pokemon.gender === 'F') gender = ' <small style="color:#C57575">&#9792;</small>';
if (pokemon.gender === 'M') gender = ' <small style="color:#7575C0">&#9794;</small>';
return '<div class="statbar' + (this.n ? ' lstatbar' : ' rstatbar') + '"><strong>' + Tools.escapeHTML(pokemon.name) + gender + (pokemon.level === 100 ? '' : ' <small>L' + pokemon.level + '</small>') + '</strong><div class="hpbar"><div class="hptext"></div><div class="hptextborder"></div><div class="prevhp"><div class="hp"></div></div><div class="status"></div></div>';
return '<div class="statbar' + (this.n ? ' lstatbar' : ' rstatbar') + '"><strong>' + (this.n && this.battle.ignoreOpponent ? pokemon.species : Tools.escapeHTML(pokemon.name)) + gender + (pokemon.level === 100 ? '' : ' <small>L' + pokemon.level + '</small>') + '</strong><div class="hpbar"><div class="hptext"></div><div class="hptextborder"></div><div class="prevhp"><div class="hp"></div></div><div class="status"></div></div>';
};
Side.prototype.switchIn = function (pokemon, slot) {
if (slot === undefined) slot = pokemon.slot;
@@ -5331,6 +5331,7 @@ var Battle = (function () {
case 'c':
name = args[1];
if (this.ignoreSpects && (name.charAt(0) === ' ' || name.charAt(0) === '+')) break;
if (this.ignoreOpponent && name.charAt(0) === '\u2605' && toUserid(name) !== app.user.get('userid')) break;
if (window.app && app.ignore && app.ignore[toUserid(name)]) break;
args.shift();
args.shift();

View File

@@ -22,7 +22,7 @@
this.$chat = this.$chatFrame.find('.inner');
this.$options = this.battle.optionsElem.html('<div style="padding-top: 3px; text-align: right"><label style="font-size: 8pt; padding: 3px 5px"><input type="checkbox" name="ignorespects" /> Ignore Spectators</label></div>');
this.$options = this.battle.optionsElem.html('<div style="padding-top: 3px; text-align: right"><label style="font-size: 8pt; padding: 3px 5px"><input type="checkbox" name="ignorespects" /> Ignore Spectators</label> <label style="font-size: 8pt; padding: 3px 5px"><input type="checkbox" name="ignoreopp" /> Ignore Opponent</label></div>');
this.battle.customCallback = _.bind(this.updateControls, this);
this.battle.endCallback = _.bind(this.updateControls, this);
@@ -32,7 +32,8 @@
this.battle.play();
},
events: {
'change input[name=ignorespects]': 'toggleIgnoreSpects'
'change input[name=ignorespects]': 'toggleIgnoreSpects',
'change input[name=ignoreopp]': 'toggleIgnoreOpponent'
},
battleEnded: false,
join: function() {
@@ -691,6 +692,10 @@
toggleIgnoreSpects: function(e) {
this.battle.ignoreSpects = !!e.currentTarget.checked;
},
toggleIgnoreOpponent: function(e) {
this.battle.ignoreOpponent = !!e.currentTarget.checked;
this.battle.add('Opponent ' + (this.battle.ignoreOpponent ? '' : 'no longer ') + 'ignored.');
},
forfeit: function() {
this.send('/forfeit');
},