-
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.
- Loading branch information
1 parent
442da3a
commit 3db2d1c
Showing
14 changed files
with
93 additions
and
153 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
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
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 |
---|---|---|
@@ -1,65 +1,48 @@ | ||
defmodule Fixtures do | ||
alias ViralSpiral.Room.State.Player | ||
alias ViralSpiral.Deck.Card | ||
alias ViralSpiral.Game.Score.Player | ||
alias ViralSpiral.Room.State.Turn | ||
alias ViralSpiral.Room.State.Round | ||
alias ViralSpiral.Room.State.Room | ||
alias ViralSpiral.Game.EngineConfig | ||
alias ViralSpiral.Room.State.Player, as: PlayerScore | ||
# alias ViralSpiral.Game.Score.Room, as: RoomScore | ||
alias ViralSpiral.Game.Player | ||
|
||
alias ViralSpiral.Room.State.Root | ||
|
||
def initialized_game() do | ||
room_config = %EngineConfig{} | ||
engine_config = %EngineConfig{} | ||
|
||
player_list = [ | ||
Player.new(room_config) |> Player.set_name("adhiraj"), | ||
Player.new(room_config) |> Player.set_name("aman"), | ||
Player.new(room_config) |> Player.set_name("krys"), | ||
Player.new(room_config) |> Player.set_name("farah") | ||
Player.new(engine_config) |> Player.set_name("adhiraj"), | ||
Player.new(engine_config) |> Player.set_name("aman"), | ||
Player.new(engine_config) |> Player.set_name("krys"), | ||
Player.new(engine_config) |> Player.set_name("farah") | ||
] | ||
|
||
players = Enum.reduce(player_list, %{}, fn player, acc -> Map.put(acc, player.id, player) end) | ||
|
||
round = Round.new(player_list) | ||
turn = Turn.new(round) | ||
|
||
player_score_list = | ||
Enum.map( | ||
player_list, | ||
&(Map.new() |> Map.put(:id, &1.id) |> Map.put(:score, PlayerScore.new(&1, room_config))) | ||
) | ||
|
||
player_score_map = | ||
Enum.reduce(player_score_list, %{}, fn player, acc -> | ||
Map.put(acc, player.id, player.score) | ||
end) | ||
|
||
%Root{ | ||
room_config: room_config, | ||
engine_config: engine_config, | ||
room: Room.new(), | ||
player_map: players, | ||
player_list: player_list, | ||
players: players, | ||
round: round, | ||
turn: turn, | ||
# room_score: RoomScore.new(), | ||
player_scores: player_score_map | ||
turn: turn | ||
} | ||
end | ||
|
||
def card_affinity() do | ||
Card.new(:affinity) | ||
end | ||
def players() do | ||
engine_config = %EngineConfig{} | ||
|
||
def player_list() do | ||
room_config = %EngineConfig{} | ||
|
||
[ | ||
Player.new(room_config) |> Player.set_name("adhiraj"), | ||
Player.new(room_config) |> Player.set_name("aman"), | ||
Player.new(room_config) |> Player.set_name("krys"), | ||
Player.new(room_config) |> Player.set_name("farah") | ||
player_list = [ | ||
Player.new(engine_config) |> Player.set_name("adhiraj"), | ||
Player.new(engine_config) |> Player.set_name("aman"), | ||
Player.new(engine_config) |> Player.set_name("krys"), | ||
Player.new(engine_config) |> Player.set_name("farah") | ||
] | ||
|
||
Enum.reduce(player_list, %{}, fn player, acc -> Map.put(acc, player.id, player) end) | ||
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
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 |
---|---|---|
@@ -1,50 +1,48 @@ | ||
defmodule ViralSpiral.Game.ScoreTest do | ||
alias ViralSpiral.Game.Score.Player, as: PlayerScore | ||
alias ViralSpiral.Room.State.Player | ||
alias ViralSpiral.Game.EngineConfig | ||
alias ViralSpiral.Game.Player | ||
use ExUnit.Case | ||
|
||
setup_all do | ||
room_config = %EngineConfig{} | ||
player = Player.new(room_config) |> Player.set_identity("yellow") | ||
player_score = PlayerScore.new(player, room_config) | ||
engine_config = %EngineConfig{} | ||
player = Player.new(engine_config) |> Player.set_identity("yellow") | ||
|
||
%{player: player, player_score: player_score} | ||
%{player: player} | ||
end | ||
|
||
test "player should not have a bias against their own identity", state do | ||
player_score = state.player_score | ||
player = state.player | ||
|
||
assert Enum.find(player_score.biases, &(&1 == "yellow")) == nil | ||
assert Enum.find(player.biases, &(&1 == "yellow")) == nil | ||
end | ||
|
||
test "change player bias", state do | ||
player_score = state.player_score | ||
player = state.player | ||
|
||
player_score = PlayerScore.change(player_score, :bias, :yellow, 3) | ||
assert player_score.biases.yellow == 3 | ||
player = Player.change(player, :bias, :yellow, 3) | ||
assert player.biases.yellow == 3 | ||
|
||
player_score = PlayerScore.change(player_score, :bias, :yellow, -2) | ||
assert player_score.biases.yellow == 1 | ||
player = Player.change(player, :bias, :yellow, -2) | ||
assert player.biases.yellow == 1 | ||
end | ||
|
||
test "change player affinity", state do | ||
player_score = state.player_score | ||
player = state.player | ||
|
||
player_score = PlayerScore.change(player_score, :affinity, :cat, 5) | ||
assert player_score.affinities.cat == 5 | ||
player = Player.change(player, :affinity, :cat, 5) | ||
assert player.affinities.cat == 5 | ||
|
||
player_score = PlayerScore.change(player_score, :affinity, :cat, -2) | ||
assert player_score.affinities.cat == 3 | ||
player = Player.change(player, :affinity, :cat, -2) | ||
assert player.affinities.cat == 3 | ||
end | ||
|
||
test "change player clout", state do | ||
player_score = state.player_score | ||
player = state.player | ||
|
||
player_score = PlayerScore.change(player_score, :clout, 3) | ||
assert player_score.clout == 3 | ||
player = Player.change(player, :clout, 3) | ||
assert player.clout == 3 | ||
|
||
player_score = PlayerScore.change(player_score, :clout, -2) | ||
assert player_score.clout == 1 | ||
player = Player.change(player, :clout, -2) | ||
assert player.clout == 1 | ||
end | ||
end |
Oops, something went wrong.