Commit 76491d08 authored by Edwise's avatar Edwise 🍷

Merge remote-tracking branch 'refs/remotes/origin/jiaoneiqunuan' into jiaoneiqunuan

parents 2cc2b8f4 0b881d58
...@@ -144,7 +144,7 @@ Page({ ...@@ -144,7 +144,7 @@ Page({
if (nranksuc < sucgl) {//能赢 if (nranksuc < sucgl) {//能赢
canwin = true; canwin = true;
} }
console.log("onload====>",query,canwin,nranksuc,canwin); console.log("onload====>", query, canwin, nranksuc, canwin);
let roomnums = [2, 3, 4][step - 1]; let roomnums = [2, 3, 4][step - 1];
let txkeys = Object.keys(gavatars); let txkeys = Object.keys(gavatars);
let othername = ["你"]; let othername = ["你"];
...@@ -230,7 +230,7 @@ Page({ ...@@ -230,7 +230,7 @@ Page({
}, 4000); }, 4000);
}, },
//新ai逻辑,tool==使用道具,task==任务,invite==邀请人 //新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 canwin = this.data.canwin;
let roomnums = this.data.roomnums - 1; let roomnums = this.data.roomnums - 1;
let roomdata = this.data.roomdata; let roomdata = this.data.roomdata;
...@@ -243,15 +243,15 @@ Page({ ...@@ -243,15 +243,15 @@ Page({
let fromedir = Math.random(); let fromedir = Math.random();
if (fromedir < 0.5) { if (fromedir < 0.5) {
for (let i = 0; i < roomdata.length; i++) { 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 { } else {
for (let i = roomdata.length - 1; i > -1; i--) { 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) { if (i == myidx) {
} else { } else {
...@@ -273,12 +273,13 @@ Page({ ...@@ -273,12 +273,13 @@ Page({
if (chawd + taskwarm < 0) { if (chawd + taskwarm < 0) {
let maxadd = Math.floor((-1 - chawd) / taskwarm); let maxadd = Math.floor((-1 - chawd) / taskwarm);
if (maxadd > 0) { if (maxadd > 0) {
let addwarm = maxadd*toolwarm; let addwarm = maxadd * toolwarm;
if (maxadd > ainum) { if (maxadd > ainum) {
maxadd = ainum; maxadd = ainum;
addwarm = aiwarm addwarm = aiwarm
} }
cando.push(["task", Math.round(Math.random() * maxadd),addwarm]);
cando.push(["task", maxadd, addwarm]);
} }
} }
...@@ -308,7 +309,7 @@ Page({ ...@@ -308,7 +309,7 @@ Page({
if (havechao) {//已经有超过的了,可操作 if (havechao) {//已经有超过的了,可操作
let math1 = Math.random(); let math1 = Math.random();
// console.log("已经有超过得了,可选使用", math1); // console.log("已经有超过得了,可选使用", math1);
if (math1 < 0.8 ) { if (math1 < 0.8) {
idoact = false; idoact = false;
} }
} else {//必操作 } else {//必操作
...@@ -324,7 +325,7 @@ Page({ ...@@ -324,7 +325,7 @@ Page({
if (type == "task") { if (type == "task") {
let chatask = (1 - chawd); let chatask = (1 - chawd);
let chanum = Math.floor(chatask / taskwarm); let chanum = Math.floor(chatask / taskwarm);
let addchawarm = chanum*taskwarm; let addchawarm = chanum * taskwarm;
if (chanum > ainum) { if (chanum > ainum) {
chanum = ainum; chanum = ainum;
addchawarm = aiwarm; addchawarm = aiwarm;
...@@ -337,7 +338,7 @@ Page({ ...@@ -337,7 +338,7 @@ Page({
} }
} }
if (chanum > 0) { if (chanum > 0) {
bido.push(["task", chanum,addchawarm]); bido.push(["task", chanum, addchawarm]);
} }
} }
if (type == "invite") { if (type == "invite") {
...@@ -395,18 +396,22 @@ Page({ ...@@ -395,18 +396,22 @@ Page({
this.updateRolewd(i + 1, inwd); this.updateRolewd(i + 1, inwd);
} else if (type == "task") { } else if (type == "task") {
let addwarm = 0; let addwarm = 0;
if(aiwarm){ if (aiwarm) {
addwarm = aiwarm; addwarm = aiwarm;
}else{ } else {
addwarm = taskwarm*nums; addwarm = taskwarm * nums;
} }
if (addwarm > 0 && nums > 0) {
let itxt = othername[i] + "完成了" + nums + "个任务,获得了" + addwarm + "温度值"; let itxt = othername[i] + "完成了" + nums + "个任务,获得了" + addwarm + "温度值";
this.addAttionTxt(itxt); this.addAttionTxt(itxt);
let inroomidx = i; let inroomidx = i;
let inwd = this.data.roomdata[inroomidx]["wd"]; let inwd = this.data.roomdata[inroomidx]["wd"];
inwd += taskwarm * nums; inwd += taskwarm * nums;
this.updateRolewd(i + 1, inwd); this.updateRolewd(i + 1, inwd);
}
} else if (type == "invite") { } else if (type == "invite") {
if (nums > 0) {
let itxt = othername[i] + "邀请了" + nums + "位好友,获得了" + invitewarm * nums + "温度值"; let itxt = othername[i] + "邀请了" + nums + "位好友,获得了" + invitewarm * nums + "温度值";
this.addAttionTxt(itxt); this.addAttionTxt(itxt);
let inroomidx = i; let inroomidx = i;
...@@ -414,6 +419,7 @@ Page({ ...@@ -414,6 +419,7 @@ Page({
inwd += invitewarm * nums; inwd += invitewarm * nums;
this.updateRolewd(i + 1, inwd); this.updateRolewd(i + 1, inwd);
} }
}
}, },
getToWarm(data, i, inwd) { getToWarm(data, i, inwd) {
let type = data[0]; let type = data[0];
...@@ -541,13 +547,13 @@ Page({ ...@@ -541,13 +547,13 @@ Page({
let tooltime1 = this.data.tooltime; let tooltime1 = this.data.tooltime;
tooltime1 -= passtime/1000; tooltime1 -= passtime / 1000;
if(tooltime1<0){ if (tooltime1 < 0) {
tooltime1 = 0; tooltime1 = 0;
} }
this.setData({ this.setData({
gametime: gametime, gametime: gametime,
tooltime:tooltime1 tooltime: tooltime1
}) })
} }
let ngametime = this.data.gametime; let ngametime = this.data.gametime;
...@@ -903,7 +909,7 @@ Page({ ...@@ -903,7 +909,7 @@ Page({
} }
} }
if (taskcount > 0 && taskwarm > 0) { if (taskcount > 0 && taskwarm > 0) {
this.newAiControl("task", taskcount,taskwarm); this.newAiControl("task", taskcount, taskwarm);
let tasktxt = "你完成了" + taskcount + "个任务,获得了" + taskwarm + "温度值"; let tasktxt = "你完成了" + taskcount + "个任务,获得了" + taskwarm + "温度值";
this.addAttionTxt(tasktxt); 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