mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-09-29 14:23:26 -05:00
Implement terrain backgrounds
This commit is contained in:
57
js/battle.js
57
js/battle.js
@@ -3059,16 +3059,7 @@ var Battle = (function () {
|
||||
if (typeof weather === 'undefined') {
|
||||
weather = this.weather;
|
||||
}
|
||||
if (weather === '' || weather === 'none' || weather === 'pseudo') {
|
||||
weather = (this.pseudoWeather.length ? 'pseudo' : '');
|
||||
}
|
||||
|
||||
var oldweather = this.weather;
|
||||
this.weather = weather;
|
||||
|
||||
if (this.fastForward) return;
|
||||
|
||||
if (instant) oldweather = true;
|
||||
var isIntense = false;
|
||||
var weatherNameTable = {
|
||||
sunnyday: 'Sun',
|
||||
desolateland: 'Intense Sun',
|
||||
@@ -3078,10 +3069,35 @@ var Battle = (function () {
|
||||
hail: 'Hail',
|
||||
deltastream: 'Strong Winds'
|
||||
};
|
||||
if (!(weather in weatherNameTable)) {
|
||||
weather = (this.pseudoWeather.length ? 'pseudo' : '');
|
||||
for (var i = 0; i < this.pseudoWeather.length; i++) {
|
||||
var pwid = toId(this.pseudoWeather[i][0]);
|
||||
switch (pwid) {
|
||||
case 'electricterrain':
|
||||
case 'grassyterrain':
|
||||
case 'mistyterrain':
|
||||
case 'psychicterrain':
|
||||
weather = pwid;
|
||||
isIntense = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (weather === 'desolateland' || weather === 'primordialsea' || weather === 'deltastream') {
|
||||
isIntense = true;
|
||||
}
|
||||
|
||||
var oldweather = this.weather;
|
||||
this.weather = weather;
|
||||
|
||||
if (this.fastForward) return;
|
||||
|
||||
if (instant) oldweather = true;
|
||||
|
||||
var weatherhtml = '';
|
||||
if (weather) {
|
||||
if (weather !== 'pseudo') {
|
||||
if (weather in weatherNameTable) {
|
||||
weatherhtml += '<br />' + weatherNameTable[weather] + this.weatherLeft();
|
||||
}
|
||||
for (var i = 0; i < this.pseudoWeather.length; i++) {
|
||||
@@ -3100,11 +3116,11 @@ var Battle = (function () {
|
||||
this.weatherElem.attr('class', 'weather');
|
||||
}
|
||||
this.weatherElem.html('<em>' + weatherhtml + '</em>');
|
||||
this.weatherElem.css({opacity: 0.5});
|
||||
this.weatherElem.css({opacity: isIntense ? 0.9 : .5});
|
||||
if (weather && !instant) this.weatherElem.animate({
|
||||
opacity: 1.0
|
||||
}, 400).animate({
|
||||
opacity: .5
|
||||
opacity: isIntense ? 0.9 : .5
|
||||
}, 400);
|
||||
return;
|
||||
}
|
||||
@@ -3116,7 +3132,7 @@ var Battle = (function () {
|
||||
}, 300, function () {
|
||||
self.weatherElem.attr('class', 'weather ' + weather + 'weather');
|
||||
self.weatherElem.html('<em>' + weatherhtml + '</em>');
|
||||
self.weatherElem.css({opacity: 0.5});
|
||||
self.weatherElem.css({opacity: isIntense ? 0.9 : 0.5});
|
||||
});
|
||||
} else {
|
||||
this.weatherElem.animate({
|
||||
@@ -3134,7 +3150,7 @@ var Battle = (function () {
|
||||
this.weatherElem.animate({
|
||||
opacity: 1.0
|
||||
}, 400).animate({
|
||||
opacity: .5
|
||||
opacity: isIntense ? 0.9 : .5
|
||||
}, 400);
|
||||
}
|
||||
};
|
||||
@@ -5740,10 +5756,13 @@ var Battle = (function () {
|
||||
}
|
||||
var maxTimeLeft = 0;
|
||||
if (effect.id in {'electricterrain': 1, 'grassyterrain': 1, 'mistyterrain': 1, 'psychicterrain': 1}) {
|
||||
this.removePseudoWeather('Electric Terrain');
|
||||
this.removePseudoWeather('Grassy Terrain');
|
||||
this.removePseudoWeather('Misty Terrain');
|
||||
this.removePseudoWeather('Psychic Terrain');
|
||||
for (var i = this.pseudoWeather.length - 1; i >= 0; i--) {
|
||||
var pwName = this.pseudoWeather[i][0];
|
||||
if (pwName === 'Electric Terrain' || pwName === 'Grassy Terrain' || pwName === 'Misty Terrain' || pwName === 'Psychic Terrain') {
|
||||
this.pseudoWeather.splice(i, 1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (this.gen > 6) maxTimeLeft = 8;
|
||||
}
|
||||
this.addPseudoWeather(effect.name, 5, maxTimeLeft);
|
||||
|
||||
@@ -417,6 +417,22 @@ License: GPLv2
|
||||
background: #AAAAAA url(../fx/weather-strongwind.png) no-repeat scroll left top;
|
||||
color: #666666;
|
||||
}
|
||||
.mistyterrainweather {
|
||||
background: #EEAACC url(../fx/weather-mistyterrain.png) no-repeat scroll left top;
|
||||
color: #551144;
|
||||
}
|
||||
.electricterrainweather {
|
||||
background: #EEEEAA url(../fx/weather-electricterrain.png) no-repeat scroll left top;
|
||||
color: #444411;
|
||||
}
|
||||
.grassyterrainweather {
|
||||
background: #CCEEAA url(../fx/weather-grassyterrain.png) no-repeat scroll left top;
|
||||
color: #335511;
|
||||
}
|
||||
.psychicterrainweather {
|
||||
background: #CCAAEE url(../fx/weather-psychicterrain.png) no-repeat scroll left top;
|
||||
color: #441155;
|
||||
}
|
||||
.pseudoweather {
|
||||
background: #DDAAEE url(../fx/weather-trickroom.png) no-repeat scroll left top;
|
||||
color: #661155;
|
||||
|
||||
Reference in New Issue
Block a user