发表于: 2020-06-02 23:06:28

1 2134


今天完成的事情:今天写了后续的页面
明天计划的事情:继续后续的页面
遇到的问题:理清逻辑需要时间需要更多的联系
收获:今天写了最后一个页面

html代码

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="bootstrap.css">
    <link rel="stylesheet" href="f3.css">
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
    </script>
</head>

<body>
    <div class="tb">
        <a href="f.html"><img src="./images/06.png" alt=""></a>
        <span class="z1">游戏结果</span>
        <a href="f.html"><img src="./images/07.png" alt=""></a>
    </div>
    <div class="d2">
        <div class="picture"></div>
        <span class="z2"><b></b></span>
        <span class="z3">本次游戏共计用时0小时35分钟<br>
            <div class="profession"></div>
            卧底词汇:安新觉罗<br>
            水民词汇:努尔哈赤
        </span>
    </div>
    <div class="main">

    </div>
    <div class="db">
        <a href="f.html">
            <div class="d4">
                再来一局
            </div>
        </a>
        <div class="d5">
            上传并分享
        </div>
    </div>
    <script src="./f3.js"></script>
</body>

</html>

css代码

body{
    letter-spacing:1px;
    margin-bottom64px;
}
.tb{
    background-color#29bde0;
    displayflex;
    justify-contentspace-between;
    align-itemscenter;
    height35px;
    border-bottomsolid #74d4eb 1px;
}
.z1{
    positionrelative;
    top4px;
    colorwhite;
    font-size14px;
}
.z2{
    displayblock;
    color#ffc865;
    font-size15px;
}
.t1{
    displayblock
    margin0px auto 11px
}
.d2{
    padding0 12.5vw 9px;
    background-color#29bde0;
}
.z3{
    colorwhite;
    font-size12px;
}
h5{
    displayinline;
    margin0 41vw 0 0;
}
.z5{
    displayblock;
    font-size13px;
    color#a6a6a6;
    padding11px 0;
    white-spacenowrap;
    letter-spacing:0;
}
.d3{
    padding6px 12.5vw;
    border-bottom#a6a6a6 solid 1px;
}
.z4{
    displayinline-block;
    color#d5d5d5;
    font-size:10px;
}
.db{
    height64px;
    positionfixed;
    left0;
    right0;
    bottom0;
    backgroundrgba(1532232400.5);
    padding11px 0 10px ;
    displayflex;
}
.d4{
    height44px;
    width42vw;
    margin0 4vw;
    background-color#f66f6f;
    text-aligncenter;
    line-height44px;
    border-radius6px;
    colorwhite;
}
.d5{
    height44px;
    width42vw;
    margin0 4vw;
    background-color#fbb435;
    text-aligncenter;
    line-height44px;
    border-radius6px;
    colorwhite;
}
.h1{
    displayflex;
    justify-contentspace-between;
    font-size12px;
    margin0px;
}
.picture{
    height150px;
    backgroundurl(./im2/center.pngcenter 12px no-repeat;
    background-size200px 120px;
    displayflex;
    justify-contentcenter;
    align-itemsflex-end;
    flex-wrapwrap;
    background-colorrgb(41189224);
    line-height82px;
    font-weight700;
    color#fff;
    font-size18px;
}
.gameMessage {
    border-bottom1px solid #e6e6e6;
    height82px;
    padding6px 52px 10px 39.5px;
}

.firstLine {
    margin-bottom14px;
    displayflex;
    justify-contentspace-between;

}

.firstLineLeft {
    colorblack;
}

.firstLineRight {
    font-size12px;
    colorrgb(166166166);
    margin-top3px;
}

.secondLine {
    font-size12px;
    colorrgb(166166166);
    margin5px 0;

}

js代码

var day = sessionStorage.getItem("day") || 1;
var killerArr = JSON.parse(sessionStorage.getItem("killerArr"));
var civiliansArr = JSON.parse(sessionStorage.getItem("civiliansArr"));
var killerDeath = JSON.parse(sessionStorage.getItem("killerDeath")) || [];
var civiliansDeath = JSON.parse(sessionStorage.getItem("civiliansDeath")) || [];
var allDeath = JSON.parse(sessionStorage.getItem("allDeath")) || [];
console.log(killerArr.length)
console.log(killerDeath.length)
console.log(civiliansArr.length)
console.log(civiliansDeath.length)
console.log(allDeath);
console.log(day);
if (killerArr.length == killerDeath.length) {
    $(".picture").text("平民胜利");
    $(".z2").text("太棒了!你知道么?在捉鬼游戏中有67%的平民取得游戏最终的胜利哦!");
else {
    $(".picture").text("杀手胜利");
    $(".z2").text("太棒了!你知道么?在捉鬼游戏中有33%的杀手取得游戏最终的胜利哦!");
}
$(".profession").text("杀手还有" + (killerArr.length - killerDeath.length) + "人" + "平民还有" + (civiliansArr.length - civiliansDeath.length) + "人");
var y = 0;
for (let i = 0i <= day - 1i++) {
    y += 2;
    if (i < day - 1) {
        $(".main").append(`     
   <div class="gameMessage">
       <div class="firstLine">
           <div class="firstLineLeft">第${i + 1}天</div>
           <div class="firstLineRight">0小时07分</div>
       </div>
       <div class="secondLine">晚上:${allDeath[y - 2].number}号被杀手杀死,身份是${allDeath[y - 2].name}</div>
       <div class="secondLine">白天:${allDeath[y - 1].number}号被投票投死,身份是${allDeath[y - 1].name}</div>
   </div>`)

    } else {
        $(".main").append(`     
   <div class="gameMessage">
       <div class="firstLine">
           <div class="firstLineLeft">第${i + 1}天</div>
           <div class="firstLineRight">0小时07分</div>
       </div>       
       <div class="secondLine">晚上:${allDeath[y - 2].number}号被杀手投死,身份是${allDeath[y - 2].name}</div>
   </div>`)
    }
}
console.log(y);

最后主要就是显示的问题了

var day = sessionStorage.getItem("day") || 1;
var killerArr = JSON.parse(sessionStorage.getItem("killerArr"));
var civiliansArr = JSON.parse(sessionStorage.getItem("civiliansArr"));
var killerDeath = JSON.parse(sessionStorage.getItem("killerDeath")) || [];
var civiliansDeath = JSON.parse(sessionStorage.getItem("civiliansDeath")) || [];
var allDeath = JSON.parse(sessionStorage.getItem("allDeath")) || [];
console.log(killerArr.length)
console.log(killerDeath.length)
console.log(civiliansArr.length)
console.log(civiliansDeath.length)
console.log(allDeath);
console.log(day);

还是先读取所有的资料

if (killerArr.length == killerDeath.length) {
    $(".picture").text("平民胜利");
    $(".z2").text("太棒了!你知道么?在捉鬼游戏中有67%的平民取得游戏最终的胜利哦!");
else {
    $(".picture").text("杀手胜利");
    $(".z2").text("太棒了!你知道么?在捉鬼游戏中有33%的杀手取得游戏最终的胜利哦!");
}

根据杀手死亡的人数判断那边赢了

$(".profession").text("杀手还有" + (killerArr.length - killerDeath.length) + "人" + "平民还有" + (civiliansArr.length - civiliansDeath.length) + "人");

写上双方还剩多少人

var y = 0;
for (let i = 0i <= day - 1i++) {
    y += 2;
    if (i < day - 1) {
        $(".main").append(`     
   <div class="gameMessage">
       <div class="firstLine">
           <div class="firstLineLeft">第${i + 1}天</div>
           <div class="firstLineRight">0小时07分</div>
       </div>
       <div class="secondLine">晚上:${allDeath[y - 2].number}号被杀手杀死,身份是${allDeath[y - 2].name}</div>
       <div class="secondLine">白天:${allDeath[y - 1].number}号被投票投死,身份是${allDeath[y - 1].name}</div>
   </div>`)

    } else {
        $(".main").append(`     
   <div class="gameMessage">
       <div class="firstLine">
           <div class="firstLineLeft">第${i + 1}天</div>
           <div class="firstLineRight">0小时07分</div>
       </div>       
       <div class="secondLine">晚上:${allDeath[y - 2].number}号被杀手投死,身份是${allDeath[y - 2].name}</div>
   </div>`)
    }
}
console.log(y);

根据经过了多少天就写入几个盒子记录流程

因为每天显示两条所以设置一个变量y每次加二

最后一天是奇数天就多加一个半天的记录来显示

明天再继续后续的任务


返回列表 返回列表
评论

    分享到