示例#1
0
        public override void ParseMessage(ITwitchMessage twitchMessage)
        {
            // If it is a whisper, do not update viewer details
            if (twitchMessage.ChatMessage == null)
            {
                return;
            }

            Viewer             viewer    = Viewers.GetViewer(twitchMessage.Username);
            GameComponentPawns component = Current.Game.GetComponent <GameComponentPawns>();

            ToolkitSettings.ViewerColorCodes[twitchMessage.Username.ToLower()] = twitchMessage.ChatMessage.ColorHex;

            if (component.HasUserBeenNamed(twitchMessage.Username))
            {
                component.PawnAssignedToUser(twitchMessage.Username).story.hairColor = twitchMessage.ChatMessage.Color;
            }

            if (twitchMessage.ChatMessage.IsModerator && !viewer.mod)
            {
                viewer.SetAsModerator();
            }

            if (twitchMessage.ChatMessage.IsSubscriber && !viewer.IsSub)
            {
                viewer.subscriber = true;
            }

            if (twitchMessage.ChatMessage.IsVip && !viewer.IsVIP)
            {
                viewer.vip = true;
            }
        }
        public override void ParseCommand(ChatMessage msg)
        {
            Viewer             viewer    = Viewers.GetViewer(msg.Username);
            GameComponentPawns component = Current.Game.GetComponent <GameComponentPawns>();

            ToolkitSettings.ViewerColorCodes[msg.Username.ToLower()] = msg.ColorHex;

            if (component.HasUserBeenNamed(msg.Username))
            {
                component.PawnAssignedToUser(msg.Username).story.hairColor = msg.Color;
            }

            if (msg.IsModerator && !viewer.mod)
            {
                viewer.SetAsModerator();
            }

            if (msg.IsSubscriber && !viewer.IsSub)
            {
                viewer.subscriber = true;
            }

            if (msg.IsVip && !viewer.IsVIP)
            {
                viewer.vip = true;
            }
        }
示例#3
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 4)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            GameComponentPawns gameComponent = Current.Game.GetComponent <GameComponentPawns>();

            if (!gameComponent.HasUserBeenNamed(viewer.username))
            {
                Toolkit.client.SendMessage($"@{viewer.username} you must be in the colony to use this command.", separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[3],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            string          skillKind = command[2].ToLower();
            List <SkillDef> allSkills = DefDatabase <SkillDef> .AllDefs.Where(s =>
                                                                              string.Join("", s.defName.Split(' ')).ToLower() == skillKind ||
                                                                              string.Join("", s.label.Split(' ')).ToLower() == skillKind
                                                                              ).ToList();

            if (allSkills.Count < 1)
            {
                Toolkit.client.SendMessage($"@{viewer.username} skill {skillKind} not found.", separateChannel);
                return(false);
            }

            skill = allSkills[0];
            pawn  = gameComponent.PawnAssignedToUser(viewer.username);

            if (pawn.skills.GetSkill(skill).TotallyDisabled)
            {
                Toolkit.client.SendMessage($"@{viewer.username} skill {skillKind} disabled on your pawn.", separateChannel);
                return(false);
            }

            if (pawn.skills.GetSkill(skill).levelInt >= 20)
            {
                Toolkit.client.SendMessage($"@{viewer.username} skill {skillKind} disabled on your pawn.", separateChannel);
                return(false);
            }

            return(true);
        }
示例#4
0
        private static void RenameAndRemove([CanBeNull] GameComponentPawns component, [CanBeNull] string username)
        {
            if (username == null || component == null)
            {
                return;
            }

            Pawn pawn = component.PawnAssignedToUser(username);

            if (pawn?.Name is NameTriple name)
            {
                pawn.Name = new NameTriple(name.First, name.Last, name.Last);
            }

            component.pawnHistory.Remove(username);
        }
示例#5
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.viewer          = viewer;

            GameComponentPawns gameComponent = Current.Game.GetComponent <GameComponentPawns>();

            if (!gameComponent.HasUserBeenNamed(viewer.username))
            {
                Toolkit.client.SendMessage($"@{viewer.username} you must be in the colony to use this command.", separateChannel);
                return(false);
            }

            pawn = gameComponent.PawnAssignedToUser(viewer.username);

            Log.Warning("changing gneder");
            return(true);
        }
