-
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: add multiple simultaneous turns
- Loading branch information
1 parent
9cdc6a5
commit 943295d
Showing
2 changed files
with
67 additions
and
3 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,42 @@ | ||
defmodule ViralSpiral.TurnTest do | ||
alias ViralSpiral.Game.Turn | ||
alias ViralSpiral.Game.Round | ||
use ExUnit.Case | ||
|
||
describe "Turn Management" do | ||
test "pass card" do | ||
game = Fixtures.initialized_game() | ||
player_list = game.player_list | ||
round = Round.new(player_list) | ||
turn = Turn.new(round) | ||
assert length(turn.pass_to) == 3 | ||
|
||
current_player = Enum.at(round.order, round.current) | ||
|
||
pass_to = | ||
Enum.filter(player_list, &(&1.id != current_player)) | ||
|> Enum.shuffle() | ||
|> Enum.take(1) | ||
|> Enum.at(0) | ||
|
||
turn = Turn.next(turn, pass_to.id) | ||
assert length(turn.pass_to) == 2 | ||
end | ||
|
||
@tag timeout: :infinity | ||
test "pass card to multiple people during viral spiral special power" do | ||
game = Fixtures.initialized_game() | ||
player_list = game.player_list | ||
round = Round.new(player_list) | ||
turn = Turn.new(round) | ||
assert length(turn.pass_to) == 3 | ||
|
||
current_player = Enum.at(round.order, 0) | ||
to_pass_players = Enum.slice(round.order, 1..2) | ||
turn = Turn.next(turn, to_pass_players) | ||
|
||
assert length(turn) == 2 | ||
assert length(Enum.at(turn, 0).pass_to) == 1 | ||
end | ||
end | ||
end |