diff --git a/src/ts/controller/newGameController.ts b/src/ts/controller/newGameController.ts
index 0aabba7f..a5d1cee6 100644
--- a/src/ts/controller/newGameController.ts
+++ b/src/ts/controller/newGameController.ts
@@ -28,17 +28,18 @@ export const newGameController = {
* Start new game event
* @param {string} bookNumber The book number
*/
- startNewGame( bookNumber: number) {
+ startNewGame( bookNumber: number, bookSeries?: string) {
state.reset(true);
routing.redirect( "setup" , {
- bookNumber
+ bookNumber,
+ bookSeries
});
},
- selectedBookChanged(newBookNumber: number) {
- const book = new Book(newBookNumber);
+ selectedBookChanged(newBookNumber: number, bookSeries?: string) {
+ const book = new Book(newBookNumber, bookSeries ?? "lw");
newGameView.setCoverImage( book.getCoverURL() );
},
diff --git a/src/ts/controller/setupController.ts b/src/ts/controller/setupController.ts
index cffafbdb..a4e14234 100644
--- a/src/ts/controller/setupController.ts
+++ b/src/ts/controller/setupController.ts
@@ -27,8 +27,9 @@ export const setupController = {
} else {
// New game. Get hash URL parameters
const bookNumber = Number(routing.getHashParameter("bookNumber"));
+ const bookSeries = routing.getHashParameter("bookSeries");
const keepActionChart = routing.getHashParameter("keepActionChart") === "true";
- state.setup(bookNumber, keepActionChart);
+ state.setup(bookNumber, keepActionChart, bookSeries);
}
template.translateMainMenu();
diff --git a/src/ts/model/book.ts b/src/ts/model/book.ts
index 5dd08996..4ae942fe 100644
--- a/src/ts/model/book.ts
+++ b/src/ts/model/book.ts
@@ -61,9 +61,7 @@ export class Book {
/** The book XML document */
public bookXml: XMLDocument|null;
- /**
- * Array of 100 positions with the random table numbers as they appear on the book
- */
+ /** Array of 100 positions with the random table numbers as they appear on the book */
public bookRandomTable: number[];
/** The book title cache, plain text */
@@ -75,14 +73,18 @@ export class Book {
/** The book disciplines cache */
private disciplines: DisciplinesTable|null = null;
+ /** The book series (lw, gs) */
+ public bookSeries: string = "lw";
+
/**
* Constructor
* @param number The book index number to create (1 = first)
*/
- public constructor(num: number) {
+ public constructor(num: number, bookSeries?: string) {
this.bookNumber = num;
this.bookXml = null;
this.bookRandomTable = [];
+ this.bookSeries = bookSeries ?? "lw";
}
/**
@@ -224,7 +226,7 @@ export class Book {
* @returns The book code name. null if it was not found
*/
public getProjectAonBookCode(): string|null {
- const bookMetadata = projectAon.supportedBooks[ this.bookNumber - 1 ];
+ const bookMetadata = this.bookSeries === "gs" ? projectAon.supportedBooks.filter((b) => b.series === "gs")[ this.bookNumber - 1 ] : projectAon.supportedBooks[ this.bookNumber - 1 ];
if ( !bookMetadata ) {
return null;
}
@@ -241,7 +243,7 @@ export class Book {
* Returns the book XML source URL
*/
public getBookXmlURL() {
- return Book.getBaseUrl() + this.bookNumber.toFixed() + "/" + this.getProjectAonBookCode() +
+ return Book.getBaseUrl() + (this.bookSeries === "gs" ? "gs/" : "") + this.bookNumber.toFixed() + "/" + this.getProjectAonBookCode() +
".xml";
}
@@ -423,7 +425,7 @@ export class Book {
if (this.bookNumber === 29) {
return null;
}
- return Book.getBaseUrl() + this.bookNumber.toFixed() + "/cover.jpg";
+ return Book.getBaseUrl() + (this.bookSeries !== "lw" ? this.bookSeries + "/" : "") + this.bookNumber.toFixed() + "/cover.jpg";
}
/**
diff --git a/src/ts/model/mechanics.ts b/src/ts/model/mechanics.ts
index 6c0dcec4..366d3143 100644
--- a/src/ts/model/mechanics.ts
+++ b/src/ts/model/mechanics.ts
@@ -61,7 +61,7 @@ export class Mechanics {
* Returns the book XML URL
*/
public getXmlURL(): string {
- return `data/mechanics-${this.book.bookNumber}.xml`;
+ return `data/mechanics${!this.book.bookSeries || this.book.bookSeries === "lw" ? "" : "-gs"}-${this.book.bookNumber}.xml`;
}
/** Set mechanics XML */
diff --git a/src/ts/model/projectAon.ts b/src/ts/model/projectAon.ts
index 3e886dc2..aadd0ef7 100644
--- a/src/ts/model/projectAon.ts
+++ b/src/ts/model/projectAon.ts
@@ -17,6 +17,12 @@ export interface BookMetadata {
/** Whether a cover exists for the book */
hasCover: boolean;
+
+ /** Book Series (lw, gs) */
+ series: string;
+
+ /** Book Number in the series */
+ bookNumber: number;
}
/**
@@ -266,14 +272,25 @@ export const projectAon = {
hasCover: false,
},
+ /////////// WORLD OF LONE WOLF ///////////
+ // Book 1:
+ {
+ bookNumber: 1,
+ title: "Grey Star the Wizard",
+ code: "01gstw",
+ illustrators: ["bonner"],
+ biographies: ["ipbiogs", "jdbiogs", "pbbiogs"],
+ series: "gs",
+ },
+
] as BookMetadata[],
/**
* Returns the title of a book
* @param bookNumber Book number, 1-index based
*/
- getBookTitle( bookNumber: number ): string {
- return projectAon.supportedBooks[bookNumber - 1][ "title" ];
+ getBookTitle( bookNumber: number, bookSeries?: string ): string {
+ return projectAon.supportedBooks.filter((b) => (b.series === bookSeries))[bookNumber - 1][ "title" ];
},
/**
diff --git a/src/ts/model/section.ts b/src/ts/model/section.ts
index 7fb200ac..58abe52c 100644
--- a/src/ts/model/section.ts
+++ b/src/ts/model/section.ts
@@ -126,7 +126,9 @@ export class Section {
const sNumber = this.getSectionNumber();
if ( sNumber ) {
- if ( sNumber === 1 ) {
+ if (this.book.bookSeries === "gs" && sNumber === 1) {
+ return "sage";
+ } else if ( sNumber === 1) {
return "kaiwisdm";
} else {
return `sect${( sNumber - 1 )}`;
diff --git a/src/ts/scripts/bookData.ts b/src/ts/scripts/bookData.ts
index 3583585b..b0d04b95 100644
--- a/src/ts/scripts/bookData.ts
+++ b/src/ts/scripts/bookData.ts
@@ -27,23 +27,27 @@ export class BookData {
/** Array with illustrations authors directories names */
private illAuthors: string[];
+ /** Book Series (lw, gs) */
+ private bookSeries: string = "lw";
+
/**
* Constructor
* @param bookNumber The book number (1-based index)
*/
constructor(bookNumber: number) {
- this.bookNumber = bookNumber;
+ this.bookNumber = projectAon.supportedBooks[ bookNumber - 1 ].bookNumber ?? bookNumber;
this.bookMetadata = projectAon.supportedBooks[ bookNumber - 1 ];
this.code = this.bookMetadata.code;
this.illAuthors = this.bookMetadata.illustrators;
this.hasCover = this.bookMetadata.hasCover === undefined ? true : this.bookMetadata.hasCover;
+ this.bookSeries = this.bookMetadata.series ?? "lw";
}
/**
* Get the local relative path for the book data
*/
private getBookDir(): string {
- return BookData.TARGET_ROOT + "/" + this.bookNumber.toFixed();
+ return BookData.TARGET_ROOT + "/" + (this.bookSeries !== "lw" ? this.bookSeries + "/" : "") + this.bookNumber.toFixed();
}
/**
@@ -86,7 +90,7 @@ export class BookData {
* Get the svn absolute URL for illustrations directory of a given author
*/
private getSvnIllustrationsDir(author: string): string {
- return "project-aon/en/png/lw/" + this.code + "/ill/" +
+ return `project-aon/en/png/${this.bookSeries}/` + this.code + "/ill/" +
author;
}
@@ -139,7 +143,7 @@ export class BookData {
*/
private downloadCover() {
if ( this.hasCover ) {
- const coverPath = "project-aon/en/jpeg/lw/" + this.code +
+ const coverPath = `project-aon/en/jpeg/${this.bookSeries}/` + this.code +
"/skins/ebook/cover.jpg";
const targetPath = this.getBookDir() + "/cover.jpg";
fs.copyFileSync(coverPath, targetPath);
@@ -147,11 +151,11 @@ export class BookData {
}
public downloadBookData() {
- const bookDir = BookData.TARGET_ROOT + "/" + this.bookNumber.toFixed();
+ const bookDir = this.getBookDir();
console.log("Re-creating directory " + bookDir);
fs.removeSync( bookDir );
- fs.mkdirSync( bookDir );
+ fs.mkdirSync( bookDir, {recursive: true} );
this.downloadCover();
diff --git a/src/ts/state.ts b/src/ts/state.ts
index 0184609e..54f52838 100644
--- a/src/ts/state.ts
+++ b/src/ts/state.ts
@@ -104,14 +104,14 @@ export class State {
/**
* Setup the state for a book number
*/
- public setup(bookNumber: number, keepActionChart: boolean) {
+ public setup(bookNumber: number, keepActionChart: boolean, bookSeries?: string) {
if (!bookNumber) {
bookNumber = 1;
}
this.sectionStates = new BookSectionStates();
- this.book = new Book(bookNumber);
+ this.book = new Book(bookNumber, bookSeries);
// Action chart
this.actionChart = null;
diff --git a/src/ts/views/newGameView.ts b/src/ts/views/newGameView.ts
index 1c178064..9249573e 100644
--- a/src/ts/views/newGameView.ts
+++ b/src/ts/views/newGameView.ts
@@ -12,13 +12,15 @@ export const newGameView = {
let html = "";
let series: BookSeriesId|null = null;
for ( let i = 1; i <= projectAon.supportedBooks.length; i++) {
- let seriesId = new Book(i).getBookSeries().id;
+ let bookNumber = projectAon.supportedBooks[i-1].bookNumber ?? i;
+ let bookSeries = projectAon.supportedBooks[i-1].series;
+ let seriesId = new Book(bookNumber, bookSeries).getBookSeries().id;
if (seriesId !== series) {
html += ``;
series = seriesId;
}
- const title = projectAon.getBookTitle( i )
- html += '";
+ const title = projectAon.getBookTitle( bookNumber, bookSeries );
+ html += "";
}
$("#newgame-book").html(html);
@@ -29,12 +31,15 @@ export const newGameView = {
alert(translations.text("youMustAgree"));
return;
}
- newGameController.startNewGame(parseInt($("#newgame-book").val()));
+
+ let selectedBook = JSON.parse($("#newgame-book").val());
+ newGameController.startNewGame(parseInt(selectedBook.bookNumber), selectedBook.bookSeries);
});
// Book change
$("#newgame-book").on("change", () => {
- newGameController.selectedBookChanged(parseInt($("#newgame-book").val()));
+ let selectedBook = JSON.parse($("#newgame-book").val());
+ newGameController.selectedBookChanged(parseInt(selectedBook.bookNumber), selectedBook.bookSeries);
});
// Random table change
diff --git a/www/data/mechanics-gs-1.xml b/www/data/mechanics-gs-1.xml
new file mode 100644
index 00000000..efd2e747
--- /dev/null
+++ b/www/data/mechanics-gs-1.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file