Fix some issues + last stand

Signed-off-by: Josef Fröhle <github@josef-froehle.de>
This commit is contained in:
2020-06-25 14:57:42 +02:00
parent 4a2526d691
commit 63024ffe8f
22 changed files with 1977 additions and 590 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 KiB

View File

@@ -1,4 +1,6 @@
var DEBUG_APP = false;
$('#dataform').on('submit', function (e) {
e.preventDefault();
@@ -6,7 +8,9 @@ $('#dataform').on('submit', function (e) {
if (inputContent.length > 0) {
var warData = JSON.parse( inputContent );
initApp(warData, 'withSave', warData);
if (initApp(warData, 'withSave', warData) != false){
$('#data').val('');
}
}
});
@@ -18,27 +22,37 @@ $('#fileUpload').on('change', function () {
});
function initApp (data, callback, callbackData) {
if( !data.results ||
if( data.results && data.results.length == 3 ){
var reWriteMapData = JSON.parse(JSON.stringify(data));
reWriteMapData.results[1].ident = reWriteMapData.results[1].ident.replace(/group_\d+_/g, "");
reWriteMapData.results[2].ident = reWriteMapData.results[2].ident.replace(/group_\d+_/g, "");
reWriteMapData.results.shift();
callbackData = data = JSON.parse(JSON.stringify(reWriteMapData)) ;
delete reWriteMapData;
if (DEBUG_APP) console.log(data);
}
if( !data.results || data.results.length !=2 ||
!data.results[0] ||
!data.results[0].ident == "body" ||
data.results[0].ident != "body" ||
!data.results[1] ||
!data.results[1].ident == "clanWarGetInfo" ||
data.results[1].ident != "clanWarGetInfo" ||
!data.results[1].result ||
!data.results[1].result.response ) {
alert("Please recreate the JSON, switch to the main screen, and switch back to GuildWars. Then copy the JSON!");
return false;
}
console.log(data)
if (DEBUG_APP) console.log(data)
var mapData = data.results[1].result.response;
console.log('data', JSON.parse( JSON.stringify(data)) );
if (DEBUG_APP) console.log('data', JSON.parse( JSON.stringify(data)) );
enhanceMap(mapData.enemySlots);
enhanceMap(mapData.ourSlots);
app.map = mapData;
app.map.warDate = data.date;
console.log('app.map', JSON.parse( JSON.stringify(mapData)) );
if (DEBUG_APP) console.log('app.map', JSON.parse( JSON.stringify(mapData)) );
Vue.nextTick(function () {
// Determine which player team has more power: titans or heroes

View File

@@ -12,18 +12,22 @@ var toe = new Vue({
matches: []
},
methods: {
getEnemyTeam: function (team) {
var titans = '';
for (titan in team) titans += titan;
findInTeam: function (team, seachTeam) {
return seachTeam.every(function (v) {
return team.includes(v)
})
},
getEnemyTeam: function (team) {
var titans = [];
for (titan in team) titans.push(titan);
return titans;
},
getSelectedTitans: function () {
var titans = '';
var titans = [];
var selectedTeam = this.sortedSelectedTitans;
for (titan in selectedTeam) titans += selectedTeam[titan];
for (titan in selectedTeam) titans.push(selectedTeam[titan])
return titans;
},
@@ -40,7 +44,7 @@ var toe = new Vue({
humanDate: function (timestamp) {
return new Date(timestamp * 1000).toLocaleString(undefined, { year: 'numeric', month: 'long', day: 'numeric' });
},
humanPlayer: function(id) {
humanPlayer: function (id) {
var player;
if (id == 7737454) player = 'Zero';