From 62464846a3634e83813138dcc34b76a82199de8e Mon Sep 17 00:00:00 2001 From: Etienne Ischer Date: Wed, 2 Jun 2021 22:24:04 +0200 Subject: [PATCH] add creature and base rp_world --- Gemfile | 2 +- Gemfile.lock | 20 +++---- app/assets/stylesheets/rp_world.scss | 3 ++ app/controllers/rp_worlds_controller.rb | 9 ++++ app/helpers/rp_world_helper.rb | 2 + app/models/rp_world.rb | 9 ++++ app/models/wow_character.rb | 2 + app/models/wow_character_play_rp_world.rb | 7 +++ app/models/wow_creature.rb | 10 ++++ app/models/wow_creature_family.rb | 9 ++++ app/models/wow_creature_type.rb | 9 ++++ app/views/layouts/_navbar.html.erb | 3 ++ app/views/rp_worlds/index.html.erb | 18 +++++++ app/views/rp_worlds/show.html.erb | 17 ++++++ app/workers/wow_creature_families_worker.rb | 22 ++++++++ app/workers/wow_creature_types_worker.rb | 22 ++++++++ app/workers/wow_creatures_worker.rb | 42 +++++++++++++++ config/locales/layouts/de-de.yml | 1 + config/locales/layouts/en-gb.yml | 1 + config/locales/layouts/en-us.yml | 1 + config/locales/layouts/es-es.yml | 1 + config/locales/layouts/es-mx.yml | 1 + config/locales/layouts/fr-fr.yml | 1 + config/locales/layouts/it.yml | 1 + config/locales/layouts/ko.yml | 1 + config/locales/layouts/pt-br.yml | 1 + config/locales/layouts/ru-ru.yml | 1 + config/locales/layouts/zh-cn.yml | 1 + config/locales/layouts/zh-tw.yml | 1 + config/locales/rp_worlds/de-de.yml | 5 ++ config/locales/rp_worlds/en-gb.yml | 5 ++ config/locales/rp_worlds/en-us.yml | 5 ++ config/locales/rp_worlds/es-es.yml | 5 ++ config/locales/rp_worlds/es-mx.yml | 5 ++ config/locales/rp_worlds/fr-fr.yml | 5 ++ config/locales/rp_worlds/it.yml | 5 ++ config/locales/rp_worlds/ko.yml | 5 ++ config/locales/rp_worlds/pt-br.yml | 5 ++ config/locales/rp_worlds/ru-ru.yml | 5 ++ config/locales/rp_worlds/zh-cn.yml | 5 ++ config/locales/rp_worlds/zh-tw.yml | 5 ++ config/locales/wow_mounts/fr-fr.yml | 2 +- config/routes.rb | 1 + db/migrate/20210602152828_create_rp_worlds.rb | 11 ++++ ...013_create_wow_character_play_rp_worlds.rb | 12 +++++ ...0602192708_create_wow_creature_families.rb | 13 +++++ ...0210602192916_create_wow_creature_types.rb | 12 +++++ .../20210602193023_create_wow_creatures.rb | 16 ++++++ db/schema.rb | 53 ++++++++++++++++++- spec/helpers/rp_world_helper_spec.rb | 15 ++++++ spec/models/rp_world_spec.rb | 5 ++ .../wow_character_play_rp_world_spec.rb | 5 ++ spec/models/wow_creature_family_spec.rb | 5 ++ spec/models/wow_creature_spec.rb | 5 ++ spec/models/wow_creature_type_spec.rb | 5 ++ spec/requests/rp_world_spec.rb | 7 +++ 56 files changed, 432 insertions(+), 13 deletions(-) create mode 100644 app/assets/stylesheets/rp_world.scss create mode 100644 app/controllers/rp_worlds_controller.rb create mode 100644 app/helpers/rp_world_helper.rb create mode 100644 app/models/rp_world.rb create mode 100644 app/models/wow_character_play_rp_world.rb create mode 100644 app/models/wow_creature.rb create mode 100644 app/models/wow_creature_family.rb create mode 100644 app/models/wow_creature_type.rb create mode 100644 app/views/rp_worlds/index.html.erb create mode 100644 app/views/rp_worlds/show.html.erb create mode 100644 app/workers/wow_creature_families_worker.rb create mode 100644 app/workers/wow_creature_types_worker.rb create mode 100644 app/workers/wow_creatures_worker.rb create mode 100644 config/locales/rp_worlds/de-de.yml create mode 100644 config/locales/rp_worlds/en-gb.yml create mode 100644 config/locales/rp_worlds/en-us.yml create mode 100644 config/locales/rp_worlds/es-es.yml create mode 100644 config/locales/rp_worlds/es-mx.yml create mode 100644 config/locales/rp_worlds/fr-fr.yml create mode 100644 config/locales/rp_worlds/it.yml create mode 100644 config/locales/rp_worlds/ko.yml create mode 100644 config/locales/rp_worlds/pt-br.yml create mode 100644 config/locales/rp_worlds/ru-ru.yml create mode 100644 config/locales/rp_worlds/zh-cn.yml create mode 100644 config/locales/rp_worlds/zh-tw.yml create mode 100644 db/migrate/20210602152828_create_rp_worlds.rb create mode 100644 db/migrate/20210602153013_create_wow_character_play_rp_worlds.rb create mode 100644 db/migrate/20210602192708_create_wow_creature_families.rb create mode 100644 db/migrate/20210602192916_create_wow_creature_types.rb create mode 100644 db/migrate/20210602193023_create_wow_creatures.rb create mode 100644 spec/helpers/rp_world_helper_spec.rb create mode 100644 spec/models/rp_world_spec.rb create mode 100644 spec/models/wow_character_play_rp_world_spec.rb create mode 100644 spec/models/wow_creature_family_spec.rb create mode 100644 spec/models/wow_creature_spec.rb create mode 100644 spec/models/wow_creature_type_spec.rb create mode 100644 spec/requests/rp_world_spec.rb diff --git a/Gemfile b/Gemfile index 57714c1..4654550 100644 --- a/Gemfile +++ b/Gemfile @@ -35,7 +35,7 @@ gem 'omniauth-bnet', '~> 2.0.0' # This gem provides a mitigation against CVE-2015-9284 gem 'omniauth-rails_csrf_protection', '~> 0.1.2' # A Ruby wrapper around Blizzard's Game Data and Profile APIs -gem 'rbattlenet', '~> 2.2.7', git: 'https://github.com/Dainii/rbattlenet' +gem 'rbattlenet', '~> 2.2.9', git: 'https://github.com/Dainii/rbattlenet' # A gem that provides Rails integration for the Sentry error logger gem 'sentry-rails', '~> 4.4.0' gem 'sentry-ruby', '~> 4.4.1' diff --git a/Gemfile.lock b/Gemfile.lock index d5d8d0e..f4d34d9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,8 +1,8 @@ GIT remote: https://github.com/Dainii/rbattlenet - revision: 6fc990a743b1cec56e95820aec9222b5ff2e843a + revision: a0492dd16f9b29b61e364009272d60e9201e1337 specs: - rbattlenet (2.2.7) + rbattlenet (2.2.9) require_all typhoeus (~> 1.1) @@ -163,7 +163,7 @@ GEM multi_xml (0.6.0) multipart-post (2.1.1) nio4r (2.5.7) - nokogiri (1.11.3-x86_64-linux) + nokogiri (1.11.6-x86_64-linux) racc (~> 1.4) oauth2 (1.4.7) faraday (>= 0.8, < 2.0) @@ -186,7 +186,7 @@ GEM orm_adapter (0.5.0) pagy (4.3.0) parallel (1.20.1) - parser (3.0.1.0) + parser (3.0.1.1) ast (~> 2.4.1) pg (1.2.3) pry (0.14.1) @@ -272,17 +272,17 @@ GEM rspec-mocks (~> 3.10) rspec-support (~> 3.10) rspec-support (3.10.2) - rubocop (1.13.0) + rubocop (1.16.0) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.2.0, < 2.0) + rubocop-ast (>= 1.7.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.4.1) - parser (>= 2.7.1.5) + rubocop-ast (1.7.0) + parser (>= 3.0.1.1) rubocop-performance (1.11.0) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) @@ -329,7 +329,7 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.2) - solargraph (0.40.4) + solargraph (0.41.1) backport (~> 1.1) benchmark bundler (>= 1.17.2) @@ -411,7 +411,7 @@ DEPENDENCIES rails (~> 6.1.3, >= 6.1.3.1) rails-erd rails-i18n (~> 6.0.0) - rbattlenet (~> 2.2.7)! + rbattlenet (~> 2.2.9)! redis (~> 4.2.5) rspec-rails rubocop diff --git a/app/assets/stylesheets/rp_world.scss b/app/assets/stylesheets/rp_world.scss new file mode 100644 index 0000000..c68ad24 --- /dev/null +++ b/app/assets/stylesheets/rp_world.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the RpWorld controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: https://sass-lang.com/ diff --git a/app/controllers/rp_worlds_controller.rb b/app/controllers/rp_worlds_controller.rb new file mode 100644 index 0000000..ed5eef5 --- /dev/null +++ b/app/controllers/rp_worlds_controller.rb @@ -0,0 +1,9 @@ +class RpWorldsController < ApplicationController + def index + @rp_worlds = RpWorld.all + end + + def show + @rp_world = RpWorld.includes(:wow_characters).find(params[:id]) + end +end diff --git a/app/helpers/rp_world_helper.rb b/app/helpers/rp_world_helper.rb new file mode 100644 index 0000000..1e02379 --- /dev/null +++ b/app/helpers/rp_world_helper.rb @@ -0,0 +1,2 @@ +module RpWorldHelper +end diff --git a/app/models/rp_world.rb b/app/models/rp_world.rb new file mode 100644 index 0000000..f600e52 --- /dev/null +++ b/app/models/rp_world.rb @@ -0,0 +1,9 @@ +class RpWorld < ApplicationRecord + belongs_to :user + alias_attribute :owner, :user + has_many :wow_character_play_rp_worlds, dependent: :destroy + has_many :wow_characters, through: :wow_character_play_rp_worlds + alias_attribute :members, :wow_characters + + validates :name, presence: true +end diff --git a/app/models/wow_character.rb b/app/models/wow_character.rb index fce4562..c5423c4 100644 --- a/app/models/wow_character.rb +++ b/app/models/wow_character.rb @@ -17,6 +17,8 @@ class WowCharacter < ApplicationRecord has_one :wow_character_medium, dependent: :destroy has_many :wow_standings, dependent: :destroy has_many :wow_reputations, through: :wow_standings + has_many :wow_character_play_rp_worlds, dependent: :destroy + has_many :rp_worlds, through: :wow_character_play_rp_worlds validates :name, presence: true validates :character_id, presence: true, uniqueness: true diff --git a/app/models/wow_character_play_rp_world.rb b/app/models/wow_character_play_rp_world.rb new file mode 100644 index 0000000..0c4742c --- /dev/null +++ b/app/models/wow_character_play_rp_world.rb @@ -0,0 +1,7 @@ +class WowCharacterPlayRpWorld < ApplicationRecord + belongs_to :wow_character + belongs_to :rp_world + + validates :status, presence: true, format: { with: /(INVITED|PENDING|PLAYING|BANNED)/ } + validates :role, presence: true, format: { with: /(PLAYER|MODERATOR|ADMIN)/ } +end diff --git a/app/models/wow_creature.rb b/app/models/wow_creature.rb new file mode 100644 index 0000000..4486363 --- /dev/null +++ b/app/models/wow_creature.rb @@ -0,0 +1,10 @@ +class WowCreature < ApplicationRecord + extend Mobility + translates :name + + belongs_to :wow_creature_family, optional: true + belongs_to :wow_creature_type, optional: true + + validates :name, presence: true + validates :creature_id, presence: true, uniqueness: true +end diff --git a/app/models/wow_creature_family.rb b/app/models/wow_creature_family.rb new file mode 100644 index 0000000..176d449 --- /dev/null +++ b/app/models/wow_creature_family.rb @@ -0,0 +1,9 @@ +class WowCreatureFamily < ApplicationRecord + extend Mobility + translates :name + + has_many :wow_creatures, dependent: :destroy + + validates :name, presence: true + validates :creature_family_id, presence: true, uniqueness: true +end diff --git a/app/models/wow_creature_type.rb b/app/models/wow_creature_type.rb new file mode 100644 index 0000000..e97ff9b --- /dev/null +++ b/app/models/wow_creature_type.rb @@ -0,0 +1,9 @@ +class WowCreatureType < ApplicationRecord + extend Mobility + translates :name + + has_many :wow_creatures, dependent: :destroy + + validates :name, presence: true + validates :creature_type_id, presence: true, uniqueness: true +end diff --git a/app/views/layouts/_navbar.html.erb b/app/views/layouts/_navbar.html.erb index a13854b..8e82f63 100644 --- a/app/views/layouts/_navbar.html.erb +++ b/app/views/layouts/_navbar.html.erb @@ -16,6 +16,9 @@ +