gdritter repos delve / master hk.py
master

Tree @master (Download .tar.gz)

hk.py @masterraw · history · blame

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
import sys

TEMPLATE = '''
<svg width="4in" height="1in" version="1.1"
     xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink">

  <rect x="0in" y="0in" width="4in" height="1in"
    style="fill: white; stroke-width: 0.02in; stroke: #ddd;" />

  <rect x="0.1in" y="0.1in" width="0.8in" height="0.8in"
    style="fill: white; stroke-width: 0.02in; stroke: #999;" />

  <line x1="1.1in" y1="0.3in" x2="1.1in" y2="0.9in" style="stroke-width: 0.02in; stroke: #999;" />

  <image x="0.1in" y="0.1in" width="0.8in" height="0.8in" xlink:href="../icons/{type}-icon.svg" />

  <text x="1in" y="0.1in"
    dominant-baseline="hanging"
    style="font-family: Fira Sans;
    font-size: 12pt;
    font-weight: bold;">
    {header}
  </text>

  {text}
</svg>
'''

TEXT_TEMPLATE = '''<text x="{x}in" y="{y}in"
  dominant-baseline="hanging"
  style="font-family: Fira Sans; font-size: 10pt; {s}">
  {t}</text>'''


WEAPONS = [
    ('Bow', 'ranged', 'Arrow-Split Shot',
     ['Split your Ranged dice to attack multiple',
      'non-adjacent targets up to 6 squares away.']),

    ('Claymore', 'melee', 'All-Out Attack',
     ['Take +1d to a Melee attack, but until the',
      'start of your next turn your Defense pool has',
      'no dice.'
      ]),

    ('Crossbow', 'ranged', 'Cover Shot',
     ['Move 1 square, make a Ranged attack with',
      '-1d, then return to your original position.'
      ]),

    ('Cutlass', 'melee', 'Pressing Attack',
     ['Melee attack a target with -1d; the target ',
      'is also pushed back 1 square and you ',
      'move into its square.'
      ]),

    ('Daggers', 'ranged', 'Sneaky Attack',
     ['You can make a +1d Ranged attack at any ',
      'engaged target in range.'
      ]),

    ("Mace", "melee", "Knockback",
     ["Melee attack at an adjacent with -1d.",
      "If the attack hits, the target is also",
      "pushed back 4 squares."]),

    ("Hammer", "melee", "Iron Wall",
        ["Your Defense pool gains 1 extra die until ",
         "the start of your next turn."]),

    ("Longsword", "melee", "Strikeback Attack",
        ["If an adjacent target has attacked you ",
         "since your last turn, you can attack that ",
         "target with +1d."]),

    ("Shortsword", "melee", "Whirlwind",
        ["Split your Melee dice to make Melee ",
         "attacks at multiple adjacent targets."]),

    ("Staff of Fire", "magic", "Flame Burst",
        ["Make 1 die Arcane attacks at all ",
         "adjacent targets, including enemies ",
         "and allies."]),

    ("Staff of Light", "magic", "Healing Touch",
        ["Remove 1 damage from yourself or an ",
         "adjacent ally."]),

    ("Staff of Telekinesis", "magic", "Wave of Force",
        ["Make a +1d Arcane attack. If it hits, do not",
         "deal damage, but move the target up to",
         "4 squares away from its current position."]),

    ("Staff of Thunder", "magic", "Fork Lightning",
        ["Split your Arcande dice to make Arcane",
         "attacks at multiple targets in range."]),

    ("Staff of Vines", "magic", "Tangling Roots",
        ["Make a -1d Arcane attack at a target in",
         "range. If it hits, the target also cannot",
         "move on its next turn."]),

    ("Staff of Water", "magic", "Freezing Strike",
        ["When you roll a 6 on an attack die, your",
         "target cannot move during their next turn."]),

    ("Whip", "ranged", "Lasso",
        ["Make a Ranged attack at a target in range.",
         "If it hits, the target takes no damage, but is",
         "pulled to an empty square closer to you."]),

    ("Longbow", "ranged", "Distant Shot",
        ["Make a -1d Ranged attack at a non-adjacent",
         "target up to 8 squares away."]),

    ("Brigand's Axe", "melee", "Brutal Slash",
        ["Re-roll any Melee attack dice that roll a 1."]),

    ("Footman's Pike", "melee", "Reaching Strike",
        ["Your Melee attacks can target characters",
         "up to 1 square away, but your Melee",
         "attacks at adjacent targets take -1d."]),

    ("Lucky Longsword", "melee", "Warrior's Luck",
        ["Once per encounter, you can re-roll all of",
         "your Melee attack dice."]),

    ("Raider's Battleaxe", "melee", "Reaping Strike",
        ["When you KO an enemy with a Melee",
         "attack, you can immediately make a Melee",
         "attack at another adjacent target."]),

    ("Swift Sword", "melee", "Following Cut",
        ["When you roll a 6 on a Melee attack die,",
         "you can immediately make a 1d Melee",
         "attack at an adjacent target."]),

    ("Bloodthirsty Blade", "melee", "Quenching Hit",
        ["The first time in each encounter that you",
         "hit with a Melee attack, the attack deals",
         "1 extra damage."]),

    ("Thundering Hammer", "melee", "Thunder Strike",
        ["Once per encounter, you can deal 1 extra",
         "damage when you hit with a Melee attack."]),

    ("Heavy Crossbow", "ranged", "Opening Shot",
        ["Once per encounter, you can use your",
         "action to make a 3d Ranged attack at",
         "a target in range."]),

    ("Faerie Wand", "magic", "Faerie Fire",
     ["When you hit a target with an Arcane attack,",
      "all attacks against that target gain +1d."]),

    ("Explosive Wand", "magic", "Arcane Burst",
     ["When you KO a target with an Arcane attack,",
      "you must immediately make 1d attacks at",
      "all characters adjacent to that target."]),

    ("Throwing Axe", "ranged", "Spinning Throw",
     ["Once per encounter, instead of moving, you",
      "can make a 2d Ranged attack at a target up",
      "to 3 squares away."]),

    ("Bandit's Bow", "ranged", "Brutal Shot",
     ["Re-roll any Ranged attack dice that roll a 1."]),

    ("Deepwood Bow", "ranged", "Precision Shot",
     ["Once per encounter, you can add +1d",
      "when you make a Ranged attack."]),

    ("Sharpshooter's Bow", "ranged", "Surprise Shot",
     ["Your first ranged attack in each encounter",
      "deals 1 extra damage if it hits."]),

    # healing equipment
    ("Staff of Light", "magic", "Healing Touch",
        ["Remove 1 damage from yourself or an ",
         "adjacent ally."]),

    ("Vampiric Staff", "magic", "Leech",
     ["On a successful Arcane attack against an",
      "enemy, you can also remove 1 damage from 1"
      "ally adjacent to that enemy."]),

    ("Staff of Dawn's Light", "magic", "Bolt of Comfort",
     ["Make an Arcane roll against an ally in range.",
      "On a hit, remove 1 damage from them."]),

    ("Divine Staff", "magic", "Godly Sigil",
     ["Mark an adjacent square. For the",
      "next 5 turns, if any creature ends its turn in",
      "that square, they remove 1 damage."]),

    ("Staff of Dusk's Shadow", "magic", "",
     ["Make an Arcane roll against yourself. On a",
      "hit, remove 2 damage from yourself or from ",
      "adjacent allies."]),

]


