Module: GamesAndRpgParadise::Gamebook::LoneWolf::Statistics

Defined in:
lib/games_and_rpg_paradise/gamebooks/lone_wolf/statistics.rb

Overview

GamesAndRpgParadise::Gamebook::LoneWolf::Statistics

Class Method Summary collapse

Class Method Details

.candidate_entries?Boolean

#

GamesAndRpgParadise::Gamebook::LoneWolf::Statistics.candidate_entries?

#

Returns:

  • (Boolean)


37
38
39
40
41
42
# File 'lib/games_and_rpg_paradise/gamebooks/lone_wolf/statistics.rb', line 37

def self.candidate_entries?
  return Dir[
           GamesAndRpgParadise.project_base_dir?+
           'yaml/gamebooks/lone_wolf*/**.yml'
         ].reject {|entry| entry.end_with?('config.yml') }
end

.e(i = '') ⇒ Object

#

GamesAndRpgParadise::Gamebook::LoneWolf::Statistics.e

#


30
31
32
# File 'lib/games_and_rpg_paradise/gamebooks/lone_wolf/statistics.rb', line 30

def self.e(i = '')
  puts i
end

.report_everythingObject

#

GamesAndRpgParadise::Gamebook::LoneWolf::Statistics.report_everything

This is currently unfinished. It is supposed to give a LOT of information pertaining to the lone wolf gamebooks series.

#


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/games_and_rpg_paradise/gamebooks/lone_wolf/statistics.rb', line 50

def self.report_everything
  require 'colours'
  e
  candidate_entries?.each {|this_file|
    n_images = 0
    n_dead_exits = 0
    _ = GamesAndRpgParadise::Gamebooks.load_dataset(this_file)
    _ = _.first if _.is_a? Array
    n_combat_encounters = 0
    if _
      _.each_pair {|a, inner_hash|
        images  = inner_hash['image']
        if images and !images.empty?
          n_images += 1
        end
        exits   = inner_hash['exits']
        if exits.nil?
          e "#{rev}A nil-value was found in the file #{::Colours.sfile(this_file)}#{rev}."
          e "#{rev}The flawed entry was at #{::Colours.steelblue(a.to_s)}"
          e rev+'This is currently not encouraged, but this class will '\
            'continue nonetheless.'
          e
          # e 'The inner hash will next be shown as well:'
          # e
          # e '='*80
          # pp inner_hash
          # e '='*80
        end
        if exits
          first_exit_key = exits.keys.first if exits.respond_to?(:keys)
          if first_exit_key == 'fin' # For instance. fin: | Your journey has come to an end.
            n_dead_exits += 1
          end
        end
        content = inner_hash['content']
        # ================================================================= #
        # Count only entries that have the substring 'COMBAT SKILL: '
        # ================================================================= #
        if content and content.include?('COMBAT SKILL: ')
          n_combat_encounters += 1
        end
      }
      shortened_filename = this_file.to_s
      if shortened_filename.include? '/'
        shortened_filename = shortened_filename.split('/')[-2 .. -1].join('/')
      end
      result = rev+'  '+
        ::Colours.steelblue(n_combat_encounters.to_s.rjust(2))+
        rev+
        ' combat encounters for '+
        ::Colours.lightgreen(shortened_filename)+
        rev+
        '. '+n_dead_exits.to_s+
        rev+
        ' dead exits exist for this gamebook'.dup
       if n_images and (n_images > 0)
         result << ' as well as '+n_images.to_s+' images'
       end
       result << '.'
       e result
    end
  }
  e
end

.revObject

#

GamesAndRpgParadise::Gamebook::LoneWolf::Statistics.rev

#


23
24
25
# File 'lib/games_and_rpg_paradise/gamebooks/lone_wolf/statistics.rb', line 23

def self.rev
  ::Colours.rev
end