将操作时间显示方式修改为css引用属性函数显示

This commit is contained in:
枫谷剑仙 2020-12-23 17:38:24 +08:00
parent de50000b54
commit 0e707794ce
6 changed files with 88 additions and 54 deletions

View File

@ -265,16 +265,16 @@
}
.team-total-info .tIf-total-hp::before{
content: "队伍HP (无觉醒)";
content: "队伍HP ";
}
.team-total-info .tIf-total-move::before{
content: "队伍操作时间:";
content: "操作时间:";
}
.team-total-info .tIf-total-move::after{
content: " 秒";
content: attr(data-general) " 秒 (封觉醒时 " attr(data-no-awoken) " 秒)";
}
.team-total-info .tIf-total-move.fixed-move-time::after{
content: " 秒 (固定)";
content: attr(data-general) " 秒 (固定)";
}
.formation-total-info .tIf-total-hp::before{
content: "总HP (无觉醒)";

View File

@ -25,6 +25,26 @@ const teamsCount = 2;
<script type="text/javascript">
var formation = new Formation(teamsCount,5);
</script>
<style type="text/css">
.show-team-name-left .team-box-name::before{
display: inline-block;
}
.show-team-name-right .team-box-name::after{
display: inline-block;
}
.show-team-name-right .team-total-info .team-awoken,
.show-team-name-right .team-total-info>div,
.show-team-name-left .team-total-info .team-awoken,
.show-team-name-left .team-total-info>div
{
display: inline-block;
}
.show-team-name-right .team-total-info .team-awoken::before,
.show-team-name-left .team-total-info .team-awoken::before
{
display: none;
}
</style>
</head>
<body>

View File

@ -692,23 +692,46 @@ function countMoveTime(team, leader1id, leader2id, teamIdx)
const time1 = leaderSkillMoveTime(ls1);
const time2 = leaderSkillMoveTime(ls2);
let moveTime = {fixed:false,duration:5}; //基础5秒
let moveTime = {
fixed:false,
duration:{
default:5,
leader:0,
badge:0,
awoken:0,
}
}; //基础5秒
//固定操作时间的直接返回
if (time1.fixed || time2.fixed)
{
moveTime.fixed = true;
moveTime.duration = time1.fixed ?
(time2.fixed && time2.duration < time1.duration ? time2.duration : time1.duration) :
moveTime.duration.leader = time1.fixed ?
(time2.fixed ? Math.min(time1.duration, time2.duration) : time1.duration) :
time2.duration;
} else
{
moveTime.duration += time1.duration + time2.duration
//2人协力时的特殊处理
if (teamsCount === 2)
moveTime.duration.leader = time1.duration + time2.duration;
//1人、3人计算徽章
if (solo || teamsCount === 3)
{
//徽章部分
if (team[2] == 1) //小手指
{
moveTime.duration.badge = 1;
} else if (team[2] == 13) //大手指
{
moveTime.duration.badge = 2;
} else if (team[2] == 18) //月卡
{
moveTime.duration.badge = 3;
}
}
else if (teamsCount === 2) //2人协力时的特殊处理
{
const teams = formation.teams;
const team2 = teamIdx === 1 ? teams[0] : teams[1]; //获取队伍2
//复制队伍1
//复制队伍1,这里参数里的 team 换成了一个新的数组
team = [
team[0].concat(),
team[1].concat()
@ -718,19 +741,12 @@ function countMoveTime(team, leader1id, leader2id, teamIdx)
team[1].push(team2[1][0]);
}
//徽章部分
if (team[2] == 1 && (solo || teamsCount === 3)) {
moveTime.duration += 1;
} else if (team[2] == 13 && (solo || teamsCount === 3)) {
moveTime.duration += 2;
}
//觉醒
const awokenMoveTime = [
{index:19,value:0.5}, //小手指
{index:53,value:1}, //大手指
];
moveTime.duration += awokenMoveTime.reduce((duration,aw)=>
moveTime.duration.awoken += awokenMoveTime.reduce((duration,aw)=>
duration + awokenCountInTeam(team, aw.index, solo, teamsCount) * aw.value
,0);
//潜觉
@ -739,7 +755,7 @@ function countMoveTime(team, leader1id, leader2id, teamIdx)
{index:31,value:0.12}, //大手指潜觉
];
moveTime.duration += latentMoveTime.reduce((duration,la)=>
moveTime.duration.awoken += latentMoveTime.reduce((duration,la)=>
duration + team[0].reduce((count,menber)=>
count + (menber.latent ? menber.latent.filter(l=>l==la.index).length : 0)
,0) * la.value

View File

@ -1974,18 +1974,26 @@ function initialize() {
const teamAbilityDom = teamBigBox.querySelector(".team-ability");
refreshAbility(teamAbilityDom, teamData, editBox.memberIdx[2]); //本人能力值
const teamTotalInfoDom = teamBigBox.querySelector(".team-total-info"); //队伍能力值合计
if (teamTotalInfoDom) refreshTeamTotalHP(teamTotalInfoDom, teamData, editBox.memberIdx[0]);
const formationTotalInfoDom = formationBox.querySelector(".formation-total-info"); //所有队伍能力值合计
if (formationTotalInfoDom) refreshFormationTotalHP(formationTotalInfoDom, formation.teams);
//如果是2人协力且修改的是队长的情况为了刷新另一个队伍时间计算直接刷新整个队形
if (teamsCount === 2 && editBox.memberIdx[2] === 0)
{
refreshAll(formation);
}else
{
const teamTotalInfoDom = teamBigBox.querySelector(".team-total-info"); //队伍能力值合计
if (teamTotalInfoDom) refreshTeamTotalHP(teamTotalInfoDom, teamData, editBox.memberIdx[0]);
const formationTotalInfoDom = formationBox.querySelector(".formation-total-info"); //所有队伍能力值合计
if (formationTotalInfoDom) refreshFormationTotalHP(formationTotalInfoDom, formation.teams);
const teamAwokenDom = teamBigBox.querySelector(".team-awoken"); //队伍觉醒合计
if (teamAwokenDom) refreshTeamAwokenCount(teamAwokenDom, teamData);
const formationAwokenDom = formationBox.querySelector(".formation-awoken"); //所有队伍觉醒合计
if (formationAwokenDom) refreshFormationAwokenCount(formationAwokenDom, formation.teams);
//刷新改队员的CD
refreshMemberSkillCD(teamBox, teamData, editBox.memberIdx[2]);
}
const teamAwokenDom = teamBigBox.querySelector(".team-awoken"); //队伍觉醒合计
if (teamAwokenDom) refreshTeamAwokenCount(teamAwokenDom, teamData);
const formationAwokenDom = formationBox.querySelector(".formation-awoken"); //所有队伍觉醒合计
if (formationAwokenDom) refreshFormationAwokenCount(formationAwokenDom, formation.teams);
//刷新改队员的CD
refreshMemberSkillCD(teamBox, teamData, editBox.memberIdx[2]);
creatNewUrl();
editBox.hide();
};
@ -2956,11 +2964,19 @@ function refreshTeamTotalHP(totalDom, team, teamIdx) {
if (tMoveDom) {
const moveTime = countMoveTime(team, leader1id, leader2id, teamIdx);
tMoveDom.textContent = moveTime.duration;
if (moveTime.fixed)
//tMoveDom.textContent = moveTime.duration;
if (moveTime.fixed) //固定时间的
{
tMoveDom.classList.add("fixed-move-time");
else
tMoveDom.setAttribute("data-no-awoken",moveTime.duration.leader);
tMoveDom.setAttribute("data-general",moveTime.duration.leader);
} else
{
tMoveDom.classList.remove("fixed-move-time");
tMoveDom.setAttribute("data-no-awoken",moveTime.duration.default + moveTime.duration.leader + moveTime.duration.badge);
tMoveDom.setAttribute("data-general",moveTime.duration.default + moveTime.duration.leader + moveTime.duration.badge + moveTime.duration.awoken);
}
}
}
//刷新所有队伍能力值合计

View File

@ -486,24 +486,6 @@ ul{
width: var(--head-block-width);
height: var(--head-block-height);
}
.show-team-name-left .team-box-name::before{
display: inline-block;
}
.show-team-name-right .team-box-name::after{
display: inline-block;
}
.show-team-name-right .team-total-info .team-awoken,
.show-team-name-right .team-total-info>div,
.show-team-name-left .team-total-info .team-awoken,
.show-team-name-left .team-total-info>div
{
display: inline-block;
}
.show-team-name-right .team-total-info .team-awoken::before,
.show-team-name-left .team-total-info .team-awoken::before
{
display: none;
}
.reverse-member-assist .team-box-name::after,

View File

@ -434,7 +434,7 @@ var formation = new Formation(teamsCount,6);
<li><input type="radio" name="team-2-badge" class="badge-radio" value="15" id="team-2-badge-15"><label class="badge" data-badge-icon="15" for="team-2-badge-15"></label></li>
<li><input type="radio" name="team-2-badge" class="badge-radio" value="16" id="team-2-badge-16"><label class="badge" data-badge-icon="16" for="team-2-badge-16"></label></li>
<li><input type="radio" name="team-2-badge" class="badge-radio" value="17" id="team-2-badge-17"><label class="badge" data-badge-icon="17" for="team-2-badge-17"></label></li>
<li><input type="radio" name="team-1-badge" class="badge-radio" value="18" id="team-1-badge-18"><label class="badge" data-badge-icon="18" for="team-1-badge-18"></label></li>
<li><input type="radio" name="team-2-badge" class="badge-radio" value="18" id="team-2-badge-18"><label class="badge" data-badge-icon="18" for="team-2-badge-18"></label></li>
<div class="team-total-info"><div class="tIf-total-hp"></div><div class="tIf-total-move"></div></div>
</ul>
<div class="team-box-name">
@ -780,7 +780,7 @@ var formation = new Formation(teamsCount,6);
<li><input type="radio" name="team-3-badge" class="badge-radio" value="15" id="team-3-badge-15"><label class="badge" data-badge-icon="15" for="team-3-badge-15"></label></li>
<li><input type="radio" name="team-3-badge" class="badge-radio" value="16" id="team-3-badge-16"><label class="badge" data-badge-icon="16" for="team-3-badge-16"></label></li>
<li><input type="radio" name="team-3-badge" class="badge-radio" value="17" id="team-3-badge-17"><label class="badge" data-badge-icon="17" for="team-3-badge-17"></label></li>
<li><input type="radio" name="team-1-badge" class="badge-radio" value="18" id="team-1-badge-18"><label class="badge" data-badge-icon="18" for="team-1-badge-18"></label></li>
<li><input type="radio" name="team-3-badge" class="badge-radio" value="18" id="team-3-badge-18"><label class="badge" data-badge-icon="18" for="team-3-badge-18"></label></li>
<div class="team-total-info"><div class="tIf-total-hp"></div><div class="tIf-total-move"></div></div>
</ul>
<div class="team-box-name">