示例#6
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.Viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                TwitchWrapper.SendChatMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}");
                return(false);
            }

            GameComponentPawns gameComponent = Current.Game.GetComponent <GameComponentPawns>();

            if (!gameComponent.HasUserBeenNamed(viewer.username))
            {
                TwitchWrapper.SendChatMessage($"@{viewer.username} you must be in the colony to use this command.");
                return(false);
            }

            pawn = gameComponent.PawnAssignedToUser(viewer.username);

            if (pawn.story.traits.allTraits != null && pawn.story.traits.allTraits.Count <= 0)
            {
                TwitchWrapper.SendChatMessage($"@{viewer.username} your pawn doesn't have any traits.");
                return(false);
            }

            string traitKind = command[2].ToLower();

            BuyableTrait search = AllTraits.buyableTraits.Find(s => traitKind == s.label);

            if (search == null)
            {
                TwitchWrapper.SendChatMessage($"@{viewer.username} trait {traitKind} not found.");
                return(false);
            }

            buyableTrait = search;

            return(true);
        }
        protected static Pawn GetPawnIfAllowed(IRCMessage message)
        {
            Viewer             viewer    = Viewers.GetViewer(message.User);
            GameComponentPawns component = Current.Game.GetComponent <GameComponentPawns>();

            if (!CommandsHandler.AllowCommand(message))
            {
                // No commands allowed in this channel
                return(null);
            }

            Log.Message($"Parsing command {message.Message} from {message.User}");

            if (!component.HasUserBeenNamed(viewer.username))
            {
                Toolkit.client.SendMessage($"@{viewer.username} you are not in the colony.", CommandsHandler.SendToChatroom(message));
                return(null);
            }

            return(component.PawnAssignedToUser(viewer.username));
        }
示例#8
0
        public override void ParseCommand(IRCMessage msg)
        {
            Viewer viewer = Viewers.GetViewer(msg.User);

            foreach (KeyValuePair <string, string> pair in msg.Parameters)
            {
                //Log.Warning(pair.Key + " : " + pair.Value);
                switch (pair.Key)
                {
                case "color":
                    if (pair.Value == null)
                    {
                        break;
                    }
                    string colorCode = "";
                    if (pair.Value.Length > 6)
                    {
                        colorCode = pair.Value.Remove(0, 1);
                        ToolkitSettings.ViewerColorCodes[msg.User.ToLower()] = colorCode;
                    }
                    else
                    {
                        break;
                    }
                    GameComponentPawns component = Current.Game.GetComponent <GameComponentPawns>();

                    if (component.HasUserBeenNamed(msg.User))
                    {
                        Pawn pawn = component.PawnAssignedToUser(msg.User);

                        pawn.story.hairColor = GetColorFromHex(colorCode);
                    }

                    break;

                case "mod":
                    if (viewer.mod || pair.Value == null)
                    {
                        break;
                    }
                    bool modValue = int.TryParse(pair.Value, out int modStatus);
                    if (modValue && modStatus == 1)
                    {
                        viewer.mod = true;
                    }
                    break;

                case "subscriber":
                    if (pair.Value == null)
                    {
                        break;
                    }
                    bool subValue = int.TryParse(pair.Value, out int subStatus);
                    if (subValue && subStatus == 1)
                    {
                        viewer.subscriber = true;
                    }
                    break;

                case "badges":
                    if (pair.Value == null)
                    {
                        break;
                    }
                    IEnumerable <string> badges = pair.Value.Split(',');
                    foreach (string badge in badges)
                    {
                        if (badge == "vip/1")
                        {
                            viewer.vip = true;
                            break;
                        }
                    }
                    break;
                }
            }

            Store_Logger.LogString("Parsed command parameters");
        }
