still frontend development

This commit is contained in:
Jonas Weinz 2019-03-07 13:07:51 +01:00
parent 7dd0857083
commit b327faba6c
4 changed files with 22 additions and 2 deletions

View File

@ -1,9 +1,11 @@
class GameManager
{
constructor(grid)
constructor(grid, n)
{
this.grid = grid;
this.n = n;
this.dummy_player = new Player("test_player", "rgb(0,128,0)");
this.grid.player_change_listener(this.dummy_player);
@ -14,6 +16,16 @@ class GameManager
// -- remote //TODO
this.game_mode = "none";
this.grid.register_click_callback((i,j,k,l) => this.click_listener(i,j,k,l));
}
click_listener(sub_x, sub_y, x,y)
{
// TODO: dummy
console.log("click");
}
register_game_mode_change_listener(func)
@ -32,10 +44,12 @@ class GameManager
{
this.set_game_mode("local");
this.grid.unblock_all();
this.grid.deactivate_all();
}
end_game()
{
this.set_game_mode("none");
this.grid.unblock_all();
}
}

View File

@ -41,7 +41,10 @@ class Sidebar
this.create_game_container.style.display = "none";
// control area:
this.control_container.appendChild(this.create_button("confirm move"));
this.b_end_game = this.create_button("end game");
this.control_container.appendChild(this.b_end_game);
this.control_container.style.display = "none";
@ -63,6 +66,7 @@ class Sidebar
this.game_manager.register_game_mode_change_listener((c) => this.game_mode_change_listener(c));
this.b_local.addEventListener("click", () => this.game_manager.start_local_game());
this.b_end_game.addEventListener("click", () => this.game_manager.end_game());
}
set_status(text)

View File

@ -43,6 +43,7 @@ class Subgrid
row.push(new Tile(b_x, b_y, b_w, b_h, button, this.ground_color, div_button));
// TODO: register listener?
row[x].register_click_callback((i,j) => this.click_listener(i,j));
row[x].register_unlock_request_callback((i,j) => this.unlock_request_listener(i,j));
}
this.cells.push(row);

View File

@ -76,6 +76,7 @@ class Tile
deactivate()
{
this.is_activated = false;
this.elem.style.background = this.ground_color;
this.elem.style.opacity = 0.3;
this.elem.style.border = "none";
}