Skip to content

Commit

Permalink
使PADDB上传功能兼容新怪物
Browse files Browse the repository at this point in the history
  • Loading branch information
Mapaler committed Aug 4, 2023
1 parent a001073 commit 24b8058
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 20 deletions.
56 changes: 39 additions & 17 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const isGuideMod = !unsupportFeatures.length && Boolean(Number(getQueryString("g
//用油猴扩展装上,把GM_xmlhttpRequest引入的脚本
const ExternalLinkScriptURL = "https://greasyfork.org/scripts/458521";
const paddbPathPrefix = "/team/"; //PADDB的获取队伍网址格式
const uploadMessage = "Use PADDashFormation to read the Team URL and restore correct team for ID > 9934.\nhttps://github.com/Mapaler/PADDashFormation";

if (location.search.includes('&')) {
location.search = location.search.replace(/&/ig, '&');
Expand Down Expand Up @@ -546,14 +547,19 @@ Formation.prototype.getPaddbQrObj = function(keepDataSource = true)
{
//PadDb服务器出现没有的怪物就会崩溃,在这里主动保护一下,转换为 1319
function protectPadDbId(cardid) {
if (cardid === null) return cardid;
return cardid > 9934 ? 1319 : cardFixId(cardid, true);
}
//PadDb服务器出现没有的怪物就会崩溃,在这里主动保护一下,转换为 1319
function changePadDbIdLevel(cardid) {
return cardid > 9934 ;
}
//PADDB目前只支持单人队伍
const t = this.teams[0];
let teamObj = {
name: this.title,
badge: paddbBadgeMap.find(badge=>badge.pdf === t[2]).paddb,
memo: this.detail,
memo: (this.detail || '') + '\n' + uploadMessage,
monsters: {},
assists: {},
}
Expand All @@ -570,26 +576,32 @@ Formation.prototype.getPaddbQrObj = function(keepDataSource = true)
for (let i = 0; i < t[0].length; i++) {
const m = t[0][i], a = t[1][i];
//计算基底的变身情况
let num = protectPadDbId(m.id, true), transform = null;
let num, transform;
if (m.card?.henshinFrom?.length > 0 //是变身
&& m.level <= m.card.maxLevel //等级不超过99
) {
transform = m.id;
num = returnHenshinRootId(m.id);
transform = m.id;
} else {
num = m.id;
transform = null;
}

let memberIdChange = changePadDbIdLevel(transform || num);
teamObj.monsters[i] = m.id <= 0 ? null : {
num: num,
level: m.level,
num: memberIdChange ? m.level : num,// protectPadDbId(num, true),
level: memberIdChange ? (transform || num) : m.level,
awoken: m.awoken,
plus: m.plus.concat(),
active_skill_level: m.skilllevel ?? Skills[m.card.activeSkillId].maxLevel,
transform: transform,
transform: memberIdChange ? m.level : num,
super_awoken: m.sawoken + 2,
latent_awokens: m.latent.map(n=>paddbLatentMap.find(latent=>latent.pdf === n).paddb),
};
let assistIdChange = changePadDbIdLevel(a.id);
teamObj.assists[i] = a.id <= 0 ? null : {
num: a.id,
level: a.level,
num: assistIdChange ? a.level : a.id,
level: assistIdChange ? a.id : a.level,
plus: a.plus.every(n=>n>=99), //只需要true和false
active_skill_level: a.skilllevel ?? Skills[a.card.activeSkillId].maxLevel,
};
Expand Down Expand Up @@ -1758,28 +1770,38 @@ function paddbFotmationToPdfFotmation(obj)
const team = JSON.parse(obj.team);
const f = new Formation(1, 6);
f.title = team.name;
f.detail = team.memo;
f.detail = team.memo.replace(new RegExp('\\n?'+uploadMessage,"i"),"");
const t = f.teams[0];
//队伍徽章
t[2] = paddbBadgeMap.find(badge=>badge.paddb === team.badge).pdf;
const members = t[0], assists = t[1];
for (let i = 0; i< members.length; i++) {
const m = members[i], a = assists[i], dm = team.monsters[i], da = team.assists[i];
if (dm) {
m.id = dm.transform || dm.num;
m.level = dm.level;
if (dm.level > 9934) { //如果等级大于9934,说明是被我改过的,所以需要交换
m.id = dm.level;
m.level = dm.transform || dm.num;
} else {
m.id = cardFixId(dm.transform || dm.num, false);
m.level = dm.level;
}
m.plus = dm.plus.concat();
m.awoken = (dm.transform && dm.transform !== dm.numdm) //有变身状态时
? Cards[dm.transform].awakenings.length //变身后的觉醒全满
m.awoken = (dm.transform && dm.transform !== dm.num) //有变身状态时
? Cards[m.id].awakenings.length //变身后的觉醒全满
: dm.awoken;
m.sawoken = dm.super_awoken - 2;
m.latent = dm.latent_awokens.map(paddbLatent=>paddbLatentMap.find(latent=>latent.paddb === paddbLatent)?.pdf ?? 0);
m.skilllevel = dm.active_skill_level;
}
if (da) {
a.id = da.num;
a.level = da.level;
a.awoken = Cards[da.num].awakenings.length;
if (da.level > 9934) { //如果等级大于9934,说明是被我改过的,所以需要交换
a.id = da.level;
a.level = da.num;
} else {
a.id = cardFixId(da.num, false);
a.level = da.level;
}
a.awoken = Cards[a.id].awakenings.length;
a.plus = da.plus ? [99,99,99]:[0,0,0];
a.skilllevel = da.active_skill_level;
}
Expand Down Expand Up @@ -2254,7 +2276,7 @@ function initialize() {
let obj = formation.getPaddbQrObj();
obj.userId = paddbUsername.value;
obj.password = paddbPassword.value;
obj.tags = [obj.userId];
obj.tags = [obj.userId,"PADDashFormation"];
let postBody = JSON.stringify(obj);
const options = {
method: "POST",
Expand Down
6 changes: 3 additions & 3 deletions service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14779,19 +14779,19 @@ const cachesMap = new Map([
],
[
"script.js",
"c52f0d5a59b3a31f64b59fa899af8d40"
"589f7198ee5ebdba175cef2b16af6bfd"
],
[
"solo.html",
"1bb0df70ea9a6f6b1c8b0aeba7d42396"
],
[
"style-monsterimages.css",
"da9a89265e34fb10c7ed24cbcc308065"
"9a902ddba52a586d868688700fed3e42"
],
[
"style.css",
"4c3e5a7008f69b9300955f81cc5b6836"
"0e51f82099f6a13e96f4c73a7a458d4a"
],
[
"temp.js",
Expand Down

0 comments on commit 24b8058

Please sign in to comment.