Commit 16ef4fac authored by zhangjinzhou's avatar zhangjinzhou

代码暂存

parent 9e93f972
......@@ -144,7 +144,7 @@ Page({
if (nranksuc < sucgl) {//能赢
canwin = true;
}
console.log("onload====>",query,canwin,nranksuc,canwin);
console.log("onload====>", query, canwin, nranksuc, canwin);
let roomnums = [2, 3, 4][step - 1];
let txkeys = Object.keys(gavatars);
let othername = ["你"];
......@@ -218,9 +218,9 @@ Page({
return;
}
my.showToast({
content: '请不要关闭APP,会导致本局游戏作废',
duration: 4500,
});
content: '请不要关闭APP,会导致本局游戏作废',
duration: 4500,
});
// console.log("游戏开始逻辑==canwin", this.data.canwin);
let attiontxt1 = "游戏开始啦,共有" + this.data.roomnums + "名玩家加入游戏,快来升温队伍拿奖励吧。";
this.addAttionTxt(attiontxt1);
......@@ -230,7 +230,7 @@ Page({
}, 4000);
},
//新ai逻辑,tool==使用道具,task==任务,invite==邀请人
async newAiControl(type = "tool", ainum = 1,aiwarm=0) {
async newAiControl(type = "tool", ainum = 1, aiwarm = 0) {
let canwin = this.data.canwin;
let roomnums = this.data.roomnums - 1;
let roomdata = this.data.roomdata;
......@@ -243,15 +243,15 @@ Page({
let fromedir = Math.random();
if (fromedir < 0.5) {
for (let i = 0; i < roomdata.length; i++) {
havechao = this.newAiControl1(i, canwin, roomnums, roomdata, myidx, mywd, havechao, type, ainum,aiwarm);
havechao = this.newAiControl1(i, canwin, roomnums, roomdata, myidx, mywd, havechao, type, ainum, aiwarm);
}
} else {
for (let i = roomdata.length - 1; i > -1; i--) {
havechao = this.newAiControl1(i, canwin, roomnums, roomdata, myidx, mywd, havechao, type, ainum,aiwarm);
havechao = this.newAiControl1(i, canwin, roomnums, roomdata, myidx, mywd, havechao, type, ainum, aiwarm);
}
}
},
newAiControl1(i, canwin, roomnums, roomdata, myidx, mywd, havechao, type = "tool", ainum = 1,aiwarm=0) {
newAiControl1(i, canwin, roomnums, roomdata, myidx, mywd, havechao, type = "tool", ainum = 1, aiwarm = 0) {
if (i == myidx) {
} else {
......@@ -273,12 +273,13 @@ Page({
if (chawd + taskwarm < 0) {
let maxadd = Math.floor((-1 - chawd) / taskwarm);
if (maxadd > 0) {
let addwarm = maxadd*toolwarm;
let addwarm = maxadd * toolwarm;
if (maxadd > ainum) {
maxadd = ainum;
addwarm = aiwarm
}
cando.push(["task", Math.round(Math.random() * maxadd),addwarm]);
cando.push(["task", maxadd, addwarm]);
}
}
......@@ -308,7 +309,7 @@ Page({
if (havechao) {//已经有超过的了,可操作
let math1 = Math.random();
// console.log("已经有超过得了,可选使用", math1);
if (math1 < 0.8 ) {
if (math1 < 0.8) {
idoact = false;
}
} else {//必操作
......@@ -324,7 +325,7 @@ Page({
if (type == "task") {
let chatask = (1 - chawd);
let chanum = Math.floor(chatask / taskwarm);
let addchawarm = chanum*taskwarm;
let addchawarm = chanum * taskwarm;
if (chanum > ainum) {
chanum = ainum;
addchawarm = aiwarm;
......@@ -337,7 +338,7 @@ Page({
}
}
if (chanum > 0) {
bido.push(["task", chanum,addchawarm]);
bido.push(["task", chanum, addchawarm]);
}
}
if (type == "invite") {
......@@ -395,24 +396,29 @@ Page({
this.updateRolewd(i + 1, inwd);
} else if (type == "task") {
let addwarm = 0;
if(aiwarm){
if (aiwarm) {
addwarm = aiwarm;
}else{
addwarm = taskwarm*nums;
} else {
addwarm = taskwarm * nums;
}
let itxt = othername[i] + "完成了" + nums + "个任务,获得了" + addwarm + "温度值";
this.addAttionTxt(itxt);
let inroomidx = i;
let inwd = this.data.roomdata[inroomidx]["wd"];
inwd += taskwarm * nums;
this.updateRolewd(i + 1, inwd);
if (addwarm > 0 && nums > 0) {
let itxt = othername[i] + "完成了" + nums + "个任务,获得了" + addwarm + "温度值";
this.addAttionTxt(itxt);
let inroomidx = i;
let inwd = this.data.roomdata[inroomidx]["wd"];
inwd += taskwarm * nums;
this.updateRolewd(i + 1, inwd);
}
} else if (type == "invite") {
let itxt = othername[i] + "邀请了" + nums + "位好友,获得了" + invitewarm * nums + "温度值";
this.addAttionTxt(itxt);
let inroomidx = i;
let inwd = this.data.roomdata[inroomidx]["wd"];
inwd += invitewarm * nums;
this.updateRolewd(i + 1, inwd);
if (nums > 0) {
let itxt = othername[i] + "邀请了" + nums + "位好友,获得了" + invitewarm * nums + "温度值";
this.addAttionTxt(itxt);
let inroomidx = i;
let inwd = this.data.roomdata[inroomidx]["wd"];
inwd += invitewarm * nums;
this.updateRolewd(i + 1, inwd);
}
}
},
getToWarm(data, i, inwd) {
......@@ -538,16 +544,16 @@ Page({
if (gametime < 0) {
gametime = 0;
}
let tooltime1 = this.data.tooltime;
tooltime1 -= passtime/1000;
if(tooltime1<0){
tooltime1 -= passtime / 1000;
if (tooltime1 < 0) {
tooltime1 = 0;
}
this.setData({
gametime: gametime,
tooltime:tooltime1
tooltime: tooltime1
})
}
let ngametime = this.data.gametime;
......@@ -903,7 +909,7 @@ Page({
}
}
if (taskcount > 0 && taskwarm > 0) {
this.newAiControl("task", taskcount,taskwarm);
this.newAiControl("task", taskcount, taskwarm);
let tasktxt = "你完成了" + taskcount + "个任务,获得了" + taskwarm + "温度值";
this.addAttionTxt(tasktxt);
}
......
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