private bool IsValidEntry(string date, string country, string name, string content)
        {
            try
            {
                bool ok1 = true, ok2 = true, ok3 = true, ok4 = true;

                if (string.IsNullOrEmpty(date) || string.IsNullOrEmpty(country) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(content))
                {
                    return(NotValid(date, country, name, content));
                }
                if (date.Length > 10 || country.Length > 50 || name.Length > 50 || content.Length > 150)
                {
                    return(NotValid(date, country, name, content));
                }

                DateTime       res_date;
                CultureInfo    culture = CultureInfo.CreateSpecificCulture("en-US");
                DateTimeStyles styles = DateTimeStyles.None;

                ok1 = DateTime.TryParse(date, culture, styles, out res_date);
                StringHelper.OnlyAlphanumeric(country, true, true, "br", Characters.Name(), out ok2);
                StringHelper.OnlyAlphanumeric(name, true, true, "br", Characters.Name(), out ok3);
                StringHelper.OnlyAlphanumeric(content, true, true, "br", Characters.All(true), out ok4);
                if (!(ok1 && ok2 && ok3 && ok4))
                {
                    return(NotValid(date, country, name, content));
                }

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Exemple #2
0
        private void SpawnPlayer(GamePadData gamepad, int index)
        {
            Vector2 spawnLocation = _spawnLocations.DistributeSpawn();
            var     spawnX        = (int)spawnLocation.X;
            var     spawnY        = (int)spawnLocation.Y;
            var     player        = scene.addEntity(new Player(Characters.All().randomItem(), spawnX, spawnY, index));

            player.addComponent(new PlayerController(gamepad));

            _connectedPlayers.Add(player);

            _playerSpawnedThisFrame = true;
        }
Exemple #3
0
        public void CheckRelations()
        {
            foreach (ClientSession session in Characters.Where(s => s != null))
            {
                foreach (CharacterRelationDTO relation in session.Character.CharacterRelations)
                {
                    if (relation.RelationType != CharacterRelationType.Spouse)
                    {
                        continue;
                    }

                    if (relation.CharacterId == session.Character.CharacterId)
                    {
                        if (Characters.All(s => s.Character.CharacterId != relation.RelatedCharacterId))
                        {
                            continue;
                        }

                        session.Character.AddBuff(new Buff.Buff(319, isPermaBuff: true));
                        session.Character.GenerateEff(881);
                        Characters.FirstOrDefault(s => s.Character.CharacterId == relation.RelatedCharacterId)?.Character.AddBuff(new Buff.Buff(319, isPermaBuff: true));
                        Characters.FirstOrDefault(s => s.Character.CharacterId == relation.RelatedCharacterId)?.Character.GenerateEff(881);
                    }

                    else if (relation.RelatedCharacterId == session.Character.CharacterId)
                    {
                        if (Characters.All(s => s.Character.CharacterId != relation.CharacterId))
                        {
                            continue;
                        }

                        session.Character.AddBuff(new Buff.Buff(319, isPermaBuff: true));
                        session.Character.GenerateEff(881);
                        Characters.FirstOrDefault(s => s.Character.CharacterId == relation.CharacterId)?.Character.AddBuff(new Buff.Buff(319, isPermaBuff: true));
                        Characters.FirstOrDefault(s => s.Character.CharacterId == relation.CharacterId)?.Character.GenerateEff(881);
                    }
                }
            }
        }
Exemple #4
0
        private void StartRandom()
        {
            int            index;
            CharacterModel character;

            while (true)
            {
                index     = Random.Next(Characters.Count);
                character = Characters[index];
                if (character.IsSelected && !(PreventDuplicates && character.WasPlayed) && character.IsAvailable)
                {
                    break;
                }
            }
            character.WasPlayed = PreventDuplicates;
            if (Characters.All(c => !c.IsSelected || c.WasPlayed))
            {
                foreach (var characterModel in Characters)
                {
                    characterModel.WasPlayed = false;
                }
            }
            while (index < Characters.CountAvaiblable() * 2 + 1)
            {
                index += Characters.CountAvaiblable() + 1;
            }
            for (int i = 0; i < index; i++)
            {
                Keylogger.PostKey(Keys.Right);
                Task.Delay(Math.Max(50, i * i / 4)).Wait();
            }
            NewPlayStarted?.Invoke(this, character);
            if (StartAfterSelection)
            {
                Task.Delay(66).Wait();
                Keylogger.PostKey(Keys.Enter);
            }
        }