Ejemplo n.º 1
0
    //--方法组--//

    /** 帮助 */
    public void help(int[] ints)
    {
        StringBuilder sb = StringBuilderPool.create();
        DescribeObj   dObj;

        for (int i = 1, len = _describeList.length(); i < len; ++i)
        {
            if (i > 1)
            {
                sb.Append("\n");
            }

            dObj = _describeList.get(i);

            for (int j = 0; j < dObj.cmds.Length; ++j)
            {
                if (j > 0)
                {
                    sb.Append(" / ");
                }

                sb.Append("<color=orange>");
                sb.Append(dObj.cmds[j]);
                sb.Append("</color>");
            }

            sb.Append(" : ");
            sb.Append(dObj.describe);
        }

        GameC.info.showInfoCode(InfoCodeType.ClientGMHelp, StringBuilderPool.releaseStr(sb));
    }
Ejemplo n.º 2
0
    /** 抛错 */
    public void throwError(Exception e)
    {
        StringBuilder sb = StringBuilderPool.create();

        writeInfo(sb);

        Ctrl.toThrowError(sb, e);
    }
Ejemplo n.º 3
0
    private void toLog(object[] args, int type)
    {
        StringBuilder sb = StringBuilderPool.create();

        StringUtils.writeObjectsToStringBuilder(sb, args);
        sb.Append(' ');
        writeInfo(sb);
        Ctrl.toLog(sb, type);
    }
Ejemplo n.º 4
0
    //--log--//

    private void toLog(string str, int type)
    {
        StringBuilder sb = StringBuilderPool.create();

        sb.Append(str);
        sb.Append(' ');
        writeInfo(sb);
        Ctrl.toLog(sb, type);
    }
Ejemplo n.º 5
0
    /** 错误日志输出错误 */
    public void errorLog(Exception e)
    {
        StringBuilder sb = StringBuilderPool.create();

        Ctrl.writeExceptionToString(sb, "", e);
        sb.Append(' ');
        writeInfo(sb);
        Ctrl.toLog(sb, SLogType.Error);
    }
Ejemplo n.º 6
0
    /** 抛错 */
    public void throwError(String str, Exception e)
    {
        StringBuilder sb = StringBuilderPool.create();

        sb.Append(str);
        sb.Append(' ');
        writeInfo(sb);

        Ctrl.toThrowError(sb, e);
    }
Ejemplo n.º 7
0
    /** 抛错 */
    public void throwError(params object[] args)
    {
        StringBuilder sb = StringBuilderPool.create();

        StringUtils.writeObjectsToStringBuilder(sb, args);
        sb.Append(' ');
        writeInfo(sb);

        Ctrl.toThrowError(sb, null);
    }
Ejemplo n.º 8
0
    /** 抛错 */
    public void throwError(string str)
    {
        StringBuilder sb = StringBuilderPool.create();

        sb.Append(str);
        sb.Append(' ');
        writeInfo(sb);

        Ctrl.toThrowError(sb, null);
    }
Ejemplo n.º 9
0
    private static String countKey(int[] arr)
    {
        StringBuilder sb = StringBuilderPool.create();

        foreach (int v in arr)
        {
            sb.Append(v);
        }

        return(StringBuilderPool.releaseStr(sb));
    }
Ejemplo n.º 10
0
    /** 警告日志 */
    public void warnLog(params object[] args)
    {
        StringBuilder sb = StringBuilderPool.create();

        StringUtils.writeObjectsToStringBuilder(sb, args);
        sb.Append(' ');
        writeInfo(sb);

        string re = sb.ToString();

        Ctrl.toLog(sb, SLogType.Warning);
    }
Ejemplo n.º 11
0
    /** 警告日志 */
    public void warnLog(string str)
    {
        StringBuilder sb = StringBuilderPool.create();

        sb.Append(str);
        sb.Append(' ');
        writeInfo(sb);

        string re = sb.ToString();

        Ctrl.toLog(sb, SLogType.Warning);
    }
Ejemplo n.º 12
0
    public String ToString()
    {
        StringBuilder sb = StringBuilderPool.create();

        sb.Append("{x=");
        sb.Append(StringUtils.roundStrF2(x));
        sb.Append(",y=");
        sb.Append(StringUtils.roundStrF2(y));
        sb.Append(",width=");
        sb.Append(StringUtils.roundStrF2(width));
        sb.Append(",height=");
        sb.Append(StringUtils.roundStrF2(height));
        sb.Append("}");
        return(StringBuilderPool.releaseStr(sb));
    }
Ejemplo n.º 13
0
    /** 随机一个名字 */
    public String randomName()
    {
        StringBuilder sb = StringBuilderPool.create();

        if (!firstNames.isEmpty())
        {
            sb.Append(firstNames.get(MathUtils.randomInt(firstNames.size())));
        }

        if (!secondNames.isEmpty())
        {
            sb.Append(secondNames.get(MathUtils.randomInt(secondNames.size())));
        }

        return(StringBuilderPool.releaseStr(sb));
    }
Ejemplo n.º 14
0
    /** 游戏服日志 */
    public void gameActionLog(params string[] args)
    {
        StringBuilder sb = StringBuilderPool.create();

        sb.Append("action");
        sb.Append(' ');

        for (int i = 0, len = args.Length; i < len; i += 2)
        {
            if (i > 0)
            {
                sb.Append('&');
            }

            sb.Append(args[i]);
            sb.Append('=');
            sb.Append(args[i + 1]);
        }

        addLog(StringBuilderPool.releaseStr(sb));
    }
Ejemplo n.º 15
0
    /** 替换字符串(颜色,文字标记) */
    public string replaceText(int type, string text, object obj)
    {
        ReplaceTextTool tool = _replaceTools[type];

        if (tool == null)
        {
            Ctrl.throwError("不该找不到替换文字工具");
            return(text);
        }

        int pos = 0;

        bool isColoring = false;
        bool isMatching = false;

        StringBuilder sb = null;

        while (true)
        {
            int index = text.IndexOfAny(_replaceMarkArr, pos);

            if (index != -1)
            {
                if (sb == null)
                {
                    sb = StringBuilderPool.create();
                }

                //颜色
                if (text[index] == CommonSetting.replaceTextColorMark)
                {
                    sb.Append(text.slice(pos, index));

                    //结束
                    if (isColoring)
                    {
                        isColoring = false;
                        addColorEnd(sb);
                        pos = index + 1;
                    }
                    //开始
                    else
                    {
                        if (text.Length <= index + CommonSetting.replaceTextColorLength)
                        {
                            Ctrl.throwError("替换文本的字符串缺少");
                        }

                        isColoring = true;
                        addColorFront(sb, text.Substring(index + 1, CommonSetting.replaceTextColorLength));
                        pos = index + 1 + CommonSetting.replaceTextColorLength;
                    }
                }
                else
                {
                    //结束
                    if (isMatching)
                    {
                        isMatching = false;
                        sb.Append(tool.replace(text.slice(pos, index), obj));
                        pos = index + 1;
                    }
                    //开始
                    else
                    {
                        sb.Append(text.slice(pos, index));

                        isMatching = true;
                        pos        = index + 1;
                    }
                }
            }
            else
            {
                if (sb != null)
                {
                    sb.Append(text.Substring(pos));
                }

                break;
            }
        }

        //无需替换
        if (sb == null)
        {
            return(text);
        }

        if (isColoring || isMatching)
        {
            StringBuilderPool.release(sb);
            Ctrl.throwError("替换文本的字符串未配置完整");
            return(text);
        }

        return(StringBuilderPool.releaseStr(sb));
    }