示例#9
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.Viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                TwitchWrapper.SendChatMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}");
                return(false);
            }

            GameComponentPawns gameComponent = Current.Game.GetComponent <GameComponentPawns>();

            if (!gameComponent.HasUserBeenNamed(viewer.username))
            {
                TwitchWrapper.SendChatMessage($"@{viewer.username} you must be in the colony to use this command.");
                return(false);
            }

            pawn = gameComponent.PawnAssignedToUser(viewer.username);

            float customMaxTraits = AddTraitSettings.maxTraits > 0 ? AddTraitSettings.maxTraits : 4;

            if (pawn.story.traits.allTraits != null && pawn.story.traits.allTraits.Count >= customMaxTraits)
            {
                TwitchWrapper.SendChatMessage($"@{viewer.username} your pawn already has max {customMaxTraits} traits.");
                return(false);
            }

            string traitKind = command[2].ToLower();

            BuyableTrait search = AllTraits.buyableTraits.Find(s => traitKind == s.label);


            if (search == null)
            {
                TwitchWrapper.SendChatMessage($"@{viewer.username} trait {traitKind} not found.");
                return(false);
            }

            buyableTrait = search;
            traitDef     = buyableTrait.def;

            //if (!pawn.story.traits.allTraits.Any((Trait tr) =>
            //    traitDef.ConflictsWith(tr)) &&
            //    (traitDef.conflictingTraits == null ||
            //    !traitDef.conflictingTraits.Any((TraitDef tr) => pawn.story.traits.HasTrait(tr))))
            //{
            //    return true;
            //}

            trait = new Trait(traitDef, buyableTrait.degree);

            foreach (Trait tr in pawn.story.traits.allTraits)
            {
                if (tr.def.ConflictsWith(trait) || traitDef.ConflictsWith(tr))
                {
                    TwitchWrapper.SendChatMessage($"@{viewer.username} {traitDef.defName} conflicts with your pawn's trait {tr.LabelCap}.");
                    return(false);
                }
            }

            if (pawn.story.traits.allTraits != null && pawn.story.traits.allTraits.Find(s => s.def.defName == search.def.defName) != null)
            {
                TwitchWrapper.SendChatMessage($"@{viewer.username} you already have this trait of this type.");
                return(false);
            }

            return(true);
        }
