Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Steccah committed Jun 23, 2024
1 parent 578dcc1 commit 11447f9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 31 deletions.
16 changes: 16 additions & 0 deletions center.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.center {
display: flex;
justify-content: center;
}

.space div {
margin: 0 1em;
}

#game table.table td {
padding: 0.5em;
width: 3em;
height: 3em;
text-align: center;
vertical-align: middle;
}
5 changes: 3 additions & 2 deletions game.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Board {
getColSum(col) {
let sum = 0;
for (let row = 0; row < this.dimension; row++) {
if (this.getCell(row, col).isEnabled() || this.getCell(row, col).isNormal()) {
if (!this.getCell(row, col).isDisabled()) {
sum += this.getCell(row, col).value;
}
}
Expand All @@ -56,7 +56,7 @@ class Board {
getRowSum(row) {
let sum = 0;
for (let col = 0; col < this.dimension; col++) {
if (this.getCell(row, col).isEnabled() || this.getCell(row, col).isNormal()) {
if (!this.getCell(row, col).isDisabled()) {
sum += this.getCell(row, col).value;
}
}
Expand Down Expand Up @@ -98,6 +98,7 @@ class Game {
constructor(dimension) {
this.board = new Board(dimension);
this.table = this.tableGenerator(dimension);
document.getElementById('game').innerHTML = '';
document.getElementById('game').appendChild(this.table);
console.log(this.board);
}
Expand Down
44 changes: 15 additions & 29 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sumplete</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.0/css/bulma.min.css">
<link rel="stylesheet" href="center.css">
<script src="game.js"></script>
<script>
let game;
Expand All @@ -13,39 +15,23 @@
game.start();
}
</script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.0/css/bulma.min.css">
</head>

<body>
<div id="game" class="section is-unselectable" onclick="game.check()">
<!-- <table class="table is-bordered">
<tr>
<td id="cell-0-0" onclick="game.toggleCell(0, 0)"></td>
<td id="cell-0-1" onclick="game.toggleCell(0, 1)"></td>
<td id="cell-0-2" onclick="game.toggleCell(0, 2)"></td>
<td id="sum-row-0" class="is-info"></td>
</tr>
<tr>
<td id="cell-1-0" onclick="game.toggleCell(1, 0)"></td>
<td id="cell-1-1" onclick="game.toggleCell(1, 1)"></td>
<td id="cell-1-2" onclick="game.toggleCell(1, 2)"></td>
<td id="sum-row-1" class="is-info"></td>
</tr>
<tr>
<td id="cell-2-0" onclick="game.toggleCell(2, 0)"></td>
<td id="cell-2-1" onclick="game.toggleCell(2, 1)"></td>
<td id="cell-2-2" onclick="game.toggleCell(2, 2)"></td>
<td id="sum-row-2" class="is-info"></td>
</tr>
<tr>
<td id="sum-col-0" class="is-info"></td>
<td id="sum-col-1" class="is-info"></td>
<td id="sum-col-2" class="is-info"></td>
<td id="null"></td>
</tr>
</table> -->
<div class="section">
<div id="game" class="container is-unselectable" onclick="game.check()">
</div>
<hr>
<div class="container">
<input style="width: 30%;" class="input" id="size" type="number" max="7">
<button class="button is-primary" onclick='
let size = document.getElementById("size").value;
game = new Game(size);
game.start();
'>change</button>
</div>
</div>
</div>
<div id="result"></div>
</body>

</html>

0 comments on commit 11447f9

Please sign in to comment.