Skip to content

Commit

Permalink
chore: wip commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dennyabrain committed Aug 31, 2024
1 parent b527bd2 commit a4f6e52
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 49 deletions.
45 changes: 1 addition & 44 deletions lib/viral_spiral/canon.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,11 @@ defmodule ViralSpiral.Canon do
# @card_data "card.ods"
# @encyclopedia "encyclopedia.ods"

@true_affinity_opts type: :affinity, veracity: true
@false_affinity_opts type: :affinity, veracity: false
@true_bias_opts type: :bias, veracity: true
@false_bias_opts type: :bias, veracity: false
@true_topical_opts type: :topical, veracity: true
@false_topical_opts type: :topical, veracity: false
@false_conflated_opts type: :conflated, veracity: false

defdelegate load_cards, to: Deck

defdelegate create_store(cards), to: Deck

defdelegate create_sets(cards), to: Deck

def draw_true_affinity_card(deck, tgb, target) do
opts = @true_affinity_opts ++ [tgb: tgb, target: target]
Deck.draw_card(deck, opts)
end

def draw_false_affinity_card(deck, tgb, target) do
opts = @false_affinity_opts ++ [tgb: tgb, target: target]
Deck.draw_card(deck, opts)
end

def draw_true_bias_card(deck, tgb, target) do
opts = @true_bias_opts ++ [tgb: tgb, target: target]
Deck.draw_card(deck, opts)
end

def draw_false_bias_card(deck, tgb, target) do
opts = @false_bias_opts ++ [tgb: tgb, target: target]
Deck.draw_card(deck, opts)
end

def true_topical_card(deck, tgb) do
opts = @true_topical_opts ++ [tgb: tgb]
Deck.draw_card(deck, opts)
end

def false_topical_card(deck, tgb) do
opts = @false_topical_opts ++ [tgb: tgb]
Deck.draw_card(deck, opts)
end

def false_conflated_card(deck, tgb) do
opts = @false_conflated_opts ++ [tgb: tgb]
Deck.draw_card(deck, opts)
end
defdelegate create_sets(cards, opts), to: Deck

def encyclopedia() do
end
Expand Down
54 changes: 49 additions & 5 deletions lib/viral_spiral/canon/deck.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule ViralSpiral.Canon.Deck do
@moduledoc """
Loads data from .csv files.
Viral Spiral writers use Google Sheet to organize the text content for the game.
Viral Spiral writers use Google Sheet to organize the text content for the game. The current sheet is [here](https://docs.google.com/spreadsheets/d/1070fP6LOjCTfLl7SoQuGA4FxNJ3XLWbzZj35eABizgk/edit?usp=sharing)
Each sheet within the sheet is exported as .csv files and stored in the `priv/canon/` directory. This module encodes the conventions used by the writers in the file to generate structured data structures from the csv file. It also converts the structured data into datastructures optimized for the game's requirements.
<div class="mermaid">
Expand All @@ -15,15 +15,27 @@ defmodule ViralSpiral.Canon.Deck do
Store is a Map of all cards. Keys in this Map are unique ids for every card and the values are cards (`ViralSpiral.Canon.Card.Affinity`, `ViralSpiral.Canon.Card.Bias`, `ViralSpiral.Canon.Card.Topical` and `ViralSpiral.Canon.Card.Conflated`).
Sets is a Map of cards. Keys of this Map are a tuple of the form `{type, veracity, target}`. Value of this Map is `MapSet` of cards.
Sets is a Map of cards. Keys of this Map are a tuple of the form `{type, veracity, target}`. Value of this Map is `MapSet` of cards. For instance, for a room where the active affinities are :cat and :sock; and the active communities are :red and :yellow; the Sets would have the following keys :
[
{:conflated, false},
{:topical, false},
{:topical, true},
{:affinity, false, :cat},
{:affinity, false, :sock},
{:affinity, true, :cat},
{:affinity, true, :sock},
{:bias, false, :red},
{:bias, false, :yellow},
{:bias, true, :red},
{:bias, true, :yellow}
]
## Example Usage
```elixir
cards = Deck.load_cards()
store = Deck.create_store(cards)
sets = Deck.create_sets(store)
sets = Deck.create_sets(cards)
card_id = Deck.draw_card(deck, type: :affinity, veracity: true, tgb: 0, target: :skub)
card_id = Deck.draw_card(deck, type: :bias, veracity: true, tgb: 0, target: :red)
Expand Down Expand Up @@ -83,6 +95,7 @@ defmodule ViralSpiral.Canon.Deck do
conflated_image: 41
}
@set_opts_default [affinities: [:cat, :sock], biases: [:red, :yellow]]
@card_master_sheet "all_cards.csv"

def load_cards() do
parse_file()
Expand Down Expand Up @@ -129,7 +142,7 @@ defmodule ViralSpiral.Canon.Deck do
end

defp parse_file() do
File.stream!(Path.join([File.cwd!(), "priv", "canon", "all_cards.csv"]))
File.stream!(Path.join([File.cwd!(), "priv", "canon", @card_master_sheet]))
|> CSV.decode()
end

Expand Down Expand Up @@ -496,4 +509,35 @@ defmodule ViralSpiral.Canon.Deck do
key
end
end

@doc """
Determines what type of card to draw.
Returns a tuple that should be a valid key of a Store.
[
{:conflated, false},
{:topical, false},
{:topical, true},
{:affinity, false, :cat},
{:affinity, false, :sock},
{:affinity, true, :cat},
{:affinity, true, :sock},
{:bias, false, :red},
{:bias, false, :yellow},
{:bias, true, :red},
{:bias, true, :yellow}
]
"""
def draw_type(opts \\ []) do

Check warning on line 533 in lib/viral_spiral/canon/deck.ex

View workflow job for this annotation

GitHub Actions / build-and-deploy

variable "opts" is unused (if the variable is not meant to be used, prefix it with an underscore)
tgb = 4

Check warning on line 534 in lib/viral_spiral/canon/deck.ex

View workflow job for this annotation

GitHub Actions / build-and-deploy

variable "tgb" is unused (if the variable is not meant to be used, prefix it with an underscore)

bias_p = :rand.uniform()
fake_p = :rand.uniform()
draw_affinity = :rand.uniform() < 0.5
draw_topical = not draw_affinity
draw_true = :rand.uniform() < 1 - 1 / 10
{bias_p, fake_p, draw_affinity, draw_topical, draw_true}
end
end

0 comments on commit a4f6e52

Please sign in to comment.