arkaan 1.9.0 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e70b9b135c0ac5b57d31e26c224937b2ed9ca69bd902f10f2cc4f7c2bddd339f
4
- data.tar.gz: 61b68c995672ff514cecf8c022a30e9231c05e9f5ed55b468e17fe528068d3a6
3
+ metadata.gz: c3f79b8da492a5bfaf83581bd87a361d6037294f185ce6c2f2287f1d2a65b0e7
4
+ data.tar.gz: fc6f180aff359447096bbda6b5b7014c0b87de9f448d536024eac852a8581954
5
5
  SHA512:
6
- metadata.gz: 94729cac55877bb9da88d9d4a7824ff99158480fe16afe1e2eee6f4732e64039ddce67fbbcef74b6f943c88b1e1ea0b88e6568955e58d22541d6c8b6365a1047
7
- data.tar.gz: 0b83a9933b47a4c47285c50bcb9aa87288e0a449068d3ae17b901497148d8998fd71a13bcfc1ecff40466df10b810ddc0b5ada68d72f1d329a465d9c49a7bd9a
6
+ metadata.gz: 6dfb33ab03f87d8a8b8dadffa1c3ed4111924eb23c3cfb97863a3cfa104cae4f98ff4167b3c2aef0d88456db78d04ea13dad69c3e046aadf3e04259e3c4ec2ee
7
+ data.tar.gz: 99db55a4ae62a79d4c5aaab2f3922b30db0455aafa3083255ebd6be60f912c473c8d1445183b8d803b6bd4fba0ce7f501b3dfb5e5f0c77c69fc7c1df84db104c
@@ -25,6 +25,5 @@ module Arkaan
25
25
  autoload :Permissions , 'arkaan/permissions'
26
26
  autoload :Phone , 'arkaan/phone'
27
27
  autoload :Ruleset , 'arkaan/ruleset'
28
- autoload :Rulesets , 'arkaan/rulesets'
29
28
  autoload :Utils , 'arkaan/utils'
30
29
  end
@@ -5,16 +5,16 @@ module Arkaan
5
5
  class Character
6
6
  include Mongoid::Document
7
7
  include Mongoid::Timestamps
8
- include Arkaan::Concerns::MimeTypable
9
- include Arkaan::Campaigns::Files::Concerns::Nameable
10
8
 
11
9
  # @!attribute [rw] selected
12
10
  # @return [Boolean] TRUE if the sheet is currently selected by the player, FALSE otherwise.
13
11
  field :selected, type: Boolean, default: false
14
- # @!attribute [rw] mime_type
15
- # @return [String] the mime_type of the character sheet, MUST be an authorized MIME type for
16
- # the ruleset the campaign is set to be in.
17
- mime_type :available_mime_types
12
+
13
+ # @!attribute [rw] data
14
+ # @return [Hash] the heart of the Arkaan::Campaigns::Character class, the polymorphic
15
+ # data representing all the fields of a character sheet are validated using the validator
16
+ # of the associated plugin, and created/updated with the corresponding form.
17
+ field :data, type: Hash, default: {}
18
18
 
19
19
  # @!attribute [rw] invitation
20
20
  # @return [Arkaan::Campaigns::Invitation] the invitation of the player playing this character.
@@ -26,13 +26,6 @@ module Arkaan
26
26
  invitation.account
27
27
  end
28
28
 
29
- # Method used to dinamically determine what MIME types are allowed for this character sheet
30
- # If the campaign this character is in has no ruleset, every MIME type is allowed.
31
- # @return [Array<String>] the available MIME type for the campaign linked to this character.
32
- def available_mime_types
33
- invitation.campaign.ruleset.mime_types
34
- end
35
-
36
29
  def campaign
37
30
  invitation.campaign
38
31
  end
@@ -18,15 +18,9 @@ module Arkaan
18
18
  # @!attribute [rw] creator
19
19
  # @return [Arkaan::Account] the account of the user creating this ruleset.
20
20
  belongs_to :creator, class_name: 'Arkaan::Account', inverse_of: :rulesets
21
- # @!attribute [rw] blueprints
22
- # @return [Arr ay<Arkaan::Rulesets::Blueprint>] the blueprints created inside this ruleset, see the class itself to know what it is.
23
- has_many :blueprints, class_name: 'Arkaan::Rulesets::Blueprint', inverse_of: :ruleset
24
21
  # @!attribute [rw] campaigns
