Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
new_taobao
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wildfirecode13
new_taobao
Commits
a522ea2d
Commit
a522ea2d
authored
Oct 15, 2020
by
zhangjinzhou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zancun
parent
99886dbb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
37 deletions
+102
-37
pagegamemain.js
taobao_jn/client/pages/pagegamemain/pagegamemain.js
+102
-37
No files found.
taobao_jn/client/pages/pagegamemain/pagegamemain.js
View file @
a522ea2d
...
@@ -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
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment