Decompiled source of BigWalkCardGames v1.0.1
plugins/BigWalkCardGames.dll
Decompiled 33 minutes ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem.Collections.Generic; using Microsoft.CodeAnalysis; using Mirror; using UnityEngine; using UnityEngine.EventSystems; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CardGamesMod { [HarmonyPatch(typeof(TextChatSource), "AddMessage")] internal static class CardGamesChatPatch { private static string _last; private static float _lastAt; private static void Prefix(TextChatMessage message) { try { string text = null; PlayerCharacter val = null; try { text = message.message; val = message.sendingPlayer; } catch { } if (string.IsNullOrEmpty(text)) { return; } string text2 = (((Object)(object)val != (Object)null) ? ((Object)val).GetInstanceID().ToString() : "0") + "|" + text; if (text2 == _last && Time.unscaledTime - _lastAt < 0.3f) { return; } _last = text2; _lastAt = Time.unscaledTime; try { DouDiZhuTool.OnChat(val, text); } catch { } try { LiarBarTool.OnChat(val, text); } catch { } } catch { } } } [BepInPlugin("plx.bigwalk.cardgames", "BigWalkCardGames", "1.0.1")] public sealed class CardGamesPlugin : BasePlugin { public sealed class CardGamesBehaviour : MonoBehaviour { public CardGamesBehaviour(IntPtr ptr) : base(ptr) { } public CardGamesBehaviour() : base(ClassInjector.DerivedConstructorPointer<CardGamesBehaviour>()) { ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this); } private void Update() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) try { if (Input.GetKeyDown(MenuKey.Value)) { CardGamesUI.Toggle(); } DouDiZhuTool.Tick(); LiarBarTool.Tick(); } catch (Exception ex) { Log.LogWarning((object)("Update异常:" + ex.GetBaseException().Message)); } } private void LateUpdate() { try { DouDiZhuTool.TickLate(); DouDiZhuTool.TickClientResult(); } catch { } } private void OnGUI() { CardGamesUI.Draw(); } } internal static ManualLogSource Log; internal static ConfigEntry<KeyCode> MenuKey; public override void Load() { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) Log = ((BasePlugin)this).Log; Log.LogInfo((object)"独立桌游mod 加载中 v1.0.1(斗地主+骗子酒馆,菜单防穿透,未动原mod)"); I18n.Init(((BasePlugin)this).Config); TexProbe.Create(); MenuKey = ((BasePlugin)this).Config.Bind<KeyCode>("按键", "打开菜单", (KeyCode)285, "打开/关闭桌游菜单(默认 F4)"); DouDiZhuTool.Install(Log, ((BasePlugin)this).Config, () => FindLocal()); LiarBarTool.Install(Log, ((BasePlugin)this).Config); try { new Harmony("plx.bigwalk.cardgames.chat").PatchAll(typeof(CardGamesChatPatch)); Log.LogInfo((object)"[桌游] 聊天补丁安装成功"); } catch (Exception ex) { Log.LogWarning((object)("[桌游] 聊天补丁安装失败:" + ex.GetBaseException().Message)); } ClassInjector.RegisterTypeInIl2Cpp<CardGamesBehaviour>(); GameObject val = new GameObject("BigWalkCardGames"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<CardGamesBehaviour>(); Log.LogInfo((object)("独立桌游mod 加载完成:" + ((object)MenuKey.Value/*cast due to .constrained prefix*/).ToString() + "=菜单(斗地主/骗子酒馆)")); } private static PlayerCharacter FindLocal() { try { List<PlayerCharacter> allPlayerCharacters = PlayerCharacter.allPlayerCharacters; if (allPlayerCharacters == null) { return null; } for (int i = 0; i < allPlayerCharacters.Count; i++) { PlayerCharacter val = allPlayerCharacters[i]; if (!((Object)(object)val == (Object)null) && (Object)(object)val.playerNetworking != (Object)null && ((NetworkBehaviour)val.playerNetworking).isLocalPlayer) { return val; } } } catch { } return null; } } internal static class CardGamesUI { internal static bool Open; private static int _tab; private static Rect _rect = new Rect(0f, 0f, 560f, 560f); private static bool _inited; private static GUIStyle _title; private static GUIStyle _label; private static GUIStyle _dim; private static readonly Color PanelBg = new Color(0.07f, 0.125f, 0.255f, 0.97f); private static readonly Color PanelEdge = new Color(0.56f, 0.79f, 1f, 0.7f); private static readonly Color TextCol = new Color(0.855f, 0.914f, 1f); private static readonly Color BtnBlue = new Color(0.6f, 0.79f, 0.98f); private static readonly Color BtnOn = new Color(1f, 0.85f, 0.35f); private static ManualLogSource Log => CardGamesPlugin.Log; private static void Init() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown if (!_inited) { _inited = true; ((Rect)(ref _rect)).x = ((float)Screen.width - ((Rect)(ref _rect)).width) * 0.5f; ((Rect)(ref _rect)).y = ((float)Screen.height - ((Rect)(ref _rect)).height) * 0.5f; _title = new GUIStyle(GUI.skin.label) { fontSize = 18, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; _label = new GUIStyle(GUI.skin.label) { fontSize = 14 }; _dim = new GUIStyle(GUI.skin.label) { fontSize = 12 }; } } internal static void Toggle() { Open = !Open; if (Open) { MenuInput.On(); } else { MenuInput.Off(); } } internal static void Draw() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) if (!Open) { return; } try { Init(); TexProbe.DrawOnce(); Color contentColor = GUI.contentColor; GUI.contentColor = TextCol; DrawGlass(_rect); float num = 16f; float num2 = ((Rect)(ref _rect)).x + num; float num3 = ((Rect)(ref _rect)).width - num * 2f; float num4 = ((Rect)(ref _rect)).y + 12f; GUI.Label(new Rect(num2, num4, num3 - 120f, 26f), I18n.T("桌游", "Card Games"), _title); if (Btn(new Rect(((Rect)(ref _rect)).xMax - 110f, ((Rect)(ref _rect)).y + 8f, 46f, 24f), I18n.ButtonLabel)) { I18n.Toggle(); } if (Btn(new Rect(((Rect)(ref _rect)).xMax - 58f, ((Rect)(ref _rect)).y + 8f, 34f, 24f), "×")) { Toggle(); GUI.contentColor = contentColor; return; } num4 += 32f; if (TabBtn(new Rect(num2, num4, num3 / 2f - 4f, 30f), I18n.T("斗地主", "Dou Dizhu"), 0)) { _tab = 0; } if (TabBtn(new Rect(num2 + num3 / 2f + 4f, num4, num3 / 2f - 4f, 30f), I18n.T("骗子酒馆", "Liar's Bar"), 1)) { _tab = 1; } num4 += 40f; if (_tab == 0) { DrawDouDiZhu(num2, num4, num3); } else { DrawLiarBar(num2, num4, num3); } GUI.contentColor = contentColor; } catch (Exception ex) { if (Log != null) { Log.LogWarning((object)("菜单绘制异常:" + ex.GetBaseException().Message)); } } } private static void DrawDouDiZhu(float x, float y, float w) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(x, y, w, 40f), I18n.T("状态:", "Status: ") + DouDiZhuTool.Status, _label); y += 46f; GUI.Label(new Rect(x, y, w, 20f), I18n.T("人数(3/4):", "Players (3/4): ") + DouDiZhuTool.PlayerCount, _dim); y += 22f; if (Btn(new Rect(x, y, w / 2f - 4f, 30f), "3 " + I18n.T("人", "players"))) { DouDiZhuTool.PlayersEntry.Value = 3; } if (Btn(new Rect(x + w / 2f + 4f, y, w / 2f - 4f, 30f), "4 " + I18n.T("人", "players"))) { DouDiZhuTool.PlayersEntry.Value = 4; } y += 38f; if (Btn(new Rect(x, y, w, 34f), I18n.T("发牌 / 开始", "Deal / Start"))) { DouDiZhuTool.StartGame(); } y += 40f; if (DouDiZhuTool.IsRobbing && Btn(new Rect(x, y, w, 30f), I18n.T("跳过抢地主", "Skip robbing"))) { DouDiZhuTool.SkipRob(); } if (Btn(new Rect(x, y + (DouDiZhuTool.IsRobbing ? 36f : 0f), w, 30f), I18n.T("结束", "End"))) { DouDiZhuTool.EndGame(); } y += 46f; if (Btn(new Rect(x, y, w, 32f), I18n.T("我来主持(客户端改字) - 当前:", "I host (client text) - now: ") + DouDiZhuTool.ClientHost)) { DouDiZhuTool.ToggleClientHost(); } y += 40f; GUI.Label(new Rect(x, y, w, 20f), I18n.T("聊天:申请斗地主 / 叫地主 / 不叫 / 抢地主 / 出牌", "Chat: apply / bid / pass / rob / play cards"), _dim); y += 20f; if (DouDiZhuTool.HasPending) { if (Btn(new Rect(x, y, w / 2f - 4f, 30f), I18n.T("同意", "Accept"))) { DouDiZhuTool.ApproveRequest(); } if (Btn(new Rect(x + w / 2f + 4f, y, w / 2f - 4f, 30f), I18n.T("拒绝", "Deny"))) { DouDiZhuTool.DenyRequest(); } } } private static void DrawLiarBar(float x, float y, float w) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(x, y, w, 40f), I18n.T("状态:", "Status: ") + LiarBarTool.Status, _label); y += 46f; GUI.Label(new Rect(x, y, w, 20f), I18n.T("人数(2-4):", "Players (2-4): ") + LiarBarTool.PlayerCount, _dim); y += 22f; for (int i = 2; i <= 4; i++) { if (Btn(new Rect(x + (float)(i - 2) * (w / 3f), y, w / 3f - 4f, 30f), i.ToString())) { LiarBarTool.PlayersEntry.Value = i; } } y += 38f; if (Btn(new Rect(x, y, w, 34f), I18n.T("发牌 / 开始", "Deal / Start"))) { LiarBarTool.StartGame(); } y += 40f; if (Btn(new Rect(x, y, w, 30f), I18n.T("结束", "End"))) { LiarBarTool.EndGame(); } y += 40f; if (Btn(new Rect(x, y, w, 32f), I18n.T("我来主持(客户端改字) - 当前:", "I host (client text) - now: ") + LiarBarTool.ClientHost)) { LiarBarTool.ToggleClientHost(); } y += 40f; GUI.Label(new Rect(x, y, w, 20f), I18n.T("聊天:出牌 / 质疑 / 过", "Chat: play / challenge / pass"), _dim); } private static bool TabBtn(Rect r, string s, int idx) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = ((_tab == idx) ? BtnOn : BtnBlue); bool result = GUI.Button(r, s); GUI.backgroundColor = backgroundColor; return result; } private static bool Btn(Rect r, string s) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = BtnBlue; bool result = GUI.Button(r, s); GUI.backgroundColor = backgroundColor; return result; } private static void DrawGlass(Rect r) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) TexProbe.Round(new Rect(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y + 7f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), new Color(0f, 0f, 0f, 0.3f), 25); TexProbe.Round(new Rect(((Rect)(ref r)).x + 1f, ((Rect)(ref r)).y + 3f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), new Color(0f, 0f, 0f, 0.2f), 23); Rect r2 = default(Rect); ((Rect)(ref r2))..ctor(((Rect)(ref r)).x + 1.5f, ((Rect)(ref r)).y + 1.5f, ((Rect)(ref r)).width - 3f, ((Rect)(ref r)).height - 3f); TexProbe.Round(r, PanelEdge, 22); TexProbe.Round(r2, PanelBg, 20); TexProbe.Fill(new Rect(((Rect)(ref r2)).x + 12f, ((Rect)(ref r2)).y + 2f, ((Rect)(ref r2)).width - 24f, 30f), new Color(0.86f, 0.95f, 1f, 0.05f)); } } internal static class CardGamesUtil { internal static string NameOf(PlayerCharacter p) { if ((Object)(object)p == (Object)null) { return "?"; } try { if ((Object)(object)p.playerNetworking != (Object)null) { string text = p.playerNetworking.username; if (string.IsNullOrEmpty(text)) { text = p.playerNetworking.Networkusername; } if (!string.IsNullOrEmpty(text)) { return text; } } } catch { } return "Player"; } } internal static class DouDiZhuTool { private enum Phase { Playing, Bidding, Robbing, Over } private enum PatKind { Invalid, Single, Pair, Triple, TripleSingle, TriplePair, Straight, PairStraight, Plane, PlaneSingle, PlanePair, FourTwoSingle, FourTwoPair, Bomb, Rocket } private struct Pattern { public PatKind kind; public int main; public int len; public int count; } private struct Seat { public Prop sign; public PlayerCharacter player; public List<string> hand; } private static ManualLogSource Log; private static Func<PlayerCharacter> _local; internal static ConfigEntry<int> PlayersEntry; internal static ConfigEntry<int> LandlordEntry; internal static string Status = ""; internal static readonly List<string> History = new List<string>(); internal static string PendingRequest = ""; private static float _nextResultScan = 0f; private static string _lastClientResult = ""; internal static bool ClientHost = false; private static readonly string[] Ranks = new string[13] { "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2" }; private static readonly string[] Suits = new string[4] { "♠", "♥", "♦", "♣" }; private static int _rotate = 0; private static readonly List<Seat> _seats = new List<Seat>(); private static int _landlordSeat = -1; private static int _turn = -1; private static Pattern _lastPat; private static bool _hasLast = false; private static int _lastSeat = -1; private static string _lastText = ""; private static Phase _phase = Phase.Playing; private static int _bidStart = -1; private static int _bidSeat = -1; private static int _bidCount = 0; private static bool[] _called = null; private static int _firstCaller = -1; private static List<string> _bottom = new List<string>(); private static float _robUntil = 0f; private static int _robShownSec = -1; private static bool _redealDone = false; private static readonly Dictionary<int, string> _nameCache = new Dictionary<int, string>(); private static float _nextNamePrewarm = 0f; private static Camera _cam; internal static bool HasPending => !string.IsNullOrEmpty(PendingRequest); internal static bool IsLogicHost { get { if (!NetworkServer.active) { return ClientHost; } return true; } } internal static bool IsRunning { get { if (_seats.Count > 0) { return _phase != Phase.Over; } return false; } } internal static bool IsRobbing => _phase == Phase.Robbing; internal static int PlayerCount { get { if (PlayersEntry == null) { return 3; } return Mathf.Clamp(PlayersEntry.Value, 3, 4); } } internal static void Install(ManualLogSource log, ConfigFile cfg, Func<PlayerCharacter> local) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) Log = log; _local = local; PlayersEntry = cfg.Bind<int>("斗地主", "人数", 3, "3 或 4 人"); LandlordEntry = cfg.Bind<int>("斗地主", "地主方式", 2, "0=房主选 1=轮流 2=随机 3=经典(轮流叫地主+抢地主)"); try { new Harmony("plx.bigwalk.ddz.chat").PatchAll(typeof(CardGamesChatPatch)); } catch (Exception ex) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)("[斗地主] 聊天补丁安装失败:" + ex.GetBaseException().Message)); } } Log.LogInfo((object)"[斗地主] 已就绪(房主发起,每人拿一块指示牌;出牌走聊天)"); } internal static void Note(string s) { if (!string.IsNullOrEmpty(s)) { History.Add(s); while (History.Count > 40) { History.RemoveAt(0); } } } private static string PlayerName(PlayerCharacter p) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown try { return ((Object)p != (Object)null && (Object)((Component)p).gameObject != (Object)null) ? ((Object)((Component)p).gameObject).name : "某玩家"; } catch { return "某玩家"; } } internal static string DisplayName(PlayerCharacter p) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown if ((Object)p == (Object)null) { return "某玩家"; } int key = PlayerKey(p); if (_nameCache.TryGetValue(key, out var value) && !string.IsNullOrEmpty(value)) { return value; } string text = null; try { text = CardGamesUtil.NameOf(p); } catch { } if (string.IsNullOrEmpty(text)) { try { PlayerNetworking playerNetworking = p.playerNetworking; if ((Object)playerNetworking != (Object)null) { try { text = playerNetworking.username; } catch { } if (string.IsNullOrEmpty(text)) { try { text = playerNetworking.Networkusername; } catch { } } } } catch { } } if (!string.IsNullOrEmpty(text)) { text = text.Trim(); _nameCache[key] = text; return text; } try { string text2 = (((Object)((Component)p).gameObject != (Object)null) ? ((Object)((Component)p).gameObject).name : null); if (!string.IsNullOrEmpty(text2)) { int num = text2.LastIndexOf('-'); if (num >= 0 && num + 1 < text2.Length) { return "玩家" + text2.Substring(num + 1); } } } catch { } return "某玩家"; } private static int PlayerKey(PlayerCharacter p) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown try { PlayerNetworking playerNetworking = p.playerNetworking; if ((Object)playerNetworking != (Object)null) { return (int)((NetworkBehaviour)playerNetworking).netId; } } catch { } try { return ((Object)p).GetInstanceID(); } catch { } return 0; } private static void PrewarmNames() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown if (Time.unscaledTime < _nextNamePrewarm) { return; } _nextNamePrewarm = Time.unscaledTime + 2f; try { Il2CppArrayBase<PlayerCharacter> val = Object.FindObjectsOfType<PlayerCharacter>(); if (val == null) { return; } foreach (PlayerCharacter item in val) { if ((Object)item == (Object)null || (Object)((Component)item).gameObject == (Object)null) { continue; } int key = PlayerKey(item); if (!_nameCache.TryGetValue(key, out var value) || string.IsNullOrEmpty(value)) { string text = null; try { text = CardGamesUtil.NameOf(item); } catch { } if (!string.IsNullOrEmpty(text)) { _nameCache[key] = text.Trim(); } } } } catch { } } internal static void ToggleClientHost() { if (NetworkServer.active) { ClientHost = false; Status = I18n.T("你是房主,直接点「发牌」即可", "You are the host, just click Deal"); return; } ClientHost = !ClientHost; Status = (ClientHost ? "客户端主持已开:点「发牌」开一局(写牌走 CmdSendNewText)" : "已退出客户端主持"); Note(Status); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[斗地主] " + Status)); } } internal static void TestClientWrite() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) try { if (NetworkServer.active) { Status = I18n.T("你是房主,不需要测客户端改字", "You are the host, no need to test client text"); return; } Il2CppArrayBase<PeckEffectTextInput> val = Object.FindObjectsOfType<PeckEffectTextInput>(); if (val == null || val.Length == 0) { Status = I18n.T("场景里没有指示牌", "No sign prop in the scene"); return; } Vector3 val2 = Vector3.zero; bool flag = false; try { PlayerCharacter val3 = _local(); if ((Object)val3 != (Object)null && (Object)((Component)val3).transform != (Object)null) { val2 = ((Component)val3).transform.position; flag = true; } } catch { } PeckEffectTextInput val4 = null; float num = float.MaxValue; foreach (PeckEffectTextInput item in val) { if (!((Object)item == (Object)null) && !((Object)((Component)item).gameObject == (Object)null)) { float num2; if (!flag) { num2 = 0f; } else { Vector3 val5 = ((Component)item).transform.position - val2; num2 = ((Vector3)(ref val5)).sqrMagnitude; } float num3 = num2; if (num3 < num) { num = num3; val4 = item; } if (!flag) { break; } } } if ((Object)val4 == (Object)null) { Status = I18n.T("没找到可用指示牌", "No usable sign prop found"); return; } string text = "【客户端改字自测】" + DateTime.Now.ToString("HH:mm:ss"); val4.CmdSendNewText(text, (NetworkConnectionToClient)null); Status = "已发 CmdSendNewText:" + text + "(看牌子有没有变)"; Note(Status); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[斗地主] " + Status)); } } catch (Exception ex) { Status = I18n.T("客户端改字失败:", "Client text write failed: ") + ex.GetBaseException().Message; ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)("[斗地主] " + Status)); } } } internal static void RequestGame() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown try { PlayerCharacter val = _local(); PlayerNetworking val2 = (((Object)val != (Object)null) ? val.playerNetworking : null); if ((Object)val2 == (Object)null) { Status = I18n.T("没找到本地玩家网络组件,请在聊天里手打:申请斗地主", "Local player network not found, type in chat: apply"); return; } val2.CmdSendTextChatMessage("申请斗地主"); Status = I18n.T("已发送斗地主申请,等房主在菜单里点「同意并开始」", "Request sent, wait for host to Accept"); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[斗地主] " + Status)); } } catch (Exception ex) { Status = I18n.T("发送失败,请在聊天里手打:申请斗地主(", "Send failed, type in chat: apply (") + ex.GetBaseException().Message + ")"; ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)("[斗地主] " + Status)); } } } internal static void ApproveRequest() { string pendingRequest = PendingRequest; PendingRequest = ""; StartGame(); Note("房主同意了 " + pendingRequest + " 的申请"); } internal static void DenyRequest() { string pendingRequest = PendingRequest; PendingRequest = ""; Note("房主忽略了 " + pendingRequest + " 的申请"); Status = I18n.T("已忽略申请", "Request ignored"); } internal static void StartGame() { if (!IsLogicHost) { Status = I18n.T("斗地主需要房主发起,或客户端点「我来主持(客户端改字)」", "Host needed to start, or client click I host"); Log.LogInfo((object)("[斗地主] " + Status)); return; } if (LiarBarTool.IsRunning) { Status = I18n.T("骗子酒馆还在进行,先点它的「结束 / 清空牌子」", "Liar's Bar is running, end it first"); Log.LogInfo((object)("[斗地主] " + Status)); return; } _nextNamePrewarm = 0f; PrewarmNames(); History.Clear(); PendingRequest = ""; _seats.Clear(); List<Seat> list = FindSignHolders(); int playerCount = PlayerCount; if (list.Count < playerCount) { Status = I18n.T("需要 ", "Need ") + playerCount + I18n.T(" 人各拿一块指示牌(当前 ", " sign holders needed (now ") + list.Count + I18n.T(" 人拿着)", " holding)"); Log.LogInfo((object)("[斗地主] " + Status)); return; } for (int i = 0; i < playerCount; i++) { _seats.Add(list[i]); } List<string> list2 = BuildDeck(); Shuffle(list2); int num = ((playerCount == 3) ? 17 : 13); int num2 = num * playerCount; _bottom = ((num2 < list2.Count) ? list2.GetRange(num2, list2.Count - num2) : new List<string>()); _landlordSeat = -1; _turn = -1; _hasLast = false; _lastSeat = -1; _lastText = ""; _lastPat = default(Pattern); _called = new bool[playerCount]; _firstCaller = -1; _robShownSec = -1; _redealDone = false; for (int j = 0; j < playerCount; j++) { List<string> range = list2.GetRange(j * num, num); range.Sort(CompareCard); Seat value = _seats[j]; value.hand = range; _seats[j] = value; } if (((LandlordEntry != null) ? LandlordEntry.Value : 2) == 3) { _phase = Phase.Bidding; _bidStart = HostSeat(); _bidSeat = _bidStart; _bidCount = 0; ShowBid(); Status = I18n.T("经典叫地主:轮到 ", "Classic bidding: ") + SeatName(_bidSeat) + I18n.T("(聊天输入 叫地主 / 不叫)", " (chat: bid / pass)"); Note(I18n.T("房主发牌(", "Host dealt (") + playerCount + " 人),开始轮流叫地主"); Log.LogInfo((object)("[斗地主] 开始轮流叫地主,从 " + SeatName(_bidStart) + " 起;地主方式=" + LandlordModeName())); } else { _landlordSeat = PickLandlord(playerCount); BeginPlay(); Status = I18n.T("已发牌:", "Dealt: ") + playerCount + I18n.T(" 人,地主=", " players, landlord=") + SeatName(_landlordSeat) + I18n.T(";轮到 ", "; now ") + SeatName(_turn) + I18n.T(" 出牌", " to play"); Note("房主发牌;地主=" + SeatName(_landlordSeat)); Log.LogInfo((object)("[斗地主] " + Status + " 地主方式=" + LandlordModeName())); } } private static void BeginPlay() { if (_bottom.Count > 0 && _landlordSeat >= 0 && _landlordSeat < _seats.Count) { Seat value = _seats[_landlordSeat]; if (value.hand != null) { value.hand.AddRange(_bottom); value.hand.Sort(CompareCard); _seats[_landlordSeat] = value; } } _bottom = new List<string>(); _turn = _landlordSeat; _hasLast = false; _lastSeat = -1; _lastText = ""; _lastPat = default(Pattern); _phase = Phase.Playing; MarkTurn(); } private static int HostSeat() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_003d: Expected O, but got Unknown PlayerCharacter val = _local(); for (int i = 0; i < _seats.Count; i++) { if ((Object)val != (Object)null && (Object)_seats[i].player == (Object)val) { return i; } } return 0; } private static void ShowBid() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown for (int i = 0; i < _seats.Count; i++) { Seat seat = _seats[i]; if (!((Object)seat.sign == (Object)null) && !((Object)((Component)seat.sign).gameObject == (Object)null) && seat.hand != null) { string text = ((i == _bidSeat) ? "\n【到你了】叫地主?聊天输入:叫地主 / 不叫" : ("\n等待 " + SeatName(_bidSeat) + " 叫地主…")); WriteSign(seat.sign, Join(seat.hand) + text); } } } private static void ShowRob() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown for (int i = 0; i < _seats.Count; i++) { Seat seat = _seats[i]; if (!((Object)seat.sign == (Object)null) && !((Object)((Component)seat.sign).gameObject == (Object)null) && seat.hand != null) { string text = ((_called != null && i < _called.Length && !_called[i]) ? "\n可抢地主:聊天输入「抢地主」" : "\n已叫过地主,不能抢"); WriteSign(seat.sign, Join(seat.hand) + text); } } } private static void FinishBid() { bool flag = true; for (int i = 0; i < _seats.Count; i++) { if (_called == null || i >= _called.Length || !_called[i]) { flag = false; break; } } if (_firstCaller < 0) { if (!_redealDone) { _redealDone = true; Note("全都不叫地主,自动重发一次"); Redeal(); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[斗地主] " + Status)); } return; } _landlordSeat = HostSeat(); BeginPlay(); Status = I18n.T("重发后仍没人叫地主,默认 ", "No bids after redeal, default ") + SeatName(_landlordSeat) + I18n.T(" 当地主;开始出牌", " as landlord; start playing"); Note("重发后无人叫地主;地主=" + SeatName(_landlordSeat)); ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)("[斗地主] " + Status)); } } else if (flag) { _landlordSeat = _firstCaller; BeginPlay(); Status = I18n.T("全员叫地主,第一位 ", "All bid, first ") + SeatName(_firstCaller) + I18n.T(" 当地主;开始出牌", " as landlord; start playing"); Note("全员叫地主;地主=" + SeatName(_landlordSeat)); ManualLogSource log3 = Log; if (log3 != null) { log3.LogInfo((object)("[斗地主] " + Status)); } } else { _landlordSeat = _firstCaller; _phase = Phase.Robbing; _robUntil = Time.unscaledTime + 15f; _robShownSec = -1; ShowRob(); Status = I18n.T("抢地主:暂定地主 ", "Robbing: tentative landlord ") + SeatName(_landlordSeat) + I18n.T(";没叫地主的人可发「抢地主」(15 秒)", "; non-bidders can chat rob (15s)"); Note("暂定地主=" + SeatName(_landlordSeat) + ",开放抢地主"); ManualLogSource log4 = Log; if (log4 != null) { log4.LogInfo((object)("[斗地主] " + Status)); } } } private static void Redeal() { int count = _seats.Count; int num; switch (count) { case 0: return; default: num = 13; break; case 3: num = 17; break; } int num2 = num; List<string> list = BuildDeck(); Shuffle(list); int num3 = num2 * count; _bottom = ((num3 < list.Count) ? list.GetRange(num3, list.Count - num3) : new List<string>()); for (int i = 0; i < count; i++) { List<string> range = list.GetRange(i * num2, num2); range.Sort(CompareCard); Seat value = _seats[i]; value.hand = range; _seats[i] = value; } _landlordSeat = -1; _turn = -1; _hasLast = false; _lastSeat = -1; _lastText = ""; _lastPat = default(Pattern); _called = new bool[count]; _firstCaller = -1; _bidCount = 0; _robShownSec = -1; _bidSeat = _bidStart; _phase = Phase.Bidding; ShowBid(); Status = I18n.T("全不叫,已自动重发一次;轮到 ", "All passed, redealt once; now ") + SeatName(_bidSeat) + I18n.T(" 叫地主", " to bid"); } internal static void SkipRob() { if (_phase == Phase.Robbing) { SettleLandlord("抢地主结束,地主=" + SeatName(_landlordSeat)); } } private static void SettleLandlord(string why) { BeginPlay(); Status = why + I18n.T(";轮到 ", "; now ") + SeatName(_turn) + " 出牌(看牌面上的【到你了】)"; Note("最终地主=" + SeatName(_landlordSeat)); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[斗地主] " + Status)); } } private static string Normalize(string s) { return (s ?? "").Trim().ToLowerInvariant().Replace(" ", ""); } internal static void EndGame() { for (int i = 0; i < _seats.Count; i++) { WriteSign(_seats[i].sign, ""); } _seats.Clear(); _landlordSeat = -1; _turn = -1; _hasLast = false; _lastSeat = -1; _lastText = ""; _lastPat = default(Pattern); _phase = Phase.Playing; _bidSeat = -1; _bidStart = -1; _bidCount = 0; _firstCaller = -1; _called = null; _bottom = new List<string>(); _robShownSec = -1; Status = I18n.T("已结束", "Ended"); } private static Vector3 ViewForward(PlayerCharacter me) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) if ((Object)_cam == (Object)null) { try { PlayerCameraReferences val = Object.FindObjectOfType<PlayerCameraReferences>(); if ((Object)val != (Object)null && (Object)val.playerCamera != (Object)null) { _cam = val.playerCamera; } } catch { } if ((Object)_cam == (Object)null) { _cam = Camera.main; } } if ((Object)_cam != (Object)null) { return ((Component)_cam).transform.forward; } if (!((Object)me != (Object)null)) { return Vector3.forward; } return ((Component)me).transform.forward; } internal static void TickLate() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) try { PlayerCharacter val = _local(); if ((Object)val == (Object)null || val.hands == null) { return; } Prop heldProp = val.hands.heldProp; if ((Object)heldProp == (Object)null || (Object)((Component)heldProp).gameObject == (Object)null) { return; } string name = ((Object)((Component)heldProp).gameObject).name; string text = ((name != null) ? name.ToLowerInvariant() : ""); if (text.Contains("signprop") && !text.Contains("permo")) { Vector3 val2 = ViewForward(val); val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = ((Component)val).transform.forward; } ((Vector3)(ref val2)).Normalize(); ((Component)heldProp).transform.rotation = Quaternion.LookRotation(-val2, Vector3.up); } } catch { } } internal static void Tick() { try { PrewarmNames(); } catch { } try { if (_phase == Phase.Robbing) { int num = Mathf.CeilToInt(_robUntil - Time.unscaledTime); if (num <= 0) { SkipRob(); } else if (num != _robShownSec) { _robShownSec = num; Status = I18n.T("抢地主:", "Robbing: ") + num + I18n.T(" 秒内,没叫地主的人可发「抢地主」;暂定地主 ", "s left, non-bidders can chat rob; tentative landlord ") + SeatName(_landlordSeat); } } } catch { } } private static int PickLandlord(int need) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_005b: Expected O, but got Unknown switch ((LandlordEntry != null) ? LandlordEntry.Value : 2) { case 0: { PlayerCharacter val = _local(); for (int i = 0; i < need; i++) { if ((Object)val != (Object)null && (Object)_seats[i].player == (Object)val) { return i; } } return 0; } case 1: _rotate = (_rotate + 1) % need; return _rotate; default: return Random.Range(0, need); } } private static string LandlordModeName() { return ((LandlordEntry != null) ? LandlordEntry.Value : 2) switch { 2 => "随机", 1 => "轮流", 0 => "房主选", _ => "经典(轮流叫地主+抢地主)", }; } private static string SeatName(int i) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown if (i < 0 || i >= _seats.Count) { return "?"; } try { PlayerCharacter player = _seats[i].player; if ((Object)player != (Object)null) { return DisplayName(player); } } catch { } return "座位" + i; } private static List<Seat> FindSignHolders() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown List<Seat> list = new List<Seat>(); try { Il2CppArrayBase<Prop> val = Object.FindObjectsOfType<Prop>(); if (val != null) { for (int i = 0; i < val.Length; i++) { Prop val2 = val[i]; if ((Object)val2 == (Object)null || (Object)((Component)val2).gameObject == (Object)null) { continue; } string name = ((Object)((Component)val2).gameObject).name; if (string.IsNullOrEmpty(name)) { continue; } string text = name.ToLowerInvariant(); if (text.Contains("signprop") && !text.Contains("permo")) { PlayerCharacter val3 = null; try { val3 = val2.exclusiveHolder; } catch { } if (!((Object)val3 == (Object)null)) { list.Add(new Seat { sign = val2, player = val3 }); } } } } } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[斗地主] 找牌异常:" + ex.GetBaseException().Message)); } } return list; } private static void WriteSign(Prop sign, string text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown if ((Object)sign == (Object)null || (Object)((Component)sign).gameObject == (Object)null) { return; } try { PeckEffectTextInput component = ((Component)sign).GetComponent<PeckEffectTextInput>(); if ((Object)component != (Object)null) { string text2 = text ?? ""; if (NetworkServer.active) { component.ServerSetText(text2, "斗地主"); } else { component.CmdSendNewText(text2, (NetworkConnectionToClient)null); } } else { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[斗地主] 这块指示牌没有 PeckEffectTextInput:" + ((Object)((Component)sign).gameObject).name)); } } } catch (Exception ex) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)("[斗地主] 写牌异常:" + ex.GetBaseException().Message)); } } } private static void MarkTurn() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown string text = (_hasLast ? _lastText : "无(本轮先手)"); for (int i = 0; i < _seats.Count; i++) { Seat seat = _seats[i]; if (!((Object)seat.sign == (Object)null) && !((Object)((Component)seat.sign).gameObject == (Object)null) && seat.hand != null) { string text2 = ((i == _landlordSeat) ? "地主 " : "农民 ") + Join(seat.hand); string text3 = ((i == _turn) ? "\n【到你了】" : "") + "\n上一手:" + text; WriteSign(seat.sign, text2 + text3); } } } private static void SettleWin(int winnerSeat) { bool flag = winnerSeat == _landlordSeat; string text = (flag ? "地主" : "农民"); string text2 = (flag ? "农民" : "地主"); string text3 = "\n最后一手:" + (_hasLast ? _lastText : "无") + "\n胜者:" + SeatName(winnerSeat) + " 出完牌"; int num = 0; int num2 = 0; for (int i = 0; i < _seats.Count; i++) { bool num3 = (flag ? (i == _landlordSeat) : (i != _landlordSeat)); if (num3) { num++; } else { num2++; } string text4 = (num3 ? ("【胜利】" + text + "胜!") : ("【失败】" + text2 + "失败 · " + text + "获胜")); WriteSign(_seats[i].sign, text4 + text3); } _turn = -1; _phase = Phase.Over; string text5 = SeatName(winnerSeat); Status = text + "胜!胜者:" + text5 + ";结果已同步所有人(胜方 " + num + " 人 / 败方 " + num2 + " 人)"; Note(text5 + " 出了 " + _lastText); Note(text + "获胜,结果已同步所有人的指示牌"); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[斗地主] " + Status)); } } internal static void TickClientResult() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown //IL_0131: Expected O, but got Unknown try { if (NetworkServer.active || Time.unscaledTime < _nextResultScan) { return; } _nextResultScan = Time.unscaledTime + 0.5f; Il2CppArrayBase<PeckEffectTextInput> val = Object.FindObjectsOfType<PeckEffectTextInput>(); if (val == null) { return; } Prop val2 = null; try { PlayerCharacter val3 = _local(); if ((Object)val3 != (Object)null && val3.hands != null) { val2 = val3.hands.heldProp; } } catch { } string text = null; string text2 = null; string text3 = null; foreach (PeckEffectTextInput item in val) { if ((Object)item == (Object)null || (Object)((Component)item).gameObject == (Object)null) { continue; } string text4 = null; try { text4 = item.NetworknetworkedText; } catch { } if (string.IsNullOrEmpty(text4)) { continue; } bool flag = text4.StartsWith("【胜利】"); bool flag2 = text4.StartsWith("【失败】"); if (!flag && !flag2) { continue; } if (flag && text == null) { text = text4; } if (flag2 && text2 == null) { text2 = text4; } try { if ((Object)val2 != (Object)null && (Object)((Component)item).gameObject == (Object)((Component)val2).gameObject) { text3 = text4; } } catch { } } if (text == null && text2 == null) { _lastClientResult = ""; return; } string text5 = (text ?? text2).Split('\n')[0]; if (!(text5 == _lastClientResult)) { _lastClientResult = text5; string text6 = ((text3 != null) ? text3.Split('\n')[0] : null); Status = ((text6 != null) ? (text6 + "(你手里的牌子)") : (text5 + "(本局结果)")); Note(text5 + "(客户端同步)"); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[斗地主] 客户端收到结算:" + text5)); } } } catch { } } internal static void OnChat(PlayerCharacter sender, string text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_00f1: Expected O, but got Unknown try { if ((Object)sender == (Object)null || string.IsNullOrEmpty(text) || LiarBarTool.IsRunning) { return; } switch (Normalize(text)) { case "申请斗地主": case "申请开局": case "申请": if (NetworkServer.active) { PendingRequest = DisplayName(sender); Note(PendingRequest + " 申请斗地主"); Status = PendingRequest + " 申请斗地主:点「同意并开始」即可发牌"; ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[斗地主] " + Status)); } } return; } if (!IsLogicHost || _seats.Count == 0) { return; } int num = -1; for (int i = 0; i < _seats.Count; i++) { if ((Object)_seats[i].player == (Object)sender) { num = i; break; } } if (num < 0) { return; } if (_phase == Phase.Bidding) { OnBidChat(num, text); return; } if (_phase == Phase.Robbing) { OnRobChat(num, text); return; } if (_phase == Phase.Over) { return; } if (num != _turn) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)("[斗地主] " + SeatName(num) + " 还没轮到(当前 " + SeatName(_turn) + ")")); } return; } if (IsPass(text)) { if (!_hasLast || _lastSeat == num) { Status = SeatName(num) + " 是本轮先手,不能过"; ManualLogSource log3 = Log; if (log3 != null) { log3.LogInfo((object)("[斗地主] " + Status)); } return; } int num2 = (num + 1) % _seats.Count; if (num2 == _lastSeat) { _hasLast = false; _lastSeat = -1; _lastText = ""; _lastPat = default(Pattern); Status = I18n.T("其他人全过,轮到 ", "All others passed, now ") + SeatName(num2) + I18n.T(" 重新出牌", " to play again"); } else { Status = SeatName(num) + " 过,轮到 " + SeatName(num2) + "(要压 " + _lastText + ")"; } _turn = num2; Note(SeatName(num) + " 过"); MarkTurn(); ManualLogSource log4 = Log; if (log4 != null) { log4.LogInfo((object)("[斗地主] " + Status)); } return; } string error; List<string> list = ParseCards(text, _seats[num].hand, out error); if (list.Count == 0) { if (!string.IsNullOrEmpty(error)) { Status = error; Note(SeatName(num) + " " + error); ManualLogSource log5 = Log; if (log5 != null) { log5.LogInfo((object)("[斗地主] " + Status)); } } return; } Pattern pattern = Eval(list); if (pattern.kind == PatKind.Invalid) { Status = I18n.T("不是合法牌型:", "Invalid combo: ") + text; Note(SeatName(num) + " 牌型无效:" + text); ManualLogSource log6 = Log; if (log6 != null) { log6.LogInfo((object)("[斗地主] " + Status)); } return; } if (!Beats(pattern)) { Status = I18n.T("压不过上一手 ", "Cannot beat last play ") + _lastText + "(" + PatternName(_lastPat) + ")"; Note(SeatName(num) + " 压不过:" + text); ManualLogSource log7 = Log; if (log7 != null) { log7.LogInfo((object)("[斗地主] " + Status)); } return; } List<string> hand = _seats[num].hand; if (hand == null) { return; } List<string> list2 = new List<string>(hand); for (int j = 0; j < list.Count; j++) { if (!list2.Remove(list[j])) { Status = SeatName(num) + " 手里没有 " + list[j]; ManualLogSource log8 = Log; if (log8 != null) { log8.LogInfo((object)("[斗地主] " + Status)); } return; } } for (int k = 0; k < list.Count; k++) { hand.Remove(list[k]); } _lastPat = pattern; _hasLast = true; _lastSeat = num; _lastText = Join(list) + "(" + PatternName(pattern) + ")"; if (hand.Count == 0) { SettleWin(num); return; } _turn = (num + 1) % _seats.Count; Note(SeatName(num) + " 出了 " + _lastText); MarkTurn(); Status = SeatName(num) + " 出 " + _lastText + I18n.T(";轮到 ", "; now ") + SeatName(_turn); ManualLogSource log9 = Log; if (log9 != null) { log9.LogInfo((object)("[斗地主] " + Status)); } } catch (Exception ex) { ManualLogSource log10 = Log; if (log10 != null) { log10.LogInfo((object)("[斗地主] 出牌异常:" + ex.GetBaseException().Message)); } } } private static void OnBidChat(int idx, string text) { if (idx == _bidSeat) { bool flag; switch (Normalize(text)) { default: return; case "不叫": case "不要": case "不": case "0": case "过": case "pass": flag = false; break; case "叫地主": case "叫": case "1": case "要": flag = true; break; } if (_called != null && idx < _called.Length) { _called[idx] = flag; } if (flag && _firstCaller < 0) { _firstCaller = idx; } Note(SeatName(idx) + (flag ? I18n.T(" 叫地主", " to bid") : " 不叫")); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[斗地主] " + SeatName(idx) + (flag ? I18n.T(" 叫地主", " to bid") : " 不叫"))); } _bidCount++; if (_bidCount >= _seats.Count) { FinishBid(); return; } _bidSeat = (_bidStart + _bidCount) % _seats.Count; ShowBid(); Status = I18n.T("经典叫地主:轮到 ", "Classic bidding: ") + SeatName(_bidSeat) + I18n.T("(聊天输入 叫地主 / 不叫)", " (chat: bid / pass)"); } } private static void OnRobChat(int idx, string text) { if (_called == null || idx >= _called.Length || !_called[idx]) { string text2 = Normalize(text); if (!(text2 != "抢地主") || !(text2 != "抢")) { _landlordSeat = idx; Note(SeatName(idx) + " 抢地主成功"); SettleLandlord("抢地主成功:" + SeatName(idx) + " 当地主"); } } } private static bool IsPass(string s) { if (string.IsNullOrEmpty(s)) { return false; } string text = s.Trim().ToLowerInvariant(); int num; switch (text) { default: num = ((text == "p") ? 1 : 0); break; case "过": case "过牌": case "不出": case "不要": case "pass": num = 1; break; } return (byte)num != 0; } private static bool Beats(Pattern a) { if (a.kind == PatKind.Invalid) { return false; } if (!_hasLast || _lastSeat < 0) { return true; } if (a.kind == PatKind.Rocket) { return true; } if (_lastPat.kind == PatKind.Rocket) { return false; } if (a.kind == PatKind.Bomb && _lastPat.kind != PatKind.Bomb) { return true; } if (_lastPat.kind == PatKind.Bomb && a.kind != PatKind.Bomb) { return false; } if (a.kind != _lastPat.kind || a.len != _lastPat.len || a.count != _lastPat.count) { return false; } return a.main > _lastPat.main; } private static Pattern Eval(List<string> cards) { Pattern result = new Pattern { kind = PatKind.Invalid, main = 0, len = 0, count = cards.Count }; int count = cards.Count; if (count == 0) { return result; } int[] array = new int[count]; for (int i = 0; i < count; i++) { array[i] = RankIndex(cards[i]); if (array[i] <= 0) { return result; } } Array.Sort(array); Dictionary<int, int> dictionary = new Dictionary<int, int>(); for (int j = 0; j < count; j++) { if (!dictionary.ContainsKey(array[j])) { dictionary[array[j]] = 0; } dictionary[array[j]]++; } if (count == 2 && array[0] == 16 && array[1] == 17) { result.kind = PatKind.Rocket; result.main = 17; result.len = 1; return result; } if (count == 4 && dictionary.Count == 1) { result.kind = PatKind.Bomb; result.main = array[0]; result.len = 1; return result; } switch (count) { case 1: result.kind = PatKind.Single; result.main = array[0]; result.len = 1; return result; case 2: if (dictionary.Count == 1) { result.kind = PatKind.Pair; result.main = array[0]; result.len = 1; return result; } break; } if (count == 3 && dictionary.Count == 1) { result.kind = PatKind.Triple; result.main = array[0]; result.len = 1; return result; } if ((count == 4 || count == 5) && dictionary.Count == 2) { foreach (KeyValuePair<int, int> item in dictionary) { if (item.Value == 3) { result.kind = ((count == 4) ? PatKind.TripleSingle : PatKind.TriplePair); result.main = item.Key; result.len = 1; return result; } } } if (count >= 5 && IsStraight(dictionary, out var main, out var len)) { result.kind = PatKind.Straight; result.main = main; result.len = len; return result; } if (count >= 6 && count % 2 == 0 && IsMultiStraight(dictionary, 2, out main, out len)) { result.kind = PatKind.PairStraight; result.main = main; result.len = len; return result; } if (count >= 6 && count % 3 == 0 && IsMultiStraight(dictionary, 3, out main, out len)) { result.kind = PatKind.Plane; result.main = main; result.len = len; return result; } Pattern result2 = EvalPlaneWings(dictionary, count); if (result2.kind != PatKind.Invalid) { return result2; } foreach (KeyValuePair<int, int> item2 in dictionary) { if (item2.Value != 4) { continue; } Dictionary<int, int> dictionary2 = new Dictionary<int, int>(dictionary); dictionary2.Remove(item2.Key); int num = 0; foreach (KeyValuePair<int, int> item3 in dictionary2) { num += item3.Value; } switch (num) { case 2: result.kind = PatKind.FourTwoSingle; result.main = item2.Key; result.len = 1; return result; case 4: { if (dictionary2.Count != 2) { break; } bool flag = true; foreach (KeyValuePair<int, int> item4 in dictionary2) { if (item4.Value != 2) { flag = false; } } if (flag) { result.kind = PatKind.FourTwoPair; result.main = item2.Key; result.len = 1; return result; } break; } } } return result; } private static bool IsStraight(Dictionary<int, int> cnt, out int main, out int len) { main = 0; len = 0; if (cnt.Count < 5) { return false; } int num = int.MaxValue; int num2 = int.MinValue; foreach (KeyValuePair<int, int> item in cnt) { if (item.Value != 1 || item.Key > 14) { return false; } if (item.Key < num) { num = item.Key; } if (item.Key > num2) { num2 = item.Key; } } if (num2 - num != cnt.Count - 1) { return false; } main = num; len = cnt.Count; return true; } private static bool IsMultiStraight(Dictionary<int, int> cnt, int group, out int main, out int len) { main = 0; len = 0; if (cnt.Count < ((group == 2) ? 3 : 2)) { return false; } int num = int.MaxValue; int num2 = int.MinValue; foreach (KeyValuePair<int, int> item in cnt) { if (item.Value != group || item.Key > 14) { return false; } if (item.Key < num) { num = item.Key; } if (item.Key > num2) { num2 = item.Key; } } if (num2 - num != cnt.Count - 1) { return false; } main = num; len = cnt.Count; return true; } private static Pattern EvalPlaneWings(Dictionary<int, int> cnt, int n) { Pattern result = new Pattern { kind = PatKind.Invalid, main = 0, len = 0, count = n }; List<int> list = new List<int>(); foreach (KeyValuePair<int, int> item in cnt) { if (item.Value >= 3 && item.Key <= 14) { list.Add(item.Key); } } if (list.Count < 2) { return result; } list.Sort(); for (int i = 2; i <= list.Count; i++) { for (int j = 0; j + i <= list.Count; j++) { bool flag = true; for (int k = 1; k < i; k++) { if (list[j + k] != list[j] + k) { flag = false; break; } } if (!flag) { continue; } Dictionary<int, int> dictionary = new Dictionary<int, int>(cnt); for (int l = 0; l < i; l++) { int key = list[j] + l; if (!dictionary.ContainsKey(key)) { flag = false; break; } dictionary[key] -= 3; if (dictionary[key] == 0) { dictionary.Remove(key); } } if (!flag) { continue; } int num = 0; foreach (KeyValuePair<int, int> item2 in dictionary) { num += item2.Value; } if (num == i) { result.kind = PatKind.PlaneSingle; result.main = list[j]; result.len = i; return result; } if (num != 2 * i || dictionary.Count != i) { continue; } bool flag2 = true; foreach (KeyValuePair<int, int> item3 in dictionary) { if (item3.Value != 2) { flag2 = false; } } if (flag2) { result.kind = PatKind.PlanePair; result.main = list[j]; result.len = i; return result; } } } return result; } private static string PatternName(Pattern p) { return p.kind switch { PatKind.Single => I18n.T("单张", "Single"), PatKind.Pair => I18n.T("对子", "Pair"), PatKind.Triple => I18n.T("三张", "Triple"), PatKind.TripleSingle => I18n.T("三带一", "Triple+1"), PatKind.TriplePair => I18n.T("三带二", "Triple+2"), PatKind.Straight => I18n.T("顺子", "Straight"), PatKind.PairStraight => I18n.T("连对", "Double straight"), PatKind.Plane => I18n.T("飞机", "Plane"), PatKind.PlaneSingle => I18n.T("飞机带单", "Plane+singles"), PatKind.PlanePair => I18n.T("飞机带对", "Plane+pairs"), PatKind.FourTwoSingle => I18n.T("四带二", "Four+2"), PatKind.FourTwoPair => I18n.T("四带两对", "Four+2 pairs"), PatKind.Bomb => I18n.T("炸弹", "Bomb"), PatKind.Rocket => I18n.T("王炸", "Rocket"), _ => I18n.T("无效", "Invalid"), }; } internal static List<string> ParseCards(string input, List<string> hand, out string error) { List<string> list = new List<string>(); error = ""; if (string.IsNullOrEmpty(input)) { return list; } bool[] used = ((hand != null) ? new bool[hand.Count] : new bool[0]); string[] array = input.Replace(',', ' ').Replace(',', ' ').Replace('、', ' ') .Replace('\u3000', ' ') .Split(new char[4] { ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length == 0 || !LooksLikeCards(text)) { continue; } if (text.Contains("王炸") || text.Contains("双王") || text.Contains("大小王")) { if (!AddByRank(list, "小王", hand, used, ref error)) { return new List<string>(); } if (!AddByRank(list, "大王", hand, used, ref error)) { return new List<string>(); } continue; } if (HasSuit(text)) { string text2 = ParseSuited(text); if (text2 == null) { error = "看不懂「" + text + "」"; return new List<string>(); } list.Add(text2); continue; } int num = 0; int num2 = 0; while (num < text.Length) { char c = char.ToUpperInvariant(text[num]); if (text[num] == '小' && num + 1 < text.Length && text[num + 1] == '王') { if (!AddByRank(list, "小王", hand, used, ref error)) { return new List<string>(); } num += 2; continue; } if (text[num] == '大' && num + 1 < text.Length && text[num + 1] == '王') { if (!AddByRank(list, "大王", hand, used, ref error)) { return new List<string>(); } num += 2; continue; } if (text[num] == '王') { if (!AddByRank(list, (num2++ == 0) ? "小王" : "大王", hand, used, ref error)) { return new List<string>(); } num++; continue; } int num3 = 1; string text3; if (c == '1' && num + 1 < text.Length && text[num + 1] == '0') { text3 = "10"; num3 = 2; } else { text3 = ParseRank(c.ToString()); } if (text3 == null) { error = "看不懂「" + text + "」里的 " + text[num]; return new List<string>(); } if (!AddByRank(list, text3, hand, used, ref error)) { return new List<string>(); } num += num3; } } return list; } private static bool LooksLikeCards(string t) { foreach (char c in t) { if ((c >= '0' && c <= '9') || c == '王') { return true; } char c2 = char.ToUpperInvariant(c); if (c2 == 'J' || c2 == 'Q' || c2 == 'K' || c2 == 'A') { return true; } } return false; } private static bool HasSuit(string t) { for (int i = 0; i < t.Length; i++) { if (IsSuitWord(t[i])) { return true; } } return false; } private static string ParseSuited(string t) { if (t.Contains("大王")) { return "大王"; } if (t.Contains("小王")) { return "小王"; } if (t.Length < 2) { return null; } int num = -1; for (int i = 0; i < t.Length; i++) { if ("♠♥♦♣".IndexOf(t[i]) >= 0) { num = i; break; } } string s; string s2; if (num >= 0) { s = t.Substring(0, num); s2 = t.Substring(num); } else { int num2 = t.Length; while (num2 > 0 && IsSuitWord(t[num2 - 1])) { num2--; } if (num2 >= t.Length || num2 == 0) { return null; } s = t.Substring(0, num2); s2 = t.Substring(num2); } string text = ParseRank(s); string text2 = ParseSuit(s2); if (text == null || text2 == null) { return null; } return text + text2; } private static bool AddByRank(List<string> result, string rank, List<string> hand, bool[] used, ref string error) { if (rank == null) { error = "点数无效"; return false; } if (rank == "小王" || rank == "大王") { if (hand == null) { result.Add(rank); return true; } for (int i = 0; i < hand.Count; i++) { if ((i >= used.Length || !used[i]) && hand[i] == rank) { used[i] = true; result.Add(rank); return true; } } error = "手里没有 " + rank; return false; } if (hand != null) { for (int j = 0; j < hand.Count; j++) { if (j < used.Length && !used[j]) { string text = hand[j]; if (!string.IsNullOrEmpty(text) && !(text == "小王") && !(text == "大王") && !(((text.Length > 1) ? text.Substring(0, text.Length - 1) : text) != rank)) { used[j] = true; result.Add(text); return true; } } } error = "手里没有足够的 " + rank; return false; } result.Add(rank + "♠"); return true; } private static bool IsSuitWord(char c) { return "黑桃红心方块梅花前后♠♥♦♣".IndexOf(c) >= 0; } private static string ParseRank(string s) { if (string.IsNullOrEmpty(s)) { return null; } s = s.Trim(); if (int.TryParse(s, out var result)) { switch (result) { case 1: return "A"; case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: return result.ToString(); default: if (result == 2) { return "2"; } return null; } } string text = s.ToUpperInvariant(); switch (text) { default: return null; case "J": case "Q": case "K": case "A": case "2": return text; } } private static string ParseSuit(string s) { if (string.IsNullOrEmpty(s)) { return null; } if (s.IndexOf('♠') >= 0 || s.Contains("黑") || s.Contains("桃") || s.Contains("前")) { return "♠"; } if (s.IndexOf('♥') >= 0 || s.Contains("红") || s.Contains("心") || s.Contains("后")) { return "♥"; } if (s.IndexOf('♦') >= 0 || s.Contains("方") || s.Contains("块")) { return "♦"; } if (s.IndexOf('♣') >= 0 || s.Contains("梅") || s.Contains("花")) { return "♣"; } return null; } private static List<string> BuildDeck() { List<string> list = new List<string>(54); for (int i = 0; i < Ranks.Length; i++) { for (int j = 0; j < Suits.Length; j++) { list.Add(Ranks[i] + Suits[j]); } } list.Add("小王"); list.Add("大王"); return list; } private static void Shuffle(List<string> d) { for (int num = d.Count - 1; num > 0; num--) { int index = Random.Range(0, num + 1); string value = d[num]; d[num] = d[index]; d[index] = value; } } private static int RankIndex(string card) { if (card == "大王") { return 17; } if (card == "小王") { return 16; } string text = ((card.Length > 1) ? card.Substring(0, card.Length - 1) : card); for (int i = 0; i < Ranks.Length; i++) { if (Ranks[i] == text) { return i + 3; } } return 0; } private static int CompareCard(string a, string b) { int num = RankIndex(a); int num2 = RankIndex(b); if (num != num2) { return num.CompareTo(num2); } return string.CompareOrdinal(a, b); } private static string Join(List<string> cards) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < cards.Count; i++) { if (i > 0) { stringBuilder.Append(' '); } stringBuilder.Append(cards[i]); } return stringBuilder.ToString(); } } internal static class I18n { private static ConfigEntry<bool> _english; internal static bool IsEnglish { get { if (_english != null) { return _english.Value; } return false; } } internal static string ButtonLabel { get { if (!IsEnglish) { return "EN"; } return "中文"; } } internal static string CurrentLabel { get { if (!IsEnglish) { return "中文"; } return "English"; } } internal static void Init(ConfigFile config) { if (_english == null) { _english = config.Bind<bool>("界面/UI", "English", false, "界面语言:false=中文,true=English。也可用烟花菜单的「中/EN」按钮实时切换。"); } } internal static string T(string zh, string en) { if (!IsEnglish) { return zh; } return en; } internal static bool Toggle() { if (_english == null) { return false; } _english.Value = !_english.Value; return _english.Value; } } internal static class LiarBarTool { private enum Phase { Idle, Playing, Decide, Reveal, Over } private struct PSeat { public Prop sign; public PlayerCharacter player; public List<string> hand; public bool alive; public int hits; } private static ManualLogSource Log; internal static ConfigEntry<int> PlayersEntry; internal static string Status = ""; internal static readonly List<string> History = new List<string>(); private const string K_Q = "Q"; private const string K_A = "A"; private const string K_K = "K"; private const string K_JOKER = "小丑"; private static readonly List<PSeat> _seats = new List<PSeat>(); private static Phase _phase = Phase.Idle; private static string _claim = "K"; private static int _turn = -1; private static int _decider = -1; private static int _roundStarter = 0; private static int _round = 0; private static int _lastSeat = -1; private static int _lastCount = 0; private static readonly List<string> _lastActual = new List<string>(); private static string _revealText = ""; private static float _revealUntil = 0f; private static int _shots = 0; private static float _nextTick = 0f; internal static bool ClientHost = false; internal static bool IsRunning { get { if (_phase != Phase.Playing && _phase != Phase.Decide) { return _phase == Phase.Reveal; } return true; } } internal static bool IsHost { get { if (!NetworkServer.active) { return ClientHost; } return true; } } internal static int PlayerCount { get { if (PlayersEntry == null) { return 3; } return Mathf.Clamp(PlayersEntry.Value, 2, 4); } } internal static void ToggleClientHost() { if (NetworkServer.active) { ClientHost = false; Status = I18n.T("你是房主,直接点「发牌」即可", "You are the host, just click Deal"); return; } ClientHost = !ClientHost; Status = (ClientHost ? "客户端主持已开:点「发牌(每人 5 张)」开一局(写牌走 CmdSendNewText)" : "已退出客户端主持"); Note(Status); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[骗子酒馆] " + Status)); } } internal static void Install(ManualLogSource log, ConfigFile cfg) { Log = log; PlayersEntry = cfg.Bind<int>("骗子酒馆", "人数", 3, "2 / 3 / 4 人(牌库 20 张,每人 5 张)"); Log.LogInfo((object)"[骗子酒馆] 已就绪(房主发起,每人 5 张,聊天出牌/质疑)"); } private static void Note(string s) { if (!string.IsNullOrEmpty(s)) { History.Add(s); while (History.Count > 40) { History.RemoveAt(0); } } } private static string Name(int i) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown if (i < 0 || i >= _seats.Count) { return "?"; } try { PlayerCharacter player = _seats[i].player; if ((Object)player != (Object)null) { string text = null; try { text = DouDiZhuTool.DisplayName(player); } catch { } if (!string.IsNullOrEmpty(text) && text != "某玩家") { return text; } } } catch { } return "玩家" + (i + 1); } private static int AliveCount() { int num = 0; for (int i = 0; i < _seats.Count; i++) { if (_seats[i].alive) { num++; } } return num; } private static List<PSeat> FindSignHolders() { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown List<PSeat> list = new List<PSeat>(); try { Il2CppArrayBase<Prop> val = Object.FindObjectsOfType<Prop>(); if (val == null) { return list; } for (int i = 0; i < val.Length; i++) { Prop val2 = val[i]; if ((Object)val2 == (Object)null || (Object)((Component)val2).gameObject == (Object)null) { continue; } string name = ((Object)((Component)val2).gameObject).name; if (string.IsNullOrEmpty(name)) { continue; } string text = name.ToLowerInvariant(); if (text.Contains("signprop") && !text.Contains("permo")) { PlayerCharacter val3 = null; try { val3 = val2.exclusiveHolder; } catch { } if (!((Object)val3 == (Object)null)) { list.Add(new PSeat { sign = val2, player = val3, hand = new List<string>(), alive = true, hits = 0 }); } } } } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[骗子酒馆] 找牌异常:" + ex.GetBaseException().Message)); } } return list; } private static void WriteSign(Prop sign, string text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown if ((Object)sign == (Object)null || (Object)((Component)sign).gameObject == (Object)null) { return; } try { PeckEffectTextInput component = ((Component)sign).GetComponent<PeckEffectTextInput>(); if ((Object)component == (Object)null) { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)"[骗子酒馆] 这块牌子没有 PeckEffectTextInput"); } } else { string text2 = text ?? ""; if (NetworkServer.active) { component.ServerSetText(text2, "骗子酒馆"); } else { component.CmdSendNewText(text2, (NetworkConnectionToClient)null); } } } catch (Exception ex) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)("[骗子酒馆] 写牌异常:" + ex.GetBaseException().Message)); } } } private static List<string> GroupKeys(List<string> hand) { List<string> list = new List<string>(); if (hand == null || hand.Count == 0) { return list; } Dictionary<string, bool> dictionary = new Dictionary<string, bool>(); for (int i = 0; i < hand.Count; i++) { string text = hand[i]; if (!string.IsNullOrEmpty(text) && !dictionary.ContainsKey(text)) { dictionary[text] = true; list.Add(text); } } list.Sort((string a, string b) => CardOrder(a).CompareTo(CardOrder(b))); return list; } private static int CardOrder(string c) { return c switch { "Q" => 0, "A" => 1, "K" => 2, "小丑" => 3, _ => 9, }; } private static string JoinGrouped(List<string> hand) { List<string> list = GroupKeys(hand); if (list.Count == 0) { return "(无牌)"; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < list.Count; i++) { if (i > 0) { stringBuilder.Append(' '); } int num = 0; for (int j = 0; j < hand.Count; j++) { if (hand[j] == list[i]) { num++; } } stringBuilder.Append(i + 1).Append(list[i]).Append('x') .Append(num); } return stringBuilder.ToString(); } private static void RefreshSigns() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown string value = "本轮:" + _claim + " · 存活 " + AliveCount() + " · 第 " + Mathf.Max(1, _round) + " 局"; for (int i = 0; i < _seats.Count; i++) { PSeat pSeat = _seats[i]; if ((Object)pSeat.sign == (Object)null || (Object)((Component)pSeat.sign).gameObject == (Object)null) { continue; } if (!pSeat.alive) { WriteSign(pSeat.sign, "【骗子酒馆】\n" + Name(i) + " 已中弹出局\n" + ((pSeat.hits > 0) ? ("(中弹 " + pSeat.hits + " 次)") : "")); continue; } if (_phase == Phase.Reveal) { WriteSign(pSeat.sign, _revealText); continue; } StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = stringBuilder.Append("【骗子酒馆】"); string value2 = ((i != _turn) ? ((i == _decider) ? "★轮到你表态" : Name(i)) : "★到你了"); stringBuilder2.Append(value2).Append('\n'); stringBuilder.Append(JoinGrouped(pSeat.hand)).Append('\n'); stringBuilder.Append(value).Append('\n'); if (_phase == Phase.Decide && i == _decider) { stringBuilder.Append(Name(_lastSeat)).Append(" 扣着出了 ").Append(_lastCount) .Append(" 张\n"); stringBuilder.Append("信:x 不信:b"); } else if (_phase == Phase.Playing && i == _turn) { stringBuilder.Append("出 1~3 张:编号+张数(22=第2种出2张)"); } else if (_lastSeat >= 0) { stringBuilder.Append("上一手:").Append(Name(_lastSeat)).Append(" 出了 ") .Append(_lastCount) .Append(" 张"); } WriteSign(pSeat.sign, stringBuilder.ToString()); } } private static List<string> BuildDeck() { List<string> list = new List<string>(20); for (int i = 0; i < 6; i++) { list.Add("Q"); } for (int j = 0; j < 6; j++) { list.Add("A"); } for (int k = 0; k < 6; k++) { list.Add("K"); } list.Add("小丑"); list.Add("小丑"); return list; } private static void Shuffle(List<string> d) { for (int num = d.Count - 1; num > 0; num--) { int index = Random.Range(0, num + 1); string value = d[num]; d[num] = d[index]; d[index] = value; } } internal static void StartGame() { if (!IsHost) { Status = I18n.T("骗子酒馆需要房主发起,或客户端点「我来主持(客户端改字)」", "Host needed, or client click I host"); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[骗子酒馆] " + Status)); } return; } if (DouDiZhuTool.IsRunning) { Status = I18n.T("斗地主还在进行,先点斗地主的「结束 / 清空牌子」", "Dou Dizhu is running, end it first"); ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)("[骗子酒馆] " + Status)); } return; } History.Clear(); _seats.Clear(); _phase = Phase.Idle; _shots = 0; _round = 0; _roundStarter = 0; _turn = (_decider = (_lastSeat = -1)); _lastCount = 0; _lastActual.Clear(); _revealText = ""; int playerCount = PlayerCount; List<PSeat> list = FindSignHolders(); if (list.Count < playerCount) { Status = I18n.T("需要 ", "Need ") + playerCount + I18n.T(" 人各拿一块指示牌(当前 ", " sign holders needed (now ") + list.Count + I18n.T(" 人拿着)", " holding)"); ManualLogSource log3 = Log; if (log3 != null) { log3.LogInfo((object)("[骗子酒馆] " + Status)); } return; } for (int i = 0; i < playerCount; i++) { PSeat item = list[i]; item.alive = true; item.hits = 0; _seats.Add(item); } Note("房主开了一局骗子酒馆(" + playerCount + " 人)"); NextRound(first: true); Status = I18n.T("骗子酒馆开局:", "Liar's Bar start: ") + playerCount + I18n.T(" 人,本轮指定 ", " players, claimed ") + _claim + I18n.T(";轮到 ", "; now ") + Name(_turn); Note(Status); ManualLogSource log4 = Log; if (log4 != null) { log4.LogInfo((object)("[骗子酒馆] " + Status)); } } private static void NextRound(bool first) { _round++; _lastSeat = -1; _lastCount = 0; _lastActual.Clear(); _revealText = ""; string[] array = new string[3] { "Q", "A", "K" }; string text = array[Random.Range(0, 3)]; if (!first && text == _claim && _seats.Count > 1) { text = array[(Array.IndexOf(array, text) + 1) % 3]; } _claim = text; List<string> list = BuildDeck(); Shuffle(list); for (int i = 0; i < _seats.Count; i++) { PSeat value = _seats[i]; value.hand = new List<string>(); if (value.alive) { for (int j = 0; j < 5; j++) { if (list.Count <= 0) { break; } value.hand.Add(list[0]); list.RemoveAt(0); } } _seats[i] = value; } _roundStarter = NextAlive((!first) ? (_roundStarter + 1) : 0); if (_roundStarter < 0) { Finish(); return; } _turn = _roundStarter; _decider = -1; _phase = Phase.Playing; Note(I18n.T("第 ", "Round ") + _round + " 局:指定 " + _claim + ",从 " + Name(_turn) + " 开始"); RefreshSigns(); } internal static void EndGame() { for (int i = 0; i < _seats.Count; i++) { WriteSign(_seats[i].sign, ""); } _seats.Clear(); _phase = Phase.Idle; _turn = (_decider = (_lastSeat = -1)); _lastActual.Clear(); _revealText = ""; _round = 0; _shots = 0; Status = I18n.T("骗子酒馆已结束", "Liar's Bar ended"); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[骗子酒馆] " + Status)); } } private static void Finish() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown int num = -1; for (int i = 0; i < _seats.Count; i++) { if (_seats[i].alive) { num = i; break; } } _phase = Phase.Over; _turn = (_decider = -1); for (int j = 0; j < _seats.Count; j++) { PSeat pSeat = _seats[j]; if (!((Object)pSeat.sign == (Object)null) && !((Object)((Component)pSeat.sign).gameObject == (Object)null)) { if (j == num) { WriteSign(pSeat.sign, "【骗子酒馆】\n" + Name(j) + " 最后活着\n赢了!"); continue; } WriteSign(pSeat.sign, "【骗子酒馆】\n" + Name(j) + " 已出局\n中弹 " + pSeat.hits + " 次"); } } Status = ((num >= 0) ? ("骗子酒馆结束:胜者 " + Name(num)) : "骗子酒馆结束:全员出局"); Note(Status); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[骗子酒馆] " + Status)); } } internal static void Tick() { if (!IsRunning || Time.unscaledTime < _nextTick) { return; } _nextTick = Time.unscaledTime + 0.5f; if (_phase != Phase.Reveal || !(Time.unscaledTime >= _revealUntil)) { return; } if (AliveCount() <= 1) { Finish(); return; } NextRound(first: false); Status = I18n.T("第 ", "Round ") + _round + I18n.T(" 局开始:指定 ", " starts: claimed ") + _claim + I18n.T(";轮到 ", "; now ") + Name(_turn); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[骗子酒馆] " + Status)); } } internal static void OnChat(PlayerCharacter sender, string text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0056: Expected O, but got Unknown try { if ((Object)sender == (Object)null || string.IsNullOrEmpty(text) || !IsHost || !IsRunning || DouDiZhuTool.IsRunning) { return; } int num = -1; for (int i = 0; i < _seats.Count; i++) { if ((Object)_seats[i].player == (Object)sender) { num = i; break; } } if (num < 0 || !_seats[num].alive) { return; } string text2 = text.Trim(); string text3 = text2.ToLowerInvariant().Replace(" ", "").Replace("\u3000", ""); if (text3.Length == 0) { return; } if (_phase == Phase.Decide) { OnDecideChat(num, text3); } else { if (_phase != Phase.Playing) { return; } if (num != _turn) { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[骗子酒馆] " + Name(num) + " 还没轮到(当前 " + Name(_turn) + ")")); } } else { TryPlay(num, text2, text3); } } } catch (Exception ex) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)("[骗子酒馆] 聊天异常:" + ex.GetBaseException().Message)); } } } private static void TryPlay(int idx, string raw, string flat) { PSeat value = _seats[idx]; List<string> list = GroupKeys(value.hand); if (list.Count == 0) { Status = Name(idx) + " 手里已经没牌了"; ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[骗子酒馆] " + Status)); } return; } int num = -1; int num2 = 0; if (IsAllDigits(flat)) { if (flat.Length == 1) { num = flat[0] - 48; num2 = 1; } else if (flat.Length == 2) { num = flat[0] - 48; num2 = flat[1] - 48; } } else { string text = ""; for (int i = 0; i < flat.Length; i++) { if (flat[i] >= '0' && flat[i] <= '9') { text += flat[i]; } } if (text.Length >= 1) { num = text[0] - 48; } if (text.Length >= 2) { num2 = text[1] - 48; } else if (text.Length == 1) { num2 = 1; } } if (num <= 0 || num > list.Count) { string text2 = MatchByName(flat, list); if (text2 == null) { Status = I18n.T("看不懂「", "Cannot understand ") + raw + I18n.T("」;输「编号+张数」,如 22 = 第2种出2张", "; enter type+count, e.g. 22 = 2 of type 2"); ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)("[骗子酒馆] " + Status)); } return; } num = list.IndexOf(text2) + 1; } if (num2 <= 0) { num2 = 1; } if (num2 > 3) { Status = I18n.T("一次最多出 3 张", "Max 3 cards at once"); ManualLogSource log3 = Log; if (log3 != null) { log3.LogInfo((object)("[骗子酒馆] " + Status)); } return; } if (num <= 0 || num > list.Count) { Status = I18n.T("没有第 ", "No type ") + num + I18n.T(" 种牌", " card"); ManualLogSource log4 = Log; if (log4 != null) { log4.LogInfo((object)("[骗子酒馆] " + Status)); } return; } string text3 = list[num - 1]; int num3 = 0; for (int j = 0; j < value.hand.Count; j++) { if (value.hand[j] == text3) { num3++; } } if (num3 < num2) { Status = Name(idx) + " 手上只有 " + num3 + " 张 " + text3; ManualLogSource log5 = Log; if (log5 != null) { log5.LogInfo((object)("[骗子酒馆] " + Status)); } return; } _lastActual.Clear(); for (int k = 0; k < num2; k++) { value.hand.Remove(text3); _lastActual.Add(text3); } _seats[idx] = value; _lastSeat = idx; _lastCount = num2; _turn = -1; _decider = NextAlive(idx + 1); if (_decider < 0) { Finish(); return; } _phase = Phase.Decide; Status = Name(idx) + " 扣着出了 " + num2 + " 张,轮到 " + Name(_decider) + " 表态"; Note(Name(idx) + " 出了 " + num2 + " 张"); ManualLogSource log6 = Log; if (log6 != null) { log6.LogInfo((object)("[骗子酒馆] " + Status)); } RefreshSigns(); } private static string MatchByName(string flat, List<string> keys) { for (int i = 0; i < keys.Count; i++) { string text = keys[i]; string value = text.ToLowerInvariant(); if (flat.Contains(value)) { return text; } if (text == "小丑" && (flat.Contains("丑") || flat.Contains("王"))) { return text; } } return null; } private static void OnDecideChat(int idx, string flat) { if (idx != _decider) { return; } bool flag; switch (flat) { default: return; case "不": case "不信": case "b": case "不行": case "n": case "质疑": case "开": flag = false; break; case "信": case "x": case "过": case "信他": case "y": flag = true; break; } if (flag) { _turn = _decider; _decider = -1; _phase = Phase.Playing; Status = Name(_turn) + " 选择相信,轮到他出牌(本轮 " + _claim + ")"; Note(Name(_turn) + " 选择相信"); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[骗子酒馆] " + Status)); } RefreshSigns(); } else { Reveal(); } } private static void Reveal() { bool flag = true; for (int i = 0; i < _lastActual.Count; i++) { string text = _lastActual[i]; if (text != _claim && text != "小丑") { flag = false; break; } } int index = (flag ? _decider : _lastSeat); string value = (flag ? ("全是真的 → " + Name(_decider) + " 质疑错,扣扳机") : ("有假牌 → " + Name(_lastSeat) + " 撒谎,扣扳机")); _shots = Mathf.Clamp(_shots + 1, 1, 6); string text2; if (Random.value < (float)_shots / 6f) { PSeat value2 = _seats[index]; value2.alive = false; value2.hits++; _seats[index] = value2; text2 = "砰!中弹,出局"; _shots = 0; } else { text2 = "咔哒…空枪(第 " + _shots + "/6 发)"; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("【开牌】第 ").Append(Mathf.Max(1, _round)).Append(" 局\n"); stringBuilder.Append(Name(_lastSeat)).Append(" 实际出的牌:").Append(Join(_lastActual)) .Append('\n'); stringBuilder.Append(value).Append('\n'); stringBuilder.Append(text2); _revealText = stringBuilder.ToString(); _phase = Phase.Reveal; _revealUntil = Time.unscaledTime + 8f; _turn = -1; _decider = -1; Status = I18n.T("开牌:", "Reveal: ") + (flag ? I18n.T("真牌", "genuine") : I18n.T("有假", "bluff")) + ";" + text2; Note(I18n.T("开牌:", "Reveal: ") + Name(_lastSeat) + " 出 " + Join(_lastActual) + "(真=" + flag + ");" + text2); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[骗子酒馆] " + Status)); } RefreshSigns(); } private static string Join(List<string> cards) { if (cards == null || cards.Count == 0) { return "(空)"; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < cards.Count; i++) { if (i > 0) { stringBuilder.Append(' '); } stringBuilder.Append(cards[i]); } return stringBuilder.ToString(); } private static bool IsAllDigits(string s) { if (string.IsNullOrEmpty(s)) { return false; } for (int i = 0; i < s.Length; i++) { if (s[i] < '0' || s[i] > '9') { return false; } } return true; } private static int NextAlive(int from) { int count = _seats.Count; if (count == 0) { return -1; } int num = (from % count + count) % count; for (int i = 0; i < count; i++) { int num2 = (num + i) % count; if (_seats[num2].alive) { return num2; } } retu