From 0baa66c4923686c133df7d89d98a120dc8039cc6 Mon Sep 17 00:00:00 2001 From: Josh Lory Date: Wed, 30 May 2018 12:17:50 -0700 Subject: [PATCH] Remove collected honeycomb / flower icons from Bee --- src/bee.js | 6 ---- src/beeItemDrawer.js | 74 +------------------------------------------- 2 files changed, 1 insertion(+), 79 deletions(-) diff --git a/src/bee.js b/src/bee.js index 307528b..fa2f79b 100644 --- a/src/bee.js +++ b/src/bee.js @@ -81,10 +81,6 @@ module.exports = class Bee extends Gatherer { }; } } - if (this.drawer) { - this.drawer.updateNectarCounter(this.nectars_); - this.drawer.updateHoneyCounter(this.honey_); - } super.reset(); } @@ -373,7 +369,6 @@ module.exports = class Bee extends Gatherer { this.gotNectarAt(row, col); this.drawer.updateItemImage(row, col, true); - this.drawer.updateNectarCounter(this.nectars_); } /** @@ -398,7 +393,6 @@ module.exports = class Bee extends Gatherer { this.madeHoneyAt(row, col); this.drawer.updateItemImage(row, col, true); - this.drawer.updateHoneyCounter(this.honey_); } /** diff --git a/src/beeItemDrawer.js b/src/beeItemDrawer.js index 376bab1..53784da 100644 --- a/src/beeItemDrawer.js +++ b/src/beeItemDrawer.js @@ -4,7 +4,7 @@ const SVG_NS = Drawer.SVG_NS; /** * Extends Drawer to draw flowers/honeycomb for bee. - * @param {MaseMap} map + * @param {MazeMap} map * @param {Object} skin The app's skin, used to get URLs for our images * @param {Bee} bee The maze's Bee object. */ @@ -14,10 +14,6 @@ module.exports = class BeeItemDrawer extends Drawer { this.skin_ = skin; this.bee_ = bee; - this.honeyImages_ = []; - this.nectarImages_ = []; - this.pegman_ = null; - // is item currently covered by a cloud? this.clouded_ = undefined; this.resetClouded(); @@ -102,79 +98,11 @@ module.exports = class BeeItemDrawer extends Drawer { } } - createCounterImage_(prefix, i, row, href) { - var id = prefix + (i + 1); - var image = document.createElementNS(SVG_NS, 'image'); - image.setAttribute('id', id); - image.setAttribute('width', SQUARE_SIZE); - image.setAttribute('height', SQUARE_SIZE); - image.setAttribute('y', row * SQUARE_SIZE); - - image.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', href); - - this.svg_.insertBefore(image, this.getPegmanElement_()); - - return image; - } - flowerImageHref_(row, col) { return this.bee_.isRedFlower(row, col) ? this.skin_.redFlower : this.skin_.purpleFlower; } - updateHoneyCounter(honeyCount) { - for (var i = 0; i < honeyCount; i++) { - if (!this.honeyImages_[i]) { - this.honeyImages_[i] = this.createCounterImage_('honey', i, 1, - this.skin_.honey); - } - - var deltaX = SQUARE_SIZE; - if (honeyCount > 8) { - deltaX = (8 - 1) * SQUARE_SIZE / (honeyCount - 1); - } - this.honeyImages_[i].setAttribute('x', i * deltaX); - } - - for (i = 0; i < this.honeyImages_.length; i++) { - this.honeyImages_[i].setAttribute('display', i < honeyCount ? 'block' : 'none'); - } - } - - updateNectarCounter(nectars) { - var nectarCount = nectars.length; - // create any needed images - for (var i = 0; i < nectarCount; i++) { - var href = this.flowerImageHref_(nectars[i].row, nectars[i].col); - - if (!this.nectarImages_[i]) { - this.nectarImages_[i] = this.createCounterImage_('nectar', i, 0, href); - } - - var deltaX = SQUARE_SIZE; - if (nectarCount > 8) { - deltaX = (8 - 1) * SQUARE_SIZE / (nectarCount - 1); - } - this.nectarImages_[i].setAttribute('x', i * deltaX); - this.nectarImages_[i].setAttributeNS('http://www.w3.org/1999/xlink', - 'xlink:href', href); - } - - for (i = 0; i < this.nectarImages_.length; i++) { - this.nectarImages_[i].setAttribute('display', i < nectarCount ? 'block' : 'none'); - } - } - - /** - * Cache pegman element - */ - getPegmanElement_() { - if (!this.pegman_) { - this.pegman_ = document.getElementsByClassName('pegman-location')[0]; - } - return this.pegman_; - } - /** * Show the cloud icon. */