查看: 900|回复: 0

[原创发布] 随机排行榜系统,即时刷新自动排名

[复制链接]
梦石
0
星屑
6412
在线时间
1700 小时
注册时间
2018-1-16
回帖
364
发表于 2025-5-31 10:00:59 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
1.用AI写的一个排行榜插件
2.实现401-410变量即时排行,可以带入变量名进行排名
3.即时刷新,变量变动,则自动刷新排行榜
4.玩家上榜实现:可以将其中一个变量带入玩家的某项数值,从而实现玩家同步上榜

[pre lang="ruby" file="VariableRanking.js"]/*:
* @target MZ
* @plugindesc 变量排行榜系统 v2.1(纯色版)
* @help 显示指定变量范围的排行榜(变量401-410),按数值从高到低排列
* 可在参数界面设置显示坐标和颜色
* @param posX
* @text 排行榜X坐标
* @desc 排行榜显示位置的X坐标(默认20)
* @type number
* @default 20
*
* @param posY
* @text 排行榜Y坐标
* @desc 排行榜显示位置的Y坐标(默认20)
* @type number
* @default 20
*
* @param bgColor
* @text 背景颜色
* @desc 排行榜背景颜色(默认#00000080)
* @type string
* @default #00000080
*
* @param titleColor
* @text 标题颜色
* @desc 标题文字颜色(默认#FFFFFF)
* @type string
* @default #FFFFFF
*
* @param rank1Color
* @text 第一名颜色
* @desc 第一名文字颜色(默认#FF0000)
* @type string
* @default #FF0000
*
* @param rank2Color
* @text 第二名颜色
* @desc 第二名文字颜色(默认#FFFF00)
* @type string
* @default #FFFF00
*
* @param rank3Color
* @text 第三名颜色
* @desc 第三名文字颜色(默认#FFFF00)
* @type string
* @default #FFFF00
*
* @param rank4Color
* @text 第四名颜色
* @desc 第四名文字颜色(默认#FFFFFF)
* @type string
* @default #FFFFFF
*
* @param rank5Color
* @text 第五名颜色
* @desc 第五名文字颜色(默认#FFFFFF)
* @type string
* @default #FFFFFF
*
* @param rank6Color
* @text 第六名颜色
* @desc 第六名文字颜色(默认#FFFFFF)
* @type string
* @default #FFFFFF
*
* @param rank7Color
* @text 第七名颜色
* @desc 第七名文字颜色(默认#FFFFFF)
* @type string
* @default #FFFFFF
*
* @param rank8Color
* @text 第八名颜色
* @desc 第八名文字颜色(默认#FFFFFF)
* @type string
* @default #FFFFFF
*
* @param rank9Color
* @text 第九名颜色
* @desc 第九名文字颜色(默认#FFFFFF)
* @type string
* @default #FFFFFF
*
* @param rank10Color
* @text 第十名颜色
* @desc 第十名文字颜色(默认#FFFFFF)
* @type string
* @default #FFFFFF
*
* @param switchId
* @text 排行榜开关ID
* @desc 控制排行榜显示的开关ID(默认0表示始终显示)
* @type switch
* @default 0
*
* @author AI助手
*/

(() => {
    const parameters = PluginManager.parameters('VariableRanking');
    const config = {
        posX: parseInt(parameters['posX'] || 20),
        posY: parseInt(parameters['posY'] || 20),
        bgColor: parameters['bgColor'] || '#00000080',
        titleColor: parameters['titleColor'] || '#FFFFFF',
        rankColors: [
            parameters['rank1Color'] || '#FF0000',
            parameters['rank2Color'] || '#FFFF00',
            parameters['rank3Color'] || '#FFFF00',
            parameters['rank4Color'] || '#FFFFFF',
            parameters['rank5Color'] || '#FFFFFF',
            parameters['rank6Color'] || '#FFFFFF',
            parameters['rank7Color'] || '#FFFFFF',
            parameters['rank8Color'] || '#FFFFFF',
            parameters['rank9Color'] || '#FFFFFF',
            parameters['rank10Color'] || '#FFFFFF'
        ],
        switchId: parseInt(parameters['switchId'] || 0)
    };

    const _Scene_Map_update = Scene_Map.prototype.update;
    Scene_Map.prototype.update = function() {
        _Scene_Map_update.call(this);
        
        // 检查开关状态(如果设置了开关ID)
        if (config.switchId > 0 && !$gameSwitches.value(config.switchId)) {
            if (this._rankingSprite) {
                this._rankingSprite.removeChildren();
            }
            return;
        }

        if (!this._rankingSprite) {
            this._rankingSprite = new Sprite();
            this._rankingSprite.z = 999;
            this.addChild(this._rankingSprite);
        }

        // 收集变量数据(范围401-410)
        const data = [];
        for (let i = 401; i <= 410; i++) {
            data.push({
                value: $gameVariables.value(i),
                id: i,
                name: $dataSystem.variables || `变量${i}` // 获取变量名(含默认值)
            });
        }

        // 按数值降序排序
        data.sort((a, b) => b.value - a.value);

        // 更新排行榜显示
        this._rankingSprite.removeChildren();
        const bgWidth = 240;
        const bgHeight = 400;
        
        // 绘制纯色背景
        const bg = new Sprite(new Bitmap(bgWidth, bgHeight));
        bg.bitmap.fillAll(config.bgColor);
        bg.x = config.posX;
        bg.y = config.posY;
        this._rankingSprite.addChild(bg);

        // 绘制标题
        const title = new Sprite(new Bitmap(bgWidth - 20, 40));
        title.bitmap.fontSize = 24;
        title.bitmap.textColor = config.titleColor;
        title.bitmap.drawText('变量排行榜', 0, 0, bgWidth - 20, 40, 'center');
        title.x = config.posX + 10;
        title.y = config.posY + 10;
        this._rankingSprite.addChild(title);

        // 绘制排名条目
        data.forEach((entry, rank) => {
            const text = new Sprite(new Bitmap(bgWidth - 20, 32));
            text.bitmap.fontSize = 20;
            text.bitmap.textColor = config.rankColors[rank] || '#FFFFFF';
            
            text.bitmap.drawText(
                `${rank+1}. ${entry.name}: ${entry.value}`,
                0, 0, bgWidth - 20, 32
            );
            text.x = config.posX + 10;
            text.y = config.posY + 60 + rank * 32;
            this._rankingSprite.addChild(text);
        });
    };
})();[/pre]
$3S7J13M]95Q89CDAD[ZNLS.png
7V$T47}B{CYAQ7HY}4`SEDA.png
C)R0[7OVRSZK$86O4SV(PAL.png
I[~U@$`)0Z\0__O9LT`E@X.png

评分

参与人数 1赞 +1 收起 理由
a875772835 + 1 我很赞同

查看全部评分

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部