-
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 encyclopedia and link cards to their encyclopedia entries
- Loading branch information
1 parent
a4f6e52
commit 4227c27
Showing
32 changed files
with
884 additions
and
125 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,8 @@ | ||
defmodule ViralSpiral.Affinity do | ||
defstruct target: nil | ||
|
||
@type target :: :cat | :sock | :highfive | :houseboat | :skub | ||
@type t :: %__MODULE__{ | ||
target: target() | ||
} | ||
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,8 @@ | ||
defmodule ViralSpiral.Bias do | ||
defstruct target: nil | ||
|
||
@type target :: :red | :yellow | :blue | ||
@type t :: %__MODULE__{ | ||
target: target() | ||
} | ||
end |
This file was deleted.
Oops, something went wrong.
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,57 @@ | ||
defmodule ViralSpiral.Canon.Article do | ||
alias ViralSpiral.Canon.Article | ||
|
||
defstruct id: nil, | ||
card_id: "", | ||
headline: "", | ||
type: nil, | ||
content: "", | ||
author: "", | ||
veracity: nil | ||
|
||
# @type article_type :: :blog | :news | :official | ||
@type t :: %__MODULE__{ | ||
id: UXID.uxid_string(), | ||
card_id: String.t(), | ||
headline: String.t() | any(), | ||
type: String.t() | any(), | ||
content: String.t() | any(), | ||
author: String.t() | any(), | ||
veracity: boolean() | ||
} | ||
|
||
# @article_types [:blog, :news, :official] | ||
|
||
@spec new(String.t()) :: Article.t() | ||
def new(headline) do | ||
%Article{ | ||
id: UXID.generate!(prefix: "article", size: :small), | ||
card_id: "card_" <> Integer.to_string(:erlang.phash2(headline)) | ||
} | ||
end | ||
|
||
@spec set_headline(Article.t(), String.t() | any()) :: Article.t() | ||
def set_headline(%Article{} = article, headline) do | ||
%{article | headline: headline} | ||
end | ||
|
||
@spec set_type(Article.t(), String.t() | any()) :: Article.t() | ||
def set_type(%Article{} = article, type) do | ||
%{article | type: type} | ||
end | ||
|
||
@spec set_content(Article.t(), String.t() | any()) :: Article.t() | ||
def set_content(%Article{} = article, content) do | ||
%{article | content: content} | ||
end | ||
|
||
@spec set_author(Article.t(), String.t() | any()) :: Article.t() | ||
def set_author(%Article{} = article, author) do | ||
%{article | author: author} | ||
end | ||
|
||
@spec set_veracity(Article.t(), boolean()) :: Article.t() | ||
def set_veracity(%Article{} = article, veracity) do | ||
%{article | veracity: veracity} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
defmodule ViralSpiral.Canon.Card.Conflated do | ||
defstruct id: nil, | ||
tgb: nil, | ||
type: :conflated, | ||
veracity: false, | ||
polarity: :neutral, | ||
headline: nil, | ||
image: nil | ||
image: nil, | ||
article_id: nil | ||
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,72 @@ | ||
defmodule ViralSpiral.Canon.CardDrawSpec do | ||
@moduledoc """ | ||
Specify requirements for the kind of card to draw. | ||
This struct is passed to `ViralSpiral.Canon.Deck.draw_type()` | ||
A common way to create a struct is by passing a current room's config | ||
# Example struct | ||
requirements = %{ | ||
tgb: 4, | ||
total_tgb: 10, | ||
biases: [:red, :blue], | ||
affinities: [:cat, :sock], | ||
current_player: %{ | ||
identity: :blue | ||
} | ||
} | ||
""" | ||
alias ViralSpiral.Game.State | ||
alias ViralSpiral.Affinity | ||
alias ViralSpiral.Bias | ||
alias ViralSpiral.Game.Player | ||
alias ViralSpiral.Canon.CardDrawSpec | ||
|
||
defstruct tgb: 0, | ||
total_tgb: Application.compile_env(:viral_spiral, EngineConfig)[:chaos_counter], | ||
biases: [], | ||
affinities: [], | ||
current_player: nil | ||
|
||
@type t :: %__MODULE__{ | ||
tgb: integer(), | ||
total_tgb: integer(), | ||
biases: list(Bias.target()), | ||
affinities: list(Affinity.target()), | ||
current_player: %{ | ||
identity: Bias.target() | ||
} | ||
} | ||
|
||
@spec set_biases(CardDrawSpec.t(), list(Bias.target())) :: CardDrawSpec.t() | ||
def set_biases(%CardDrawSpec{} = spec, biases) do | ||
%{spec | biases: biases} | ||
end | ||
|
||
@spec set_affinities(CardDrawSpec.t(), list(Affinity.target())) :: CardDrawSpec.t() | ||
def set_affinities(%CardDrawSpec{} = spec, affinities) do | ||
%{spec | affinities: affinities} | ||
end | ||
|
||
@spec set_current_player(CardDrawSpec.t(), Player.t()) :: CardDrawSpec.t() | ||
def set_current_player(%CardDrawSpec{} = spec, %Player{} = player) do | ||
%{spec | current_player: adapt_player(player)} | ||
end | ||
|
||
defp adapt_player(%Player{} = player) do | ||
%{identity: Player.identity(player)} | ||
end | ||
|
||
defp new(%State{} = state) do | ||
%CardDrawSpec{ | ||
tgb: state.room.chaos_countdown, | ||
# todo | ||
biases: state.room_config.biases, | ||
# todo | ||
affinities: state.room_config.affinities | ||
# todo | ||
# current_player: player_store[state.turn.current] | ||
} | ||
end | ||
end |
Oops, something went wrong.