Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</head>

<body>

<!-- <ul class="ul"></ul> -->

<div id="wrapper"></div>

<script src="utils/numbers.js"></script>
Expand Down
55 changes: 54 additions & 1 deletion models/battleground.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
// var BattleGround = (function() {
// function BattleGround(element, size, amountOfMonsters) {
// this.wrapperElement = null;
// this.cellsElement = null;
// this.controllsElement = null;
// this.element = element;
// this.size = size;
// this.amountOfMonsters = amountOfMonsters || size / 2;
// this.area = new Array(size).fill(1).map(function() {
// return new Grass();
// });
// this.render();
// this.update();
// }

// BattleGround.prototype.fill = function(monstersArr) {
// var self = this;
// Array(this.amountOfMonsters)
// .fill(1)
// .forEach(function() {
// self.area[random(1, self.area.length)] = new monstersArr[
// random(0, monstersArr.length)
// ](random(1, 3));
// });

// this.update();
// };

// BattleGround.prototype.render = function() {
// var ul = document.querySelector('.ul');

// this.area.forEach(function(el) {
// ul.append
// })
// for (var i = 1; i < this.size; i++) {
// var li = document.createElement('li')
// li.innerHTML
// ul.append(li)
// }
// };

// BattleGround.prototype.addCharacter = function(character) {
// this.area[0] = character;
// };

// return BattleGround;
// })();






var BattleGround = (function() {
function BattleGround(element, size, amountOfMonsters) {
this.wrapperElement = null;
Expand Down Expand Up @@ -90,4 +143,4 @@ var BattleGround = (function() {
};

return BattleGround;
})();
})();
10 changes: 6 additions & 4 deletions models/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ var Unit = (function() {
this.maxHealth = this.health = health + modifier;
this.level = level;
}

Unit.prototype.attack = function() {
console.log('Attack', this);
};
console.log('Attack', this)
}



Unit.prototype.render = function() {
return this.el;
};
}

return Unit;
})();
28 changes: 27 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/* .ul {
padding: 0;
display: flex;
align-items: center;
justify-content: center;
}

.ul li {
display: flex;
list-style-type: none;
width: 70px;
height: 30px;
margin: 5px;
align-self: baseline;
border: 1px solid #8B0000;
padding: 5px;
}

.ul li:hover {
cursor: pointer;
transform: scale(1.2);
box-shadow: inset 0 0 0 1px #B22222;
} */



html,
body,
#wrapper {
Expand Down Expand Up @@ -39,4 +65,4 @@ body,
display: flex;
width: 100%;
height: 100%;
}
}
30 changes: 15 additions & 15 deletions utils/dom.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
function consoleNodesRecursive(root) {
console.dir(root);
root.childNodes.forEach(function(child) {
if (child.childNodes && child.childNodes.length) {
console.group("ELEMENT " + child.tagName);
consoleNodesRecursive(child);
console.groupEnd();
} else {
var value =
child.nodeType !== Node.TEXT_NODE && child.tagName !== "SCRIPT"
? child.nodeValue.trim() || ""
: "";
console.log(child.nodeName, value);
}
});
}
console.dir(root);
root.childNodes.forEach(function(child) {
if (child.childNodes && child.childNodes.length) {
console.group("ELEMENT " + child.tagName);
consoleNodesRecursive(child);
console.groupEnd();
} else {
var value =
child.nodeType !== Node.TEXT_NODE && child.tagName !== "SCRIPT"
? child.nodeValue.trim() || ""
: "";
console.log(child.nodeName, value);
}
});
}