wayfinder 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/wayfinder +300 -0
  3. data/lib/wayfinder.rb +147 -0
  4. metadata +77 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 04e0689646c906a8aeaa97be76dce05d711a74e1
4
+ data.tar.gz: 6ab236a77d2786b759654631d85f834ed551886c
5
+ SHA512:
6
+ metadata.gz: 6e06774be9d859c2fe54f3d1af22ec55995ff472fcd52dce7d13af78787df1b59fb8dcc3468a9e0c948209dfcc3cf491308ce174e13bc280d702a269f39db43d
7
+ data.tar.gz: edb60f0c7417529f9270d36dac1d69115df449b1df01c7fe6212a17a0c30ff2b83e1cb0f72a8f9f31763df76941a9950be1d486cd3bf5790db86f94ba6c4d25d
data/bin/wayfinder ADDED
@@ -0,0 +1,300 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'box'
4
+ require 'yaml'
5
+ require 'mote'
6
+ require 'wayfinder'
7
+
8
+ source_data = {}
9
+ %i(meta stats gear feats buffs skills).each do |source_file|
10
+ source_data[source_file] = YAML.load_file("#{ source_file.to_s }.yml")
11
+ end
12
+
13
+ character = Wayfinder::Character.new(source_data)
14
+ template = Mote.parse(Box::FILES['character_sheet.htm'],
15
+ self,
16
+ [:character]
17
+ )
18
+
19
+ File.open('character_sheet.htm', 'w') do |f|
20
+ f.write(template.call(character: character))
21
+ end
22
+
23
+ __END__
24
+ @@ character_sheet.htm
25
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
26
+ <html>
27
+ <head>
28
+ <meta http-equiv="content-type" content="text-html; charset=utf-8" />
29
+ <title>Unnamed 1 [0 Points]</title>
30
+ <style type="text/css">
31
+ .font4 { font-family: Arial; font-size:4pt; }
32
+ .font5 { font-family: Arial; font-size:5pt; }
33
+ .font6 { font-family: Arial; font-size:6pt; }
34
+ .font7 { font-family: Arial; font-size:7pt; }
35
+ .font8 { font-family: Arial; font-size:8pt; }
36
+ .font9 { font-family: Arial; font-size:9pt; }
37
+ .h { font-family: Arial; font-size:8pt; vertical-align: bottom; }
38
+ .hs { font-family: Arial; font-size:6pt; border-top-width:1px; border-top: 1pt solid black; vertical-align:top; background: #CCCCCC; }
39
+ .ah { font-family: Arial; font-size:4pt; text-align:center; }
40
+ .ab { font-family: Arial; font-size:10pt; text-align:center; color:white; background:black; }
41
+ .sc { font-family: Arial; font-size: 5pt }
42
+ .scr { font-family: Arial; font-size: 5pt; text-align:right }
43
+ .scbr { font-family: Arial; font-size: 5pt; border-right-width:1px; border-right: 1pt solid black; text-align:right}
44
+ .hph { font-family: Arial; font-size: 7pt; text-align:center; vertical-align:bottom;}
45
+ .ach { font-family: Arial; font-size: 7pt; text-align:center; vertical-align:middle;}
46
+ .acb { font-family: Arial; font-size: 9pt; font-weight:bold; text-align:center; vertical-align:middle; border: 1px solid black;}
47
+ .hphs { font-family: Arial; font-size: 5pt; text-align:center; vertical-align:bottom;}
48
+ .hpb { font-family: Arial; font-size: 9pt; font-weight:bold; text-align:center; vertical-align:middle; border: 1px solid black;}
49
+ .hpbb { font-family: Arial; font-size: 9pt; font-weight:bold; color:white; background:black; text-align:center; vertical-align:middle; border: 1px solid black;}
50
+ .abb { font-family: Arial; font-size:10pt; text-align:center; font-weight:bold; border: 1px solid black;}
51
+ .abt { font-family: Arial; font-size:10pt; text-align:center; font-weight:bold; border: 5px solid lightgray;}
52
+ .sptab { font-family: Arial; vertical-align:top;border: 1px solid black; text-align:center;font-size:8pt;}
53
+ .spname { font-family: Arial; vertical-align:top;border: 1px solid black; text-align:left;font-size:8pt;}
54
+ .sptop { font-family: Arial; vertical-align:top;border: 1px solid black; text-align:center;font-size:8pt; color:white;}
55
+ .splevel { font-family: Arial; background:black; text-align:center;font-size:9pt; color:white;}
56
+ .sphead { font-family: Arial; background:black; text-align:center;font-size:12pt; color:white;}
57
+ .spcomp { font-family: Arial; vertical-align:top; text-align:left;font-size:6pt;}
58
+ .spcomp2 { font-family: Arial; vertical-align:top; text-align:left;font-size:5pt;}
59
+ .spcomp3 { font-family: Arial; vertical-align:top; text-align:left;font-size:9pt;}
60
+ .topline {
61
+ border-top-width:1px;
62
+ border-top: 1pt solid black;
63
+ font-family: Arial;
64
+ font-size:6pt;
65
+ }
66
+ .border {
67
+ border: 1px solid black;
68
+ }
69
+ .border7 {
70
+ border: 1px solid black;
71
+ font-size:7pt;
72
+ }
73
+ .border8 {
74
+ border: 1px solid black;
75
+ font-size:8pt;
76
+ }
77
+ .border9 {
78
+ border: 1px solid black;
79
+ font-size:9pt;
80
+ }
81
+ .border10 {
82
+ border: 1px solid black;
83
+ }
84
+ .tempborder {
85
+ font-size:10pt; border: 5px solid lightgray;
86
+ }
87
+ .borderbottom {
88
+ border-bottom-width:1px;
89
+ border-bottom: 1pt solid black;
90
+ }
91
+ .borderright {
92
+ border-right-width:1px;
93
+ border-right: 1pt solid black;
94
+ }
95
+ .c, .wbc {
96
+ text-align: center;
97
+ }
98
+ TD {
99
+ font-family: Arial
100
+ }
101
+ span.notes p {margin-top:0; margin-bottom:0;}
102
+ </style>
103
+ </head>
104
+ <body bgcolor="white">
105
+ <table border="0" cellpadding="0" cellspacing="0" width="100%" summary="Master Page Table">
106
+ <tr>
107
+ <td rowspan="2" valign="top">
108
+ <!-- START Abilities Table -->
109
+ <table summary="Ability Table">
110
+ <tr>
111
+ <td align="center" width="20%" class="font4">ABILITY<br />NAME</td>
112
+ <td align="center" width="20%" class="font4">ABILITY<br />SCORE</td>
113
+ <td align="center" width="20%" class="font4">ABILITY<br />MODIFIER</td>
114
+ </tr>
115
+ <tr>
116
+ <td class="ab"><b>STR</b><font style="font-size:5pt"><br />Strength</font></td>
117
+ <td class="abb">{{ character.strength }}</td>
118
+ <td class="abb">{{ character.strength_modifier }}</td>
119
+ </tr>
120
+ <tr>
121
+ <td class="ab"><b>DEX</b><font style="font-size:5pt"><br />Dexterity</font></td>
122
+ <td class="abb">{{ character.dexterity }}</td>
123
+ <td class="abb">{{ character.dexterity_modifier }}</td>
124
+ </tr>
125
+ <tr>
126
+ <td class="ab"><b>CON</b><font style="font-size:5pt"><br />Constitution</font></td>
127
+ <td class="abb">{{ character.constitution }}</td>
128
+ <td class="abb">{{ character.constitution_modifier }}</td>
129
+ </tr>
130
+ <tr>
131
+ <td class="ab"><b>INT</b><font style="font-size:5pt"><br />Intelligence</font></td>
132
+ <td class="abb">{{ character.intelligence }}</td>
133
+ <td class="abb">{{ character.intelligence_modifier }}</td>
134
+ </tr>
135
+ <tr>
136
+ <td class="ab"><b>WIS</b><font style="font-size:5pt"><br />Wisdom</font></td>
137
+ <td class="abb">{{ character.wisdom }}</td>
138
+ <td class="abb">{{ character.wisdom_modifier }}</td>
139
+ </tr>
140
+ <tr>
141
+ <td class="ab"><b>CHA</b><font style="font-size:5pt"><br />Charisma</font></td>
142
+ <td class="abb">{{ character.charisma }}</td>
143
+ <td class="abb">{{ character.charisma_modifier }}</td>
144
+ </tr>
145
+ </table>
146
+ <!-- STOP Abilities Table -->
147
+
148
+ </td>
149
+ <td colspan="2" valign="top">
150
+
151
+ <!-- START Hit point Table -->
152
+ <table summary="HP Table">
153
+ <tr>
154
+ <td align="center" width="50"></td>
155
+ <td align="center" width="25" valign="bottom"></td>
156
+ <td align="center"></td>
157
+ <td align="center" width="119" class="font5"><br />WOUNDS/CURRENT HP</td>
158
+ <td align="center"></td>
159
+ <td align="center" width="60" class="font5"><br />DAMAGE<br />REDUCTION</td>
160
+ <td align="center"></td>
161
+ <td align="center" width="60" class="font5"><br />SPEED</td>
162
+ </tr>
163
+ <tr>
164
+ <td align="center" bgcolor="black"><font style="font-size:9pt" color="white"><b>HP</b></font><font style="font-size:5pt" color="white"><br />Hit Points</font></td>
165
+ <td align="center" class="border9"><b>{{ character.hp }}</b></td>
166
+ <td align="center" class="font7"><br /></td>
167
+ <td align="center" class="border9">{{ character.received_damage }}<br /></td>
168
+ <td align="center" class="font7"><br /></td>
169
+ <td align="center" class="border9"><b>&nbsp;&nbsp;</b></td>
170
+ <td align="center" class="font7"><br /></td>
171
+ <td align="center" class="border9"><b><br /></b></td>
172
+ </tr>
173
+ </table>
174
+ <!-- STOP Hit point Table -->
175
+ <!-- START AC Table -->
176
+ <table summary="AC Table">
177
+ <tr>
178
+ <td align="center" bgcolor="black"><font style="font-size:9pt" color="white"><b>AC</b></font><font style="font-size:5pt" color="white"><br />Armour Class</font></td>
179
+ <!-- Thomas Behr 13-02-02: replaced old tokens with new ones -->
180
+ <td align="center" class="border9"><b>{{ character.ac }}</b></td>
181
+ </tr>
182
+ <tr>
183
+ <td align="center" width="50"></td>
184
+ </tr>
185
+ </table>
186
+ <!-- STOP AC Table -->
187
+ </td>
188
+ </tr>
189
+ <tr>
190
+ <td valign="top">
191
+ <!-- START Initiative Table -->
192
+ <table width="35%" summary="Initiative Table">
193
+ <tr>
194
+ <td align="center" bgcolor="black"><font style="font-size:9pt" color="white"><b>INITIATIVE</b></font><font style="font-size:5pt" color="white"><br />Modifier</font></td>
195
+ <td align="center" class="border9"><b>{{ character.initiative }}</b></td>
196
+ </tr>
197
+ <tr>
198
+ </tr>
199
+ </table>
200
+ <!-- STOP Initiative Table -->
201
+ <!-- START Base Attack Table -->
202
+ <table width="100%" summary="Base Attack Table">
203
+ <tr>
204
+ <td align="center" bgcolor="black"><font style="font-size:9pt" color="white"><b>BASE ATTACK</b></font><font style="font-size:5pt" color="white"><br />Bonus</font></td>
205
+ <td align="center" width="94" class="border10"><b>{{ character.bab }} <br /></b></td>
206
+ <td align="center" width="50%"><br /></td>
207
+ </tr>
208
+ </table>
209
+ <!-- STOP Base Attack Table -->
210
+ </td>
211
+ <td rowspan="2" valign="top" width="50%">
212
+
213
+ <!-- STOP PSI Power Points Table -->
214
+ <!-- START Skills Table -->
215
+ <table cellpadding="0" cellspacing="0" border="0" width="100%" summary="Skills Table">
216
+ <tr>
217
+ <td colspan="3" bgcolor="black" align="center"><font style="font-size: 9pt" color="white"><b>SKILLS</b></font>
218
+ </td>
219
+ </tr>
220
+ <tr>
221
+ <td align="left" class="border" valign="top">
222
+ <table cellpadding="0" cellspacing="0" border="0" width="100%" summary="Skills Table">
223
+ <tr><td align="left" class="borderbottom"><font style="font-size: 5pt">&nbsp;Name</font></td><td align="left" class="borderbottom"><font style="font-size: 5pt">Abb</font></td><td align="right" class="borderbottom"><font style="font-size: 5pt">Rnk</font></td><td align="right" class="borderbottom"><font style="font-size: 5pt">Tot&nbsp;</font></td><td align="left" class="borderbottom"><font style="font-size: 5pt">&nbsp;Name</font></td><td align="left" class="borderbottom"><font style="font-size: 5pt">Abb</font></td><td align="right" class="borderbottom"><font style="font-size: 5pt">Rnk</font></td><td align="right" class="borderbottom"><font style="font-size: 5pt">Tot&nbsp;</font></td><td align="left" class="borderbottom"><font style="font-size: 5pt">&nbsp;Name</font></td><td align="left" class="borderbottom"><font style="font-size: 5pt">Abb</font></td><td align="right" class="borderbottom"><font style="font-size: 5pt">Rnk</font></td><td align="right" class="borderbottom"><font style="font-size: 5pt">Tot&nbsp;</font></td><tr>
224
+ <tr><td align="left"><font style="font-size: 5pt">&nbsp;Acrobatics</font></td><td align="left"><font style="font-size: 5pt">DEX</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-11&nbsp;</font></td><td align="left"><font style="font-size: 5pt">&nbsp;Disguise</font></td><td align="left"><font style="font-size: 5pt">CHA</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-5&nbsp;</font></td><td align="left"><font style="font-size: 5pt">&nbsp;Ride</font></td><td align="left"><font style="font-size: 5pt">DEX</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-11&nbsp;</font></td><tr><tr><td align="left"><font style="font-size: 5pt">&nbsp;Acrobatics (Jump)</font></td><td align="left"><font style="font-size: 5pt">DEX</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-23&nbsp;</font></td><td align="left"><font style="font-size: 5pt">&nbsp;Escape Artist</font></td><td align="left"><font style="font-size: 5pt">DEX</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-11&nbsp;</font></td><td align="left"><font style="font-size: 5pt">&nbsp;Sense Motive</font></td><td align="left"><font style="font-size: 5pt">WIS</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-5&nbsp;</font></td><tr><tr><td align="left"><font style="font-size: 5pt">&nbsp;Appraise</font></td><td align="left"><font style="font-size: 5pt">INT</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-5&nbsp;</font></td><td align="left"><font style="font-size: 5pt">&nbsp;Fly</font></td><td align="left"><font style="font-size: 5pt">DEX</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-11&nbsp;</font></td><td align="left"><font style="font-size: 5pt">&nbsp;Stealth</font></td><td align="left"><font style="font-size: 5pt">DEX</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-11&nbsp;</font></td><tr><tr><td align="left"><font style="font-size: 5pt">&nbsp;Bluff</font></td><td align="left"><font style="font-size: 5pt">CHA</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-5&nbsp;</font></td><td align="left"><font style="font-size: 5pt">&nbsp;Heal</font></td><td align="left"><font style="font-size: 5pt">WIS</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-5&nbsp;</font></td><td align="left"><font style="font-size: 5pt">&nbsp;Survival</font></td><td align="left"><font style="font-size: 5pt">WIS</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-5&nbsp;</font></td><tr><tr><td align="left"><font style="font-size: 5pt">&nbsp;Climb</font></td><td align="left"><font style="font-size: 5pt">STR</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-3&nbsp;</font></td><td align="left"><font style="font-size: 5pt">&nbsp;Intimidate</font></td><td align="left"><font style="font-size: 5pt">CHA</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-5&nbsp;</font></td><td align="left"><font style="font-size: 5pt">&nbsp;Swim</font></td><td align="left"><font style="font-size: 5pt">STR</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-3&nbsp;</font></td><tr><tr><td align="left"><font style="font-size: 5pt">&nbsp;Craft (Untrained)</font></td><td align="left"><font style="font-size: 5pt">INT</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-5&nbsp;</font></td><td align="left"><font style="font-size: 5pt">&nbsp;Perception</font></td><td align="left"><font style="font-size: 5pt">WIS</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-5&nbsp;</font></td><tr><tr><td align="left"><font style="font-size: 5pt">&nbsp;Diplomacy</font></td><td align="left"><font style="font-size: 5pt">CHA</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-5&nbsp;</font></td><td align="left"><font style="font-size: 5pt">&nbsp;Perform (Untrained)</font></td><td align="left"><font style="font-size: 5pt">CHA</font></td><td align="right"><font style="font-size: 5pt">0.0</font></td><td align="right" class="borderright"><font style="font-size: 5pt">-5&nbsp;</font></td><tr>
225
+ </table>
226
+ </td>
227
+ </tr>
228
+ </table>
229
+ <!-- STOP Skills Table -->
230
+ <!-- START Special Attacks Table -->
231
+ <!-- STOP Special Attacks Table -->
232
+ <!-- START Animal Tricks Table -->
233
+ <!-- STOP Animal Tricks Table -->
234
+ <!-- START Special Quality Table -->
235
+ <!-- STOP Special Quality Table -->
236
+ <!-- START Special Abilities Table -->
237
+
238
+ <!-- STOP Special Abilities Table -->
239
+ <!-- START Feats Table -->
240
+ <table cellpadding="0" cellspacing="0" border="0" width="100%" summary="Feats Table">
241
+ <tr>
242
+ <td colspan="1" bgcolor="black" align="center"><font style="font-size: 9pt" color="white"><b>FEATS</b></font></td>
243
+ </tr>
244
+ <tr>
245
+ <td align="left" width="100%" class="border7"></td>
246
+ </tr>
247
+ </table>
248
+ <!-- STOP Feats Table -->
249
+
250
+ </td>
251
+ </tr>
252
+ <tr>
253
+ <td colspan="2" valign="top">
254
+ <!-- START Saving Throws Table -->
255
+ <table width="25%" summary="Saving Throws">
256
+ <tr>
257
+ <td align="center" bgcolor="black"><font style="font-size:10pt" color="white"><b>Fortitude</b></font>
258
+ <font style="font-size:5pt" color="white"><br />
259
+ Constitution
260
+ </font>
261
+ </td>
262
+ <td align="center" class="border9"><b>{{ character.fortitude }}</b></td>
263
+ </tr>
264
+ <tr>
265
+ <td align="center" bgcolor="black"><font style="font-size:10pt" color="white"><b>Reflex</b></font>
266
+ <font style="font-size:5pt" color="white"><br />
267
+ Dexterity
268
+ </font>
269
+ </td>
270
+ <td align="center" class="border9"><b>{{ character.reflex }}</b></td>
271
+ </tr>
272
+ <tr>
273
+ <td align="center" bgcolor="black"><font style="font-size:10pt" color="white"><b>Will</b></font>
274
+ <font style="font-size:5pt" color="white"><br />
275
+ Wisdom
276
+ </font>
277
+ </td>
278
+ <td align="center" class="border9"><b>{{ character.will }}</b></td>
279
+ </tr>
280
+ </table>
281
+ <!-- STOP Saving Throws Table -->
282
+ <!-- START Unarmed Attack Table -->
283
+ <table cellpadding="0" cellspacing="0" border="0" width="100%" summary="Unarmed Attack Table">
284
+ <tr>
285
+ <td align="center" height="25" bgcolor="black" rowspan="2" width="125"><font style="font-size:10pt" color="white"><b>Attack</b></font></td>
286
+ <td align="center" bgcolor="black" width="110" height="15"><font style="font-size:6pt" color="white"><b>TOTAL ATTACK BONUS</b></font></td>
287
+ <td align="center" bgcolor="black" width="60" height="15"><font style="font-size:6pt" color="white"><b>DAMAGE</b></font></td>
288
+ <td align="center" bgcolor="black" width="60" height="15"><font style="font-size:6pt" color="white"><b>CRITICAL</b></font></td>
289
+ </tr>
290
+ <tr><td align="center" bgcolor="white" class="border8"><b>{{ character.full_attack.join('/') }}<br /></b></td>
291
+ <td align="center" bgcolor="white" class="border8"><b>{{ character.damage }}<br /></b></td>
292
+ <td align="center" bgcolor="white" class="border8"><b>--<br /></b></td>
293
+ </tr>
294
+ </table>
295
+ <!-- STOP Saving Throws Table -->
296
+ </td>
297
+ </tr>
298
+ </table>
299
+ </body>
300
+ </html>
data/lib/wayfinder.rb ADDED
@@ -0,0 +1,147 @@
1
+ module Wayfinder
2
+
3
+ BASE_STATS = %w(strength dexterity constitution wisdom charisma intelligence)
4
+
5
+ class Character
6
+
7
+ ## :source must be a hash with the following keys, each containing the data of
8
+ ## its appropriate yaml file.
9
+ #
10
+ # * meta - contains hp, base attack bonus, saving throws, xp, name,
11
+ # and other metadata.
12
+ # * stats - contains basic stats, str, dex, con, wis, int and cha.
13
+ # * gear - contains descriptions of items that modify the final
14
+ # computed stats for the character.
15
+ # * feats - character feats, similar to gear in that it contributes
16
+ # to the final stack.
17
+ # * buffs - buffs are temporary modifiers that are expected to change
18
+ # often, but act much like feats and gear.
19
+ # * skills - skills contain data on the ranks and associated stats for
20
+ # each given skill.
21
+ #
22
+ ## :modifier_stack is an array of gear, feats and buffs and is what will be
23
+ ## iterated while computing final modifiers for all character stats.
24
+
25
+ attr_accessor :source, :modifier_stack
26
+
27
+ def initialize(source_data = {})
28
+ self.source = source_data
29
+ self.modifier_stack = [
30
+ self.source[:gear],
31
+ self.source[:feats],
32
+ self.source[:buffs]
33
+ ]
34
+ end
35
+
36
+ BASE_STATS.each do |base_stat|
37
+ define_method(base_stat) do
38
+ self.source[:stats][base_stat] + modifier_for(base_stat)
39
+ end
40
+
41
+ define_method("#{ base_stat }_modifier") do
42
+ stat = self.source[:stats][base_stat] + modifier_for(base_stat)
43
+ (stat - 10) / 2
44
+ end
45
+ end
46
+
47
+ ## Returns an array of object who affect the specified attribute
48
+ def stack_for(attribute)
49
+ self.modifier_stack.map(&:values).flatten.keep_if do |item|
50
+ item['active'] && item['modifiers'].keys.include?(attribute)
51
+ end
52
+ end
53
+
54
+ ## Outputs the final modifier for the specified attribute.
55
+ def modifier_for(attribute)
56
+ modifier = 0
57
+ stack_for(attribute).each do |mod|
58
+ modifier += mod['modifiers'][attribute]
59
+ end
60
+
61
+ modifier
62
+ end
63
+
64
+ ## Combat
65
+
66
+ def hp
67
+ self.source[:meta]['hp'] + modifier_for('hp')
68
+ end
69
+
70
+ def received_damage
71
+ self.source[:meta]['received_damage']
72
+ end
73
+
74
+ def current_hp
75
+ self.hp - self.received_damage
76
+ end
77
+
78
+ def initiative
79
+ dexterity_modifier + modifier_for('initiative')
80
+ end
81
+
82
+ def bab
83
+ self.source[:meta]['bab']
84
+ end
85
+
86
+ def to_hit(base_attack = self.bab)
87
+ base_attack + strength_modifier + modifier_for('to_hit')
88
+ end
89
+
90
+ def damage
91
+ strength_modifier + modifier_for('damage')
92
+ end
93
+
94
+ def full_attack
95
+ attack_babs = [self.bab]
96
+
97
+ ## Fuck yeah I used a while in ruby, fuck you, fuck everything, EVERYTHING.
98
+ while attack_babs.last - 5 > 1
99
+ attack_babs << attack_babs.last - 5
100
+ end
101
+
102
+ attack_babs.map { |attack| to_hit(attack) }
103
+ end
104
+
105
+ def ac
106
+ 10 + dexterity_modifier + modifier_for('ac')
107
+ end
108
+
109
+ ## Saving Throws
110
+ def saving_throws
111
+ {
112
+ fortitude: self.fortitude,
113
+ reflex: self.reflex,
114
+ will: self.will
115
+ }
116
+ end
117
+
118
+ def fortitude
119
+ self.source[:meta]['fortitude'] + constitution_modifier + modifier_for('fortitude')
120
+ end
121
+
122
+ def reflex
123
+ self.source[:meta]['reflex'] + dexterity_modifier + modifier_for('reflex')
124
+ end
125
+
126
+ def will
127
+ self.source[:meta]['will'] + wisdom_modifier + modifier_for('will')
128
+ end
129
+
130
+ def skill(skill_name)
131
+ skill = self.source[:skills].fetch(skill_name, {})
132
+ computed_score = skill.fetch('ranks', 0) + self.send("#{ skill['stat'] }_modifier") + modifier_for(skill_name)
133
+
134
+ if skill['class']
135
+ computed_score += 3
136
+ end
137
+
138
+ computed_score
139
+ end
140
+
141
+ def skills
142
+ all_skills = {}
143
+ self.source[:skills].keys.each { |s| all_skills[s] = self.skill(s) }
144
+ all_skills
145
+ end
146
+ end
147
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wayfinder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - PoTe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: box
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mote
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: |-
42
+ Wayfinder assumes you'll keep your character described in yaml following a set of conventions, all the data points are
43
+ aggregated together to generate a nicely formatted output from the input data, with all the numbers crunched in for you.
44
+ email:
45
+ - pote@tardis.com.uy
46
+ executables:
47
+ - wayfinder
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - bin/wayfinder
52
+ - lib/wayfinder.rb
53
+ homepage: https://github.com/pote/wayfinder
54
+ licenses:
55
+ - MIT
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.0.3
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Pathfinder RPG character bookkeeping made easy.
77
+ test_files: []