人品计算器大起底

最近有个人品计算器在网上广泛流传,我计算之后发现自己人品低的可怜,为了证明这是一个伪科学作品。我现在来公开一下它的算法。看下面这个函数
function getResult(str) {
        var _local2 = 0;
        var _local1 = 0;
        while (_local1 < str.length) {
            _local2 = _local2 + str.charCodeAt(_local1);
            _local1++;
        }
        return (_local2 % 100);
    }
这个函数就是计算人品核心算法,charCodeAt是字符返回 Unicode 字符编码。也就是说这个算法就是遍历你输入的每个字符,然后求和之后再和100求余数。这个数字就是你的人品了。全部代码附后
    function nameResult(str) {
        var _local2 = checkPreList(str);
        if (_local2 == null) {
            _local2 = getResult(str);
        }
        var _local1 = ("姓名:" + str) + newline;
        _local1 = _local1 + (("人品得分:" + foramtResult(_local2)) + newline);
        _local1 = _local1 + ("评价:" + getValue(_local2));
        return (_local1);
    }
    function foramtResult(n) {
        return ((((n >= 0) && (n <= 100)) ? (n) : "负溢出"));
    }
    function getValue(n) {
        var _local2 = "";
        if (n == 0) {
            _local2 = "你一定不是人吧?怎么一点人品都没有?!";
        } else if ((n > 0) && (n <= 5)) {
            _local2 = "算了,跟你没什么人品好谈的…";
        } else if ((n > 5) && (n <= 10)) {
            _local2 = "是我不好…不应该跟你谈人品问题的…";
        } else if ((n > 10) && (n <= 15)) {
            _local2 = "杀过人没有?放过火没有?你应该无恶不做吧?";
        } else if ((n > 15) && (n <= 20)) {
            _local2 = "你貌似应该三岁就偷看隔壁大妈洗澡的吧…";
        } else if ((n > 20) && (n <= 25)) {
            _local2 = "你的人品之低下实在让人惊讶啊…";
        } else if ((n > 25) && (n <= 30)) {
            _local2 = "你的人品太差了。你应该有干坏事的嗜好吧?";
        } else if ((n > 30) && (n <= 35)) {
            _local2 = "你的人品真差!肯定经常做偷鸡摸狗的事…";
        } else if ((n > 35) && (n <= 40)) {
            _local2 = "你拥有如此差的人品请经常祈求佛祖保佑你吧…";
        } else if ((n > 40) && (n <= 45)) {
            _local2 = "老实交待..那些论坛上面经常出现的偷拍照是不是你的杰作?";
        } else if ((n > 45) && (n <= 50)) {
            _local2 = "你随地大小便之类的事没少干吧?";
        } else if ((n > 50) && (n <= 55)) {
            _local2 = "你的人品太差了..稍不小心就会去干坏事了吧?";
        } else if ((n > 55) && (n <= 60)) {
            _local2 = "你的人品很差了..要时刻克制住做坏事的冲动哦..";
        } else if ((n > 60) && (n <= 65)) {
            _local2 = "你的人品比较差了..要好好的约束自己啊..";
        } else if ((n > 65) && (n <= 70)) {
            _local2 = "你的人品勉勉强强..要自己好自为之..";
        } else if ((n > 70) && (n <= 75)) {
            _local2 = "有你这样的人品算是不错了..";
        } else if ((n > 75) && (n <= 80)) {
            _local2 = "你有较好的人品..继续保持..";
        } else if ((n > 80) && (n <= 85)) {
            _local2 = "你的人品不错..应该一表人才吧?";
        } else if ((n > 85) && (n <= 90)) {
            _local2 = "你的人品真好..做好事应该是你的爱好吧..";
        } else if ((n > 90) && (n <= 95)) {
            _local2 = "你的人品太好了..你就是当代活雷锋啊…";
        } else if ((n > 95) && (n <= 99)) {
            _local2 = "你是世人的榜样!";
        } else if (n == 100) {
            _local2 = "天啦!你不是人!你是神!!!";
        } else {
            _local2 = "你的人品竟然负溢出了…我对你无语..";
         }
        return (_local2);
    }
    function getResult(str) {
        var _local2 = 0;
        var _local1 = 0;
        while (_local1 < str.length) {
            _local2 = _local2 + str.charCodeAt(_local1);
            _local1++;
        }
        return (_local2 % 100);
    }
    function checkPreList(str) {
        var _local1 = null;
        for (var _local3 in PrenameList) {
            if (PrenameList[_local3][0] == str) {
                _local1 = PrenameList[_local3][1];
                break;
            }
        }
        return (_local1);
    }
    PrenameList = new Array ();
    PrenameList.push(["日本人", -1]);
    PrenameList.push(["小日本", -1]);
    PrenameList.push(["日本", -1]);
    PrenameList.push(["日本鬼子", -1]);
    btn.onRelease = function () {
        getURL ("http://2006.56.com/acss/acss.php?atable=200607&targetUrl=http%3A%2F%2Fwww.56.com%2Fgx%2F&aid=51", "_blank");
    };
    fscommand ("showmenu", false);
    inputName.maxChars = 20;
    resultArea.text = "请输入姓名计算人品值";
    okBtAction = new Object ();
    okBtAction.click = function () {
        var _local1 = inputName.text;
        _local1 = _local1.split(" ").join("");
        _local1 = _local1.split(" ").join("");
        _local1 = _local1.split("\t").join("");
        inputName.text = _local1;
        if (_local1 == "") {
            resultArea.text = "请先输入要计算的名字";
        } else {
            resultArea.text = nameResult(_local1);
         }
    };
    okBt.addEventListener("click", okBtAction);
 
Advertisements

发布者:supeng

peng.su@hotmail.com

加入对话

4条评论

  1. 这个rp计算器的作者好像还有这一手
    …….
           } else if (n > 100) {            _local2 = "天啦!你的rp居然正溢出了…老婆快来看上帝!!!";
    ……….
    ………
     
    PrenameList.push(["水果阿生", 101]);
    ………..
     

留下评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

You are commenting using your WordPress.com account. Log Out /  更改 )

Google photo

You are commenting using your Google account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )

Connecting to %s

%d 博主赞过: