Commit a522ea2d authored by zhangjinzhou's avatar zhangjinzhou

zancun

parent 99886dbb
......@@ -81,7 +81,7 @@ Page({
toolshow_v: false,
taskshow_v: false,
invite_v: false,
unLockPkData:{
unLockPkData: {
},
pk1data: {
......@@ -107,15 +107,15 @@ Page({
avatar2: "",
avatar3: "",
avatar4: "",
canwin:false
canwin: false
},
onLoad(props) {
console.log("onLoad========>", app, props);
let step = 1;
let sucgl = 70;
let nranksuc = Math.random()*100;
let nranksuc = Math.random() * 100;
let canwin = false;
if(nranksuc<sucgl){//能赢
if (nranksuc < sucgl) {//能赢
canwin = true;
}
let roomnums = [2, 3, 4][step - 1];
......@@ -141,7 +141,8 @@ Page({
roomdata: roomdata,
attionlist: [],
showattionlist: [],
canwin:canwin,
canwin: canwin,
isfirst: true,
});
let attiontxt1 = "游戏开始啦,共有" + roomnums + "名玩家加入游戏,快来升温队伍拿奖励吧。";
this.addAttionTxt(attiontxt1);
......@@ -152,13 +153,63 @@ Page({
this.newAiControl();
},
//新ai逻辑
newAiControl(){
newAiControl() {
let canwin = this.data.canwin;
let roomnums = this.data.roomnums-1;
if(canwin){// 机器不用操作
let roomnums = this.data.roomnums - 1;
let doact = false;
if (canwin) {// 机器不用操作
doact = false;
} else {//机器使用道具
doact = true;
}else{//机器使用道具
}
let i = 1;
if (doact) {
let isfirst = this.data.isfirst;
if (isfirst) {
this.setData({
isfirst: false
});
let itxt = "玩家" + (i + 1) + "使用道具获得了" + toolwarm + "温度值";
this.addAttionTxt(itxt);
let inroomidx = i + 1;
let inwd = this.data.roomdata[inroomidx]["wd"];
inwd += toolwarm;
this.updateRolewd(i + 2, inwd);
} else {
//任务,或是邀请人
let randfrom = Math.random();
if (randfrom < 0.3) {//任务
let itxt = "玩家" + (i + 1) + "完成了一个任务,获得了" + taskwarm + "温度值";
this.addAttionTxt(itxt);
let inroomidx = i + 1;
let inwd = this.data.roomdata[inroomidx]["wd"];
inwd += taskwarm;
this.updateRolewd(i + 2, inwd);
} else {//邀请人
let itxt = "玩家" + (i + 1) + "邀请了一位好友,获得了" + invitewarm + "温度值";
this.addAttionTxt(itxt);
let inroomidx = i + 1;
let inwd = this.data.roomdata[inroomidx]["wd"];
inwd += invitewarm;
this.updateRolewd(i + 2, inwd);
}
}
}
},
aiUseOneTool() {
let roomnums = this.data.roomnums - 1;
for (let i = 0; i < roomnums; i++) {
let chatime = Math.ceil(Math.random() * 5) + 2;
let itime1 = Number((Math.random() * chatime).toFixed(2)) * 1000;
setTimeout(() => {
let itxt = "玩家" + (i + 1) + "使用道具获得了" + toolwarm + "温度值";
this.addAttionTxt(itxt);
let inroomidx = i + 1;
let inwd = this.data.roomdata[inroomidx]["wd"];
inwd += toolwarm;
this.updateRolewd(i + 2, inwd);
}, itime1);
}
},
//其余机器人升温逻辑
......@@ -312,7 +363,21 @@ Page({
async gameover() {
this.closetool();
// console.log("游戏结束");
let iswin = this.data.iswin;
let roomnums = this.data.roomnums;
let mywd = this.data.roomdata[this.data.myidx - 1].wd;
let iswin = true;
for (let i = 1; i < roomnums; i++) {
let idata = this.data.roomdata[i];
let iwd = idata.wd;
if (iwd >= mywd) {
iswin = false;
break;
}
}
this.setData({
iswin: iswin
});
let step = this.data.step;
const overdata = await API.gameOver({
isWin: iswin,
......@@ -323,7 +388,7 @@ Page({
const { success, data } = overdata;
if (success) {
const { warms, isWin, prize, unLockStep } = data;
console.log("over",data)
console.log("over", data)
if (isWin) {
if (prize && prize.image && prize.image.length > 0) {
this.setData({
......@@ -331,23 +396,23 @@ Page({
})
this.openprize1();
} else {
this.setData({
pk1data: data
})
this.setData({
pk1data: data
})
this.openprize4();
}
}else{
} else {
if (prize && prize.image && prize.image.length > 0) {
this.setData({
pk1data: data
})
this.openprize1();
} else {
this.setData({
pk1data: data
})
this.openprize3();
}
this.setData({
pk1data: data
})
this.openprize1();
} else {
this.setData({
pk1data: data
})
this.openprize3();
}
}
// console.log("结束数据", overdata);
}
......@@ -623,7 +688,7 @@ Page({
this.closeLockStep();
this.closeTask();
// my.navigateBack();
my.redirectTo({url:'/pages/pagepageindex/pagepageindex'})
my.redirectTo({ url: '/pages/pagepageindex/pagepageindex' })
},
//打开道具页面
......@@ -693,15 +758,15 @@ Page({
})
},
openLockStep(data){
this.closeprize1();
this.closeprize2();
this.closeprize3();
this.closeprize4();
this.setData({
unLockPkData:data,
lockstepshow_v:true
})
openLockStep(data) {
this.closeprize1();
this.closeprize2();
this.closeprize3();
this.closeprize4();
this.setData({
unLockPkData: data,
lockstepshow_v: true
})
},
closeLockStep() {
this.setData({
......@@ -780,7 +845,7 @@ Page({
console.log(err);
}
)
SvgaParser.loadSvga(
SvgaParser.loadSvga(
paple3,
(v) => {
console.log("svga" + v);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment