WIKI冒险团明确声明不支持涉及代练和账号买卖的现金交易活动。
参与者应自行承担对应后果。

全站通知:

Widget:Wiki测试服-装备特效

来自地下城堡2WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

<script>

class 装备特效类 {
    constructor(owner, discription) {
        this.上级 = owner;
        this.描述 = discription;
        this.名称 = "";
        this.条件 = "";
        this.概率 = NaN;
        this.类型 = "";
        this.增幅内容 = [];
        this.状态名称 = "";
        this.状态类型 = "";
        this.状态持续时间 = "";
        this.状态最大层数 = "";
        this.对象 = "";
        this.系数 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0];
    }
    触发 (condition) { 
        if (condition!=this.条件 || !Rand(this.概率)) return null;
        TimeLine("    "+this.上级.名称+"触发了装备特效"+this.名称);
        if (this.类型 == "状态类" && ["战斗开始", "受到物理攻击", "受到魔法攻击"].includes(condition)) { this.上级.附加(this, this.对象); }
        if (this.类型 == "状态类" && ["发动物理攻击", "发动魔法攻击", "使用回复技能"].includes(condition)) {  }
        if (this.类型 == "增幅类") { for (let i=0;i<this.增幅内容.length;i++) { 
            let j = this.增幅内容[i]; 
            if (j[1] == "当前生命") { this.上级.增幅[P(j[2])] += Int(j[0] * this.上级.当前生命); }
            else { this.上级.增幅[P(j[2])] += Int(j[0] * (this.上级.属性(j[1]) - this.上级.增幅[P(j[1])])); }
        }}
        if (this.类型 == "连击类") { this.上级.冷却时间增加 = -4; }
        if (this.类型 == "回复类") { 
            if (this.对象 == "自身") {
                this.上级.被治疗(this, Int(数值计算(this.系数,this.上级) * this.上级.属性("回复效果")));
            }
            if (this.对象 == "我方单体") {
                this.上级.我方目标.被治疗(this, Int(数值计算(this.系数,this.上级) * this.上级.属性("回复效果")));
            }
            if (this.对象 == "我方全体") { for (let i=0;i<this.上级.我方阵营.length;i++) { if (this.上级.我方阵营[i].存活 != 0) {
                this.上级.我方阵营[i].被治疗(this, Int(数值计算(this.系数,this.上级) * this.上级.属性("回复效果")));
            }}}
        }
        if (this.类型 == "真伤类") { 
            if (this.对象 == "敌方单体") {
                this.上级.敌方目标.被攻击(this.上级, Int(数值计算(this.系数, this.上级, this上级.敌方目标)));
            }
            if (this.对象 == "敌方全体") { for (let i=0;i<this.上级.敌方阵营.length;i++) { if (this.上级.敌方阵营[i].存活 != 0) {
                this.上级.敌方阵营[i].被攻击(this.上级, Int(数值计算(this.系数, this.上级, this.上级.敌方阵营[i])));
            }}}
        }
        return this;
    }
    
    Decode(index) {
        var text = this.描述;
        
        if (!text.includes(":")) { Reject("特效名称后面要接中文冒号"); return false; }
        this.名称 = Partition(text, ":")[0];
        text = Partition(text, ":")[2];
        if (index != "") { M("特效"+index+"名称文本框").value = this.名称; }
        
        if (!text.includes(",")) { Reject("特效条件后面要接中文逗号"); return false; }
        this.条件 = Partition(text, ",")[0];
        text = Partition(text, ",")[2];
        this.条件 = this.条件.replace(/在/, "").replace(/时/, "").replace(/的瞬间/, "");
        if (!CheckInside(this.条件, 条件列表, "条件列表")) return false;
        if (index != "") { M("特效"+index+"条件文本框").value = this.条件; }
        
        text = text.replace(/的/g, "").replace(/有/g, "").replace(/值/g, "").replace(/武器威力/g, "武威");
        if (!text.includes("%概率")) { this.概率 = 1; if (index != "") {M("特效"+index+"概率文本框").value = "100%";} }
        else { 
            var p = Partition(text, "%概率")[0];
            if (isNaN(parseFloat(p)) || !isFinite(p)) { Reject("概率\"" + p + "\"无法被识别为数值"); return false; }
            this.概率 = p * 0.01;
            if (index != "") { M("特效"+index+"概率文本框").value = String(this.概率*100) + "%"; }
            text = Partition(text, "%概率")[2];
        }
        
        if(text.startsWith("增幅")||text.startsWith("将")||text.startsWith("同时增幅")||text.startsWith("同时将")){if(!this.Decode增幅类(text, index))return false;}
        else if ((text.startsWith("对") || text.startsWith("为")) && text.includes("附加")) { if(!this.Decode状态类(text, index)) return false; }
        else if (text.startsWith("为") && text.includes("回复")) { if(!this.Decode回复类(text, index)) return false; }
        else if (text.startsWith("对") && text.includes("造成")) { if(!this.Decode真伤类(text, index)) return false; }
        else if (text.startsWith("立即执行下次行动(可连续触发)")) { if(!this.Decode连击类(text, index)) return false; }
        else { Reject("特效类型无法识别。需要与游戏内一致,且标点为中文标点"); return false; }
        
        return true;
    }
    Decode增幅类(text, index){
        this.类型 = "增幅类";
        if (this.条件 == "战斗开始") { Reject("战斗开始时的特效不可能是增幅类特效"); return false; }
        $("#特效"+index+"增幅容器").show();
        if (index != "") { M("特效"+index+"类型文本框").value = this.类型; }
        if (text.startsWith("增幅")) {
            text = text.replace("增幅", "")
            if (!text.includes("%")) { Reject("增幅描述中找不到百分号"); return false; }
            var left = Partition(text, "%")[0];
            var right = Partition(text, "%")[2];
            if (isNaN(parseFloat(left)) || !isFinite(left)) { Reject("增幅比例\"" + left + "\"无法被识别为数值"); return false; }
            var coe = left * 0.01;
            if (!CheckInside(right, 系数列表, "系数列表")) return false;
            this.增幅内容.push([String(coe), right, right]);
        }
        else if (text.startsWith("将")) {
            text = text.replace("将", "")
            if (!text.includes("%")) { Reject("增幅描述中找不到百分号"); return false; }
            if (!text.includes("附加为")) { Reject("增幅描述中找不到\"附加为\""); return false; }
            var left = Partition(text, "%")[0];
            if (isNaN(parseFloat(left)) || !isFinite(left)) { Reject("增幅比例\"" + left + "\"无法被识别为数值"); return false; }
            var coe = left * 0.01;
            var right = Partition(text, "%")[2];
            left = Partition(right, "附加为")[0];
            right = Partition(right, "附加为")[2];
            if (!CheckInside(left, 系数列表, "系数列表")) return false;
            if (!CheckInside(right, 系数列表, "系数列表")) return false;
            this.增幅内容.push([String(coe), left, right]);
        }
        else if (text.startsWith("同时增幅")) {
            text = text.replace("同时增幅", "")
            var left, right, coe;
            if (!text.includes("和")) { Reject("增幅描述中找不到\"和\""); return false; }
            left = Partition(text, "和")[0];
            right = Partition(text, "和")[2];
            if (!left.includes("%")) { Reject("增幅描述中找不到\"%\""); return false; }
            coe = Partition(left, "%")[0];
            left = Partition(left, "%")[2];
            if (isNaN(parseFloat(coe)) || !isFinite(coe)) { Reject("增幅比例\"" + coe + "\"无法被识别为数值"); return false; }
            coe = coe * 0.01;
            if (!CheckInside(left, 系数列表, "系数列表")) return false;
            this.增幅内容.push([String(coe), left, left]);
            if (!right.includes("%")) { Reject("增幅描述中找不到\"%\""); return false; }
            coe = Partition(right, "%")[0];
            right = Partition(right, "%")[2];
            if (isNaN(parseFloat(coe)) || !isFinite(coe)) { Reject("增幅比例\"" + coe + "\"无法被识别为数值"); return false; }
            coe = coe * 0.01;
            if (!CheckInside(right, 系数列表, "系数列表")) return false;
            this.增幅内容.push([String(coe), right, right]);
        }
        else if (text.startsWith("同时将")){
            text = text.replace("同时将", "");
            var left, right, coe, attr;
            if (!text.includes("和")) { Reject("增幅描述中找不到\"和\""); return false; }
            left = Partition(text, "和")[0]; right = Partition(text, "和")[2];
            if (!right.includes("附加为")) { Reject("增幅描述中找不到\"附加为\""); return false; }
            attr = Partition(right, "附加为")[2]; right = Partition(right, "附加为")[0];
            if (!CheckInside(attr, 系数列表, "系数列表")) return false;
            if (!left.includes("%")) { Reject("增幅描述中找不到\"%\""); return false; }
            coe = Partition(left, "%")[0]; left = Partition(left, "%")[2];
            if (isNaN(parseFloat(coe)) || !isFinite(coe)) { Reject("增幅比例\"" + coe + "\"无法被识别为数值"); return false; }
            coe = coe * 0.01;
            if (!CheckInside(left, 系数列表, "系数列表")) return false;
            this.增幅内容.push([String(coe), left, attr]);
            coe = Partition(right, "%")[0]; right = Partition(right, "%")[2];
            if (isNaN(parseFloat(coe)) || !isFinite(coe)) { Reject("增幅比例\"" + coe + "\"无法被识别为数值"); return false; }
            coe = coe * 0.01;
            if (!CheckInside(right, 系数列表, "系数列表")) return false;
            this.增幅内容.push([String(coe), right, attr]);
        }
        else { return false; }
        if (index != "") { 
            for (var i=0;i<this.增幅内容.length;i++) {
                 M("特效"+index+"增幅内容文本框").value += String(this.增幅内容[i][0] * 100) + "%" + this.增幅内容[i][1] + "→" + this.增幅内容[i][2] + "   ";
            }
        }
        return true;
    }
    Decode状态类(text, index){
        this.类型 = "状态类";
        $("#特效"+index+"状态容器").show();
        if (index != "") { M("特效"+index+"类型文本框").value = this.类型; }
        if (!text.includes("附加")) { Reject("状态描述中找不到\"附加\""); return false; }
        text = text.replace(/对/g, "").replace(/为/g, "");
        this.对象 = Partition(text, "附加")[0]; text = Partition(text, "附加")[2];
        if (!CheckInside(this.对象, 对象列表, "对象列表")) return false;
        if (index != "")M("特效"+index+"状态对象文本框").value = this.对象;
        var content = Partition(text, ",")[0]; text = Partition(text, ",")[2];
        content = content.replace(")", "")
        this.状态名称 = Partition(content, "(")[0]; content = Partition(content, "(")[2];
        if (index != "")M("特效"+index+"状态名称文本框").value = this.状态名称;
        content = content.replace(/提升/, "提高").replace(/增加/, "提高").replace(/减少/, "降低").replace(/恢复/, "回复").replace(/\*/g, "×").replace(/x/g, "×");
        
        if (content.startsWith("每秒失去")){
            content = content.replace("每秒失去", "", ).replace("点", "").replace("生命", "")
            this.状态类型 = "dot";
            this.系数 = 系数解析(content);
            if (this.系数 == [0,0,0,0,0,0,0,0,0,0,0,0,0,0]) return false;
            if (index != "")M("特效"+index+"状态数值文本框").value = 系数表述(this.系数);
        }
        else if (content.startsWith("每秒回复")){
            content = content.replace("每秒回复", "", ).replace("点", "").replace("生命", "")
            this.状态类型 = "hot"
            this.系数 = 系数解析(content);
            if (this.系数 == [0,0,0,0,0,0,0,0,0,0,0,0,0,0]) return false;
            if (index != "")M("特效"+index+"状态数值文本框").value = 系数表述(this.系数);
        }
        else if (this.状态名称 == "眩晕"){
            this.状态类型 = "眩晕buff";
        }
        else if (this.状态名称 == "反击"){
            this.状态类型 = "反击buff";
            content = Partition(content, "反弹")[2];
            content = Partition(content, "%")[0];
            this.系数 = 系数解析(content);
            if (this.系数 == [0,0,0,0,0,0,0,0,0,0,0,0,0,0]) return false;
            if (index != "")M("特效"+index+"状态数值文本框").value = 系数表述(this.系数);
        }
        else if (this.状态名称 == "物理易伤"){
            this.状态类型 = "物理易伤buff";
            content = content.replace("提高", "").replace("受到", "").replace("物理", "").replace("伤害", "").replace("%", "");
            this.系数 = 系数解析(content);
            if (this.系数 == [0,0,0,0,0,0,0,0,0,0,0,0,0,0]) return false;
            if (index != "")M("特效"+index+"状态数值文本框").value = 系数表述(this.系数);
        }
        else if (this.状态名称 == "魔法易伤"){
            this.状态类型 = "魔法易伤buff";
            content = content.replace("提高", "").replace("受到", "").replace("魔法", "").replace("伤害", "").replace("%", "");
            this.系数 = 系数解析(content);
            if (this.系数 == [0,0,0,0,0,0,0,0,0,0,0,0,0,0]) return false;
            if (index != "")M("特效"+index+"状态数值文本框").value = 系数表述(this.系数);
        }
        else if (content.startsWith("提高") || content.startsWith("降低")){
            if (content.startsWith("降低")) this.状态类型 = "debuff";
            else this.状态类型 = "buff";
            content = content.replace("提高", "", ).replace("降低", "")
            this.状态类型 = Partition(content, "点")[2] + this.状态类型;
            content = Partition(content, "点")[0];
            if (this.状态类型 == "buff" || this.状态类型 == "debuff"){ this.状态类型 = Partition(content, "%")[2] + this.状态类型;}
            this.系数 = 系数解析(content);
            if (this.系数 == [0,0,0,0,0,0,0,0,0,0,0,0,0,0]) return false;
            if (index != "")M("特效"+index+"状态数值文本框").value = 系数表述(this.系数);
        }
        else { Reject("无法识别状态类型"); return false; }
        if (!CheckInside(this.状态类型, 状态类型列表, "状态类型列表")) return false;
        if (index != "")M("特效"+index+"状态类型文本框").value = this.状态类型;
        this.状态持续时间 = -1;
        this.状态最大层数 = 1;
        var raw_suffix = text.split(",");
        var suffix = [];
        for (var i=0; i<raw_suffix.length; i++) if (raw_suffix[i]!="") suffix.push(raw_suffix[i]);
        for (var i=0; i<suffix.length; i++){
            var 后缀 = suffix[i];
            if (后缀.startsWith("持续")){
                后缀 = 后缀.replace("持续", "").replace("秒", "");
                if (isNaN(parseFloat(后缀)) || !isFinite(后缀)) { Reject("持续时间\"" + 后缀 + "\"无法被识别为数值"); return false; }
                this.状态持续时间 = 后缀 * 1;
            }
            else if (后缀.startsWith("可叠加")) {
                后缀 = 后缀.replace("可叠加", "").replace("层", "");
                if (后缀 == ""){ this.状态最大层数 = 999; }
                else{
                    if (isNaN(parseFloat(后缀)) || !isFinite(后缀)) { Reject("最大层数\"" + 后缀 + "\"无法被识别为数值"); return false; }
                    this.状态最大层数 = 后缀 * 1;
                }
            }
            else if (后缀 == "重伤后失效") {}
            else { Reject("无法识别的特效后缀:" + 后缀); return false; }
        }
        if (index != "")M("特效"+index+"持续时间文本框").value = String(this.状态持续时间);
        if (index != "")M("特效"+index+"最大层数文本框").value = String(this.状态最大层数);
        return true;
    }
    Decode连击类(text, index){
        this.类型 = "连击类";
        if (index != "") { M("特效"+index+"类型文本框").value = this.类型; }
        return true;
    }
    Decode回复类(text, index){
        this.类型 = "回复类";
        $("#特效"+index+"回复容器").show();
        if (index != "") { M("特效"+index+"类型文本框").value = this.类型; }
        text = text.replace("为", "").replace("点", "").replace("(", "").replace(")", "")
        text = Partition(text, "生命")[0];
        this.对象 = Partition(text, "回复")[0];
        if (!CheckInside(this.对象, 对象列表, "对象列表")) return false;
        if (index != "")M("特效"+index+"回复对象文本框").value = this.对象;   
        text = Partition(text, "回复")[2];
        this.系数 = 系数解析(text);
        if (this.系数 == [0,0,0,0,0,0,0,0,0,0,0,0,0,0]) return false;
        if (index != "")M("特效"+index+"回复数值文本框").value = 系数表述(this.系数);   
        return true;
    }
    Decode真伤类(text, index){
        this.类型 = "真伤类";
        $("#特效"+index+"真伤容器").show();
        if (index != "") { M("特效"+index+"类型文本框").value = this.类型; }
        text = text.replace("对", "").replace("点", "").replace("(", "").replace(")", "").replace("真实伤害", "").replace("无属性伤害","")
        this.对象 = Partition(text, "造成")[0];
        if (!CheckInside(this.对象, 对象列表, "对象列表")) return false;
        if (index != "")M("特效"+index+"真伤对象文本框").value = this.对象;
        text = Partition(text, "造成")[2];
        this.系数 = 系数解析(text);
        if (this.系数 == [0,0,0,0,0,0,0,0,0,0,0,0,0,0]) return false;
        if (index != "")M("特效"+index+"真伤数值文本框").value = 系数表述(this.系数);   
        return true;
    }
}

</script>