aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates.json1
-rw-r--r--index.html53
-rw-r--r--server.ts8
3 files changed, 45 insertions, 17 deletions
diff --git a/crates.json b/crates.json
index fb3ab78..9d4058f 100644
--- a/crates.json
+++ b/crates.json
@@ -1,5 +1,6 @@
{"crates":[
{"price":5,"name":"red#1","contents":[{"color":"#330000","rarity":"common","value":3},{"color":"#660000","rarity":"common","value":3},{"color":"#990000","rarity":"common","value":3},{"color":"#CC0000","rarity":"common","value":3},{"color":"#FF0000","rarity":"common","value":3},{"color":"#FF3333","rarity":"uncommon","value":7},{"color":"#FF6666","rarity":"uncommon","value":7},{"color":"#FF9999","rarity":"uncommon","value":7},{"color":"#FFCCCC","rarity":"rare","value":15}]}
, {"price":10,"name":"blue#1","contents":[{"color":"#1313ff","rarity":"common","value":5},{"color":"#1d1dff","rarity":"common","value":5},{"color":"#2727ff","rarity":"common","value":5},{"color":"#3131ff","rarity":"common","value":5},{"color":"#3b3bff","rarity":"common","value":5},{"color":"#4545ff","rarity":"common","value":5},{"color":"#4f4fff","rarity":"uncommon","value":15},{"color":"#5959ff","rarity":"uncommon","value":15},{"color":"#6363ff","rarity":"uncommon","value":15},{"color":"#6d6dff","rarity":"uncommon","value":15},{"color":"#8181ff","rarity":"rare","value":30}]}
+,{"price":50,"name":"green#1","contents":[{"color":"#003300","rarity":"common","value":5},{"color":"#006600","rarity":"common","value":5},{"color":"#009900","rarity":"common","value":5},{"color":"#00CC00","rarity":"common","value":5},{"color":"#00FF00","rarity":"common","value":5},{"color":"#33FF33","rarity":"uncommon","value":15},{"color":"#66FF66","rarity":"uncommon","value":15},{"color":"#99FF99","rarity":"uncommon","value":15},{"color":"#CCFFCC","rarity":"rare","value":30}]}
]} \ No newline at end of file
diff --git a/index.html b/index.html
index cdd6ad9..0457f47 100644
--- a/index.html
+++ b/index.html
@@ -174,7 +174,7 @@ transform:scale(0.7);
} else {
craft+="dirty"
}
- let ne = {"color": hex, "rarity": craft + "\<font size=1>(crafted)\</font>", "value": v}
+ let ne = {"color": hex, "rarity": craft + "\<font size=1>(crafted)\</font>", "value": v, "att":r,"def":g,"spd":b,"level":0,"xp":0}
//if(data!=index && inv[data].color != inv[data].color){
var inv = getCookie('inv');
@@ -291,27 +291,51 @@ transform:scale(0.7);
x[0].hidden = !x[0].hidden
}
- async function fight() {
+ function randomColor() {
+ var letters = '0123456789ABCDEF';
+ var color = '#';
+ for (var i = 0; i < 6; i++) {
+ color += letters[Math.floor(Math.random() * 16)];
+ }
+ return ({
+ color: color,
+ att: hexToRgb(color).r,
+ def: hexToRgb(color).g,
+ spd: hexToRgb(color).b
+ })
+ }
+ function fight() {
var inv = getCookie('inv');
inv = JSON.parse(inv)
var storage = getCookie('storage');
storage = JSON.parse(storage)
let team = [inv[0], inv[1], inv[2], inv[3], inv[4]]
- let opp = [roll(0,true), roll(0,true), roll(0,true), roll(0,true), roll(0,true)]
-
-
+ let opp = [randomColor(), randomColor(), randomColor(), randomColor(), randomColor()]
+ document.write("<div id='fight' style='position:absolute;height: 100%;width: 100%;top:0%;background-color: "+BgColor+"'>")
+ let po = 75
+ let le = 40
+ for(let t of team){
+ document.write("<div class='"+t.color+"' style='left:"+le+"px;top:"+po+"px;position:absolute;height: 75px;width: 75px;background-color: "+t.color+"'></div>")
+ po+=90
+ le+= 15
+ }
+ po = 75
+ le = 600
+ for(let t of opp){
+ document.write("<div class='"+t.color+"' style='left:"+le+"px;top:"+po+"px;position:absolute;height: 75px;width: 75px;background-color: "+t.color+"'></div>")
+ po+=90
+ le+= 15
+ }
+ document.write("</div>")
}
- function roll(item, opp=false) {
+ function roll(item) {
fetch(file)
.then(response => {
return response.json();
})
.then(data => {
- if(!opp){
var bank = getCookie('bank');
- } else {
- var bank = 999999999999999999
- }
+
var inv = getCookie('inv');
var arr = JSON.parse(inv);
if (data.crates[item].price <= bank) {
@@ -331,15 +355,20 @@ transform:scale(0.7);
}
x.style.background = (data.crates[item].contents[select].color)
- if(!opp){
+
createCookie('bank', bank - data.crates[item].price);
console.log(chance)
data.crates[item].contents[select]['storage'] = false
data.crates[item].contents[select]['s'] = shiny
+ data.crates[item].contents[select]['att'] = hexToRgb(data.crates[item].contents[select].color).r
+ data.crates[item].contents[select]['def'] = hexToRgb(data.crates[item].contents[select].color).g
+ data.crates[item].contents[select]['spd'] = hexToRgb(data.crates[item].contents[select].color).b
+ data.crates[item].contents[select]['level'] = 0
+ data.crates[item].contents[select]['xp'] = 0
arr.push(data.crates[item].contents[select])
createCookie('inv', JSON.stringify(arr));
- }
+
setTimeout(function () {document.getElementById("popup").style.display = "none";}, 500);
diff --git a/server.ts b/server.ts
index 05807cd..14fa79c 100644
--- a/server.ts
+++ b/server.ts
@@ -1,14 +1,12 @@
-var fs = require('fs');
var express = require('express');
var app = express();
-const PORT = 8008 || process.env.PORT;
-fs.readFile('./index.html', function (err:any, html:any) {
+const PORT = 8008;
app.listen(PORT, function () {
- console.log('listening! http://localhost:' + PORT);
+ console.log('listening! http://localhost:' + PORT + ' | http://' + require("ip").address() + ':' + PORT);
});
app.get('/', function (req:any, res:any) {
res.sendFile('index.html', {root: __dirname })
})
app.get('/crates.json', function (req:any, res:any) {
res.sendFile('crates.json', {root: __dirname })
-})}); \ No newline at end of file
+});