-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: init setup of liveviews for home, waiting room and game room
- Loading branch information
1 parent
c97ca64
commit 99580b7
Showing
10 changed files
with
132 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
defmodule ViralSpiral.Room.RoomGenserver do | ||
use GenServer | ||
|
||
@impl true | ||
def init(init_arg) do | ||
{:ok, root} | ||
end | ||
|
||
@impl true | ||
def handle_cast({:join, player_name}, state) do | ||
end | ||
|
||
@impl true | ||
def handle_cast({:pass, from, to}, state) do | ||
end | ||
|
||
@impl true | ||
def handle_cast({:keep, from}, state) do | ||
end | ||
|
||
@impl true | ||
def handle_cast({:discard, from}, state) do | ||
end | ||
|
||
@impl true | ||
def handle_cast({:check_source, from}, state) do | ||
end | ||
|
||
@impl true | ||
def handle_cast({:cancel, from, target}, state) do | ||
end | ||
|
||
@impl true | ||
def handle_cast({:viral_spiral, from, targets}, state) do | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
defmodule ViralSpiralWeb.GameRoom do | ||
alias ViralSpiral.Room.State.Room | ||
alias ViralSpiral.Room.State.Root | ||
use ViralSpiralWeb, :live_view | ||
|
||
def mount(params, session, socket) do | ||
room = | ||
Room.new() | ||
|> Room.start(4) | ||
|
||
root = Root.new(room, ["adhiraj", "krys", "aman", "farah"]) | ||
IO.inspect(root) | ||
IO.puts("hi") | ||
|
||
{:ok, assign(socket, :root, root)} | ||
end | ||
|
||
def handle_event("start_game", _params, socket) do | ||
{:noreply, socket} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<div class="p-4 border-red-200 border-2 rounded-2xl flex flex-row justify-between "> | ||
<span><%= @root.room.name %></span> | ||
<span><%= @root.room.id %></span> | ||
<span><%= @root.room.state %></span> | ||
<span><%= @root.room.chaos_counter %></span> | ||
</div> | ||
|
||
<div class="p-4 mt-2 border-red-200 border-2 rounded-2xl flex flex-row justify-between"> | ||
<%= for player <- Enum.map(@root.players, fn {_id, player} -> player end) do %> | ||
<div class={[ | ||
"p-2 border-2 w-full rounded-xl", | ||
if(@root.turn.current == player.id, | ||
do: "border-red-400", | ||
else: "border-red-100" | ||
) | ||
]}> | ||
<%= player.name %> | ||
</div> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
defmodule ViralSpiralWeb.Home do | ||
alias ViralSpiral.Room.State.Room | ||
use ViralSpiralWeb, :live_view | ||
|
||
def mount(params, session, socket) do | ||
{:ok, socket} | ||
end | ||
|
||
def handle_event("create_room", _params, socket) do | ||
name = Room.name() | ||
# {:noreply, push_navigate(socket, to: "/waiting-room/#{name}")} | ||
{:noreply, push_navigate(socket, to: "/room/#{name}")} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h1>Home</h1> | ||
|
||
<.button phx-click="create_room" class="ml-2">Create a new Room!</.button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
defmodule ViralSpiralWeb.WaitingRoom do | ||
@moduledoc """ | ||
A space for people to wait while other players join. | ||
We enforce that atleast 3 players are present before someone can start the game. | ||
""" | ||
use ViralSpiralWeb, :live_view | ||
|
||
def mount(params, session, socket) do | ||
{:ok, socket} | ||
end | ||
|
||
def handle_event("start_game", _params, socket) do | ||
{:noreply, socket} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>Waiting for everyone to join</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters