studio_game_alec 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +143 -8
  3. metadata +49 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7568733f543e2785e59632a7e4faaecc2124dd3b3f2ee312428944327f4c057
4
- data.tar.gz: cd449ee1a87747501e6224a5b0c58eaa0c74df020f39639b30a319de1117fffe
3
+ metadata.gz: b7ef493cd57a4029f2f8fb25822758b15615a7aa9182c7f147fe5dad9a943c01
4
+ data.tar.gz: 7fcd9f2bf8bb475d5dbe9a45d5ce8e782b6c45ab8a0188d62890c21712053bb9
5
5
  SHA512:
6
- metadata.gz: 919f706a3dc21b5dc73fbe2223bfd1ed544ccea35cc8a8ae837fb54efe0b8af79f3f27f647682bceede1ab9f9bf0862c5361b351df604d9e51926bc53584db77
7
- data.tar.gz: be7a75f072dac13eb99e4f3bb063831562b3cc22a234b5e38972a3435bf71381cb8039402cb0c08371e509ef17f9fb7b1bb9485f4ad7e17e9201c460a5da67a1
6
+ metadata.gz: d498da2d6117cb51838b6a7f0082b6567853daf7870d8d1a941854125866484af642d797ca422d2a58e7f89f67e25c5770ccf7f445691158ffe1fbd8b00d4498
7
+ data.tar.gz: 9fba2237bab643eae1a05e6d9a065e315df4b6ddbbf91442a0293875ae2ab178fcad412522f7906183518cc93e113d5bf8a768f282333d9354f423764a51c9c5
data/README.md CHANGED
@@ -1,12 +1,147 @@
1
- # Flicks
1
+ # StudioGame (Alec)
2
2
 
3
- Command-line app/gem to play a game.
3
+ Jogo de terminal em Ruby com **jogadores, dados, tesouros e variações de jogadores** (Clumsy e Berserk), empacotado como gem.
4
4
 