示例#10
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            GameComponentPawns gameComponent = Current.Game.GetComponent <GameComponentPawns>();

            if (!gameComponent.HasUserBeenNamed(viewer.username))
            {
                Toolkit.client.SendMessage($"@{viewer.username} you must be in the colony to use this command.", separateChannel);
                return(false);
            }

            pawn = gameComponent.PawnAssignedToUser(viewer.username);

            if (pawn.story.traits.allTraits != null && pawn.story.traits.allTraits.Count >= 4)
            {
                Toolkit.client.SendMessage($"@{viewer.username} your pawn already has max 4 traits.", separateChannel);
                return(false);
            }

            string traitKind = command[2].ToLower();

            List <TraitDef> allTraits = DefDatabase <TraitDef> .AllDefs.Where(s =>
                                                                              string.Join("", s.defName.Split(' ')).ToLower() == traitKind
                                                                              ).ToList();


            if (allTraits.Count < 1)
            {
                Toolkit.client.SendMessage($"@{viewer.username} skill {traitKind} not found.", separateChannel);
                return(false);
            }

            traitDef = allTraits[0];

            if (!pawn.story.traits.allTraits.Any((Trait tr) =>
                                                 traitDef.ConflictsWith(tr)) &&
                (traitDef.conflictingTraits == null ||
                 !traitDef.conflictingTraits.Any((TraitDef tr) => pawn.story.traits.HasTrait(tr))))
            {
                return(true);
            }

            foreach (Trait tr in pawn.story.traits.allTraits)
            {
                if (tr.def.ConflictsWith(trait) || traitDef.ConflictsWith(tr))
                {
                    Toolkit.client.SendMessage($"@{viewer.username} {traitDef.defName} conflicts with your pawn's trait {tr.LabelCap}.");
                    return(false);
                }
            }

            return(true);
        }
        public override void ParseCommand(IRCMessage msg)
        {
            foreach (KeyValuePair <string, string> pair in msg.Parameters)
            {
                //Log.Warning($"{pair.Key} : {pair.Value}");

                return;

                switch (pair.Key)
                {
                case "color":
                    if (pair.Value == null)
                    {
                        return;
                    }
                    string colorCode = "";
                    if (pair.Value.Length > 6)
                    {
                        colorCode = pair.Value.Remove(0, 1);
                        ToolkitSettings.ViewerColorCodes[msg.User.ToLower()] = colorCode;
                    }
                    else
                    {
                        break;
                    }
                    GameComponentPawns component = Current.Game.GetComponent <GameComponentPawns>();

                    if (component.HasUserBeenNamed(msg.User))
                    {
                        Pawn pawn = component.PawnAssignedToUser(msg.User);

                        pawn.story.hairColor = GetColorFromHex(colorCode);
                    }

                    break;

                case "mod":
                    if (pair.Value == null)
                    {
                        return;
                    }
                    bool modValue = int.TryParse(pair.Value, out int modStatus);
                    if (modValue && modStatus == 1)
                    {
                        Viewers.GetViewer(msg.User).mod = true;
                    }
                    break;

                case "subscriber":
                    if (pair.Value == null)
                    {
                        return;
                    }
                    bool subValue = int.TryParse(pair.Value, out int subStatus);
                    if (subValue && subStatus == 1)
                    {
                        Viewers.GetViewer(msg.User).subscriber = true;
                    }
                    break;
                }
            }

            Store_Logger.LogString("Parsed command parameters");
        }
示例#12
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            GameComponentPawns gameComponent = Current.Game.GetComponent <GameComponentPawns>();

            if (!gameComponent.HasUserBeenNamed(viewer.username))
            {
                Toolkit.client.SendMessage($"@{viewer.username} you must be in the colony to use this command.", separateChannel);
                return(false);
            }

            pawn = gameComponent.PawnAssignedToUser(viewer.username);

            float customMaxTraits = CustomSettings.LookupFloatSetting("Toolkit.AddTrait.MaxTraits") > 0 ? CustomSettings.LookupFloatSetting("Toolkit.AddTrait.MaxTraits") : 4;

            if (pawn.story.traits.allTraits != null && pawn.story.traits.allTraits.Count >= customMaxTraits)
            {
                Toolkit.client.SendMessage($"@{viewer.username} your pawn already has max {customMaxTraits} traits.", separateChannel);
                return(false);
            }

            string traitKind = command[2].ToLower();

            BuyableTrait search = AllTraits.buyableTraits.Find(s => traitKind == s.label);


            if (search == null)
            {
                Toolkit.client.SendMessage($"@{viewer.username} trait {traitKind} not found.", separateChannel);
                return(false);
            }

            buyableTrait = search;
            traitDef     = buyableTrait.def;

            if (!pawn.story.traits.allTraits.Any((Trait tr) =>
                                                 traitDef.ConflictsWith(tr)) &&
                (traitDef.conflictingTraits == null ||
                 !traitDef.conflictingTraits.Any((TraitDef tr) => pawn.story.traits.HasTrait(tr))))
            {
                return(true);
            }

            foreach (Trait tr in pawn.story.traits.allTraits)
            {
                if (tr.def.ConflictsWith(trait) || traitDef.ConflictsWith(tr))
                {
                    Toolkit.client.SendMessage($"@{viewer.username} {traitDef.defName} conflicts with your pawn's trait {tr.LabelCap}.");
                    return(false);
                }
            }

            return(true);
        }