|
@@ -26,10 +26,10 @@ module RpgCards {
|
26
|
26
|
constructor() {
|
27
|
27
|
this.foreground_color = "white";
|
28
|
28
|
this.background_color = "white";
|
29
|
|
- this.empty_color = "white";
|
|
29
|
+ this.empty_color = "black";
|
30
|
30
|
this.default_color = "black";
|
31
|
31
|
this.default_icon = "ace";
|
32
|
|
- this.default_title_size = "13pt";
|
|
32
|
+ this.default_title_size = "13";
|
33
|
33
|
this.page_size = "A4";
|
34
|
34
|
this.page_rows = 3;
|
35
|
35
|
this.page_columns = 3;
|
|
@@ -130,7 +130,7 @@ module RpgCards {
|
130
|
130
|
return this.title || "";
|
131
|
131
|
}
|
132
|
132
|
public getTitleSize(options: Options): string {
|
133
|
|
- return this.title_size || options.default_title_size || "13pt";
|
|
133
|
+ return this.title_size || options.default_title_size || "13";
|
134
|
134
|
}
|
135
|
135
|
public getColorFront(options: Options): string {
|
136
|
136
|
return this.color_front || this.color || options.default_color || "black";
|
|
@@ -191,7 +191,7 @@ module RpgCards {
|
191
|
191
|
|
192
|
192
|
public duplicateCard(card: Card): Card {
|
193
|
193
|
var newCard = card.duplicate();
|
194
|
|
- this._actions.push({ fn: "add", card: new Card(), ref: card });
|
|
194
|
+ this._actions.push({ fn: "add", card: newCard, ref: card });
|
195
|
195
|
return newCard;
|
196
|
196
|
}
|
197
|
197
|
|
|
@@ -216,6 +216,7 @@ module RpgCards {
|
216
|
216
|
}
|
217
|
217
|
}
|
218
|
218
|
}
|
|
219
|
+ this._actions = [];
|
219
|
220
|
}
|
220
|
221
|
}
|
221
|
222
|
|
|
@@ -281,7 +282,7 @@ module RpgCards {
|
281
|
282
|
var result = "";
|
282
|
283
|
result += ind + '<card-dndstats';
|
283
|
284
|
for (var i = 0; i < stats.length; ++i) {
|
284
|
|
- var value = parseInt(params[0], 10) || "";
|
|
285
|
+ var value = parseInt(params[i], 10) || "";
|
285
|
286
|
var stat = stats[i];
|
286
|
287
|
result += ' ' + stat + '="' + value + '"';
|
287
|
288
|
}
|
|
@@ -374,7 +375,10 @@ module RpgCards {
|
374
|
375
|
}
|
375
|
376
|
|
376
|
377
|
private _card_empty(options: Options, ind: string, ind0: string): string {
|
377
|
|
- return '';
|
|
378
|
+ var result = "";
|
|
379
|
+ result += ind + '<card-contents>\n';
|
|
380
|
+ result += ind + '</card-contents>\n';
|
|
381
|
+ return result;
|
378
|
382
|
}
|
379
|
383
|
|
380
|
384
|
private _card(options: Options, ind: string, ind0: string, content: string, color: string): string {
|
|
@@ -461,7 +465,7 @@ module RpgCards {
|
461
|
465
|
|
462
|
466
|
/** Empty slots on the page */
|
463
|
467
|
public capacity(): number {
|
464
|
|
- return this.cards.length - this.rows * this.cols;
|
|
468
|
+ return this.rows * this.cols - this.cards.length;
|
465
|
469
|
}
|
466
|
470
|
|
467
|
471
|
/** Empty slots on the current line */
|
|
@@ -475,10 +479,10 @@ module RpgCards {
|
475
|
479
|
throw new Error("Cannot perform this operation while the page is not full");
|
476
|
480
|
}
|
477
|
481
|
|
478
|
|
- for (var r = 0; r < Math.floor(this.rows / 2); ++r) {
|
479
|
|
- for (var c = 0; c < this.cols; ++c) {
|
|
482
|
+ for (var r = 0; r < this.rows; ++r) {
|
|
483
|
+ for (var c = 0; c < Math.floor(this.cols / 2); ++c) {
|
480
|
484
|
var indexL = this._posToIndex(r, c);
|
481
|
|
- var indexR = this._posToIndex(this.rows - r - 1, c);
|
|
485
|
+ var indexR = this._posToIndex(r, this.cols - c - 1);
|
482
|
486
|
var cardL = this.cards[indexL];
|
483
|
487
|
var cardR = this.cards[indexR];
|
484
|
488
|
this.cards[indexL] = cardR;
|
|
@@ -616,6 +620,9 @@ module RpgCards {
|
616
|
620
|
pages.addCards(front, card.count);
|
617
|
621
|
}
|
618
|
622
|
|
|
623
|
+ // Fill empty slots
|
|
624
|
+ pages.forEach((page) => page.fillPage(empty));
|
|
625
|
+
|
619
|
626
|
return pages;
|
620
|
627
|
}
|
621
|
628
|
|
|
@@ -631,13 +638,19 @@ module RpgCards {
|
631
|
638
|
var card = cards[i];
|
632
|
639
|
var front = generator.card_front(card, options, this.indent);
|
633
|
640
|
var back = generator.card_back(card, options, this.indent);
|
634
|
|
- if (pages.lastPage().capacityRow() < 2) {
|
635
|
|
- pages.lastPage().fillRow(empty);
|
|
641
|
+
|
|
642
|
+ for (var j = 0; j < card.count; ++j) {
|
|
643
|
+ if (pages.pages.length > 0 && pages.lastPage().capacityRow() < 2) {
|
|
644
|
+ pages.lastPage().fillRow(empty);
|
|
645
|
+ }
|
|
646
|
+ pages.addCard(front);
|
|
647
|
+ pages.addCard(back);
|
636
|
648
|
}
|
637
|
|
- pages.addCards(front, card.count);
|
638
|
|
- pages.addCards(back, card.count);
|
639
|
649
|
}
|
640
|
650
|
|
|
651
|
+ // Fill empty slots
|
|
652
|
+ pages.forEach((page) => page.fillPage(empty));
|
|
653
|
+
|
641
|
654
|
return pages;
|
642
|
655
|
}
|
643
|
656
|
|