mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-26 15:57:50 +01:00
basic game creation
This commit is contained in:
@@ -5,8 +5,8 @@ export class DeckStateManager {
|
||||
}
|
||||
|
||||
addToDeck(role) {
|
||||
let option = this.customRoleOptions.find((option) => option.role === role)
|
||||
let existingCard = this.deck.find((card) => card.role === role)
|
||||
let option = this.customRoleOptions.find((option) => option.role === role);
|
||||
let existingCard = this.deck.find((card) => card.role === role);
|
||||
if (option && !existingCard) {
|
||||
option.quantity = 0;
|
||||
this.deck.push(option);
|
||||
@@ -32,11 +32,21 @@ export class DeckStateManager {
|
||||
}
|
||||
}
|
||||
|
||||
getCurrentDeck() { return this.deck }
|
||||
getCurrentDeck() { return this.deck; }
|
||||
|
||||
getCard(role) { return this.deck.find((card) => card.role === role) }
|
||||
getCard(role) {
|
||||
return this.deck.find(
|
||||
(card) => card.role.toLowerCase().trim() === role.toLowerCase().trim()
|
||||
);
|
||||
}
|
||||
|
||||
getCurrentCustomRoleOptions() { return this.customRoleOptions }
|
||||
getCurrentCustomRoleOptions() { return this.customRoleOptions; }
|
||||
|
||||
getCustomRoleOption(role) {
|
||||
return this.customRoleOptions.find(
|
||||
(option) => option.role.toLowerCase().trim() === role.toLowerCase().trim()
|
||||
)
|
||||
};
|
||||
|
||||
getDeckSize() {
|
||||
let total = 0;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export const ModalManager = {
|
||||
displayModal: displayModal
|
||||
displayModal: displayModal,
|
||||
dispelModal: dispelModal
|
||||
}
|
||||
|
||||
function displayModal(modalId, backgroundId, closeButtonId) {
|
||||
|
||||
40
client/modules/XHRUtility.js
Normal file
40
client/modules/XHRUtility.js
Normal file
@@ -0,0 +1,40 @@
|
||||
export const XHRUtility =
|
||||
{
|
||||
standardHeaders: [['Content-Type', 'application/json'], ['Accept', 'application/json'], ['X-Requested-With', 'XMLHttpRequest']],
|
||||
|
||||
// Easily make XHR calls with a promise wrapper. Defaults to GET and MIME type application/JSON
|
||||
xhr (url, method = 'GET', headers, body = null) {
|
||||
if (headers === undefined || headers === null) {
|
||||
headers = this.standardHeaders;
|
||||
}
|
||||
if (typeof url !== 'string' || url.trim().length < 1) {
|
||||
return Promise.reject('Cannot request with empty URL: ' + url);
|
||||
}
|
||||
|
||||
const req = new XMLHttpRequest();
|
||||
req.open(method, url.trim());
|
||||
|
||||
for (const hdr of headers) {
|
||||
if (hdr.length !== 2) continue;
|
||||
req.setRequestHeader(hdr[0], hdr[1]);
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
req.onload = function () {
|
||||
const response = {
|
||||
status: this.status,
|
||||
statusText: this.statusText,
|
||||
content: this.responseText
|
||||
};
|
||||
if (this.status >= 200 && this.status < 400) {
|
||||
resolve(response);
|
||||
} else {
|
||||
reject(response);
|
||||
}
|
||||
};
|
||||
body ? req.send(body) : req.send();
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
2
client/modules/third_party/jQuery/jquery-3.6.0.min.js
vendored
Normal file
2
client/modules/third_party/jQuery/jquery-3.6.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
client/modules/third_party/semantic-ui/dropdown.min.js
vendored
Normal file
1
client/modules/third_party/semantic-ui/dropdown.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3956
client/modules/third_party/semantic-ui/index.js
vendored
Normal file
3956
client/modules/third_party/semantic-ui/index.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
client/modules/third_party/semantic-ui/search.min.js
vendored
Normal file
1
client/modules/third_party/semantic-ui/search.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
client/modules/third_party/semantic-ui/transition.min.js
vendored
Normal file
1
client/modules/third_party/semantic-ui/transition.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user