char_gen 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0a856cd1f1b7bb58a5c77c3a5158f4457a4b8d672d63a556318185e4774f3ddc
4
+ data.tar.gz: 53f78c25ed0aea5d400e8b963adcacb8e6deba82dcfe4917154070edc4a0cda5
5
+ SHA512:
6
+ metadata.gz: b6a689472a190f4465326d24e04f596b96d16fae0a1c9c3495f3dd5aba1b63c8ffefe688d6b23b367f4d075ac802a279fbcb14e5fffb5da6785ee2ad3d2aceef
7
+ data.tar.gz: c4aa64b4344a1b8f3f892d71a6e51f691ce6fbcf741f9ee2eddeb272391e72bedf6fb0db7bac8ac850dc966a502bcd28a109b205ee297400ec60c4e3e1d07bdf
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
4
+
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'rspec'
@@ -0,0 +1,26 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.3)
5
+ rspec (3.8.0)
6
+ rspec-core (~> 3.8.0)
7
+ rspec-expectations (~> 3.8.0)
8
+ rspec-mocks (~> 3.8.0)
9
+ rspec-core (3.8.0)
10
+ rspec-support (~> 3.8.0)
11
+ rspec-expectations (3.8.2)
12
+ diff-lcs (>= 1.2.0, < 2.0)
13
+ rspec-support (~> 3.8.0)
14
+ rspec-mocks (3.8.0)
15
+ diff-lcs (>= 1.2.0, < 2.0)
16
+ rspec-support (~> 3.8.0)
17
+ rspec-support (3.8.0)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ rspec
24
+
25
+ BUNDLED WITH
26
+ 1.17.2
@@ -0,0 +1,5 @@
1
+ This is a small library to generate classes for a game I'm working on.
2
+
3
+ The goal is to link a Rails backend with a JS-based player game client, so I'll be serializing everything into JSON.
4
+
5
+ The exact function of each stat is proprietary, but the core of this can be used by anyone as the starting point for their own character generation.
@@ -0,0 +1,13 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'char_gen'
3
+ s.version = '0.1'
4
+ s.date = '2019-01-01'
5
+ s.summary = "A character generator"
6
+ s.description = "A gem to generate characters for an RPG"
7
+ s.authors = ["Matthew Miner"]
8
+ s.email = 'matthew.miner89@gmail.com'
9
+ s.files = `git ls-files`.split("\n")
10
+ s.homepage =
11
+ 'http://rubygems.org/gems/char_gen'
12
+ s.license = 'MIT'
13
+ end
@@ -0,0 +1,32 @@
1
+ class BaseCreature
2
+
3
+ def initialize
4
+ @base_creature_stats = {
5
+ might: 5,
6
+ cunning: 5,
7
+ mental: 5,
8
+ influence: 5,
9
+ vitality: 5,
10
+ resolve: 5,
11
+ enmity: 5,
12
+ luck: 0
13
+ }
14
+
15
+ isolated_stats = @base_creature_stats
16
+
17
+ @base_creature = {
18
+ name: "N/A",
19
+ class: "creature",
20
+ stats: isolated_stats,
21
+ health: 25,
22
+ mana: 15
23
+ }
24
+
25
+ end
26
+
27
+ def info
28
+ @base_creature
29
+ end
30
+
31
+ end
32
+
@@ -0,0 +1,38 @@
1
+ module ClassStats
2
+ APPRENTICE = {
3
+ class: "apprentice",
4
+ stats: {
5
+ mental: 8,
6
+ enmity: 7
7
+ }
8
+ }
9
+
10
+ BRAWLER = {
11
+ class: "brawler",
12
+ stats: {
13
+ might: 7,
14
+ mental: 6,
15
+ vitality: 6,
16
+ resolve: 6
17
+ }
18
+ }
19
+
20
+ INITIATE = {
21
+ class: "initiate",
22
+ stats: {
23
+ mental: 7,
24
+ influence: 7,
25
+ resolve: 6
26
+ }
27
+ }
28
+
29
+ SCOUNDREL = {
30
+ class: "scoundrel",
31
+ stats: {
32
+ cunning: 7,
33
+ mental: 6,
34
+ enmity: 6,
35
+ luck: 1
36
+ }
37
+ }
38
+ end
@@ -0,0 +1,63 @@
1
+ require 'json'
2
+ require_relative 'base_stats/base_creature'
3
+ require_relative 'names/names_collection'
4
+ require_relative 'base_stats/class_stats'
5
+
6
+ class CharacterGenerator
7
+
8
+ def process_health(vitality)
9
+ vitality * 5
10
+ end
11
+
12
+ def process_mana(mental)
13
+ mental * 5
14
+ end
15
+
16
+ def process_dependent_stats(new_creature, stats)
17
+ new_creature[:health] = process_health(stats[:vitality])
18
+ new_creature[:mana] = process_mana(stats[:mental])
19
+ end
20
+
21
+ def select_name
22
+ names_collection = NamesCollection::MALE_NAMES
23
+ names_collection.sample
24
+ end
25
+
26
+ def create_base_creature
27
+ base_creature = BaseCreature.new
28
+ end
29
+
30
+ def generate_creature(creature)
31
+
32
+ new_creature = create_base_creature.info
33
+
34
+ new_creature[:class] = creature[:class]
35
+ new_creature[:name] = select_name
36
+
37
+ stats = new_creature[:stats]
38
+
39
+ creature[:stats].each do |stat_name, value|
40
+ stats[stat_name] = value
41
+ end
42
+
43
+ process_dependent_stats(new_creature, stats)
44
+
45
+ new_creature.to_json
46
+ end
47
+
48
+ def make_apprentice
49
+ generate_creature(ClassStats::APPRENTICE)
50
+ end
51
+
52
+ def make_brawler
53
+ generate_creature(ClassStats::BRAWLER)
54
+ end
55
+
56
+ def make_initiate
57
+ generate_creature(ClassStats::INITIATE)
58
+ end
59
+
60
+ def make_scoundrel
61
+ generate_creature(ClassStats::SCOUNDREL)
62
+ end
63
+ end
@@ -0,0 +1,103 @@
1
+ module NamesCollection
2
+ MALE_NAMES = ['Lenard',
3
+ 'Fredrick',
4
+ 'Vance',
5
+ 'Erik',
6
+ 'Devin',
7
+ 'Cesar',
8
+ 'Sylvester',
9
+ 'Sheldon',
10
+ 'Avery',
11
+ 'Sid',
12
+ 'Conrad',
13
+ 'Lavern',
14
+ 'Hans',
15
+ 'Adan',
16
+ 'Tod',
17
+ 'Angelo',
18
+ 'Herschel',
19
+ 'Arnold',
20
+ 'Lincoln',
21
+ 'Mario',
22
+ 'Alton',
23
+ 'Neil',
24
+ 'Ricardo',
25
+ 'Mathew',
26
+ 'Carmine',
27
+ 'Francis',
28
+ 'Cary',
29
+ 'Werner',
30
+ 'Lacy',
31
+ 'Marty',
32
+ 'Gail',
33
+ 'Danial',
34
+ 'Lucio',
35
+ 'Efrain',
36
+ 'Robt',
37
+ 'Samual',
38
+ 'Hank',
39
+ 'Mikel',
40
+ 'Dane',
41
+ 'Sammie',
42
+ 'Minh',
43
+ 'Jame',
44
+ 'Felipe',
45
+ 'Lucius',
46
+ 'Alonzo',
47
+ 'Federico',
48
+ 'Richard',
49
+ 'Roderick',
50
+ 'Trevor',
51
+ 'Olen']
52
+
53
+ FEMALE_NAMES = ['Judy',
54
+ 'Tu',
55
+ 'Petrina',
56
+ 'Rashida',
57
+ 'Karena',
58
+ 'Analisa',
59
+ 'Takako',
60
+ 'Valarie',
61
+ 'Lurline',
62
+ 'Zaida',
63
+ 'Concetta',
64
+ 'Mercy',
65
+ 'Elvina',
66
+ 'Ada',
67
+ 'Armanda',
68
+ 'Charlyn',
69
+ 'Therese',
70
+ 'Mertie',
71
+ 'Enola',
72
+ 'Katheleen',
73
+ 'Stacia',
74
+ 'Coletta',
75
+ 'Annalisa',
76
+ 'Venice',
77
+ 'Jule',
78
+ 'Virgen',
79
+ 'Tresa',
80
+ 'Gaylene',
81
+ 'Sharla',
82
+ 'Eura',
83
+ 'Burma',
84
+ 'Eryn',
85
+ 'Diedra',
86
+ 'Mariela',
87
+ 'Cortney',
88
+ 'Gertrude',
89
+ 'Chrystal',
90
+ 'Amparo',
91
+ 'Rachal',
92
+ 'Willow',
93
+ 'Nella',
94
+ 'Kaye',
95
+ 'Vanda',
96
+ 'Stephanie',
97
+ 'Fanny',
98
+ 'Joy',
99
+ 'Lucile',
100
+ 'Margorie',
101
+ 'Starla',
102
+ 'Waltraud']
103
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+ require_relative '../lib/char_gen'
3
+ require_relative '../lib/base_stats/base_creature'
4
+
5
+ describe CharacterGenerator do
6
+ before(:each) do
7
+ @test_class = CharacterGenerator.new
8
+ end
9
+
10
+ describe "#process_health" do
11
+ it "multiplies vitality times 5" do
12
+ expect(@test_class.process_health(5)).to eq(25)
13
+ end
14
+ end
15
+
16
+ describe "#process_mana" do
17
+ it "multiplies mental times 5" do
18
+ expect(@test_class.process_mana(5)).to eq(25)
19
+ end
20
+ end
21
+
22
+ describe "#select_name" do
23
+ it "returns a string" do
24
+ expect(@test_class.select_name).to be_a(String)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,100 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
+ RSpec.configure do |config|
17
+ # rspec-expectations config goes here. You can use an alternate
18
+ # assertion/expectation library such as wrong or the stdlib/minitest
19
+ # assertions if you prefer.
20
+ config.expect_with :rspec do |expectations|
21
+ # This option will default to `true` in RSpec 4. It makes the `description`
22
+ # and `failure_message` of custom matchers include text for helper methods
23
+ # defined using `chain`, e.g.:
24
+ # be_bigger_than(2).and_smaller_than(4).description
25
+ # # => "be bigger than 2 and smaller than 4"
26
+ # ...rather than:
27
+ # # => "be bigger than 2"
28
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
29
+ end
30
+
31
+ # rspec-mocks config goes here. You can use an alternate test double
32
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
33
+ config.mock_with :rspec do |mocks|
34
+ # Prevents you from mocking or stubbing a method that does not exist on
35
+ # a real object. This is generally recommended, and will default to
36
+ # `true` in RSpec 4.
37
+ mocks.verify_partial_doubles = true
38
+ end
39
+
40
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
41
+ # have no way to turn it off -- the option exists only for backwards
42
+ # compatibility in RSpec 3). It causes shared context metadata to be
43
+ # inherited by the metadata hash of host groups and examples, rather than
44
+ # triggering implicit auto-inclusion in groups with matching metadata.
45
+ config.shared_context_metadata_behavior = :apply_to_host_groups
46
+
47
+ # The settings below are suggested to provide a good initial experience
48
+ # with RSpec, but feel free to customize to your heart's content.
49
+ =begin
50
+ # This allows you to limit a spec run to individual examples or groups
51
+ # you care about by tagging them with `:focus` metadata. When nothing
52
+ # is tagged with `:focus`, all examples get run. RSpec also provides
53
+ # aliases for `it`, `describe`, and `context` that include `:focus`
54
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
55
+ config.filter_run_when_matching :focus
56
+
57
+ # Allows RSpec to persist some state between runs in order to support
58
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
59
+ # you configure your source control system to ignore this file.
60
+ config.example_status_persistence_file_path = "spec/examples.txt"
61
+
62
+ # Limits the available syntax to the non-monkey patched syntax that is
63
+ # recommended. For more details, see:
64
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
65
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
66
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
67
+ config.disable_monkey_patching!
68
+
69
+ # This setting enables warnings. It's recommended, but in some cases may
70
+ # be too noisy due to issues in dependencies.
71
+ config.warnings = true
72
+
73
+ # Many RSpec users commonly either run the entire suite or an individual
74
+ # file, and it's useful to allow more verbose output when running an
75
+ # individual spec file.
76
+ if config.files_to_run.one?
77
+ # Use the documentation formatter for detailed output,
78
+ # unless a formatter has already been configured
79
+ # (e.g. via a command-line flag).
80
+ config.default_formatter = "doc"
81
+ end
82
+
83
+ # Print the 10 slowest examples and example groups at the
84
+ # end of the spec run, to help surface which specs are running
85
+ # particularly slow.
86
+ config.profile_examples = 10
87
+
88
+ # Run specs in random order to surface order dependencies. If you find an
89
+ # order dependency and want to debug it, you can fix the order by providing
90
+ # the seed, which is printed after each run.
91
+ # --seed 1234
92
+ config.order = :random
93
+
94
+ # Seed global randomization in this process using the `--seed` CLI option.
95
+ # Setting this allows you to use `--seed` to deterministically reproduce
96
+ # test failures related to randomization by passing the same `--seed` value
97
+ # as the one that triggered the failure.
98
+ Kernel.srand config.seed
99
+ =end
100
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: char_gen
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Matthew Miner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-01-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A gem to generate characters for an RPG
14
+ email: matthew.miner89@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".rspec"
20
+ - Gemfile
21
+ - Gemfile.lock
22
+ - README.md
23
+ - char_gen.gemspec
24
+ - lib/base_stats/base_creature.rb
25
+ - lib/base_stats/class_stats.rb
26
+ - lib/char_gen.rb
27
+ - lib/names/names_collection.rb
28
+ - spec/char_gen_spec.rb
29
+ - spec/spec_helper.rb
30
+ homepage: http://rubygems.org/gems/char_gen
31
+ licenses:
32
+ - MIT
33
+ metadata: {}
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 2.7.8
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: A character generator
54
+ test_files: []