25
22
  # @return [Array<Arkaan::Campaign>] the campaigns using this set of rules.
26
23
  has_many :campaigns, class_name: 'Arkaan::Campaign', inverse_of: :ruleset
27
- # @!attribute [rw] sheet
28
- # @return [Arkaan::Rulesets::Sheet] the character sheet template for this set of rules.
29
- has_one :sheet, class_name: 'Arkaan::Rulesets::Sheet', inverse_of: :ruleset
30
24
 
31
25
  validates :name,
32
26
  presence: {message: 'required'},
@@ -1,3 +1,3 @@
1
1
  module Arkaan
2
- VERSION = '1.9.0'
2
+ VERSION = '1.10.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arkaan
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Courtois
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-11 00:00:00.000000000 Z
11
+ date: 2019-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -350,16 +350,6 @@ files:
350
350
  - lib/arkaan/permissions/right.rb
351
351
  - lib/arkaan/phone.rb
352
352
  - lib/arkaan/ruleset.rb
353
- - lib/arkaan/rulesets.rb
354
- - lib/arkaan/rulesets/blueprint.rb
355
- - lib/arkaan/rulesets/field.rb
356
- - lib/arkaan/rulesets/fields.rb
357
- - lib/arkaan/rulesets/fields/gauge.rb
358
- - lib/arkaan/rulesets/fields/integer.rb
359
- - lib/arkaan/rulesets/sheet.rb
360
- - lib/arkaan/rulesets/sheets.rb
361
- - lib/arkaan/rulesets/sheets/attribute.rb
362
- - lib/arkaan/rulesets/sheets/category.rb
363
353
  - lib/arkaan/specs.rb
364
354
  - lib/arkaan/utils.rb
365
355
  - lib/arkaan/utils/controllers.rb