CARDS = [
    # items
    ("Bomb",
     "item",
     ["Make 1d attacks at a target or square up to",
      "5 squares away and all adjacent targets."]),

    # wards
    ("Ward of Force",
     "item",
     ["Mark an adjacent square. The next creature to",
      "enter that square takes 2 damage."]),

    ("Ward of Healing",
     "item",
     ["Mark an adjacent square. The next creature to",
      "enter that square recovers 2 damage."]),

    # oils
    ("Cruel Oil",
     "item",
     ["On your next successful hit, deal 1 extra damage."]),

    ("Greedy Oil",
     "item",
     ["On your next successful hit, remove 1 damage from yourself."]),

    # tools
    ("Rope",
     "item",
     ["Take +1d to any ability test to climb or",
      "traverse obstacles or difficult terrain."]),

    ("Bait",
     "item",
     ["Toss this item on an adjacent square. On",
      "their next turn, one enemy will ignore",
      "everything else and move straight for the",
      "targeted square."]),

    ("Goldleaf Herb",
     "plant",
     ["Can be used to brew a Potion of Healing.",
      "Requires an Intelligence (Alchemy) roll of",
      "5 or higher to brew."]),

    ("Frostberry Seeds",
     "plant",
     ["Can be used to brew a Potion of Dexterity.",
      "Requires an Intelligence (Alchemy) roll of",
      "5 or higher to brew."]),

    ("Oxroot Strands",
     "plant",
     ["Can be used to brew a Potion of Strength.",
      "Requires an Intelligence (Alchemy) roll of",
      "5 or higher to brew."]),

    ("Coldwine Flowers",
     "plant",
     ["Can be used to brew a Potion of Intelligence.",
      "Requires an Intelligence (Alchemy) roll of",
      "5 or higher to brew."]),

    ("Potion of Healing",
     "item",
     ["Restore yourself or an ally to full health."]),

    ("Potion of Charisma",
     "item",
     ["You become extra-charismatic for 5",
      "minutes. You gain +2d to Intelligence",
      "(Talking) tests."]),

    ("Potion of Dexterity",
     "item",
     ["You become nimble for 5 minutes.",
      "You gain +2d to your Ranged pool and when",
      "making Dexterity ability tests."]),

    ("Potion of Intelligence",
     "item",
     ["You become smarter for 5 minutes.",
      "You gain +2d to your Arcane pool and when",
      "making Intelligence ability tests."]),

    ("Potion of Invisibility",
     "item",
     ["You become invisible for 5 minutes.",
      "You gain +2d to your Defense pool and when",
      "making Dexterity (Stealth) ability tests."]),

    ("Potion of Quickness",
     "item",
     ["You become quicker for 5 minutes.",
      "If you don't move on your turn, you can",
      "take 2 actions."]),

    ("Potion of Strength",
     "item",
     ["You become stronger for 5 minutes.",
      "Gain +2d to your Melee pool and when",
      "making Strength ability tests."]),

    ("Stack of Gold",
     "treasure",
     ["Treasure. Can be exchanged for goods and",
      "services."]),

    ("Pile of Gems",
     "treasure",
     ["Treasure. Can be exchanged for goods and",
      "services."]),

    # abilities
    ("Teamwork", "ability",
     ["When your target is engaged, your Melee",
      "attacks gain +1d."]),

    ("Nimble", "ability",
     ["You can move up to 5 squares on your turn,",
      "ignoring obstacles, enemies, and allies."]),

    ("Revenge Strike", "ability",
     ["Take an extra +1d when attacking an enemy",
      "that has previously attacked you."]),

    ("Retaliation", "ability",
     ["When you hit a target that has damaged",
      "you since your last turn, deal 2 damage."]),

    ("Power Surge", "ability",
     ["When you are not at full health, your",
      "attacks gain +1d."]),

    ("Keen Reflexes", "ability",
     ["When defending against Melee attacks,",
      "you gain +1d to your Defense pool."]),

    ("Evasive Maneuver", "ability",
     ["When you're damaged by an attack, you",
      "can immediately move 1 square."]),

    ("Alchemical Training", "ability",
     ["Take +1d on all Intelligence (Alchemy)",
      "ability tests."]),

    ("Rhetorical Training", "ability",
     ["Take +1d on all Intelligence (Talking)",
      "ability tests."]),

    ("Stealth Training", "ability",
     ["Take +1d on all Dexterity (Stealth)",
      "ability tests."]),

    ("Keen Vision", "ability",
     ["You can see even in dark or low-light",
      "conditions."]),

    ("Academic Background", "ability",
     ["Take +1d on all Intelligence (Lore)",
      "ability tests."]),

    ("Defender", "ability",
     ["When an adjacent ally is hit, you can take",
      "the damage instead of the ally."]),

    ("Hard to Kill", "ability",
     ["When you take damage that would KO you,",
      "you can still act on your next turn. If you're",
      "still KO'd at the end of your next turn,",
      "you are knocked out."]),

    ("Unstoppable", "ability",
     ["You can move through spaces occupied",
      "by enemies."]),

    ("Aggravated", "ability",
     ["When you miss an enemy with an attack,",
      "you can add +1d to your next attack",
      "against that enemy."]),

    ("Momentum", "ability",
     ["When you deal damage to an enemy,",
      "you can add +1d to your next attack",
      "against that enemy."]),

    ("Barkskin", "ability",
     ["When you are not at full health, your Defense",
      "pool gains +1d."]),

    # equipment
    ("Boomerang Buckler", "equipment",
     ["Ranged attack with your Defense dice at a ",
      "target up to 4 squares away, but until the ",
      "start of your next turn your Defense pool",
      "has no dice."]),

    ("Defender's Shield", "equipment",
     ["Move 1 die from your Defense pool to an",
      "adjacent ally's Defense pool until the start",
      "of your next turn."]),

    ("Everpresent Shield", "equipment",
     ["When you are attacked by more than ",
      "1 enemy, your Defense pool gains 1 extra die",
      "until the start of your next turn."]),

    ("Guard's Shield", "equipment",
     ["Use your action to add all of your Melee,",
      "Ranged, or Arcane dice to your Defense pool",
      "until the start of your next turn."]),

    ("Heavy Shield", "equipment",
     ["Gain 1 extra Defence die. Your movement is",
      "reduced by 2 squares."]),

    ("Light Shield", "equipment",
     ["Re-roll any Defence dice that roll a 1."]),

    ("Striker's Spauldron", "equipment",
     ["When you are attacked by an enemy that",
      "attacked last turn, you gain 1 die to your",
      "Defence pool."]),

    ("Wrist Bracers", "equipment",
     ["You can add 1 extra die to your Defence",
      "pool, but on your next turn your attacks",
      "have 1 fewer dice."]),

    ("Charged Amulet", "equipment",
     ["Once per encounter, you can add +1d to",
      "any Arcane attack."]),

    ("Crystal Amulet", "equipment",
     ["Re-roll any Arcane attack die that rolls a 1."]),

    ("Amulet of Protection", "equipment",
     ["At the start of your turn, you can move 1d",
      "from your Arcane pool to your Defense pool",
      "until the start of your next turn."]),

    ("Amulet of Retreat", "equipment",
     ["After you have been attacked, you can",
      "teleport up to 3 squares away."]),

    ("Amulet of Healing", "equipment",
     ["Extend the range of healing powers 1 square",
      "(including touch or adjacent powers.)"]),

    ("Lucky Charm", "equipment",
     ["Once per encounter, you can re-roll 1d in",
      "an attack, Defence, or ability test."]),

    ("Vengeful Pendant", "equipment",
     ["When you take attack damage that will ",
      "KO you, you can immediately make a",
      "normal attack."]),

    ("Focus Charm", "equipment",
     ["Once per encounter, you can add +1d to",
      "any Ranged attack."]),

    ("Charm of Power", "equipment",
     ["Once per encounter, you can add +1d to",
      "any Melee attack."]),

    ("Studded Armor", "equipment",
     ["Take +1d to your Defense dice when",
      "defending against any Melee attack."]),

    ("Leather Armor", "equipment",
     ["Take +1d to your Defense dice when",
      "defending against any Ranged attack."]),

    ("Consecrated Armor", "equipment",
     ["Take +1d to your Defense dice when",
      "defending against any Arcane attack."]),

    ("Banded Armor", "equipment",
     ["Take +1d to your Defense dice when",
      "defending against any Arcane attack."]),

]


def weapon(name, type, special, special_text):
    raw_text = ['Special: {0}'.format(special)] + special_text
    text = ''
    for n, t in enumerate(raw_text):
        s = '' if n else 'font-weight: bold;'
        y = 0.3 + n * 0.16
        x = '1.2' if n else '1.15'
        text += TEXT_TEMPLATE.format(x=x, t=t, y=y, s=s)

    with open('cards/weapon_{0}.svg'.format(slug(name)), 'w') as f:
        f.write(TEMPLATE.format(
            type=type,
            header='{0} (Weapon, {1})'.format(name, type.capitalize()),
            text=text
        ))


def slug(name):
    return ''.join(
        c for c in '_'.join(name.lower().split())
        if c.isalpha() or c == '_')


def card(name, type, raw_text):
    text = ''
    for n, t in enumerate(raw_text):
        s = ''
        y = 0.3 + n * 0.16
        x = '1.15'
        text += TEXT_TEMPLATE.format(x=x, t=t, y=y, s=s)

    if type == 'plant' or type == 'treasure':
        named_type = 'item'
    else:
        named_type = type

    with open('cards/{0}_{1}.svg'.format(named_type.lower(), slug(name)), 'w') as f:
        f.write(TEMPLATE.format(
            type=type,
            header='{0} ({1})'.format(name, named_type.capitalize()),
            text=text
        ))


def main():
    for thing in WEAPONS:
        weapon(*thing)

    for thing in CARDS:
        card(*thing)


def to_rec():
    print('%rec: Weapon')
    for (name, typ, ability, effect) in WEAPONS:
        print('Name: {0}'.format(name))
        print('Type: {0}'.format(typ))
        print('Ability: {0}'.format(ability))
        print('Effect: {0}'.format(' '.join(effect)))
        print()

    stuffs = {}
    for (name, typ, effect) in CARDS:
        if not stuffs.get(typ):
            stuffs[typ] = []
        stuffs[typ].append((name, ' '.join(effect)))

    for (typ, things) in stuffs.items():
        print('%rec: {0}'.format(typ.capitalize()))
        for (name, effect) in things:
            print('Name: {0}'.format(name))
            print('Effect: {0}'.format(effect))
            print()


if __name__ == '__main__':
    if sys.argv[1:] and sys.argv[1] == 'rec':
        to_rec()
    else:
        main()