Website Summary Files Commits Branches @commit @diff @stats
path: root / scripts / utility
diff options
context:
space:
mode:
Commit86df07a5daa6aa1545bdf17e4661af0cb80bc48b (patch)
Author
 ivaylo.zhelev <ivaylo.zhelev@solarwinds.com>
2021-01-31 16:43:06 +0200
Committer
 ivaylo.zhelev <ivaylo.zhelev@solarwinds.com>
2021-01-31 16:43:06 +0200
Filesf3bb4a842fc199b48bcdc4c9de6dbd2770d02c55 /scripts/utility
pusg-front-end-86df07a5daa6aa1545bdf17e4661af0cb80bc48b.tar
pusg-front-end-86df07a5daa6aa1545bdf17e4661af0cb80bc48b.tar.gz
pusg-front-end-86df07a5daa6aa1545bdf17e4661af0cb80bc48b.zip
Parentd95945a4c1f567fd479d68c3a6ecff02320f6d5c (diff)
Major Game Mechanics implementation
1 files changed, 41 insertions, 0 deletions
-rw-r--r--scripts/utility/shellContainer.js41
diff --git a/scripts/utility/shellContainer.js b/scripts/utility/shellContainer.js
new file mode 100644
index 0000000..9153a90
--- /dev/null
+++ b/scripts/utility/shellContainer.js
@@ -0,0 +1,41 @@
+var app = app || {};
+
+class ShellContainer {
+ constructor() {
+ this.shells = [];
+ }
+
+ add(shell) {
+ this.shells.push(shell);
+ }
+
+ remove(id) {
+ this.shells.remove(this.shells.find(shell => shell.id === id));
+ }
+
+ contains(id) {
+ return !!this.shells.find(shell => shell.id === id);
+ }
+
+ get(id) {
+ return this.shells.find(shell => shell.id === id);
+ }
+
+ each(action) {
+ this.shells.forEach(shell => action(shell));
+ }
+
+ find(predicate) {
+ return this.shells.find(predicate);
+ }
+
+ update() {
+ this.each(shell => {
+ if(shell.isDestroyed) {
+ shell.destroy();
+ }
+ });
+ this.shells = this.shells.filter(shell => !shell.isDestroyed);
+ this.each(shell => shell.update());
+ }
+}