Created
February 19, 2020 19:01
-
-
Save Sephi-Chan/9e2b507e7bffbbe29bbaa68d7627cd99 to your computer and use it in GitHub Desktop.
Diggers simple game test
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
test "Start the exploration phase when all players disabled three tiles on each board" do | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerOpensLobby{game_id: "game_1", player_id: "Corwin"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerJoinsLobby{game_id: "game_1", player_id: "Mandor"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerStartsGame{game_id: "game_1", player_id: "Corwin"}) | |
# Corwin has board 0, Mandor has board 1. | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerDisablesTile{game_id: "game_1", player_id: "Corwin", tile: "1_3"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerDisablesTile{game_id: "game_1", player_id: "Corwin", tile: "0_1"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerDisablesTile{game_id: "game_1", player_id: "Corwin", tile: "3_4"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerDisablesTile{game_id: "game_1", player_id: "Mandor", tile: "1_0"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerDisablesTile{game_id: "game_1", player_id: "Mandor", tile: "3_2"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerDisablesTile{game_id: "game_1", player_id: "Mandor", tile: "5_4"}) | |
# Corwin has board 1, Mandor has board 0. | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerDisablesTile{game_id: "game_1", player_id: "Corwin", tile: "2_3"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerDisablesTile{game_id: "game_1", player_id: "Corwin", tile: "0_1"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerDisablesTile{game_id: "game_1", player_id: "Corwin", tile: "3_0"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerDisablesTile{game_id: "game_1", player_id: "Mandor", tile: "8_8"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerDisablesTile{game_id: "game_1", player_id: "Mandor", tile: "2_2"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerDisablesTile{game_id: "game_1", player_id: "Mandor", tile: "4_3"}) | |
{:error, :not_allowed_now} = Diggers.Application.dispatch(%Diggers.PlayerStartsGame{game_id: "game_1", player_id: "Corwin"}) | |
{:error, :not_allowed_now} = Diggers.Application.dispatch(%Diggers.PlayerDisablesTile{game_id: "game_1", player_id: "Corwin", tile: "1_2"}) | |
# Game starts. Corwin has board 0, Mandor has board 1. | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerRollsDices{game_id: "game_1", dices_rolls: [1, 2, 2, 1]}) | |
{:error, :dices_already_rolled} = Diggers.Application.dispatch(%Diggers.PlayerRollsDices{game_id: "game_1", dices_rolls: [1, 2, 2, 1]}) | |
# Corwin suffocates since no tile with 2 and 1 is available from the start tile. | |
{:error, :player_not_found} = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Eric", tile: "1_1"}) | |
{:error, :suffocated_this_round} = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Mandor", tile: "1_1"}) | |
{:error, :tile_not_in_neighbours} = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Corwin", tile: "9_9"}) | |
{:error, :tile_is_disabled} = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Corwin", tile: "0_1"}) | |
{:error, :tile_is_unavailable} = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Corwin", tile: "1_1"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Corwin", tile: "1_0"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerRollsDices{game_id: "game_1", dices_rolls: [3, 3, 5, 6]}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Corwin", tile: "2_1"}) | |
{:error, :already_moved_this_round} = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Corwin", tile: "2_1"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Mandor", tile: "1_1"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerRollsDices{game_id: "game_1", dices_rolls: [3, 4, 5, 6]}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Mandor", tile: "2_2"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Corwin", tile: "3_2"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerRollsDices{game_id: "game_1", dices_rolls: [3, 4, 5, 6]}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Corwin", tile: "4_2"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Mandor", tile: "3_3"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerRollsDices{game_id: "game_1", dices_rolls: [1, 2, 4, 5]}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Corwin", tile: "5_3"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Mandor", tile: "4_4"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerRollsDices{game_id: "game_1", dices_rolls: [1, 2, 4, 5]}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Corwin", tile: "6_4"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Mandor", tile: "5_5"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerRollsDices{game_id: "game_1", dices_rolls: [3, 3, 3, 3]}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Corwin", tile: "6_5"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Mandor", tile: "6_5"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerRollsDices{game_id: "game_1", dices_rolls: [2, 2, 2, 2]}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Corwin", tile: "7_6"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Mandor", tile: "7_6"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerRollsDices{game_id: "game_1", dices_rolls: [4, 4, 4, 4]}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Corwin", tile: "8_7"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Mandor", tile: "8_7"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerRollsDices{game_id: "game_1", dices_rolls: [2, 2, 3, 5]}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Corwin", tile: "9_8"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Mandor", tile: "8_8"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerRollsDices{game_id: "game_1", dices_rolls: [2, 2, 4, 5]}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Corwin", tile: "9_9"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Mandor", tile: "8_9"}) | |
{:error, :too_many_dices_rolls} = Diggers.Application.dispatch(%Diggers.PlayerRollsDices{game_id: "game_1", dices_rolls: [2, 2, 4, 5]}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerRollsDices{game_id: "game_1", dices_rolls: [2, 3, 4]}) | |
{:error, :player_already_left} = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Corwin", tile: "9_9"}) | |
:ok = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Mandor", tile: "9_9"}) | |
{:error, :not_allowed_now} = Diggers.Application.dispatch(%Diggers.PlayerRollsDices{game_id: "game_1", dices_rolls: [2, 2, 4, 5]}) | |
{:error, :not_allowed_now} = Diggers.Application.dispatch(%Diggers.PlayerMoves{game_id: "game_1", player_id: "Mandor", tile: "9_9"}) | |
[{16, "Corwin"}, {8, "Mandor"}] = Diggers.Game.results(game("game_1")) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment