/* using UnityEngine; using System.Collections.Generic; using BrewMonster.Network; using CSNetwork.GPDataType; namespace BrewMonster.Scripts.ChatUI { public class ChatCommandProcessor { private struct ChatHistoryEntry { public ChatChannel channel; public float time; public string message; } private static List _history = new List(); private const int MAX_HISTORY = 10; private static float _lastFarCryTime = 0; private static float _lastSuperFarCryTime = 0; public struct ProcessResult { public bool success; public ChatChannel channel; public string message; public string targetPlayer; // For whisper public int itemPack; public int itemSlot; public string errorString; public bool showConfirmation; public int confirmationStringId; } public static ProcessResult Process(string text, int itemPack = -1, int itemSlot = -1) { ProcessResult result = new ProcessResult { success = false, channel = ChatChannel.GP_CHAT_LOCAL, message = text, itemPack = itemPack, itemSlot = itemSlot, showConfirmation = false }; if (string.IsNullOrWhiteSpace(text)) { return result; } // Flood protection float now = Time.time; if (_history.Count > 0) { var last = _history[_history.Count - 1]; if (now - last.time <= 1.0f) { result.errorString = GetStringFromTable(272); return result; } foreach (var entry in _history) { if (entry.channel != ChatChannel.GP_CHAT_WHISPER && entry.message == text && now - entry.time <= 6.0f) { result.errorString = GetStringFromTable(273); return result; } } } // Debug commands if (text == "##debug") { // Toggle console logic here if needed result.success = true; return result; } string pszMsg = text; ChatChannel channel = ChatChannel.GP_CHAT_LOCAL; if (text.Length >= 2 && text.StartsWith("!!")) { channel = ChatChannel.GP_CHAT_TEAM; pszMsg = text.Substring(2); } else if (text.Length >= 2 && text.StartsWith("!~")) { channel = ChatChannel.GP_CHAT_FACTION; pszMsg = text.Substring(2); } else if (text.Length >= 2 && text.StartsWith("!@")) { channel = ChatChannel.GP_CHAT_FARCRY; pszMsg = text.Substring(2); // Requirement check int itemNum = GetPlayerItemCount(12979) + GetPlayerItemCount(36092); if (itemNum < 1 || GetPlayerLevel() < 5) { result.errorString = GetStringFromTable(731); return result; } if (now - _lastFarCryTime <= 1.0f) { result.errorString = GetStringFromTable(730); return result; } result.showConfirmation = true; result.confirmationStringId = 732; } else if (text.Length >= 2 && text.StartsWith("!#")) { channel = ChatChannel.GP_CHAT_SUPERFARCRY; pszMsg = text.Substring(2); int itemNum = GetPlayerItemCount(27728) + GetPlayerItemCount(27729); if (itemNum < 1) { result.errorString = GetStringFromTable(8531); return result; } if (now - _lastSuperFarCryTime <= 1.0f) { result.errorString = GetStringFromTable(8530); return result; } result.showConfirmation = true; result.confirmationStringId = 8532; } else if (text.Length >= 1 && text.StartsWith("$")) { if (HasCountryChannel()) { channel = ChatChannel.GP_CHAT_COUNTRY; pszMsg = text.Substring(1); // Add king/money checks if needed } else { channel = ChatChannel.GP_CHAT_TRADE; pszMsg = text.Substring(1); if (GetPlayerLevel() <= 30) { result.errorString = GetStringFromTable(530); return result; } } } else if (text.Length >= 1 && text.StartsWith("/")) { string cmdPart = text.Substring(1); int spaceIdx = cmdPart.IndexOf(' '); if (spaceIdx > 0) { result.targetPlayer = cmdPart.Substring(0, spaceIdx); pszMsg = cmdPart.Substring(spaceIdx + 1); channel = ChatChannel.GP_CHAT_WHISPER; } else { // Maybe just showing help or something result.errorString = GetStringFromTable(234); return result; } } else { channel = HasCountryWarChannel() ? ChatChannel.GP_CHAT_BATTLE : ChatChannel.GP_CHAT_LOCAL; pszMsg = text; } if (string.IsNullOrWhiteSpace(pszMsg)) { return result; } result.success = true; result.channel = channel; result.message = pszMsg; // Update history if (_history.Count >= MAX_HISTORY) _history.RemoveAt(0); _history.Add(new ChatHistoryEntry { channel = channel, time = now, message = text }); if (channel == ChatChannel.GP_CHAT_FARCRY) _lastFarCryTime = now; if (channel == ChatChannel.GP_CHAT_SUPERFARCRY) _lastSuperFarCryTime = now; return result; } private static string GetStringFromTable(int id) { return CECUIManager.Instance?.GetInGameUIMan()?.GetStringFromTable(id) ?? $"[STR_{id}]"; } private static int GetPlayerItemCount(int tid) { return 0; //return EC_GameRun.Instance?.GetHostPlayer()?.GetPack()?.GetItemTotalNum(tid) ?? 0; } private static int GetPlayerLevel() { return 0; //return EC_GameRun.Instance?.GetHostPlayer()?.GetBasicProps()?.iLevel ?? 0; } private static bool HasCountryChannel() { return false; //return EC_GameRun.Instance?.GetHostPlayer()?.HasCountryChannel() ?? false; } private static bool HasCountryWarChannel() { return false; //return EC_GameRun.Instance?.GetHostPlayer()?.HasCountryWarChannel() ?? false; } } } */