5
- ## Run from source
5
+ > Nome do gem (exemplo): `studio_game_alec`
6
+
7
+ ---
8
+
9
+ ## 🚀 Instalação e execução
10
+
11
+ ### Rodando direto do código-fonte
12
+ No diretório do projeto:
13
+
14
+ ```bash
6
15
  ruby bin/studio_game
16
+ ```
17
+
18
+ Se você não passar um arquivo de jogadores via CLI, o script usa o `players.csv` que fica em `bin/` por padrão.
19
+
20
+ Também funciona passando um CSV na linha de comando:
21
+
22
+ ```bash
23
+ ruby bin/studio_game my_favorite_players.csv
24
+ ```
25
+
26
+ ### Como gem (local)
27
+ Empacote e instale localmente:
28
+
29
+ ```bash
30
+ gem build studio_game.gemspec
31
+ gem install studio_game_alec-<versao>.gem
32
+ ```
33
+
34
+ Depois rode:
35
+
36
+ ```bash
37
+ studio_game
38
+ ```
39
+
40
+ > No Windows, o executável será resolvido pelo RubyGems. Se preferir, rode: `ruby bin/studio_game`.
41
+
42
+ ---
43
+
44
+ ## 📁 Estrutura do projeto
45
+
46
+ ```
47
+ games/
48
+ ├─ bin/
49
+ │ ├─ studio_game # script principal (tem shebang)
50
+ │ └─ players.csv # CSV padrão (nome,vida)
51
+ ├─ lib/
52
+ │ └─ studio_game/
53
+ │ ├─ auditable.rb
54
+ │ ├─ berserk_player.rb
55
+ │ ├─ clumsy_player.rb
56
+ │ ├─ die.rb
57
+ │ ├─ game.rb
58
+ │ ├─ game_turn.rb
59
+ │ ├─ loaded_die.rb
60
+ │ ├─ playable.rb
61
+ │ ├─ player.rb
62
+ │ └─ treasure_trove.rb
63
+ ├─ spec/
64
+ │ └─ studio_game/ # specs RSpec
65
+ ├─ LICENSE
66
+ ├─ README.md
67
+ └─ studio_game.gemspec
68
+ ```
69
+
70
+ - **Namespace:** todo o código vive dentro do módulo `StudioGame` para evitar colisões.
71
+ - **bin/studio_game:** script CLI com shebang (`#!/usr/bin/env ruby`). Faz _fallback_ do `$LOAD_PATH` para `lib` quando usado fora da gem.
72
+ - **lib/studio_game/**: código da biblioteca (classes/módulos).
73
+ - **spec/**: testes RSpec.
74
+
75
+ ---
76
+
77
+ ## 🧩 Conceitos principais
78
+
79
+ - **Player** (`player.rb`): representa um jogador com `name`, `health`, coleta tesouros e calcula `score` (= `health` + `points`). Inclui o mixin **Playable**.
80
+ - **Playable** (`playable.rb`): mixin com `w00t`, `blam` e `strong?` (altera/consulta `health` via getters/setters).
81
+ - **TreasureTrove** (`treasure_trove.rb`): define `Treasure = Struct.new(:name,:points)` e a constante `TREASURES`; possui `.random`.
82
+ - **Die/LoadedDie** (`die.rb`, `loaded_die.rb`): rolam valores (o carregado favorece 1,1,2,5,6,6). Ambos incluem **Auditable**.
83
+ - **Auditable** (`auditable.rb`): imprime “Rolled a X (DieClass)” após cada rolagem.
84
+ - **Game** (`game.rb`): agrega jogadores, carrega CSV, executa rodadas, soma pontos e salva _high scores_.
85
+ - **GameTurn** (`game_turn.rb`): executa a lógica de um turno para um jogador (rola dado, aplica `blam/w00t/skip` e concede tesouro).
86
+ - **ClumsyPlayer / BerserkPlayer**: variações de `Player` que modificam comportamento de `w00t` e de coleta de tesouros.
87
+
88
+ ---
89
+
90
+ ## 🧪 Testes
91
+
92
+ Rode todos os testes:
93
+
94
+ ```bash
95
+ rspec
96
+ ```
97
+
98
+ Principais coisas testadas:
99
+ - Ordenação de jogadores por `score` (usa `<=>` em `Player`).
100
+ - Cálculo de `points` e `score` (soma de tesouros + vida).
101
+ - Efeitos de `w00t`/`blam` e força (`strong?`).
102
+ - Lógica de turno com _stubs_ de dado (`allow_any_instance_of(LoadedDie).to receive(:roll).and_return(n)`).
103
+ - Comportamentos de `ClumsyPlayer` e `BerserkPlayer`.
104
+
105
+ ---
106
+
107
+ ## 📦 CSVs e caminhos
108
+
109
+ - `bin/studio_game` resolve o CSV padrão assim:
110
+
111
+ ```ruby
112
+ default_player_file = File.join(File.dirname(__FILE__), 'players.csv')
113
+ game.load_players(ARGV.shift || default_player_file)
114
+ ```
115
+
116
+ - Você pode passar um arquivo `.csv` via CLI como primeiro argumento.
117
+
118
+ Formato do CSV:
119
+ ```
120
+ Moe,100
121
+ Larry,60
122
+ Curly,125
123
+ ```
124
+
125
+ ---
126
+
127
+ ## 🧾 High Scores
128
+
129
+ Após sair do loop, o jogo grava `high_score.txt` com as entradas ordenadas. Cada linha é formatada por `Game#high_score_entry`:
130
+
131
+ ```
132
+ <nome com padding de pontos> <score>
133
+ ```
134
+
135
+ ---
136
+
137
+ ## 🛠️ Dicas de desenvolvimento
138
+
139
+ - Use `require 'studio_game/arquivo'` quando a gem estiver instalada.
140
+ - No script binário, o `begin/rescue LoadError` faz _fallback_ para `$LOAD_PATH` local, útil fora da gem.
141
+ - Para debugar I/O em testes, o spec redireciona `STDOUT` (`$stdout = StringIO.new`).
142
+
143
+ ---
144
+
145
+ ## 📚 Licença
7
146
 
8
- ## Features
9
- - Load players from CSV
10
- - Points system (blam/w00t)
11
- - Treasure trove
12
- - Clumsy and beserker player
147
+ MIT – veja o arquivo `LICENSE`.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: studio_game_alec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - LucioAlec
@@ -23,19 +23,54 @@ dependencies:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
25
  version: '3'
26
- description: |
27
- # Flicks
28
-
29
- Command-line app/gem to play a game.
30
-
31
- ## Run from source
32
- ruby bin/studio_game
33
-
34
- ## Features
35
- - Load players from CSV
36
- - Points system (blam/w00t)
37
- - Treasure trove
38
- - Clumsy and beserker player
26
+ description: "# StudioGame (Alec)\n\nJogo de terminal em Ruby com **jogadores, dados,
27
+ tesouros e variações de jogadores** (Clumsy e Berserk), empacotado como gem.\n\n>
28
+ Nome do gem (exemplo): `studio_game_alec`\n\n---\n\n## \U0001F680 Instalação e execução\n\n###
29
+ Rodando direto do código-fonte\nNo diretório do projeto:\n\n```bash\nruby bin/studio_game\n```\n\nSe
30
+ você não passar um arquivo de jogadores via CLI, o script usa o `players.csv` que
31
+ fica em `bin/` por padrão.\n\nTambém funciona passando um CSV na linha de comando:\n\n```bash\nruby
32
+ bin/studio_game my_favorite_players.csv\n```\n\n### Como gem (local)\nEmpacote e
33
+ instale localmente:\n\n```bash\ngem build studio_game.gemspec\ngem install studio_game_alec-<versao>.gem\n```\n\nDepois
34
+ rode:\n\n```bash\nstudio_game\n```\n\n> No Windows, o executável será resolvido
35
+ pelo RubyGems. Se preferir, rode: `ruby bin/studio_game`.\n\n---\n\n## \U0001F4C1
36
+ Estrutura do projeto\n\n```\ngames/\n├─ bin/\n│ ├─ studio_game # script
37
+ principal (tem shebang)\n│ └─ players.csv # CSV padrão (nome,vida)\n├─
38
+ lib/\n│ └─ studio_game/\n│ ├─ auditable.rb\n│ ├─ berserk_player.rb\n│ ├─
39
+ clumsy_player.rb\n│ ├─ die.rb\n│ ├─ game.rb\n│ ├─ game_turn.rb\n│ ├─
40
+ loaded_die.rb\n│ ├─ playable.rb\n│ ├─ player.rb\n│ └─ treasure_trove.rb\n├─
41
+ spec/\n│ └─ studio_game/ # specs RSpec\n├─ LICENSE\n├─ README.md\n└─ studio_game.gemspec\n```\n\n-
42
+ **Namespace:** todo o código vive dentro do módulo `StudioGame` para evitar colisões.\n-
43
+ **bin/studio_game:** script CLI com shebang (`#!/usr/bin/env ruby`). Faz _fallback_
44
+ do `$LOAD_PATH` para `lib` quando usado fora da gem.\n- **lib/studio_game/**: código
45
+ da biblioteca (classes/módulos).\n- **spec/**: testes RSpec.\n\n---\n\n## \U0001F9E9
46
+ Conceitos principais\n\n- **Player** (`player.rb`): representa um jogador com `name`,
47
+ `health`, coleta tesouros e calcula `score` (= `health` + `points`). Inclui o mixin
48
+ **Playable**.\n- **Playable** (`playable.rb`): mixin com `w00t`, `blam` e `strong?`
49
+ (altera/consulta `health` via getters/setters).\n- **TreasureTrove** (`treasure_trove.rb`):
50
+ define `Treasure = Struct.new(:name,:points)` e a constante `TREASURES`; possui
51
+ `.random`.\n- **Die/LoadedDie** (`die.rb`, `loaded_die.rb`): rolam valores (o carregado
52
+ favorece 1,1,2,5,6,6). Ambos incluem **Auditable**.\n- **Auditable** (`auditable.rb`):
53
+ imprime “Rolled a X (DieClass)” após cada rolagem.\n- **Game** (`game.rb`): agrega
54
+ jogadores, carrega CSV, executa rodadas, soma pontos e salva _high scores_.\n- **GameTurn**
55
+ (`game_turn.rb`): executa a lógica de um turno para um jogador (rola dado, aplica
56
+ `blam/w00t/skip` e concede tesouro).\n- **ClumsyPlayer / BerserkPlayer**: variações
57
+ de `Player` que modificam comportamento de `w00t` e de coleta de tesouros.\n\n---\n\n##
58
+ \U0001F9EA Testes\n\nRode todos os testes:\n\n```bash\nrspec\n```\n\nPrincipais
59
+ coisas testadas:\n- Ordenação de jogadores por `score` (usa `<=>` em `Player`).\n-
60
+ Cálculo de `points` e `score` (soma de tesouros + vida).\n- Efeitos de `w00t`/`blam`
61
+ e força (`strong?`).\n- Lógica de turno com _stubs_ de dado (`allow_any_instance_of(LoadedDie).to
62
+ receive(:roll).and_return(n)`).\n- Comportamentos de `ClumsyPlayer` e `BerserkPlayer`.\n\n---\n\n##
63
+ \U0001F4E6 CSVs e caminhos\n\n- `bin/studio_game` resolve o CSV padrão assim:\n\n```ruby\ndefault_player_file
64
+ = File.join(File.dirname(__FILE__), 'players.csv')\ngame.load_players(ARGV.shift
65
+ || default_player_file)\n```\n\n- Você pode passar um arquivo `.csv` via CLI como
66
+ primeiro argumento.\n\nFormato do CSV:\n```\nMoe,100\nLarry,60\nCurly,125\n```\n\n---\n\n##
67
+ \U0001F9FE High Scores\n\nApós sair do loop, o jogo grava `high_score.txt` com as
68
+ entradas ordenadas. Cada linha é formatada por `Game#high_score_entry`:\n\n```\n<nome
69
+ com padding de pontos> <score>\n```\n\n---\n\n## \U0001F6E0️ Dicas de desenvolvimento\n\n-
70
+ Use `require 'studio_game/arquivo'` quando a gem estiver instalada.\n- No script
71
+ binário, o `begin/rescue LoadError` faz _fallback_ para `$LOAD_PATH` local, útil
72
+ fora da gem.\n- Para debugar I/O em testes, o spec redireciona `STDOUT` (`$stdout
73
+ = StringIO.new`).\n\n---\n\n## \U0001F4DA Licença\n\nMIT – veja o arquivo `LICENSE`.\n"
39
74
  email: lucioalec@gmail.com
40
75
  executables:
41
76
  - studio_game