Code Monkey home page Code Monkey logo

bh3_antientropy's Introduction

bh3_antiEntropy

A js script to auto-get all collections for bh3 Anti-Entropy adventure game

自动完成崩崩崩逆熵视觉小说成就的JavaScript脚本

Usage

function my_post_achievement(str_ach, now_galgame, now_scene){
    var ajax_answer = null;
    var ajax_async = false;
    $.ajax({
        type:"POST",
        url:"./utils/achievement.php" + achievementQueryString,
        dataType:"json",
        data:{achievement:str_ach,
            chapter:now_galgame,
            scene:now_scene},
        async:ajax_async,
        success:function(result) {
            console.log("章节"+now_galgame+"场景"+now_scene+". 状态:"+result.msg+"\n code:"+result.achievement);
        },
        error:function(XMLHttpRequest, textStatus, errorThrown){
            console.log(XMLHttpRequest);
            console.log(textStatus);
            console.log(errorThrown);
        } 
        });
    return ajax_answer;
}

function loadXmlFile(xmlFile)
{   
    var xmlDom = null;
    if (window.ActiveXObject)
    {
        xmlDom = new ActiveXObject("Microsoft.XMLDOM");
        xmlDom.async="false";
        xmlDom.load(xmlFile);
    }
    else if(document.implementation && document.implementation.createDocument)
    {
        var xmlhttp = new window.XMLHttpRequest();
        xmlhttp.open("GET", xmlFile, false);
        xmlhttp.send(null);
        xmlDom = xmlhttp.responseXML;
    }
    else
    {
        xmlDom = null;
        
    }
    return xmlDom;
}

function galgame(name){
    let i,j;
    let now_galgame  = Number(name);
    let xmlDoc = loadXmlFile("./lang_CN/xml/ch"+name+".xml?sid="+Math.random());

    let sceneList0 = [];
    sceneList0 = xmlDoc.getElementsByTagName('scene');    
    let sceneList = new Array();    
    for(i = 0;sceneList0[i] != null;i++){
    	j = sceneList0[i].getAttribute("id");
    	sceneList[Number(j)] = sceneList0[i];
    	sceneList0[i] = null;
    }    	
    pa(sceneList, now_galgame)
}

function post_achievement_in_event(eventNode, now_galgame, now_scene){
    if(eventNode.getAttribute("post")){
        my_post_achievement(eventNode.getAttribute("post"), now_galgame, now_scene);
    }	
}

function systemAutoSave(now_galgame, now_scene){
    setCookie(now_galgame_tag, now_galgame);
    setCookie(now_scene_tag, now_scene);
}

function pa(sceneList, now_galgame) {
    for (sceneIndex = 0; sceneIndex < sceneList.length; sceneIndex++) {
        if (sceneList[sceneIndex]) {
            let thisScene = sceneList[sceneIndex];
            let now_scene = sceneIndex;
            for (i = 0; i < thisScene.childNodes.length; i++) {
                let thisEvent = thisScene.childNodes[i];
                systemAutoSave(now_galgame, now_scene);
                if (thisEvent.nodeName == "remark") {
                    post_achievement_in_event(thisEvent, now_galgame, now_scene);
                }
                let thisTag = thisEvent.tagName;
                if (thisTag == "end" || thisTag == "speak" || thisTag == "text") {
                    post_achievement_in_event(thisEvent, now_galgame, now_scene);
                }
            }
        }
    }
}

for (let i = 1; i <= 26; i++) {
    galgame(i);
}

Notice

仅在Chrome 66.0.3359.139 上测试通过。其他浏览器不保证兼容性

部分代码摘抄自米忽悠前端,风格不保证统一

License

WTFPL License

bh3_antientropy's People

Contributors

povsister avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.