Commit a522ea2d authored by zhangjinzhou's avatar zhangjinzhou

zancun

parent 99886dbb
...@@ -81,7 +81,7 @@ Page({ ...@@ -81,7 +81,7 @@ Page({
toolshow_v: false, toolshow_v: false,
taskshow_v: false, taskshow_v: false,
invite_v: false, invite_v: false,
unLockPkData:{ unLockPkData: {
}, },
pk1data: { pk1data: {
...@@ -107,15 +107,15 @@ Page({ ...@@ -107,15 +107,15 @@ Page({
avatar2: "", avatar2: "",
avatar3: "", avatar3: "",
avatar4: "", avatar4: "",
canwin:false canwin: false
}, },
onLoad(props) { onLoad(props) {
console.log("onLoad========>", app, props); console.log("onLoad========>", app, props);
let step = 1; let step = 1;
let sucgl = 70; let sucgl = 70;
let nranksuc = Math.random()*100; let nranksuc = Math.random() * 100;
let canwin = false; let canwin = false;
if(nranksuc<sucgl){//能赢 if (nranksuc < sucgl) {//能赢
canwin = true; canwin = true;
} }
let roomnums = [2, 3, 4][step - 1]; let roomnums = [2, 3, 4][step - 1];
...@@ -141,7 +141,8 @@ Page({ ...@@ -141,7 +141,8 @@ Page({
roomdata: roomdata, roomdata: roomdata,
attionlist: [], attionlist: [],
showattionlist: [], showattionlist: [],
canwin:canwin, canwin: canwin,
isfirst: true,
}); });
let attiontxt1 = "游戏开始啦,共有" + roomnums + "名玩家加入游戏,快来升温队伍拿奖励吧。"; let attiontxt1 = "游戏开始啦,共有" + roomnums + "名玩家加入游戏,快来升温队伍拿奖励吧。";
this.addAttionTxt(attiontxt1); this.addAttionTxt(attiontxt1);
...@@ -152,14 +153,64 @@ Page({ ...@@ -152,14 +153,64 @@ Page({
this.newAiControl(); this.newAiControl();
}, },
//新ai逻辑 //新ai逻辑
newAiControl(){ newAiControl() {
let canwin = this.data.canwin; let canwin = this.data.canwin;
let roomnums = this.data.roomnums-1; let roomnums = this.data.roomnums - 1;
if(canwin){// 机器不用操作 let doact = false;
if (canwin) {// 机器不用操作
}else{//机器使用道具 doact = false;
} else {//机器使用道具
doact = true;
} }
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);
}
}, },
//其余机器人升温逻辑 //其余机器人升温逻辑
doAiControl() { doAiControl() {
...@@ -312,7 +363,21 @@ Page({ ...@@ -312,7 +363,21 @@ Page({
async gameover() { async gameover() {
this.closetool(); this.closetool();
// console.log("游戏结束"); // 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; let step = this.data.step;
const overdata = await API.gameOver({ const overdata = await API.gameOver({
isWin: iswin, isWin: iswin,
...@@ -323,7 +388,7 @@ Page({ ...@@ -323,7 +388,7 @@ Page({
const { success, data } = overdata; const { success, data } = overdata;
if (success) { if (success) {
const { warms, isWin, prize, unLockStep } = data; const { warms, isWin, prize, unLockStep } = data;
console.log("over",data) console.log("over", data)
if (isWin) { if (isWin) {
if (prize && prize.image && prize.image.length > 0) { if (prize && prize.image && prize.image.length > 0) {
this.setData({ this.setData({
...@@ -336,7 +401,7 @@ Page({ ...@@ -336,7 +401,7 @@ Page({
}) })
this.openprize4(); this.openprize4();
} }
}else{ } else {
if (prize && prize.image && prize.image.length > 0) { if (prize && prize.image && prize.image.length > 0) {
this.setData({ this.setData({
pk1data: data pk1data: data
...@@ -623,7 +688,7 @@ Page({ ...@@ -623,7 +688,7 @@ Page({
this.closeLockStep(); this.closeLockStep();
this.closeTask(); this.closeTask();
// my.navigateBack(); // my.navigateBack();
my.redirectTo({url:'/pages/pagepageindex/pagepageindex'}) my.redirectTo({ url: '/pages/pagepageindex/pagepageindex' })
}, },
//打开道具页面 //打开道具页面
...@@ -693,14 +758,14 @@ Page({ ...@@ -693,14 +758,14 @@ Page({
}) })
}, },
openLockStep(data){ openLockStep(data) {
this.closeprize1(); this.closeprize1();
this.closeprize2(); this.closeprize2();
this.closeprize3(); this.closeprize3();
this.closeprize4(); this.closeprize4();
this.setData({ this.setData({
unLockPkData:data, unLockPkData: data,
lockstepshow_v:true lockstepshow_v: true
}) })
}, },
closeLockStep() { closeLockStep() {
......
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