Skip to content

Commit

Permalink
feat: wip turn to fake
Browse files Browse the repository at this point in the history
  • Loading branch information
dennyabrain committed Dec 8, 2024
1 parent 34ac373 commit 6fc590d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/viral_spiral/game.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ defmodule ViralSpiral.Game do
|> draw_card()
|> view_source()
|> hide_source()
|> mark_as_fake()
|> pass_card(card, from, to)
|> turn_to_fake(card)
|> pass_card(card, from, to)
Expand Down
10 changes: 10 additions & 0 deletions lib/viral_spiral/room/actions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,14 @@ defmodule ViralSpiral.Room.Actions do
}
}
end

def turn_card_to_fake(player_id, card_id) do
%Action{
type: :turn_card_to_fake,
payload: %{
player_id: player_id,
card_id: card_id
}
}
end
end
5 changes: 5 additions & 0 deletions lib/viral_spiral/room/change_descriptions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defmodule ViralSpiral.Room.ChangeDescriptions do
@moduledoc """
Commonly used change options put behind user friendly names.
"""
alias ViralSpiral.Room.Action

def change_clout(offset), do: [type: :clout, offset: offset]
def change_affinity(target, offset), do: [type: :affinity, target: target, offset: offset]
Expand Down Expand Up @@ -56,4 +57,8 @@ defmodule ViralSpiral.Room.ChangeDescriptions do
[type: :join, player_name: player_name]
end
end

def turn_to_fake(%Action{type: :turn_card_to_fake, payload: payload}) do
[type: :turn_card_to_fake, card_id: payload.card_id, player_id: payload.player_id]
end
end
13 changes: 7 additions & 6 deletions lib/viral_spiral/room/reducer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ defmodule ViralSpiral.Room.Reducer do
}
end

def reduce(%State{} = state, %{type: :turn_to_fake}) do
# card = action.payload.card
def reduce(%State{} = state, %Action{type: :turn_card_to_fake} = action) do
%{player_id: player_id} = action.payload

# changes = [
# # modify the player's active
# {state.players[player.id], ChangeDescriptions.turn_to_fake()}
# ]
changes = [
{state.players[player_id], ChangeDescriptions.turn_to_fake(action)}
]

State.apply_changes(state, changes)
end

def reduce(%State{} = state, %{type: :viral_spiral_pass, to: players} = action)
Expand Down

0 comments on commit 6fc590d

Please sign in to comment.