mirror of
https://github.com/Aviortheking/Puissance4.git
synced 2025-04-22 10:52:15 +00:00
Ajout vérification de vitoire
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
parent
9e007cae96
commit
3a0d29816f
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
||||
node_modules
|
||||
.cache
|
||||
dist/
|
||||
|
26
dist/front.3abc0af9.css
vendored
26
dist/front.3abc0af9.css
vendored
@ -1,26 +0,0 @@
|
||||
body{
|
||||
margin: 0;
|
||||
padding:0;
|
||||
|
||||
}
|
||||
.tableContainer{
|
||||
display:flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 40rem;
|
||||
}
|
||||
table{
|
||||
border: 2px solid;
|
||||
|
||||
}
|
||||
tr{
|
||||
|
||||
border: 1px solid;
|
||||
} td{
|
||||
border: 1px solid;
|
||||
height:10px;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
|
||||
/*# sourceMappingURL=/front.3abc0af9.css.map */
|
1
dist/front.3abc0af9.css.map
vendored
1
dist/front.3abc0af9.css.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"sources":["style.css"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"front.3abc0af9.css","sourceRoot":"../public","sourcesContent":["body{\n\tmargin: 0;\n\tpadding:0;\n\n}\n.tableContainer{\n\tdisplay:flex;\n\talign-items: center;\n\tjustify-content: center;\n\theight: 40rem;\n}\ntable{\n\tborder: 2px solid;\n\n}\ntr{\n\n\tborder: 1px solid;\n} td{\n\tborder: 1px solid;\n\theight:10px;\n\twidth: 20px;\n}\n"]}
|
635
dist/front.3abc0af9.js
vendored
635
dist/front.3abc0af9.js
vendored
@ -1,635 +0,0 @@
|
||||
// modules are defined as an array
|
||||
// [ module function, map of requires ]
|
||||
//
|
||||
// map of requires is short require name -> numeric require
|
||||
//
|
||||
// anything defined in a previous bundle is accessed via the
|
||||
// orig method which is the require for previous bundles
|
||||
parcelRequire = (function (modules, cache, entry, globalName) {
|
||||
// Save the require from previous bundle to this closure if any
|
||||
var previousRequire = typeof parcelRequire === 'function' && parcelRequire;
|
||||
var nodeRequire = typeof require === 'function' && require;
|
||||
|
||||
function newRequire(name, jumped) {
|
||||
if (!cache[name]) {
|
||||
if (!modules[name]) {
|
||||
// if we cannot find the module within our internal map or
|
||||
// cache jump to the current global require ie. the last bundle
|
||||
// that was added to the page.
|
||||
var currentRequire = typeof parcelRequire === 'function' && parcelRequire;
|
||||
if (!jumped && currentRequire) {
|
||||
return currentRequire(name, true);
|
||||
}
|
||||
|
||||
// If there are other bundles on this page the require from the
|
||||
// previous one is saved to 'previousRequire'. Repeat this as
|
||||
// many times as there are bundles until the module is found or
|
||||
// we exhaust the require chain.
|
||||
if (previousRequire) {
|
||||
return previousRequire(name, true);
|
||||
}
|
||||
|
||||
// Try the node require function if it exists.
|
||||
if (nodeRequire && typeof name === 'string') {
|
||||
return nodeRequire(name);
|
||||
}
|
||||
|
||||
var err = new Error('Cannot find module \'' + name + '\'');
|
||||
err.code = 'MODULE_NOT_FOUND';
|
||||
throw err;
|
||||
}
|
||||
|
||||
localRequire.resolve = resolve;
|
||||
localRequire.cache = {};
|
||||
|
||||
var module = cache[name] = new newRequire.Module(name);
|
||||
|
||||
modules[name][0].call(module.exports, localRequire, module, module.exports, this);
|
||||
}
|
||||
|
||||
return cache[name].exports;
|
||||
|
||||
function localRequire(x){
|
||||
return newRequire(localRequire.resolve(x));
|
||||
}
|
||||
|
||||
function resolve(x){
|
||||
return modules[name][1][x] || x;
|
||||
}
|
||||
}
|
||||
|
||||
function Module(moduleName) {
|
||||
this.id = moduleName;
|
||||
this.bundle = newRequire;
|
||||
this.exports = {};
|
||||
}
|
||||
|
||||
newRequire.isParcelRequire = true;
|
||||
newRequire.Module = Module;
|
||||
newRequire.modules = modules;
|
||||
newRequire.cache = cache;
|
||||
newRequire.parent = previousRequire;
|
||||
newRequire.register = function (id, exports) {
|
||||
modules[id] = [function (require, module) {
|
||||
module.exports = exports;
|
||||
}, {}];
|
||||
};
|
||||
|
||||
var error;
|
||||
for (var i = 0; i < entry.length; i++) {
|
||||
try {
|
||||
newRequire(entry[i]);
|
||||
} catch (e) {
|
||||
// Save first error but execute all entries
|
||||
if (!error) {
|
||||
error = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.length) {
|
||||
// Expose entry point to Node, AMD or browser globals
|
||||
// Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
|
||||
var mainExports = newRequire(entry[entry.length - 1]);
|
||||
|
||||
// CommonJS
|
||||
if (typeof exports === "object" && typeof module !== "undefined") {
|
||||
module.exports = mainExports;
|
||||
|
||||
// RequireJS
|
||||
} else if (typeof define === "function" && define.amd) {
|
||||
define(function () {
|
||||
return mainExports;
|
||||
});
|
||||
|
||||
// <script>
|
||||
} else if (globalName) {
|
||||
this[globalName] = mainExports;
|
||||
}
|
||||
}
|
||||
|
||||
// Override the current require with this new one
|
||||
parcelRequire = newRequire;
|
||||
|
||||
if (error) {
|
||||
// throw error from earlier, _after updating parcelRequire_
|
||||
throw error;
|
||||
}
|
||||
|
||||
return newRequire;
|
||||
})({"../node_modules/parcel/src/builtins/bundle-url.js":[function(require,module,exports) {
|
||||
var bundleURL = null;
|
||||
|
||||
function getBundleURLCached() {
|
||||
if (!bundleURL) {
|
||||
bundleURL = getBundleURL();
|
||||
}
|
||||
|
||||
return bundleURL;
|
||||
}
|
||||
|
||||
function getBundleURL() {
|
||||
// Attempt to find the URL of the current script and use that as the base URL
|
||||
try {
|
||||
throw new Error();
|
||||
} catch (err) {
|
||||
var matches = ('' + err.stack).match(/(https?|file|ftp|chrome-extension|moz-extension):\/\/[^)\n]+/g);
|
||||
|
||||
if (matches) {
|
||||
return getBaseURL(matches[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return '/';
|
||||
}
|
||||
|
||||
function getBaseURL(url) {
|
||||
return ('' + url).replace(/^((?:https?|file|ftp|chrome-extension|moz-extension):\/\/.+)\/[^/]+$/, '$1') + '/';
|
||||
}
|
||||
|
||||
exports.getBundleURL = getBundleURLCached;
|
||||
exports.getBaseURL = getBaseURL;
|
||||
},{}],"../node_modules/parcel/src/builtins/css-loader.js":[function(require,module,exports) {
|
||||
var bundle = require('./bundle-url');
|
||||
|
||||
function updateLink(link) {
|
||||
var newLink = link.cloneNode();
|
||||
|
||||
newLink.onload = function () {
|
||||
link.remove();
|
||||
};
|
||||
|
||||
newLink.href = link.href.split('?')[0] + '?' + Date.now();
|
||||
link.parentNode.insertBefore(newLink, link.nextSibling);
|
||||
}
|
||||
|
||||
var cssTimeout = null;
|
||||
|
||||
function reloadCSS() {
|
||||
if (cssTimeout) {
|
||||
return;
|
||||
}
|
||||
|
||||
cssTimeout = setTimeout(function () {
|
||||
var links = document.querySelectorAll('link[rel="stylesheet"]');
|
||||
|
||||
for (var i = 0; i < links.length; i++) {
|
||||
if (bundle.getBaseURL(links[i].href) === bundle.getBundleURL()) {
|
||||
updateLink(links[i]);
|
||||
}
|
||||
}
|
||||
|
||||
cssTimeout = null;
|
||||
}, 50);
|
||||
}
|
||||
|
||||
module.exports = reloadCSS;
|
||||
},{"./bundle-url":"../node_modules/parcel/src/builtins/bundle-url.js"}],"style.css":[function(require,module,exports) {
|
||||
var reloadCSS = require('_css_loader');
|
||||
|
||||
module.hot.dispose(reloadCSS);
|
||||
module.hot.accept(reloadCSS);
|
||||
},{"_css_loader":"../node_modules/parcel/src/builtins/css-loader.js"}],"../node_modules/@dzeio/dom-manager/dist/DOMElement.js":[function(require,module,exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class DOMElement {
|
||||
constructor(tagName, options) {
|
||||
if (tagName instanceof HTMLElement) {
|
||||
this.item = tagName;
|
||||
return;
|
||||
}
|
||||
this.item = document.createElement(tagName, options);
|
||||
}
|
||||
static create(tagName, options) {
|
||||
return new DOMElement(tagName, options);
|
||||
}
|
||||
static get(query, source) {
|
||||
if (!(query instanceof HTMLElement)) {
|
||||
const tmp = (source instanceof DOMElement ? source.item : source || document).querySelector(query);
|
||||
if (!tmp) {
|
||||
return undefined;
|
||||
}
|
||||
return new DOMElement(tmp);
|
||||
}
|
||||
return new DOMElement(query);
|
||||
}
|
||||
on(type, listener, options) {
|
||||
this.item.addEventListener(type, listener, options);
|
||||
return this;
|
||||
}
|
||||
off(type, listener) {
|
||||
this.item.removeEventListener(type, listener);
|
||||
return this;
|
||||
}
|
||||
text(val) {
|
||||
if (val) {
|
||||
this.item.innerText = val;
|
||||
return this;
|
||||
}
|
||||
return this.item.innerText;
|
||||
}
|
||||
html(val) {
|
||||
if (val) {
|
||||
this.item.innerHTML = val;
|
||||
return this;
|
||||
}
|
||||
return this.item.innerText;
|
||||
}
|
||||
addClass(...classes) {
|
||||
this.item.classList.add(...classes);
|
||||
return this;
|
||||
}
|
||||
setClass(...classes) {
|
||||
this.item.classList.forEach((cls) => {
|
||||
if (!classes.includes(cls)) {
|
||||
this.item.classList.remove(cls);
|
||||
}
|
||||
});
|
||||
this.addClass(...classes);
|
||||
return this;
|
||||
}
|
||||
classList(...classes) {
|
||||
if (!classes) {
|
||||
const res = [];
|
||||
this.item.classList.forEach((el) => res.push(el));
|
||||
return res;
|
||||
}
|
||||
return this.setClass(...classes);
|
||||
}
|
||||
toggleClass(...classes) {
|
||||
for (const classe of classes) {
|
||||
this.item.classList.toggle(classe);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
removeClass(...classes) {
|
||||
this.item.classList.remove(...classes);
|
||||
return this;
|
||||
}
|
||||
emit(event) {
|
||||
if (event in this.item) {
|
||||
this.item[event]();
|
||||
return this;
|
||||
}
|
||||
this.item.dispatchEvent(new Event(event));
|
||||
return this;
|
||||
}
|
||||
attr(key, value) {
|
||||
if (!value) {
|
||||
return this.item.getAttribute(key);
|
||||
}
|
||||
if (value === null) {
|
||||
this.item.removeAttribute(key);
|
||||
return this;
|
||||
}
|
||||
if (typeof value === 'boolean') {
|
||||
this.item[key] = value;
|
||||
return this;
|
||||
}
|
||||
this.item.setAttribute(key, value);
|
||||
return this;
|
||||
}
|
||||
data(key, value) {
|
||||
// @ts-ignore
|
||||
return this.attr(`data-${key}`, value);
|
||||
}
|
||||
style(key, value) {
|
||||
if (typeof value === 'undefined') {
|
||||
return this.item.style[key];
|
||||
}
|
||||
this.item.style[key] = value;
|
||||
return this;
|
||||
}
|
||||
exist() {
|
||||
return !!this.item;
|
||||
}
|
||||
placeBefore(item) {
|
||||
if (item instanceof DOMElement) {
|
||||
item = item.item;
|
||||
}
|
||||
const parent = item.parentElement;
|
||||
if (!parent) {
|
||||
throw new Error('can\'t place DOMElement before item because it has no parent');
|
||||
}
|
||||
parent.insertBefore(this.item, item);
|
||||
return this;
|
||||
}
|
||||
placeAsChildOf(item) {
|
||||
if (item instanceof DOMElement) {
|
||||
item = item.item;
|
||||
}
|
||||
item.appendChild(this.item);
|
||||
return this;
|
||||
}
|
||||
place(verb, item) {
|
||||
if (verb === 'before') {
|
||||
return this.placeBefore(item);
|
||||
}
|
||||
else {
|
||||
return this.placeAsChildOf(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.default = DOMElement;
|
||||
|
||||
},{}],"../node_modules/@dzeio/dom-manager/dist/DOMFleetManager.js":[function(require,module,exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const _1 = require(".");
|
||||
class DOMFleetManager {
|
||||
constructor(query, source) {
|
||||
this.query = query;
|
||||
this.source = source;
|
||||
this.items = [];
|
||||
this.refresh();
|
||||
}
|
||||
last() {
|
||||
return this.items[this.items.length - 1];
|
||||
}
|
||||
each(fn) {
|
||||
this.items.forEach((el, index) => fn(el, index));
|
||||
}
|
||||
on(type, listener, options) {
|
||||
this.each((item) => item.on(type, listener, options));
|
||||
}
|
||||
off(type, listener) {
|
||||
this.each((item) => item.off(type, listener));
|
||||
}
|
||||
refresh() {
|
||||
this.items = [];
|
||||
(this.source instanceof _1.DOMElement ? this.source.item : this.source || document).querySelectorAll(this.query).forEach((item) => {
|
||||
const element = _1.DOMElement.get(item);
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
this.items.push(element);
|
||||
});
|
||||
}
|
||||
[Symbol.iterator]() {
|
||||
return this.items;
|
||||
}
|
||||
}
|
||||
exports.default = DOMFleetManager;
|
||||
|
||||
},{".":"../node_modules/@dzeio/dom-manager/dist/index.js"}],"../node_modules/@dzeio/dom-manager/dist/index.js":[function(require,module,exports) {
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DOMFleetManager = exports.DOMElement = void 0;
|
||||
const DOMElement_1 = __importDefault(require("./DOMElement"));
|
||||
exports.DOMElement = DOMElement_1.default;
|
||||
const DOMFleetManager_1 = __importDefault(require("./DOMFleetManager"));
|
||||
exports.DOMFleetManager = DOMFleetManager_1.default;
|
||||
|
||||
},{"./DOMElement":"../node_modules/@dzeio/dom-manager/dist/DOMElement.js","./DOMFleetManager":"../node_modules/@dzeio/dom-manager/dist/DOMFleetManager.js"}],"front.ts":[function(require,module,exports) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
require("./style.css");
|
||||
|
||||
var dom_manager_1 = require("@dzeio/dom-manager");
|
||||
|
||||
var Game =
|
||||
/** @class */
|
||||
function () {
|
||||
function Game(table) {
|
||||
this.table = new dom_manager_1.DOMElement(table);
|
||||
var rows = new dom_manager_1.DOMFleetManager('tr', this.table);
|
||||
rows.each(function (item) {
|
||||
console.log(item.item);
|
||||
});
|
||||
}
|
||||
|
||||
Game.prototype.setupGeneral = function () {};
|
||||
|
||||
Game.prototype.setupMultiplayer = function () {};
|
||||
|
||||
Game.prototype.setupSinglePlayer = function () {};
|
||||
/**
|
||||
* Make a move and return and true if the move was done and false if the move was not done
|
||||
*/
|
||||
|
||||
|
||||
Game.prototype.makeMove = function (xPos) {
|
||||
return true;
|
||||
};
|
||||
|
||||
Game.prototype.checkWinner = function () {};
|
||||
|
||||
Game.prototype.makeIATakeTurn = function () {};
|
||||
|
||||
return Game;
|
||||
}();
|
||||
|
||||
exports.default = Game;
|
||||
},{"./style.css":"style.css","@dzeio/dom-manager":"../node_modules/@dzeio/dom-manager/dist/index.js"}],"../node_modules/parcel/src/builtins/hmr-runtime.js":[function(require,module,exports) {
|
||||
var global = arguments[3];
|
||||
var OVERLAY_ID = '__parcel__error__overlay__';
|
||||
var OldModule = module.bundle.Module;
|
||||
|
||||
function Module(moduleName) {
|
||||
OldModule.call(this, moduleName);
|
||||
this.hot = {
|
||||
data: module.bundle.hotData,
|
||||
_acceptCallbacks: [],
|
||||
_disposeCallbacks: [],
|
||||
accept: function (fn) {
|
||||
this._acceptCallbacks.push(fn || function () {});
|
||||
},
|
||||
dispose: function (fn) {
|
||||
this._disposeCallbacks.push(fn);
|
||||
}
|
||||
};
|
||||
module.bundle.hotData = null;
|
||||
}
|
||||
|
||||
module.bundle.Module = Module;
|
||||
var checkedAssets, assetsToAccept;
|
||||
var parent = module.bundle.parent;
|
||||
|
||||
if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
|
||||
var hostname = "" || location.hostname;
|
||||
var protocol = location.protocol === 'https:' ? 'wss' : 'ws';
|
||||
var ws = new WebSocket(protocol + '://' + hostname + ':' + "42925" + '/');
|
||||
|
||||
ws.onmessage = function (event) {
|
||||
checkedAssets = {};
|
||||
assetsToAccept = [];
|
||||
var data = JSON.parse(event.data);
|
||||
|
||||
if (data.type === 'update') {
|
||||
var handled = false;
|
||||
data.assets.forEach(function (asset) {
|
||||
if (!asset.isNew) {
|
||||
var didAccept = hmrAcceptCheck(global.parcelRequire, asset.id);
|
||||
|
||||
if (didAccept) {
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
}); // Enable HMR for CSS by default.
|
||||
|
||||
handled = handled || data.assets.every(function (asset) {
|
||||
return asset.type === 'css' && asset.generated.js;
|
||||
});
|
||||
|
||||
if (handled) {
|
||||
console.clear();
|
||||
data.assets.forEach(function (asset) {
|
||||
hmrApply(global.parcelRequire, asset);
|
||||
});
|
||||
assetsToAccept.forEach(function (v) {
|
||||
hmrAcceptRun(v[0], v[1]);
|
||||
});
|
||||
} else if (location.reload) {
|
||||
// `location` global exists in a web worker context but lacks `.reload()` function.
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === 'reload') {
|
||||
ws.close();
|
||||
|
||||
ws.onclose = function () {
|
||||
location.reload();
|
||||
};
|
||||
}
|
||||
|
||||
if (data.type === 'error-resolved') {
|
||||
console.log('[parcel] ✨ Error resolved');
|
||||
removeErrorOverlay();
|
||||
}
|
||||
|
||||
if (data.type === 'error') {
|
||||
console.error('[parcel] 🚨 ' + data.error.message + '\n' + data.error.stack);
|
||||
removeErrorOverlay();
|
||||
var overlay = createErrorOverlay(data);
|
||||
document.body.appendChild(overlay);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function removeErrorOverlay() {
|
||||
var overlay = document.getElementById(OVERLAY_ID);
|
||||
|
||||
if (overlay) {
|
||||
overlay.remove();
|
||||
}
|
||||
}
|
||||
|
||||
function createErrorOverlay(data) {
|
||||
var overlay = document.createElement('div');
|
||||
overlay.id = OVERLAY_ID; // html encode message and stack trace
|
||||
|
||||
var message = document.createElement('div');
|
||||
var stackTrace = document.createElement('pre');
|
||||
message.innerText = data.error.message;
|
||||
stackTrace.innerText = data.error.stack;
|
||||
overlay.innerHTML = '<div style="background: black; font-size: 16px; color: white; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; padding: 30px; opacity: 0.85; font-family: Menlo, Consolas, monospace; z-index: 9999;">' + '<span style="background: red; padding: 2px 4px; border-radius: 2px;">ERROR</span>' + '<span style="top: 2px; margin-left: 5px; position: relative;">🚨</span>' + '<div style="font-size: 18px; font-weight: bold; margin-top: 20px;">' + message.innerHTML + '</div>' + '<pre>' + stackTrace.innerHTML + '</pre>' + '</div>';
|
||||
return overlay;
|
||||
}
|
||||
|
||||
function getParents(bundle, id) {
|
||||
var modules = bundle.modules;
|
||||
|
||||
if (!modules) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var parents = [];
|
||||
var k, d, dep;
|
||||
|
||||
for (k in modules) {
|
||||
for (d in modules[k][1]) {
|
||||
dep = modules[k][1][d];
|
||||
|
||||
if (dep === id || Array.isArray(dep) && dep[dep.length - 1] === id) {
|
||||
parents.push(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bundle.parent) {
|
||||
parents = parents.concat(getParents(bundle.parent, id));
|
||||
}
|
||||
|
||||
return parents;
|
||||
}
|
||||
|
||||
function hmrApply(bundle, asset) {
|
||||
var modules = bundle.modules;
|
||||
|
||||
if (!modules) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (modules[asset.id] || !bundle.parent) {
|
||||
var fn = new Function('require', 'module', 'exports', asset.generated.js);
|
||||
asset.isNew = !modules[asset.id];
|
||||
modules[asset.id] = [fn, asset.deps];
|
||||
} else if (bundle.parent) {
|
||||
hmrApply(bundle.parent, asset);
|
||||
}
|
||||
}
|
||||
|
||||
function hmrAcceptCheck(bundle, id) {
|
||||
var modules = bundle.modules;
|
||||
|
||||
if (!modules) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!modules[id] && bundle.parent) {
|
||||
return hmrAcceptCheck(bundle.parent, id);
|
||||
}
|
||||
|
||||
if (checkedAssets[id]) {
|
||||
return;
|
||||
}
|
||||
|
||||
checkedAssets[id] = true;
|
||||
var cached = bundle.cache[id];
|
||||
assetsToAccept.push([bundle, id]);
|
||||
|
||||
if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return getParents(global.parcelRequire, id).some(function (id) {
|
||||
return hmrAcceptCheck(global.parcelRequire, id);
|
||||
});
|
||||
}
|
||||
|
||||
function hmrAcceptRun(bundle, id) {
|
||||
var cached = bundle.cache[id];
|
||||
bundle.hotData = {};
|
||||
|
||||
if (cached) {
|
||||
cached.hot.data = bundle.hotData;
|
||||
}
|
||||
|
||||
if (cached && cached.hot && cached.hot._disposeCallbacks.length) {
|
||||
cached.hot._disposeCallbacks.forEach(function (cb) {
|
||||
cb(bundle.hotData);
|
||||
});
|
||||
}
|
||||
|
||||
delete bundle.cache[id];
|
||||
bundle(id);
|
||||
cached = bundle.cache[id];
|
||||
|
||||
if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
|
||||
cached.hot._acceptCallbacks.forEach(function (cb) {
|
||||
cb();
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},{}]},{},["../node_modules/parcel/src/builtins/hmr-runtime.js","front.ts"], null)
|
||||
//# sourceMappingURL=/front.3abc0af9.js.map
|
1
dist/front.3abc0af9.js.map
vendored
1
dist/front.3abc0af9.js.map
vendored
File diff suppressed because one or more lines are too long
72
dist/index.html
vendored
72
dist/index.html
vendored
@ -1,72 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Puissance 4</title>
|
||||
<link rel="stylesheet" href="/main.c39d6dcf.css"></head>
|
||||
|
||||
<body>
|
||||
<div class="tableContainer">
|
||||
<table>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2</td>
|
||||
<td>2</td>
|
||||
<td>2</td>
|
||||
<td>2</td>
|
||||
<td>2</td>
|
||||
<td>2</td>
|
||||
<td>2</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3</td>
|
||||
<td>3</td>
|
||||
<td>3</td>
|
||||
<td>3</td>
|
||||
<td>3</td>
|
||||
<td>3</td>
|
||||
<td>3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>4</td>
|
||||
<td>4</td>
|
||||
<td>4</td>
|
||||
<td>4</td>
|
||||
<td>4</td>
|
||||
<td>4</td>
|
||||
<td>4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>5</td>
|
||||
<td>5</td>
|
||||
<td>5</td>
|
||||
<td>5</td>
|
||||
<td>5</td>
|
||||
<td>5</td>
|
||||
<td>5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>6</td>
|
||||
<td>6</td>
|
||||
<td>6</td>
|
||||
<td>6</td>
|
||||
<td>6</td>
|
||||
<td>6</td>
|
||||
<td>6</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
<script src="/main.c39d6dcf.js"></script>
|
||||
|
||||
</html>
|
39
dist/main.c39d6dcf.css
vendored
39
dist/main.c39d6dcf.css
vendored
@ -1,39 +0,0 @@
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
}
|
||||
|
||||
.tableContainer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 40rem;
|
||||
}
|
||||
|
||||
table {
|
||||
border: 2px solid;
|
||||
|
||||
}
|
||||
|
||||
tr {
|
||||
|
||||
border: 1px solid;
|
||||
}
|
||||
|
||||
td {
|
||||
border: 1px solid;
|
||||
height: 10px;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
td[data-color="red"] {
|
||||
background: red
|
||||
}
|
||||
|
||||
td[data-color="yellow"] {
|
||||
background: yellow
|
||||
}
|
||||
|
||||
|
||||
/*# sourceMappingURL=/main.c39d6dcf.css.map */
|
1
dist/main.c39d6dcf.css.map
vendored
1
dist/main.c39d6dcf.css.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"sources":["style.css"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"main.c39d6dcf.css","sourceRoot":"../public","sourcesContent":["body {\n margin: 0;\n padding: 0;\n\n}\n\n.tableContainer {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 40rem;\n}\n\ntable {\n border: 2px solid;\n\n}\n\ntr {\n\n border: 1px solid;\n}\n\ntd {\n border: 1px solid;\n height: 10px;\n width: 20px;\n}\n\ntd[data-color=\"red\"] {\n background: red\n}\n\ntd[data-color=\"yellow\"] {\n background: yellow\n}\n"]}
|
722
dist/main.c39d6dcf.js
vendored
722
dist/main.c39d6dcf.js
vendored
@ -1,722 +0,0 @@
|
||||
// modules are defined as an array
|
||||
// [ module function, map of requires ]
|
||||
//
|
||||
// map of requires is short require name -> numeric require
|
||||
//
|
||||
// anything defined in a previous bundle is accessed via the
|
||||
// orig method which is the require for previous bundles
|
||||
parcelRequire = (function (modules, cache, entry, globalName) {
|
||||
// Save the require from previous bundle to this closure if any
|
||||
var previousRequire = typeof parcelRequire === 'function' && parcelRequire;
|
||||
var nodeRequire = typeof require === 'function' && require;
|
||||
|
||||
function newRequire(name, jumped) {
|
||||
if (!cache[name]) {
|
||||
if (!modules[name]) {
|
||||
// if we cannot find the module within our internal map or
|
||||
// cache jump to the current global require ie. the last bundle
|
||||
// that was added to the page.
|
||||
var currentRequire = typeof parcelRequire === 'function' && parcelRequire;
|
||||
if (!jumped && currentRequire) {
|
||||
return currentRequire(name, true);
|
||||
}
|
||||
|
||||
// If there are other bundles on this page the require from the
|
||||
// previous one is saved to 'previousRequire'. Repeat this as
|
||||
// many times as there are bundles until the module is found or
|
||||
// we exhaust the require chain.
|
||||
if (previousRequire) {
|
||||
return previousRequire(name, true);
|
||||
}
|
||||
|
||||
// Try the node require function if it exists.
|
||||
if (nodeRequire && typeof name === 'string') {
|
||||
return nodeRequire(name);
|
||||
}
|
||||
|
||||
var err = new Error('Cannot find module \'' + name + '\'');
|
||||
err.code = 'MODULE_NOT_FOUND';
|
||||
throw err;
|
||||
}
|
||||
|
||||
localRequire.resolve = resolve;
|
||||
localRequire.cache = {};
|
||||
|
||||
var module = cache[name] = new newRequire.Module(name);
|
||||
|
||||
modules[name][0].call(module.exports, localRequire, module, module.exports, this);
|
||||
}
|
||||
|
||||
return cache[name].exports;
|
||||
|
||||
function localRequire(x){
|
||||
return newRequire(localRequire.resolve(x));
|
||||
}
|
||||
|
||||
function resolve(x){
|
||||
return modules[name][1][x] || x;
|
||||
}
|
||||
}
|
||||
|
||||
function Module(moduleName) {
|
||||
this.id = moduleName;
|
||||
this.bundle = newRequire;
|
||||
this.exports = {};
|
||||
}
|
||||
|
||||
newRequire.isParcelRequire = true;
|
||||
newRequire.Module = Module;
|
||||
newRequire.modules = modules;
|
||||
newRequire.cache = cache;
|
||||
newRequire.parent = previousRequire;
|
||||
newRequire.register = function (id, exports) {
|
||||
modules[id] = [function (require, module) {
|
||||
module.exports = exports;
|
||||
}, {}];
|
||||
};
|
||||
|
||||
var error;
|
||||
for (var i = 0; i < entry.length; i++) {
|
||||
try {
|
||||
newRequire(entry[i]);
|
||||
} catch (e) {
|
||||
// Save first error but execute all entries
|
||||
if (!error) {
|
||||
error = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.length) {
|
||||
// Expose entry point to Node, AMD or browser globals
|
||||
// Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
|
||||
var mainExports = newRequire(entry[entry.length - 1]);
|
||||
|
||||
// CommonJS
|
||||
if (typeof exports === "object" && typeof module !== "undefined") {
|
||||
module.exports = mainExports;
|
||||
|
||||
// RequireJS
|
||||
} else if (typeof define === "function" && define.amd) {
|
||||
define(function () {
|
||||
return mainExports;
|
||||
});
|
||||
|
||||
// <script>
|
||||
} else if (globalName) {
|
||||
this[globalName] = mainExports;
|
||||
}
|
||||
}
|
||||
|
||||
// Override the current require with this new one
|
||||
parcelRequire = newRequire;
|
||||
|
||||
if (error) {
|
||||
// throw error from earlier, _after updating parcelRequire_
|
||||
throw error;
|
||||
}
|
||||
|
||||
return newRequire;
|
||||
})({"../node_modules/parcel/src/builtins/bundle-url.js":[function(require,module,exports) {
|
||||
var bundleURL = null;
|
||||
|
||||
function getBundleURLCached() {
|
||||
if (!bundleURL) {
|
||||
bundleURL = getBundleURL();
|
||||
}
|
||||
|
||||
return bundleURL;
|
||||
}
|
||||
|
||||
function getBundleURL() {
|
||||
// Attempt to find the URL of the current script and use that as the base URL
|
||||
try {
|
||||
throw new Error();
|
||||
} catch (err) {
|
||||
var matches = ('' + err.stack).match(/(https?|file|ftp|chrome-extension|moz-extension):\/\/[^)\n]+/g);
|
||||
|
||||
if (matches) {
|
||||
return getBaseURL(matches[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return '/';
|
||||
}
|
||||
|
||||
function getBaseURL(url) {
|
||||
return ('' + url).replace(/^((?:https?|file|ftp|chrome-extension|moz-extension):\/\/.+)\/[^/]+$/, '$1') + '/';
|
||||
}
|
||||
|
||||
exports.getBundleURL = getBundleURLCached;
|
||||
exports.getBaseURL = getBaseURL;
|
||||
},{}],"../node_modules/parcel/src/builtins/css-loader.js":[function(require,module,exports) {
|
||||
var bundle = require('./bundle-url');
|
||||
|
||||
function updateLink(link) {
|
||||
var newLink = link.cloneNode();
|
||||
|
||||
newLink.onload = function () {
|
||||
link.remove();
|
||||
};
|
||||
|
||||
newLink.href = link.href.split('?')[0] + '?' + Date.now();
|
||||
link.parentNode.insertBefore(newLink, link.nextSibling);
|
||||
}
|
||||
|
||||
var cssTimeout = null;
|
||||
|
||||
function reloadCSS() {
|
||||
if (cssTimeout) {
|
||||
return;
|
||||
}
|
||||
|
||||
cssTimeout = setTimeout(function () {
|
||||
var links = document.querySelectorAll('link[rel="stylesheet"]');
|
||||
|
||||
for (var i = 0; i < links.length; i++) {
|
||||
if (bundle.getBaseURL(links[i].href) === bundle.getBundleURL()) {
|
||||
updateLink(links[i]);
|
||||
}
|
||||
}
|
||||
|
||||
cssTimeout = null;
|
||||
}, 50);
|
||||
}
|
||||
|
||||
module.exports = reloadCSS;
|
||||
},{"./bundle-url":"../node_modules/parcel/src/builtins/bundle-url.js"}],"style.css":[function(require,module,exports) {
|
||||
var reloadCSS = require('_css_loader');
|
||||
|
||||
module.hot.dispose(reloadCSS);
|
||||
module.hot.accept(reloadCSS);
|
||||
},{"_css_loader":"../node_modules/parcel/src/builtins/css-loader.js"}],"../node_modules/@dzeio/dom-manager/dist/DOMElement.js":[function(require,module,exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class DOMElement {
|
||||
constructor(tagName, options) {
|
||||
if (tagName instanceof HTMLElement) {
|
||||
this.item = tagName;
|
||||
return;
|
||||
}
|
||||
this.item = document.createElement(tagName, options);
|
||||
}
|
||||
static create(tagName, options) {
|
||||
return new DOMElement(tagName, options);
|
||||
}
|
||||
static get(query, source) {
|
||||
if (!(query instanceof HTMLElement)) {
|
||||
const tmp = (source instanceof DOMElement ? source.item : source || document).querySelector(query);
|
||||
if (!tmp) {
|
||||
return undefined;
|
||||
}
|
||||
return new DOMElement(tmp);
|
||||
}
|
||||
return new DOMElement(query);
|
||||
}
|
||||
on(type, listener, options) {
|
||||
this.item.addEventListener(type, listener, options);
|
||||
return this;
|
||||
}
|
||||
off(type, listener) {
|
||||
this.item.removeEventListener(type, listener);
|
||||
return this;
|
||||
}
|
||||
text(val) {
|
||||
if (val) {
|
||||
this.item.innerText = val;
|
||||
return this;
|
||||
}
|
||||
return this.item.innerText;
|
||||
}
|
||||
html(val) {
|
||||
if (val) {
|
||||
this.item.innerHTML = val;
|
||||
return this;
|
||||
}
|
||||
return this.item.innerText;
|
||||
}
|
||||
addClass(...classes) {
|
||||
this.item.classList.add(...classes);
|
||||
return this;
|
||||
}
|
||||
setClass(...classes) {
|
||||
this.item.classList.forEach((cls) => {
|
||||
if (!classes.includes(cls)) {
|
||||
this.item.classList.remove(cls);
|
||||
}
|
||||
});
|
||||
this.addClass(...classes);
|
||||
return this;
|
||||
}
|
||||
classList(...classes) {
|
||||
if (!classes) {
|
||||
const res = [];
|
||||
this.item.classList.forEach((el) => res.push(el));
|
||||
return res;
|
||||
}
|
||||
return this.setClass(...classes);
|
||||
}
|
||||
toggleClass(...classes) {
|
||||
for (const classe of classes) {
|
||||
this.item.classList.toggle(classe);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
removeClass(...classes) {
|
||||
this.item.classList.remove(...classes);
|
||||
return this;
|
||||
}
|
||||
emit(event) {
|
||||
if (event in this.item) {
|
||||
this.item[event]();
|
||||
return this;
|
||||
}
|
||||
this.item.dispatchEvent(new Event(event));
|
||||
return this;
|
||||
}
|
||||
attr(key, value) {
|
||||
if (!value) {
|
||||
return this.item.getAttribute(key);
|
||||
}
|
||||
if (value === null) {
|
||||
this.item.removeAttribute(key);
|
||||
return this;
|
||||
}
|
||||
if (typeof value === 'boolean') {
|
||||
this.item[key] = value;
|
||||
return this;
|
||||
}
|
||||
this.item.setAttribute(key, value);
|
||||
return this;
|
||||
}
|
||||
data(key, value) {
|
||||
// @ts-ignore
|
||||
return this.attr(`data-${key}`, value);
|
||||
}
|
||||
style(key, value) {
|
||||
if (typeof value === 'undefined') {
|
||||
return this.item.style[key];
|
||||
}
|
||||
this.item.style[key] = value;
|
||||
return this;
|
||||
}
|
||||
exist() {
|
||||
return !!this.item;
|
||||
}
|
||||
placeBefore(item) {
|
||||
if (item instanceof DOMElement) {
|
||||
item = item.item;
|
||||
}
|
||||
const parent = item.parentElement;
|
||||
if (!parent) {
|
||||
throw new Error('can\'t place DOMElement before item because it has no parent');
|
||||
}
|
||||
parent.insertBefore(this.item, item);
|
||||
return this;
|
||||
}
|
||||
placeAsChildOf(item) {
|
||||
if (item instanceof DOMElement) {
|
||||
item = item.item;
|
||||
}
|
||||
item.appendChild(this.item);
|
||||
return this;
|
||||
}
|
||||
place(verb, item) {
|
||||
if (verb === 'before') {
|
||||
return this.placeBefore(item);
|
||||
}
|
||||
else {
|
||||
return this.placeAsChildOf(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.default = DOMElement;
|
||||
|
||||
},{}],"../node_modules/@dzeio/dom-manager/dist/DOMFleetManager.js":[function(require,module,exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const _1 = require(".");
|
||||
class DOMFleetManager {
|
||||
constructor(query, source) {
|
||||
this.query = query;
|
||||
this.source = source;
|
||||
this.items = [];
|
||||
this.refresh();
|
||||
}
|
||||
last() {
|
||||
return this.items[this.items.length - 1];
|
||||
}
|
||||
each(fn) {
|
||||
this.items.forEach((el, index) => fn(el, index));
|
||||
}
|
||||
on(type, listener, options) {
|
||||
this.each((item) => item.on(type, listener, options));
|
||||
}
|
||||
off(type, listener) {
|
||||
this.each((item) => item.off(type, listener));
|
||||
}
|
||||
refresh() {
|
||||
this.items = [];
|
||||
(this.source instanceof _1.DOMElement ? this.source.item : this.source || document).querySelectorAll(this.query).forEach((item) => {
|
||||
const element = _1.DOMElement.get(item);
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
this.items.push(element);
|
||||
});
|
||||
}
|
||||
[Symbol.iterator]() {
|
||||
return this.items;
|
||||
}
|
||||
}
|
||||
exports.default = DOMFleetManager;
|
||||
|
||||
},{".":"../node_modules/@dzeio/dom-manager/dist/index.js"}],"../node_modules/@dzeio/dom-manager/dist/index.js":[function(require,module,exports) {
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DOMFleetManager = exports.DOMElement = void 0;
|
||||
const DOMElement_1 = __importDefault(require("./DOMElement"));
|
||||
exports.DOMElement = DOMElement_1.default;
|
||||
const DOMFleetManager_1 = __importDefault(require("./DOMFleetManager"));
|
||||
exports.DOMFleetManager = DOMFleetManager_1.default;
|
||||
|
||||
},{"./DOMElement":"../node_modules/@dzeio/dom-manager/dist/DOMElement.js","./DOMFleetManager":"../node_modules/@dzeio/dom-manager/dist/DOMFleetManager.js"}],"Game.ts":[function(require,module,exports) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var dom_manager_1 = require("@dzeio/dom-manager");
|
||||
|
||||
var Game =
|
||||
/** @class */
|
||||
function () {
|
||||
function Game(table) {
|
||||
this.columns = [];
|
||||
this.rows = [];
|
||||
this.table = new dom_manager_1.DOMElement(table);
|
||||
this.setupGeneral();
|
||||
}
|
||||
|
||||
Game.prototype.setupGeneral = function () {
|
||||
var _this = this; // Clear la table
|
||||
|
||||
|
||||
var rows = new dom_manager_1.DOMFleetManager('tr', this.table);
|
||||
rows.each(function (item, rowIndex) {
|
||||
var cells = new dom_manager_1.DOMFleetManager('td', item);
|
||||
|
||||
_this.rows.push([]); // cellIndex = 0-6
|
||||
|
||||
|
||||
cells.each(function (cell, cellIndex) {
|
||||
_this.rows[rowIndex].push(cell);
|
||||
|
||||
if (_this.columns.length <= cellIndex) {
|
||||
_this.columns.push([]);
|
||||
}
|
||||
|
||||
_this.columns[cellIndex].push(cell);
|
||||
|
||||
cell.text(' ').data('color', null); // Put each cells in the corresponding column
|
||||
});
|
||||
console.log(_this.columns);
|
||||
}); // Setup la base du jeux
|
||||
};
|
||||
|
||||
Game.prototype.setupMultiplayer = function () {};
|
||||
|
||||
Game.prototype.setupSinglePlayer = function () {};
|
||||
/**
|
||||
* Make a move and return and true if the move was done and false if the move was not done
|
||||
*/
|
||||
|
||||
|
||||
Game.prototype.makeMove = function (xPos, color) {
|
||||
var cellToFill;
|
||||
|
||||
for (var _i = 0, _a = this.columns[xPos]; _i < _a.length; _i++) {
|
||||
var cell = _a[_i];
|
||||
var color_1 = cell.data('color');
|
||||
|
||||
if (!color_1) {
|
||||
cellToFill = cell;
|
||||
}
|
||||
|
||||
if (color_1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cellToFill) {
|
||||
return false;
|
||||
}
|
||||
|
||||
cellToFill.data('color', color);
|
||||
return true;
|
||||
};
|
||||
|
||||
Game.prototype.checkWinner = function () {};
|
||||
|
||||
Game.prototype.makeIATakeTurn = function () {
|
||||
var turnDone = false;
|
||||
|
||||
while (!turnDone) {
|
||||
var pos = getRandomInt(0, this.columns.length - 1);
|
||||
turnDone = this.makeMove(pos, 'red');
|
||||
}
|
||||
};
|
||||
|
||||
return Game;
|
||||
}();
|
||||
|
||||
exports.default = Game;
|
||||
|
||||
function getRandomInt(min, max) {
|
||||
return Math.floor(Math.random() * (max + 1 - min)) + min;
|
||||
} // const cell = new DOMElement('tr')
|
||||
// cell.data('color') // return 'red | 'yello' pour get
|
||||
// cell.data('color', 'red') //return void pour set
|
||||
},{"@dzeio/dom-manager":"../node_modules/@dzeio/dom-manager/dist/index.js"}],"main.ts":[function(require,module,exports) {
|
||||
"use strict";
|
||||
|
||||
var __importDefault = this && this.__importDefault || function (mod) {
|
||||
return mod && mod.__esModule ? mod : {
|
||||
"default": mod
|
||||
};
|
||||
};
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
require("./style.css");
|
||||
|
||||
var Game_1 = __importDefault(require("./Game"));
|
||||
|
||||
var table = document.querySelector('table');
|
||||
|
||||
if (!table) {
|
||||
throw new Error('Table not found');
|
||||
}
|
||||
|
||||
var game = new Game_1.default(table);
|
||||
game.makeMove(0, 'red');
|
||||
game.makeIATakeTurn();
|
||||
game.makeMove(0, 'red');
|
||||
game.makeMove(0, 'red');
|
||||
game.makeMove(0, 'red');
|
||||
game.makeMove(0, 'red');
|
||||
game.makeMove(0, 'red');
|
||||
game.makeMove(0, 'red');
|
||||
game.makeMove(0, 'red');
|
||||
},{"./style.css":"style.css","./Game":"Game.ts"}],"../node_modules/parcel/src/builtins/hmr-runtime.js":[function(require,module,exports) {
|
||||
var global = arguments[3];
|
||||
var OVERLAY_ID = '__parcel__error__overlay__';
|
||||
var OldModule = module.bundle.Module;
|
||||
|
||||
function Module(moduleName) {
|
||||
OldModule.call(this, moduleName);
|
||||
this.hot = {
|
||||
data: module.bundle.hotData,
|
||||
_acceptCallbacks: [],
|
||||
_disposeCallbacks: [],
|
||||
accept: function (fn) {
|
||||
this._acceptCallbacks.push(fn || function () {});
|
||||
},
|
||||
dispose: function (fn) {
|
||||
this._disposeCallbacks.push(fn);
|
||||
}
|
||||
};
|
||||
module.bundle.hotData = null;
|
||||
}
|
||||
|
||||
module.bundle.Module = Module;
|
||||
var checkedAssets, assetsToAccept;
|
||||
var parent = module.bundle.parent;
|
||||
|
||||
if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
|
||||
var hostname = "" || location.hostname;
|
||||
var protocol = location.protocol === 'https:' ? 'wss' : 'ws';
|
||||
var ws = new WebSocket(protocol + '://' + hostname + ':' + "42925" + '/');
|
||||
|
||||
ws.onmessage = function (event) {
|
||||
checkedAssets = {};
|
||||
assetsToAccept = [];
|
||||
var data = JSON.parse(event.data);
|
||||
|
||||
if (data.type === 'update') {
|
||||
var handled = false;
|
||||
data.assets.forEach(function (asset) {
|
||||
if (!asset.isNew) {
|
||||
var didAccept = hmrAcceptCheck(global.parcelRequire, asset.id);
|
||||
|
||||
if (didAccept) {
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
}); // Enable HMR for CSS by default.
|
||||
|
||||
handled = handled || data.assets.every(function (asset) {
|
||||
return asset.type === 'css' && asset.generated.js;
|
||||
});
|
||||
|
||||
if (handled) {
|
||||
console.clear();
|
||||
data.assets.forEach(function (asset) {
|
||||
hmrApply(global.parcelRequire, asset);
|
||||
});
|
||||
assetsToAccept.forEach(function (v) {
|
||||
hmrAcceptRun(v[0], v[1]);
|
||||
});
|
||||
} else if (location.reload) {
|
||||
// `location` global exists in a web worker context but lacks `.reload()` function.
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === 'reload') {
|
||||
ws.close();
|
||||
|
||||
ws.onclose = function () {
|
||||
location.reload();
|
||||
};
|
||||
}
|
||||
|
||||
if (data.type === 'error-resolved') {
|
||||
console.log('[parcel] ✨ Error resolved');
|
||||
removeErrorOverlay();
|
||||
}
|
||||
|
||||
if (data.type === 'error') {
|
||||
console.error('[parcel] 🚨 ' + data.error.message + '\n' + data.error.stack);
|
||||
removeErrorOverlay();
|
||||
var overlay = createErrorOverlay(data);
|
||||
document.body.appendChild(overlay);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function removeErrorOverlay() {
|
||||
var overlay = document.getElementById(OVERLAY_ID);
|
||||
|
||||
if (overlay) {
|
||||
overlay.remove();
|
||||
}
|
||||
}
|
||||
|
||||
function createErrorOverlay(data) {
|
||||
var overlay = document.createElement('div');
|
||||
overlay.id = OVERLAY_ID; // html encode message and stack trace
|
||||
|
||||
var message = document.createElement('div');
|
||||
var stackTrace = document.createElement('pre');
|
||||
message.innerText = data.error.message;
|
||||
stackTrace.innerText = data.error.stack;
|
||||
overlay.innerHTML = '<div style="background: black; font-size: 16px; color: white; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; padding: 30px; opacity: 0.85; font-family: Menlo, Consolas, monospace; z-index: 9999;">' + '<span style="background: red; padding: 2px 4px; border-radius: 2px;">ERROR</span>' + '<span style="top: 2px; margin-left: 5px; position: relative;">🚨</span>' + '<div style="font-size: 18px; font-weight: bold; margin-top: 20px;">' + message.innerHTML + '</div>' + '<pre>' + stackTrace.innerHTML + '</pre>' + '</div>';
|
||||
return overlay;
|
||||
}
|
||||
|
||||
function getParents(bundle, id) {
|
||||
var modules = bundle.modules;
|
||||
|
||||
if (!modules) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var parents = [];
|
||||
var k, d, dep;
|
||||
|
||||
for (k in modules) {
|
||||
for (d in modules[k][1]) {
|
||||
dep = modules[k][1][d];
|
||||
|
||||
if (dep === id || Array.isArray(dep) && dep[dep.length - 1] === id) {
|
||||
parents.push(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bundle.parent) {
|
||||
parents = parents.concat(getParents(bundle.parent, id));
|
||||
}
|
||||
|
||||
return parents;
|
||||
}
|
||||
|
||||
function hmrApply(bundle, asset) {
|
||||
var modules = bundle.modules;
|
||||
|
||||
if (!modules) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (modules[asset.id] || !bundle.parent) {
|
||||
var fn = new Function('require', 'module', 'exports', asset.generated.js);
|
||||
asset.isNew = !modules[asset.id];
|
||||
modules[asset.id] = [fn, asset.deps];
|
||||
} else if (bundle.parent) {
|
||||
hmrApply(bundle.parent, asset);
|
||||
}
|
||||
}
|
||||
|
||||
function hmrAcceptCheck(bundle, id) {
|
||||
var modules = bundle.modules;
|
||||
|
||||
if (!modules) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!modules[id] && bundle.parent) {
|
||||
return hmrAcceptCheck(bundle.parent, id);
|
||||
}
|
||||
|
||||
if (checkedAssets[id]) {
|
||||
return;
|
||||
}
|
||||
|
||||
checkedAssets[id] = true;
|
||||
var cached = bundle.cache[id];
|
||||
assetsToAccept.push([bundle, id]);
|
||||
|
||||
if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return getParents(global.parcelRequire, id).some(function (id) {
|
||||
return hmrAcceptCheck(global.parcelRequire, id);
|
||||
});
|
||||
}
|
||||
|
||||
function hmrAcceptRun(bundle, id) {
|
||||
var cached = bundle.cache[id];
|
||||
bundle.hotData = {};
|
||||
|
||||
if (cached) {
|
||||
cached.hot.data = bundle.hotData;
|
||||
}
|
||||
|
||||
if (cached && cached.hot && cached.hot._disposeCallbacks.length) {
|
||||
cached.hot._disposeCallbacks.forEach(function (cb) {
|
||||
cb(bundle.hotData);
|
||||
});
|
||||
}
|
||||
|
||||
delete bundle.cache[id];
|
||||
bundle(id);
|
||||
cached = bundle.cache[id];
|
||||
|
||||
if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
|
||||
cached.hot._acceptCallbacks.forEach(function (cb) {
|
||||
cb();
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},{}]},{},["../node_modules/parcel/src/builtins/hmr-runtime.js","main.ts"], null)
|
||||
//# sourceMappingURL=/main.c39d6dcf.js.map
|
1
dist/main.c39d6dcf.js.map
vendored
1
dist/main.c39d6dcf.js.map
vendored
File diff suppressed because one or more lines are too long
26
dist/style.e308ff8e.css
vendored
26
dist/style.e308ff8e.css
vendored
@ -1,26 +0,0 @@
|
||||
body{
|
||||
margin: 0;
|
||||
padding:0;
|
||||
|
||||
}
|
||||
.tableContainer{
|
||||
display:flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 40rem;
|
||||
}
|
||||
table{
|
||||
border: 2px solid;
|
||||
|
||||
}
|
||||
tr{
|
||||
|
||||
border: 1px solid;
|
||||
} td{
|
||||
border: 1px solid;
|
||||
height:10px;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
|
||||
/*# sourceMappingURL=/style.e308ff8e.css.map */
|
1
dist/style.e308ff8e.css.map
vendored
1
dist/style.e308ff8e.css.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"sources":["style.css"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"style.e308ff8e.css","sourceRoot":"../public","sourcesContent":["body{\n\tmargin: 0;\n\tpadding:0;\n\n}\n.tableContainer{\n\tdisplay:flex;\n\talign-items: center;\n\tjustify-content: center;\n\theight: 40rem;\n}\ntable{\n\tborder: 2px solid;\n\n}\ntr{\n\n\tborder: 1px solid;\n} td{\n\tborder: 1px solid;\n\theight:10px;\n\twidth: 20px;\n}\n"]}
|
397
dist/style.e308ff8e.js
vendored
397
dist/style.e308ff8e.js
vendored
@ -1,397 +0,0 @@
|
||||
// modules are defined as an array
|
||||
// [ module function, map of requires ]
|
||||
//
|
||||
// map of requires is short require name -> numeric require
|
||||
//
|
||||
// anything defined in a previous bundle is accessed via the
|
||||
// orig method which is the require for previous bundles
|
||||
parcelRequire = (function (modules, cache, entry, globalName) {
|
||||
// Save the require from previous bundle to this closure if any
|
||||
var previousRequire = typeof parcelRequire === 'function' && parcelRequire;
|
||||
var nodeRequire = typeof require === 'function' && require;
|
||||
|
||||
function newRequire(name, jumped) {
|
||||
if (!cache[name]) {
|
||||
if (!modules[name]) {
|
||||
// if we cannot find the module within our internal map or
|
||||
// cache jump to the current global require ie. the last bundle
|
||||
// that was added to the page.
|
||||
var currentRequire = typeof parcelRequire === 'function' && parcelRequire;
|
||||
if (!jumped && currentRequire) {
|
||||
return currentRequire(name, true);
|
||||
}
|
||||
|
||||
// If there are other bundles on this page the require from the
|
||||
// previous one is saved to 'previousRequire'. Repeat this as
|
||||
// many times as there are bundles until the module is found or
|
||||
// we exhaust the require chain.
|
||||
if (previousRequire) {
|
||||
return previousRequire(name, true);
|
||||
}
|
||||
|
||||
// Try the node require function if it exists.
|
||||
if (nodeRequire && typeof name === 'string') {
|
||||
return nodeRequire(name);
|
||||
}
|
||||
|
||||
var err = new Error('Cannot find module \'' + name + '\'');
|
||||
err.code = 'MODULE_NOT_FOUND';
|
||||
throw err;
|
||||
}
|
||||
|
||||
localRequire.resolve = resolve;
|
||||
localRequire.cache = {};
|
||||
|
||||
var module = cache[name] = new newRequire.Module(name);
|
||||
|
||||
modules[name][0].call(module.exports, localRequire, module, module.exports, this);
|
||||
}
|
||||
|
||||
return cache[name].exports;
|
||||
|
||||
function localRequire(x){
|
||||
return newRequire(localRequire.resolve(x));
|
||||
}
|
||||
|
||||
function resolve(x){
|
||||
return modules[name][1][x] || x;
|
||||
}
|
||||
}
|
||||
|
||||
function Module(moduleName) {
|
||||
this.id = moduleName;
|
||||
this.bundle = newRequire;
|
||||
this.exports = {};
|
||||
}
|
||||
|
||||
newRequire.isParcelRequire = true;
|
||||
newRequire.Module = Module;
|
||||
newRequire.modules = modules;
|
||||
newRequire.cache = cache;
|
||||
newRequire.parent = previousRequire;
|
||||
newRequire.register = function (id, exports) {
|
||||
modules[id] = [function (require, module) {
|
||||
module.exports = exports;
|
||||
}, {}];
|
||||
};
|
||||
|
||||
var error;
|
||||
for (var i = 0; i < entry.length; i++) {
|
||||
try {
|
||||
newRequire(entry[i]);
|
||||
} catch (e) {
|
||||
// Save first error but execute all entries
|
||||
if (!error) {
|
||||
error = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.length) {
|
||||
// Expose entry point to Node, AMD or browser globals
|
||||
// Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
|
||||
var mainExports = newRequire(entry[entry.length - 1]);
|
||||
|
||||
// CommonJS
|
||||
if (typeof exports === "object" && typeof module !== "undefined") {
|
||||
module.exports = mainExports;
|
||||
|
||||
// RequireJS
|
||||
} else if (typeof define === "function" && define.amd) {
|
||||
define(function () {
|
||||
return mainExports;
|
||||
});
|
||||
|
||||
// <script>
|
||||
} else if (globalName) {
|
||||
this[globalName] = mainExports;
|
||||
}
|
||||
}
|
||||
|
||||
// Override the current require with this new one
|
||||
parcelRequire = newRequire;
|
||||
|
||||
if (error) {
|
||||
// throw error from earlier, _after updating parcelRequire_
|
||||
throw error;
|
||||
}
|
||||
|
||||
return newRequire;
|
||||
})({"../node_modules/parcel/src/builtins/bundle-url.js":[function(require,module,exports) {
|
||||
var bundleURL = null;
|
||||
|
||||
function getBundleURLCached() {
|
||||
if (!bundleURL) {
|
||||
bundleURL = getBundleURL();
|
||||
}
|
||||
|
||||
return bundleURL;
|
||||
}
|
||||
|
||||
function getBundleURL() {
|
||||
// Attempt to find the URL of the current script and use that as the base URL
|
||||
try {
|
||||
throw new Error();
|
||||
} catch (err) {
|
||||
var matches = ('' + err.stack).match(/(https?|file|ftp|chrome-extension|moz-extension):\/\/[^)\n]+/g);
|
||||
|
||||
if (matches) {
|
||||
return getBaseURL(matches[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return '/';
|
||||
}
|
||||
|
||||
function getBaseURL(url) {
|
||||
return ('' + url).replace(/^((?:https?|file|ftp|chrome-extension|moz-extension):\/\/.+)\/[^/]+$/, '$1') + '/';
|
||||
}
|
||||
|
||||
exports.getBundleURL = getBundleURLCached;
|
||||
exports.getBaseURL = getBaseURL;
|
||||
},{}],"../node_modules/parcel/src/builtins/css-loader.js":[function(require,module,exports) {
|
||||
var bundle = require('./bundle-url');
|
||||
|
||||
function updateLink(link) {
|
||||
var newLink = link.cloneNode();
|
||||
|
||||
newLink.onload = function () {
|
||||
link.remove();
|
||||
};
|
||||
|
||||
newLink.href = link.href.split('?')[0] + '?' + Date.now();
|
||||
link.parentNode.insertBefore(newLink, link.nextSibling);
|
||||
}
|
||||
|
||||
var cssTimeout = null;
|
||||
|
||||
function reloadCSS() {
|
||||
if (cssTimeout) {
|
||||
return;
|
||||
}
|
||||
|
||||
cssTimeout = setTimeout(function () {
|
||||
var links = document.querySelectorAll('link[rel="stylesheet"]');
|
||||
|
||||
for (var i = 0; i < links.length; i++) {
|
||||
if (bundle.getBaseURL(links[i].href) === bundle.getBundleURL()) {
|
||||
updateLink(links[i]);
|
||||
}
|
||||
}
|
||||
|
||||
cssTimeout = null;
|
||||
}, 50);
|
||||
}
|
||||
|
||||
module.exports = reloadCSS;
|
||||
},{"./bundle-url":"../node_modules/parcel/src/builtins/bundle-url.js"}],"style.css":[function(require,module,exports) {
|
||||
var reloadCSS = require('_css_loader');
|
||||
|
||||
module.hot.dispose(reloadCSS);
|
||||
module.hot.accept(reloadCSS);
|
||||
},{"_css_loader":"../node_modules/parcel/src/builtins/css-loader.js"}],"../node_modules/parcel/src/builtins/hmr-runtime.js":[function(require,module,exports) {
|
||||
var global = arguments[3];
|
||||
var OVERLAY_ID = '__parcel__error__overlay__';
|
||||
var OldModule = module.bundle.Module;
|
||||
|
||||
function Module(moduleName) {
|
||||
OldModule.call(this, moduleName);
|
||||
this.hot = {
|
||||
data: module.bundle.hotData,
|
||||
_acceptCallbacks: [],
|
||||
_disposeCallbacks: [],
|
||||
accept: function (fn) {
|
||||
this._acceptCallbacks.push(fn || function () {});
|
||||
},
|
||||
dispose: function (fn) {
|
||||
this._disposeCallbacks.push(fn);
|
||||
}
|
||||
};
|
||||
module.bundle.hotData = null;
|
||||
}
|
||||
|
||||
module.bundle.Module = Module;
|
||||
var checkedAssets, assetsToAccept;
|
||||
var parent = module.bundle.parent;
|
||||
|
||||
if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
|
||||
var hostname = "" || location.hostname;
|
||||
var protocol = location.protocol === 'https:' ? 'wss' : 'ws';
|
||||
var ws = new WebSocket(protocol + '://' + hostname + ':' + "42925" + '/');
|
||||
|
||||
ws.onmessage = function (event) {
|
||||
checkedAssets = {};
|
||||
assetsToAccept = [];
|
||||
var data = JSON.parse(event.data);
|
||||
|
||||
if (data.type === 'update') {
|
||||
var handled = false;
|
||||
data.assets.forEach(function (asset) {
|
||||
if (!asset.isNew) {
|
||||
var didAccept = hmrAcceptCheck(global.parcelRequire, asset.id);
|
||||
|
||||
if (didAccept) {
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
}); // Enable HMR for CSS by default.
|
||||
|
||||
handled = handled || data.assets.every(function (asset) {
|
||||
return asset.type === 'css' && asset.generated.js;
|
||||
});
|
||||
|
||||
if (handled) {
|
||||
console.clear();
|
||||
data.assets.forEach(function (asset) {
|
||||
hmrApply(global.parcelRequire, asset);
|
||||
});
|
||||
assetsToAccept.forEach(function (v) {
|
||||
hmrAcceptRun(v[0], v[1]);
|
||||
});
|
||||
} else if (location.reload) {
|
||||
// `location` global exists in a web worker context but lacks `.reload()` function.
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === 'reload') {
|
||||
ws.close();
|
||||
|
||||
ws.onclose = function () {
|
||||
location.reload();
|
||||
};
|
||||
}
|
||||
|
||||
if (data.type === 'error-resolved') {
|
||||
console.log('[parcel] ✨ Error resolved');
|
||||
removeErrorOverlay();
|
||||
}
|
||||
|
||||
if (data.type === 'error') {
|
||||
console.error('[parcel] 🚨 ' + data.error.message + '\n' + data.error.stack);
|
||||
removeErrorOverlay();
|
||||
var overlay = createErrorOverlay(data);
|
||||
document.body.appendChild(overlay);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function removeErrorOverlay() {
|
||||
var overlay = document.getElementById(OVERLAY_ID);
|
||||
|
||||
if (overlay) {
|
||||
overlay.remove();
|
||||
}
|
||||
}
|
||||
|
||||
function createErrorOverlay(data) {
|
||||
var overlay = document.createElement('div');
|
||||
overlay.id = OVERLAY_ID; // html encode message and stack trace
|
||||
|
||||
var message = document.createElement('div');
|
||||
var stackTrace = document.createElement('pre');
|
||||
message.innerText = data.error.message;
|
||||
stackTrace.innerText = data.error.stack;
|
||||
overlay.innerHTML = '<div style="background: black; font-size: 16px; color: white; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; padding: 30px; opacity: 0.85; font-family: Menlo, Consolas, monospace; z-index: 9999;">' + '<span style="background: red; padding: 2px 4px; border-radius: 2px;">ERROR</span>' + '<span style="top: 2px; margin-left: 5px; position: relative;">🚨</span>' + '<div style="font-size: 18px; font-weight: bold; margin-top: 20px;">' + message.innerHTML + '</div>' + '<pre>' + stackTrace.innerHTML + '</pre>' + '</div>';
|
||||
return overlay;
|
||||
}
|
||||
|
||||
function getParents(bundle, id) {
|
||||
var modules = bundle.modules;
|
||||
|
||||
if (!modules) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var parents = [];
|
||||
var k, d, dep;
|
||||
|
||||
for (k in modules) {
|
||||
for (d in modules[k][1]) {
|
||||
dep = modules[k][1][d];
|
||||
|
||||
if (dep === id || Array.isArray(dep) && dep[dep.length - 1] === id) {
|
||||
parents.push(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bundle.parent) {
|
||||
parents = parents.concat(getParents(bundle.parent, id));
|
||||
}
|
||||
|
||||
return parents;
|
||||
}
|
||||
|
||||
function hmrApply(bundle, asset) {
|
||||
var modules = bundle.modules;
|
||||
|
||||
if (!modules) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (modules[asset.id] || !bundle.parent) {
|
||||
var fn = new Function('require', 'module', 'exports', asset.generated.js);
|
||||
asset.isNew = !modules[asset.id];
|
||||
modules[asset.id] = [fn, asset.deps];
|
||||
} else if (bundle.parent) {
|
||||
hmrApply(bundle.parent, asset);
|
||||
}
|
||||
}
|
||||
|
||||
function hmrAcceptCheck(bundle, id) {
|
||||
var modules = bundle.modules;
|
||||
|
||||
if (!modules) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!modules[id] && bundle.parent) {
|
||||
return hmrAcceptCheck(bundle.parent, id);
|
||||
}
|
||||
|
||||
if (checkedAssets[id]) {
|
||||
return;
|
||||
}
|
||||
|
||||
checkedAssets[id] = true;
|
||||
var cached = bundle.cache[id];
|
||||
assetsToAccept.push([bundle, id]);
|
||||
|
||||
if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return getParents(global.parcelRequire, id).some(function (id) {
|
||||
return hmrAcceptCheck(global.parcelRequire, id);
|
||||
});
|
||||
}
|
||||
|
||||
function hmrAcceptRun(bundle, id) {
|
||||
var cached = bundle.cache[id];
|
||||
bundle.hotData = {};
|
||||
|
||||
if (cached) {
|
||||
cached.hot.data = bundle.hotData;
|
||||
}
|
||||
|
||||
if (cached && cached.hot && cached.hot._disposeCallbacks.length) {
|
||||
cached.hot._disposeCallbacks.forEach(function (cb) {
|
||||
cb(bundle.hotData);
|
||||
});
|
||||
}
|
||||
|
||||
delete bundle.cache[id];
|
||||
bundle(id);
|
||||
cached = bundle.cache[id];
|
||||
|
||||
if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
|
||||
cached.hot._acceptCallbacks.forEach(function (cb) {
|
||||
cb();
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},{}]},{},["../node_modules/parcel/src/builtins/hmr-runtime.js"], null)
|
||||
//# sourceMappingURL=/style.e308ff8e.js.map
|
1
dist/style.e308ff8e.js.map
vendored
1
dist/style.e308ff8e.js.map
vendored
File diff suppressed because one or more lines are too long
@ -4,6 +4,7 @@
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@dzeio/dom-manager": "^1.2.2",
|
||||
"@types/express": "^4.17.9",
|
||||
"express": "^4.17.1",
|
||||
"nodemon": "^2.0.6",
|
||||
@ -15,5 +16,8 @@
|
||||
"start": "ts-node main.ts",
|
||||
"dev-front": "parcel public/index.html",
|
||||
"dev": "ts-node-dev main.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"parcel": "^1.12.4"
|
||||
}
|
||||
}
|
||||
|
136
public/Game.ts
136
public/Game.ts
@ -5,7 +5,8 @@ export default class Game {
|
||||
|
||||
private table: DOMElement<HTMLTableElement>
|
||||
private columns: Array<Array<DOMElement>> = []
|
||||
private rows: Array<Array<DOMElement>> = []
|
||||
|
||||
private gameStarted = false
|
||||
|
||||
public constructor(
|
||||
table: HTMLTableElement
|
||||
@ -16,13 +17,12 @@ export default class Game {
|
||||
|
||||
public setupGeneral() {
|
||||
// Clear la table
|
||||
this.columns = []
|
||||
const rows = new DOMFleetManager('tr', this.table)
|
||||
rows.each((item, rowIndex) => {
|
||||
const cells = new DOMFleetManager('td', item)
|
||||
this.rows.push([])
|
||||
// cellIndex = 0-6
|
||||
cells.each((cell, cellIndex) => {
|
||||
this.rows[rowIndex].push(cell)
|
||||
if (this.columns.length <= cellIndex) {
|
||||
this.columns.push([])
|
||||
}
|
||||
@ -31,6 +31,15 @@ export default class Game {
|
||||
cell
|
||||
.text(' ')
|
||||
.data('color', null)
|
||||
.data('winner', null)
|
||||
if (cell.data('event-added') === null) {
|
||||
cell.on('click', () => {
|
||||
if (this.gameStarted) {
|
||||
this.onPlayerMove(cell, cellIndex)
|
||||
}
|
||||
})
|
||||
cell.data('event-added', 'true')
|
||||
}
|
||||
|
||||
// Put each cells in the corresponding column
|
||||
|
||||
@ -40,37 +49,146 @@ export default class Game {
|
||||
})
|
||||
|
||||
// Setup la base du jeux
|
||||
|
||||
}
|
||||
|
||||
public setupMultiplayer() { }
|
||||
public setRestartButton(btn: DOMElement) {
|
||||
btn.on('click', () => {
|
||||
this.setupGeneral()
|
||||
this.startSinglePlayer()
|
||||
})
|
||||
}
|
||||
|
||||
public setupSinglePlayer() { }
|
||||
public isWaitingForPlayerMove = false
|
||||
public playerColor: 'red' | 'yellow' = 'red'
|
||||
public gameType: 'single' | 'multi' = 'single'
|
||||
|
||||
public startSinglePlayer() {
|
||||
this.gameStarted = true
|
||||
this.isWaitingForPlayerMove = true
|
||||
}
|
||||
|
||||
public setPlayerTurn(player: boolean) {
|
||||
const playerShower = DOMElement.get('.playerColor')
|
||||
if (!playerShower) {
|
||||
return
|
||||
}
|
||||
playerShower.text(player ? this.playerColor : this.playerColor === 'red' ? 'yellow' : 'red')
|
||||
if (player) {
|
||||
this.isWaitingForPlayerMove = true
|
||||
}
|
||||
}
|
||||
|
||||
public setupMultiplayer() {}
|
||||
|
||||
public onPlayerMove(cell: DOMElement, xPos: number) {
|
||||
if (this.isWaitingForPlayerMove) {
|
||||
this.isWaitingForPlayerMove = !this.makeMove(xPos, this.playerColor)
|
||||
if (this.isWaitingForPlayerMove) {
|
||||
return
|
||||
}
|
||||
if (this.gameType === 'single' && this.gameStarted) {
|
||||
setTimeout(() => {
|
||||
this.makeIATakeTurn()
|
||||
this.setPlayerTurn(true)
|
||||
}, getRandomInt(200, 2000))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a move and return and true if the move was done and false if the move was not done
|
||||
*/
|
||||
public makeMove(xPos: number, color: 'red' | 'yellow'): boolean {
|
||||
|
||||
let cellToFill: DOMElement | undefined
|
||||
for (const cell of this.columns[xPos]) {
|
||||
let yPos = 0
|
||||
for (let i = 0; i < this.columns[xPos].length; i++) {
|
||||
const cell = this.columns[xPos][i];
|
||||
const color = cell.data('color')
|
||||
if (!color) {
|
||||
cellToFill = cell
|
||||
yPos = i
|
||||
}
|
||||
if (color) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
console.log('cellToFill', cellToFill)
|
||||
if (!cellToFill) {
|
||||
return false
|
||||
}
|
||||
cellToFill.data('color', color)
|
||||
this.checkWinner(xPos, yPos)
|
||||
return true
|
||||
}
|
||||
|
||||
public checkWinner() {
|
||||
public checkWinner(x: number, y: number) {
|
||||
const win = this.checkDirection(x, y, 'horizontal') || this.checkDirection(x, y, 'vertical') || this.checkDirection(x, y, 'diagonal-left') || this.checkDirection(x, y, 'diagonal-right')
|
||||
if (win === false) {
|
||||
console.log('FALSE')
|
||||
return false
|
||||
}
|
||||
console.log(win)
|
||||
win.forEach((item) => {
|
||||
console.log(item.data('winner', 'true'))
|
||||
})
|
||||
this.gameStarted = false
|
||||
}
|
||||
|
||||
public checkDirection(x: number, y: number, direction: 'horizontal' | 'vertical' | 'diagonal-left' | 'diagonal-right'): Array<DOMElement> | false {
|
||||
console.log('Starting Check', direction)
|
||||
const color = this.columns[x][y].data('color')
|
||||
if (!color) {
|
||||
return false
|
||||
}
|
||||
const items = []
|
||||
let wentReverse: number | undefined
|
||||
for (let i = 0; i < 4; i++) {
|
||||
let newX = x
|
||||
if (direction === 'horizontal' || direction.startsWith('diagonal')) {
|
||||
newX = typeof wentReverse !== 'undefined' ? x + i - wentReverse : x - i
|
||||
if (direction === 'diagonal-left') {
|
||||
newX = typeof wentReverse !== 'undefined' ? x - i + wentReverse : x + i
|
||||
}
|
||||
}
|
||||
let newY = y
|
||||
if (direction === 'vertical' || direction.startsWith('diagonal')) {
|
||||
newY = typeof wentReverse !== 'undefined' ? y + i - wentReverse : y - i
|
||||
}
|
||||
|
||||
console.log('index', i, 'y', newY, 'Y exist', this.isYCorrect(newY))
|
||||
console.log('index', i, 'x', newX, 'X exist', this.isXCorrect(newX))
|
||||
|
||||
if (!this.isYCorrect(newY) || !this.isXCorrect(newX)) {
|
||||
if (typeof wentReverse === 'undefined') {
|
||||
wentReverse = --i
|
||||
continue
|
||||
}
|
||||
return false
|
||||
}
|
||||
const element = this.columns[newX][newY]
|
||||
|
||||
console.log('element color', element.data('color'), 'color wanted', color)
|
||||
|
||||
if (element.data('color') !== color) {
|
||||
if (typeof wentReverse === 'undefined') {
|
||||
wentReverse = --i
|
||||
continue
|
||||
}
|
||||
return false
|
||||
}
|
||||
items.push(element)
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
private isXCorrect(x: number) {
|
||||
return x >= 0 && x < this.columns.length
|
||||
}
|
||||
|
||||
private isYCorrect(y: number) {
|
||||
return y >= 0 && y < this.columns[0].length
|
||||
}
|
||||
|
||||
public makeIATakeTurn() {
|
||||
|
@ -8,6 +8,8 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>Tour du joueur <span class="playerColor"></span></div>
|
||||
<button class="restartBtn">Recommencer</button>
|
||||
<div class="tableContainer">
|
||||
<table>
|
||||
<tr>
|
||||
|
@ -1,6 +1,7 @@
|
||||
import './style.css'
|
||||
|
||||
import Game from './Game'
|
||||
import { DOMElement } from '@dzeio/dom-manager'
|
||||
|
||||
const table = document.querySelector('table')
|
||||
|
||||
@ -9,12 +10,12 @@ if (!table) {
|
||||
}
|
||||
|
||||
const game = new Game(table)
|
||||
game.makeMove(0, 'red')
|
||||
game.makeIATakeTurn()
|
||||
game.makeMove(0, 'red')
|
||||
game.makeMove(0, 'red')
|
||||
game.makeMove(0, 'red')
|
||||
game.makeMove(0, 'red')
|
||||
game.makeMove(0, 'red')
|
||||
game.makeMove(0, 'red')
|
||||
game.makeMove(0, 'red')
|
||||
const restartBtn = DOMElement.get('.restartBtn')
|
||||
if (restartBtn) {
|
||||
game.setRestartButton(restartBtn)
|
||||
}
|
||||
|
||||
game.playerColor = 'yellow'
|
||||
game.startSinglePlayer()
|
||||
|
||||
window.dm = DOMElement
|
||||
|
@ -34,3 +34,7 @@ td[data-color="red"] {
|
||||
td[data-color="yellow"] {
|
||||
background: yellow
|
||||
}
|
||||
|
||||
td[data-winner="true"] {
|
||||
background: gold
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user