import 'mocha';
import { PinusWSClient } from 'pinus-robot-plugin';
import { expect } from 'chai';
import { Client } from './Client';
import { addItem, checkSuccessResponse } from './CheckPatten';
describe('测试英杰传宝箱', function () {
    let pinusClient: PinusWSClient;

    let roleInfo;
    const GOOD_ID_ZHUGE = 71058;
    const GOOD_ID_RED_RAND = 71072;

    before(function (done) {
        const c = new Client();
        const timer = setInterval(() => {
            if (c.client) {
                pinusClient = c.client;
                roleInfo = c.roleInfo;
                clearInterval(timer);
                done();
            }
        }, 500);
    });

    after(function (done) {
        pinusClient.disconnect();
        // disconnect 后等待 500ms，供服务器清理环境、退出频道等
        setTimeout(() => {
            done();
        }, 500);
    });

    it('使用随机保底宝箱', function (done) {
        addItem(pinusClient, GOOD_ID_RED_RAND, 1, (res) => {
            pinusClient.request('role.itemHandler.useItem', {
                id: GOOD_ID_RED_RAND,
                selected: [],
                count: 1
            }, (res) => {
                checkSuccessResponse(res);
                console.log(JSON.stringify(res));
                done();
            });

        });
    });

    it('查看保底情况', function (done) {
        pinusClient.request('role.itemHandler.getGiftPackageFloor', {
            id: GOOD_ID_RED_RAND,
        }, (res) => {
            checkSuccessResponse(res);
            console.log(JSON.stringify(res));
            done();
        });
    });
});
