import ExactMath = require("./FrameSync/Core/Math/ExactMath");

export default class PIFS {
    /**存储匹配后的玩家信息 */
    static matchPlayerInfos: MatchPlayerInfo[] = [
        {nickname:"PlyaerA",gender:0,avatarUrl:""},
        {nickname:"PlyaerB",gender:1,avatarUrl:""},
        {nickname:"PlyaerC",gender:0,avatarUrl:""},
        {nickname:"PlyaerD",gender:1,avatarUrl:""},
    ];
    static setMatchPlayerInfos(playerInfos, timestamp) {
        ExactMath.setSeed(timestamp);
        let aiInfoIndexes = [];
        for (let i = 0; i < this.aiPlayerInfos.length; i++) {
            aiInfoIndexes.push(i);
        }
        aiInfoIndexes.sort(() => ExactMath.sub(0.5, ExactMath.random()))
        for (let i = 0; i < this.matchPlayerInfos.length; i++) {
            let a = this.matchPlayerInfos[i];
            let b = playerInfos[i];
            if (!b) b = this.aiPlayerInfos[aiInfoIndexes.shift()];
            a.nickname = b.nickname;
            a.gender = b.gender;
            a.avatarUrl = b.avatarUrl;
        }
    }
    /**我的玩家信息，在请求匹配时需要用到 */
    static myPlayerInfo: MatchPlayerInfo = {
        nickname: "JC",
        gender: 0,
        avatarUrl: "data:image/jpeg;base64,[encoded data, 17884 characters]"
    };
    static aiPlayerInfos: MatchPlayerInfo[] = [
        {
            nickname: "大佬啊",
            gender: 0,
            avatarUrl: "data:image/jpeg;base64,[encoded data, 24968 characters]"
        },
        {
            nickname: "天天睡懒觉",
            gender: 1,
            avatarUrl: "data:image/jpeg;base64,[encoded data, 24952 characters]"
        },
        {
            nickname: "这也太奢侈了吧",
            gender: 0,
            avatarUrl: "data:image/jpeg;base64,[encoded data, 19024 characters]"
        },
        {
            nickname: "我要起飞咯",
            gender: 1,
            avatarUrl: "data:image/jpeg;base64,[encoded data, 25600 characters]"
        },
        {
            nickname: "工作不如睡觉",
            gender: 0,
            avatarUrl: "data:image/jpeg;base64,[encoded data, 18008 characters]"
        },
    ];
}
