コード例 #1
0
    public static void Take(TwitchModule module, string user, bool isWhisper)
    {
        if (isWhisper)
        {
            IRCConnection.SendMessageFormat("Sorry {0}, taking modules is not allowed in whispers.", user);
        }
        else if (TwitchPlaySettings.data.AnarchyMode)
        {
            IRCConnection.SendMessageFormat("Sorry {0}, taking modules is not allowed in anarchy mode.", user);
        }

        // Attempt to take over from another user
        else if (module.PlayerName != null && user != module.PlayerName)
        {
            module.AddToClaimQueue(user);
            if (module.TakeInProgress == null)
            {
                IRCConnection.SendMessageFormat(TwitchPlaySettings.data.TakeModule, module.PlayerName, user, module.Code, module.HeaderText);
                module.TakeInProgress = module.TakeModule();
                module.StartCoroutine(module.TakeInProgress);
            }
            else
            {
                IRCConnection.SendMessageFormat(TwitchPlaySettings.data.TakeInProgress, user, module.Code, module.HeaderText);
            }
        }

        // Module is already claimed by the same user
        else if (module.PlayerName != null)
        {
            if (!module.PlayerName.Equals(user))
            {
                module.AddToClaimQueue(user);
            }
            IRCConnection.SendMessageFormat(TwitchPlaySettings.data.ModuleAlreadyOwned, user, module.Code, module.HeaderText);
        }

        // Module is not claimed at all: just claim it
        else
        {
            IRCConnection.SendMessage(module.ClaimModule(user).Second);
        }
    }