<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport"
content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>赛尔手册SDK例子2- 对战例子</title>
<style type="text/css">
.btn {
display: block;
margin: 20px auto;
padding: 5px;
background-color: #007aff;
border: 0;
color: #ffffff;
height: 40px;
width: 200px;
}
.btn-red {
background-color: #dd524d;
}
.btn-yellow {
background-color: #f0ad4e;
}
.desc {
padding: 10px;
color: #999999;
}
</style>
<script type="text/javascript" src="https://cdnh5.xiaoseer.com/test/ByteArray.js"></script>
<script type="text/javascript" src="https://cdnh5.xiaoseer.com/test/uniapp.js"></script>
<script type="text/javascript" src="https://cdnh5.xiaoseer.com/test/seer.js"></script>
</head>
<body>
<div>
<p class="desc">这里是赛尔手册 SDK例子,点我对战谱尼</p>
<div class="btn-list">
<button class="btn btn-red" type="button" id="postMessage">通用对战1次谱尼</button>
<button class="btn btn-red" type="button" id="post2">自定义出招对战谱尼</button>
</div>
<button class="btn" type="button" id="back">点我返回赛尔手册</button>
</div>
<script type="text/javascript">
// 这里是监听页面打开,执行操作
document.addEventListener('UniAppJSBridgeReady', function() {
});
// 这里是监听 id为 postmessage 的组件被点击执行操作
document.getElementById('postMessage').addEventListener('click', function() {
//这里是通用对战, 包 次数 对战延迟
battlemethod_common_use('00000015310000A0A90016A86C0000021500001A4A',1,5000).then(count=>{
alert('对战全部完成了,次数'+count)
})
});
//出招回调,同易语言SDK id为回调类型 battleObject为返回的对象
//id 1 对战结束 battleObject 返回 FightOverInfo 类
// this._type
// this._reason
// this._winnerID
// this.isCanSave
// this.twoTimes
// this.threeTimes
// this.autoFightTimes
// this.btlDetectTimes
// this.energyTimes
// this.learnTimes
// this._deltaTopLv
// this._daltaTopHonour
// this.maxH
// this.totalH
// this._roundNum
//id 0 对战出招 battleObject 返回 UseSkillInfo 类
// this.firstAttackInfo
// this.secondAttackInfo
//firstAttackInfo 包括·
// this.userid
// this._skillID
// this._round
// this._atkTimes
// this._lostHP
// this._realHurtHp
// this._gainHP
// this._remainHp
//this._maxHp
// this._state
// this._petStatus
// this._skillList = []; 为数组 每个元素为字典包括 id 和pp
//第一次出招 返回FightPetInfo类 包括pet1 pet2
//
//id 3 切换精灵 battleObject 返回 ChangePetInfo 类
// this.userid
// this.id
// this.catchtime
// this._petName
// this._level
// this.hp
// this._maxHp
// this._skillList = [];
function battlemethod_callback_use5(id,battleObject,info_mypet,info_otherpet){
if (id == 0)
battle_useskill(0)
else if (id == 3)
battle_changepet(0)
}
//自动84
function battlemethod_callback_use84(id,battleObject,info_mypet,info_otherpet){
//判断是否为出招回调
if (id == 0){
if (info_mypet.id == 3512) // 表姐
battle_useskill(31505);
else if (info_mypet.id == 3329 || info_mypet.id == 3045)
battle_useskill(19314);
else
battle_useskill(0)
}
else if (id == 3)
battle_changepet([3329, 3045],true)
}
// 这里是监听 id为 post2 的组件被点击执行操作
document.getElementById('post2').addEventListener('click', function() {
//这里是通用对战,同易语言SDK, 包 次数 对战延迟 ,出招回调
battlemethod_common_use('00000015310000A0A90016A86C0000021500001A4A',1,5000,battlemethod_callback_use84).then(count=>{
alert('对战全部完成了,次数'+count)
})
});
// 这里是监听 id为 back 的组件被点击执行操作
document.getElementById('back').addEventListener('click', function() {
//返回上一页
uni.navigateBack({
delta: 1
});
})
</script>
</body>
</html>