Robert Carnecky 10 years ago
parent
commit
5ec5016949
3 changed files with 45 additions and 9 deletions
  1. 30
    0
      generator/components-test.html
  2. 9
    4
      generator/generate.html
  3. 6
    5
      generator/js/ui.ts

+ 30
- 0
generator/components-test.html View File

6
     <link rel="import" href="components/card.html">
6
     <link rel="import" href="components/card.html">
7
     <style type="text/css">
7
     <style type="text/css">
8
 
8
 
9
+        rpg-card {
10
+            margin: 4px;
11
+        }
12
+
9
         body {
13
         body {
10
             display: flex;
14
             display: flex;
11
             flex-direction: column;
15
             flex-direction: column;
70
                 <card-description><p>+1d6 damage for each slot above 1st</p></card-description>
74
                 <card-description><p>+1d6 damage for each slot above 1st</p></card-description>
71
             </card-contents>
75
             </card-contents>
72
         </rpg-card>
76
         </rpg-card>
77
+        <rpg-card class="card-size-25x35" color="maroon">
78
+            <card-title>
79
+                <h1>Burning Hands</h1>
80
+            </card-title>
81
+            <card-contents>
82
+                <card-subtitle>1st level evocation</card-subtitle>
83
+                <card-rule></card-rule>
84
+                <card-fill size="1"></card-fill>
85
+                <card-description>
86
+                    <h4>Mechanics</h4>
87
+                    <p>Each creature in a 15-foot cone must make a Dexterity saving throw. A creature takes <b>3d6 fire damage</b> on a failed save, or half as much damage on a successful one.</p>
88
+                </card-description>
89
+                <card-description>
90
+                    <h4>Ignite</h4>
91
+                    <p>The fire ignites any flammable objects in the area that aren't being worn or carried.</p>
92
+                </card-description>
93
+                <card-fill size="2"></card-fill>
94
+                <card-section>At higher levels</card-section>
95
+                <card-description><p>+1d6 damage for each slot above 1st</p></card-description>
96
+            </card-contents>
97
+            <card-title>
98
+                <card-icon src="/icons/gears.svg" style="float: left"></card-icon>
99
+                <h1 style="text-align: center;">Evocation 1</h1>
100
+                <card-icon src="/icons/stopwatch.svg"></card-icon>
101
+            </card-title>
102
+        </rpg-card>
73
         <rpg-card class="card-size-25x35" color="saddlebrown">
103
         <rpg-card class="card-size-25x35" color="saddlebrown">
74
             <card-title>
104
             <card-title>
75
                 <h1>Brown bear</h1>
105
                 <h1>Brown bear</h1>

+ 9
- 4
generator/generate.html View File

19
     <script type="text/javascript" defer src="js/ui.js"></script>
19
     <script type="text/javascript" defer src="js/ui.js"></script>
20
     <!-- CSS -->
20
     <!-- CSS -->
21
     <link href="css/ui.css" rel="stylesheet" />
21
     <link href="css/ui.css" rel="stylesheet" />
22
-    <link href="css/card-size.css" rel="stylesheet" />
23
     <!-- Components -->
22
     <!-- Components -->
24
     <link rel="import" href="components/card.html">
23
     <link rel="import" href="components/card.html">
25
 </head>
24
 </head>
428
                     </p>
427
                     </p>
429
                     <textarea class="form-control" rows="10" id="filter-function" wrap="off">
428
                     <textarea class="form-control" rows="10" id="filter-function" wrap="off">
430
 // Color all spell cards yellow
429
 // Color all spell cards yellow
431
-if (card_has_tag(card, "spell")) {
430
+if (card.hasTag("spell")) {
432
     card.color = "yellow";
431
     card.color = "yellow";
433
 }
432
 }
434
 
433
 
435
 // Remove all creature cards
434
 // Remove all creature cards
436
-if (card_has_tag(card, "creature")) {
437
-    return false;
435
+if (card.hasTag("creature")) {
436
+    deck.deleteCard(card);
437
+}
438
+
439
+// Duplicate all consumable item cards
440
+if (card.hasTag("item") && card.hasTag("consumable")) {
441
+    var newCard = deck.duplicateCard(card);
442
+    newCard.color = "pink";
438
 }
443
 }
439
                     </textarea>
444
                     </textarea>
440
                 </div>
445
                 </div>

+ 6
- 5
generator/js/ui.ts View File

61
         if (card) {
61
         if (card) {
62
             $("#card-title").val(card.title);
62
             $("#card-title").val(card.title);
63
             $("#card-title-size").val(card.title_size);
63
             $("#card-title-size").val(card.title_size);
64
+            $("#card-title-icon-text").val(card.title_icon_text);
64
             $("#card-count").val(""+card.count);
65
             $("#card-count").val(""+card.count);
65
             $("#card-icon").val(card.icon);
66
             $("#card-icon").val(card.icon);
66
             $("#card-icon-back").val(card.icon_back);
67
             $("#card-icon-back").val(card.icon_back);
70
         } else {
71
         } else {
71
             $("#card-title").val("");
72
             $("#card-title").val("");
72
             $("#card-title-size").val("");
73
             $("#card-title-size").val("");
74
+            $("#card-title-icon-text").val("");
73
             $("#card-count").val("1");
75
             $("#card-count").val("1");
74
             $("#card-icon").val("");
76
             $("#card-icon").val("");
75
             $("#card-icon-back").val("");
77
             $("#card-icon-back").val("");
317
         hideModal("#filter-modal");
319
         hideModal("#filter-modal");
318
 
320
 
319
         var fn_code = $("#filter-function").val();
321
         var fn_code = $("#filter-function").val();
320
-        var fn = new Function("card", fn_code);
322
+        var fn = new Function("card", "deck", fn_code);
321
 
323
 
322
-        deck.cards = deck.cards.filter(function (card) {
323
-            var result = fn(card);
324
-            if (result === undefined) return true;
325
-            else return result;
324
+        deck.cards.forEach((card) => {
325
+            fn(card, deck);
326
         });
326
         });
327
+        deck.commit();
327
 
328
 
328
         update_card_list();
329
         update_card_list();
329
     }
330
     }

Loading…
Cancel
Save