pfrpg_core 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: c3faf2b11ff72a3773190bbca752cb91e396e5de
4
- data.tar.gz: 27ec52012c6da8fd2268051d71267da7adf2cbeb
3
+ metadata.gz: 610d988da2ebe77fd60c1f8ad1904f26a947d8df
4
+ data.tar.gz: 4601365c45fca1f5742d52005524ae05473eaa2d
5
5
  SHA512:
6
- metadata.gz: db46185a206aa149283d6019a98f5399cf1037139a0cabc69a32fc83496cf6afcff58b4b980b105d2be5ea06539c1f16139180fa6a099efce1d50146305f4837
7
- data.tar.gz: 887e030f4931acbab944cbb93eb1b23792b39f03a224cc3717a575aeee62592a49fe00ddb3f13a9d85d9f78a7a1300d44a9b6018e14bada54b6bc6fe5f97f6b7
6
+ metadata.gz: a21797c54385926b80bab3fad41628ce71ab8579b7eb29d7cd20fcc94cb9ac49cbb0a0cb112d9f241ad3f95c878ed208161995ec548e7d63ce9d306818b93ab8
7
+ data.tar.gz: eb5788cf0fef4992fff0f257a19ddee691d527bce3c09ab257b1ce07c2d33b3b5c6a703b594de8e3ed18d3411106e2528ba286118bc520c3772adbfaada23456
@@ -27,5 +27,14 @@ module PfrpgCore
27
27
  name: @name
28
28
  }
29
29
  end
30
+
31
+
32
+ def self.granted_feature(feature_name, class_name)
33
+ c = PfrpgClasses::Heroclass.by_name(class_name)
34
+ f = Object::const_get("#{c.feature_type}").new()
35
+ f.ability_name = feature_name
36
+ f.class_name = class_name
37
+ f
38
+ end
30
39
  end
31
40
  end
@@ -5,7 +5,7 @@ module PfrpgCore
5
5
  def level_string
6
6
  str = "#{@alignment} :"
7
7
  @levels.each do |l|
8
- str += "#{l.name}/#{l.rank}"
8
+ str += "#{l.classname}/#{l.rank}"
9
9
  str += "*" if l.favored
10
10
  end
11
11
  str
@@ -97,7 +97,7 @@ module PfrpgCore
97
97
  def misc_json
98
98
  {
99
99
  :initiative => initiative,
100
- :alignment => @alignment,
100
+ :alignment => @alignment.alignment,
101
101
  :speed => speed,
102
102
  :hit_points => hit_points,
103
103
  :feats => @feats,
@@ -32,7 +32,7 @@ module PfrpgCore
32
32
  end
33
33
 
34
34
  def prereq_check(entity, feat)
35
- prereqs = Prerequisite.load(feat.prereq_code)
35
+ prereqs = PfrpgUtility::Prerequisite.load(feat.prereq_code)
36
36
  prereqs.all? { |x| x.match(entity) }
37
37
  end
38
38
 
@@ -3,7 +3,8 @@ module PfrpgCore
3
3
  attr_reader :entity, :levels
4
4
  def initialize(entity)
5
5
  @entity = entity
6
- @levels = PfrpgCore::LevelParser.new(entity.level)
6
+ @levels = entity.levels
7
+ @total_level = levels.inject(0) { |sum, x| sum + x.rank }
7
8
  end
8
9
 
9
10
  def total
@@ -11,16 +12,16 @@ module PfrpgCore
11
12
  end
12
13
 
13
14
  def level_granted
14
- i = (1..levels.total).inject(0) do |sum, x|
15
+ i = (1..@total_level).inject(0) do |sum, x|
15
16
  choices = PfrpgTables::Tables::LevelTable.for_level(x)[:choices]
16
- sum = sum + (choices.select { |c| choice_is_feat(c) }).size
17
+ sum + (choices.select { |c| choice_is_feat(c) }).size
17
18
  end
18
19
  return i
19
20
  end
20
21
 
21
22
  def race_granted
22
23
  i = entity.race.bonus_choices.inject(0) do |sum, x|
23
- sum = sum + 1 if choice_is_feat(x)
24
+ sum + 1 if choice_is_feat(x)
24
25
  end
25
26
  return i
26
27
  end
@@ -29,7 +30,7 @@ module PfrpgCore
29
30
  i = entity.class_features.inject(0) do |sum, x|
30
31
  if x.respond_to? 'granted_choice'
31
32
  choices = [x.granted_choice].flatten
32
- sum += (choices.select { |c| choice_is_feat(c) }).size
33
+ sum + (choices.select { |c| choice_is_feat(c) }).size
33
34
  end
34
35
  end
35
36
  return i || 0
@@ -37,14 +38,13 @@ module PfrpgCore
37
38
 
38
39
  def choice_granted
39
40
  choices = []
40
- lvls = @levels.parse
41
- lvls.keys.each do |hc|
42
- clazz = PfrpgClasses::Heroclass.by_name(hc)
43
- level = lvls[hc]
44
- (1..level).each do |l|
41
+ @levels.each do |level|
42
+ clazz = PfrpgClasses::Heroclass.by_name(level.classname)
43
+ (1..level.rank).each do |l|
45
44
  clazz.bonuses_for_level(l)[:choices].each do |choice|
46
45
  if (choice_is_feat(choice))
47
- choice.npc_id = entity.id
46
+ #TODO : this wont support another object
47
+ choice.npc_id = entity.character_id
48
48
  choices << choice
49
49
  end
50
50
  end
@@ -54,8 +54,8 @@ module PfrpgCore
54
54
 
55
55
  def as_json(options={})
56
56
  {
57
- equipment: get_equipment,
58
- inventory: get_inventory
57
+ equipment: equipment,
58
+ inventory: inventory
59
59
  }
60
60
  end
61
61
  end
@@ -1,3 +1,3 @@
1
1
  module PfrpgCore
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -1,8 +1,10 @@
1
1
  require 'minitest/autorun'
2
2
  require 'pfrpg_utility'
3
3
  require 'pfrpg_core'
4
+ require_relative './test_helper'
4
5
 
5
6
  class FeatTotalerTest < Minitest::Test
7
+ include TestHelper
6
8
 
7
9
  MockFeat = Struct.new(:name) do
8
10
  def prereq_code
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pfrpg_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan OMara