@@ -1,13 +0,0 @@
1
- module Arkaan
2
- # The rulesets module holds all the logic for components present inside a ruleset.
3
- # @author Vincent Courtois <courtois.vincent@outlook.com>
4
- module Rulesets
5
- autoload :Blueprint, 'arkaan/rulesets/blueprint'
6
- autoload :Field , 'arkaan/rulesets/field'
7
- autoload :Fields , 'arkaan/rulesets/fields'
8
- autoload :Gauge , 'arkaan/rulesets/gauge'
9
- autoload :Integer , 'arkaan/rulesets/integer'
10
- autoload :Sheet , 'arkaan/rulesets/sheet'
11
- autoload :Sheets , 'arkaan/rulesets/sheets'
12
- end
13
- end
@@ -1,34 +0,0 @@
1
- module Arkaan
2
- module Rulesets
3
- # A blueprint defines what a type of entity contains.
4
- # @author Vincent Courtois <courtois.vincent@outlook.com>
5
- class Blueprint
6
- include Mongoid::Document
7
- include Mongoid::Timestamps
8
-
9
- # @!attribute [rw] name
10
- # @return [String] the name of this type of entity in the ruleset.
11
- field :name, type: String
12
-
13
- # @!attribute [rw] ruleset
14
- # @return [Arkaan::Ruleset] the ruleset to which this blueprint belongs.
15
- belongs_to :ruleset, class_name: 'Arkaan::Ruleset', inverse_of: :blueprints
16
- # @!attribute [rw] _fields
17
- # @return [Array<Arkaan::Rulesets::Field>] the field composing the attributes of this blueprint.
18
- embeds_many :_fields, class_name: 'Arkaan::Rulesets::Field', inverse_of: :blueprint
19
-
20
- validates :name,
21
- presence: {message: 'required'},
22
- length: {minimum: 4, message: 'minlength', if: :name?}
23
-
24
- validate :name_unicity
25
-
26
- def name_unicity
27
- has_duplicate = ruleset.blueprints.where(:_id.ne => _id, name: name).exists?
28
- if !ruleset.nil? && name? && has_duplicate
29
- errors.add(:name, 'uniq')
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,71 +0,0 @@
1
- module Arkaan
2
- module Rulesets
3
- # A field is an attribute of a blueprint, with a type and a name.
4
- # It does not have a defined value as it will be given in the instance of the blueprint.
5
- # @author Vincent Courtois <courtois.vincent@outlook.com>
6
- class Field
7
- include Mongoid::Document
8
- include Mongoid::Timestamps
9
- include Arkaan::Concerns::Enumerable
10
-
11
- # @!attribute [rw] name
12
- # @return [String] the name of the field is comparable to the name of a variable.
13
- field :name, type: String
14
- # @!attribute [rw] data
15
- # @return [Hash] the additional data, mainly constraints and needed values, for the field.
16
- field :data, type: Hash, default: {}
17
-
18
- # @!attribute [rw] blueprint
19
- # @return [Arkaan::Rulesets::Blueprint] the blueprint in which the field belongs.
20
- embedded_in :blueprint, class_name: 'Arkaan::Rulesets::Blueprint', inverse_of: :_fields
21
-
22
- validates :name,
23
- presence: {message: 'required'},
24
- length: {minimum: 4, message: 'minlength', if: :name?},
25
- format: {with: /\A[a-zA-Z_]*\z/, message: 'pattern', if: :name?}
26
-
27
- validate :name_unicity
28
-
29
- validate :options_validity
30
-
31
- # Getter for the type of the field, returning simply the last element of the type for simpler use.
32
- # @return [Symbol] the name of the type of the field (eq :Integer or :Gauge)
33
- def type
34
- return _type.split('::').last.to_sym
35
- end
36
-
37
- # Default options for this type of field, specialize it in the subclasses.
38
- # @return [Hash] a hash with the default value for all options you want default values on.
39
- def default_options
40
- return {}
41
- end
42
-
43
- # Setter for the additional datas, merging it with the default options for the current type.
44
- # @param new_data [Hash] the additional data to add to this field.
45
- def data=(new_data)
46
- self[:data] = default_options.merge(new_data)
47
- end
48
-
49
- def name_unicity
50
- has_duplicate = blueprint._fields.where(:_id.ne => _id, name: name).exists?
51
- if name? && blueprint && has_duplicate
52
- errors.add(:name, 'uniq')
53
- end
54
- end
55
-
56
- def options_validity
57
- send(:validate_options) rescue true
58
- end
59
-
60
- # Checks the corresponding option key against the given data type. All types can be used.
61
- # @param key [String] the name of the key in the options you want to check the type of.
62
- # @param required_type [String] the exact name of the class you want to check the option against.
63
- def check_type(key, required_type)
64
- parsed_type = Object.const_get("::#{required_type}")
65
- if !errors.messages.has_key?(:data) && data[key.to_sym] && !data[key.to_sym].is_a?(parsed_type)
66
- errors.add(:data, "#{key.to_s}|type")
67
- end
68
- end
69
- end
70
- end
71
- end
@@ -1,10 +0,0 @@
1
- module Arkaan
2
- module Rulesets
3
- # This module holds all the classes for the different fields types in the blueprints.
4
- # @author Vincent Courtois <courtois.vincent@outlook.com>
5
- module Fields
6
- autoload :Gauge , 'arkaan/rulesets/fields/gauge'
7
- autoload :Integer, 'arkaan/rulesets/fields/integer'
8
- end
9
- end
10
- end
@@ -1,20 +0,0 @@
1
- module Arkaan
2
- module Rulesets
3
- module Fields
4
- # A gauge is composed of a max value, and a min value, and when instanciated has a current value that can't go above max or below min.
5
- # @author Vincent Courtois <courtois.vincent@outlook.com>
6
- class Gauge < Arkaan::Rulesets::Field
7
- def default_options
8
- return {initial: 0, max: 100, min: 0, show: true}
9
- end
10
-
11
- def validate_options
12
- check_type(:initial, 'Integer')
13
- check_type(:max, 'Integer')
14
- check_type(:min, 'Integer')
15
- check_type(:show, 'Boolean')
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,14 +0,0 @@
1
- module Arkaan
2
- module Rulesets
3
- module Fields
4
- # An integer field can have a minimum and maximum value.
5
- # @author Vincent Courtois <courtois.vincent@outlook.com>
6
- class Integer < Arkaan::Rulesets::Field
7
- def validate_options
8
- check_type(:max, 'Integer')
9
- check_type(:min, 'Integer')
10
- end
11
- end
12
- end
13
- end
14
- end
@@ -1,28 +0,0 @@
1
- module Arkaan
2
- module Rulesets
3
- # A character sheet is the templating to parse and transform an uploaded
4
- # XML file into a readable character sheet we can display on the interface.
5
- # The main way to do it is to create attributes sorted into categories (optional)
6
- # and to link each of these attributes to a XPath selector in the XML sheet
7
- # the game master uploaded and linked to the player.
8
- #
9
- # This way we can just rebuild a JSON object with the categories and fields
10
- # defined in the sheet, extracted from the XML sheet of the character.
11
- #
12
- # @author Vincent Courtois <courtois.vincent@outlook.com>
13
- class Sheet
14
- include Mongoid::Document
15
- include Mongoid::Timestamps
16
-
17
- # @!attribute [rw] ruleset
18
- # @return [Arkaan::Ruleset] the set of rules this sheet corresponds to.
19
- belongs_to :ruleset, class_name: 'Arkaan::Ruleset', inverse_of: :sheet
20
- # @!attribute [rw] creator
21
- # @return [Arkaan::Account] the account of the creator of the sheet.
22
- belongs_to :creator, class_name: 'Arkaan::Account'
23
- # @!attribute [rw] categories
24
- # @return [Array<Arkaan::Rulesets::Sheets::Category>] the categories declared in this sheet.
25
- embeds_many :categories, class_name: 'Arkaan::Rulesets::Sheets::Category', inverse_of: :sheet
26
- end
27
- end
28
- end
@@ -1,10 +0,0 @@
1
- module Arkaan
2
- module Rulesets
3
- # This module regroups the entities embedded in a character sheet template.
4
- # @author Vincent Courtois <courtois.vincent@outlook.com>
5
- module Sheets
6
- autoload :Attribute, 'arkaan/rulesets/sheets/attribute'
7
- autoload :Category , 'arkaan/rulesets/sheets/category'
8
- end
9
- end
10
- end
@@ -1,40 +0,0 @@
1
- module Arkaan
2
- module Rulesets
3
- module Sheets
4
- class Attribute
5
- include Mongoid::Document
6
- include Mongoid::Timestamps
7
- include Arkaan::Concerns::Enumerable
8
-
9
- # @!attribute [rw] name
10
- # @return [String] the name of the attribute in the character sheet.
11
- # This name is then used in the translation files as a key to retrieve it.
12
- field :name, type: String, default: ''
13
- # @!attribute [rw] default
14
- # @return [Object] the default value for this attribute. Not typed so it
15
- # can be any type of value (mainly integer, strings or datetimes)
16
- field :default
17
- # @!attribute [rw] xpath
18
- # @return [String] the path to find this attribute in the XML sheet uploaded.
19
- field :xpath, type: String
20
-
21
- # @!attribute [rw] category
22
- # @return [Arkaan::Rulesets::Sheets::Category] the category the attribute is in.
23
- embedded_in :category, class_name: 'Arkaan::Rulesets::Sheets::Category', inverse_of: :attrs
24
-
25
- validates :name,
26
- presence: {message: 'required'},
27
- format: {with: /\A[a-zA-Z_]*\z/, message: 'pattern', if: :name?}
28
-
29
- validate :name_unicity
30
-
31
- def name_unicity
32
- has_duplicate = category.attrs.where(:_id.ne => _id, name: name).exists?
33
- if name? && category && has_duplicate
34
- errors.add(:name, 'uniq')
35
- end
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,25 +0,0 @@
1
- module Arkaan
2
- module Rulesets
3
- module Sheets
4
- # A category is just a semantic group of attributes having the same function
5
- # or sharing some semantic proximity (eg. all characteristics or skills).
6
- # @author Vincent Courtois <courtois.vincent@outlook.com>
7
- class Category
8
- include Mongoid::Document
9
- include Mongoid::Timestamps
10
-
11
- # @!attribute [rw] name
12
- # @return [String] the name of the category you're creating.
13
- field :name, type: String, default: ''
14
-
15
- # @!attribute [rw] sheet
16
- # @return [Arkaan::Rulesets::Sheet] the sheet template the category is embedded in;
17
- embedded_in :sheet, class_name: 'Arkaan::Rulesets::Sheet', inverse_of: :categories
18
-
19
- # @!attribute [rw] attributes
20
- # @return [Array<Arkaan::Rulesets::Sheets::Attribute>] the attributes linked to this category.
21
- embeds_many :attrs, class_name: 'Arkaan::Rulesets::Sheets::Attribute', inverse_of: :category
22
- end
23
- end
24
- end
25
- end