示例#1
0
        public string Fight()
        {
            MainPlayer mainPlayer = new MainPlayer();

            GangNeighbourhood gangNeighbourhood = new GangNeighbourhood();

            gangNeighbourhood.Action(mainPlayer, civilPlayers);

            StringBuilder sb = new StringBuilder();

            if (civilPlayers.Any(p => p.IsAlive == true) &&
                mainPlayer.LifePoints == 100)
            {
                sb.AppendLine("Everything is okay!");
            }
            else
            {
                sb.AppendLine("A fight happened:");
                sb.AppendLine($"Tommy live points: {mainPlayer.LifePoints}!");
                sb.AppendLine($"Tommy has killed: {civilPlayers.Where(p => p.IsAlive == false).Count()} players!");
                sb.AppendLine($"Left Civil Players: {civilPlayers.Where(p => p.IsAlive == true).Count()}!");
            }

            return(sb.ToString().TrimEnd());
        }
示例#2
0
        public string Fight()
        {
            var oldPlayer = player;
            var oldCivils = civils;

            // Fight
            var gang = new GangNeighbourhood();

            gang.Action(player, civils as ICollection <IPlayer>);

            // Nothing happend
            if (oldPlayer == player && oldCivils == civils)
            {
                return("Everything is okay!");
            }

            // Result
            StringBuilder sb = new StringBuilder();

            sb.Append("A fight happened:" + Environment.NewLine);
            sb.Append($"Tommy live points: {player.LifePoints}!" + Environment.NewLine);
            sb.Append($"Tommy has killed: {oldCivils.Count - civils.Count} players!" + Environment.NewLine);
            sb.Append($"Left Civil Players: {civils.Count}!" + Environment.NewLine);

            return(sb.ToString());
        }
示例#3
0
        public string Fight()
        {
            if (civilPlayers.Count > 0)
            {
                neighbourhood.Action(mainPlayer, civilPlayers);

                for (int i = 0; i < civilPlayers.Count; i++)
                {
                    if (!civilPlayers[i].IsAlive)
                    {
                        deadPlayers.Add(civilPlayers[i]);
                        civilPlayers.Remove(civilPlayers[i]);
                        i--;
                    }
                }
            }


            if (mainPlayer.LifePoints == 100 && deadPlayers.Count == 0)
            {
                return("Everything is okay!");
            }
            else
            {
                StringBuilder sb = new StringBuilder();

                sb.AppendLine("A fight happened:")
                .AppendLine($"Tommy live points: {mainPlayer.LifePoints}!")
                .AppendLine($"Tommy has killed: {deadPlayers.Count} players!")
                .AppendLine($"Left Civil Players: {civilPlayers.Count}!");

                return(sb.ToString().TrimEnd());
            }
        }
        public string Fight()
        {
            StringBuilder sb = new StringBuilder();

            INeighbourhood neighbourhood = new GangNeighbourhood();
            int            playersCountBeforeTheFight = this.players.Count;
            int            playersHealthBefore        = this.players.Sum(p => p.LifePoints);

            neighbourhood.Action(this.mainPlayer, this.players);

            int playersHealthAfter = this.players.Sum(p => p.LifePoints);

            if (this.mainPlayer.LifePoints == 100 && this.players.Count == playersCountBeforeTheFight &&
                playersHealthBefore == playersHealthAfter)
            {
                return("Everything is okay!");
            }

            sb.AppendLine("A fight happened:");
            sb.AppendLine($"Tommy live points: {this.mainPlayer.LifePoints}!");
            sb.AppendLine($"Tommy has killed: {playersCountBeforeTheFight - this.players.Count} players!");
            sb.AppendLine($"Left Civil Players: {this.players.Count}!");

            return(sb.ToString().TrimEnd());
        }
示例#5
0
        public string Fight()
        {
            var mainPlayerHp      = mainPlayer.LifePoints;
            var civilPlayersHp    = new List <int>();
            var civilPlayersCount = civilPlayers.Count;

            foreach (var player in civilPlayers)
            {
                civilPlayersHp.Add(player.LifePoints);
            }

            gangNeighbourhood.Action(mainPlayer, civilPlayers);


            if (mainPlayerHp != mainPlayer.LifePoints)
            {
                return(FightHappened(civilPlayersCount));
            }

            var index = 0;

            foreach (var player in civilPlayers)
            {
                if (civilPlayersHp[index] != player.LifePoints)
                {
                    return(FightHappened(civilPlayersCount));
                }
                index++;
            }
            return("Everything is okay!");
        }
示例#6
0
        public string Fight()
        {
            int  tommysHealthBeforeFight = tommy.LifePoints;
            bool isEveryBodyFine         = true;

            neighbourhood.Action(tommy, civilPlayers);

            if (!civilPlayers.Any(x => x.IsAlive) || civilPlayers.Any(x => x.LifePoints != 50))
            {
                isEveryBodyFine = false;
            }

            if (isEveryBodyFine && tommysHealthBeforeFight == tommy.LifePoints)
            {
                return("Everything is okay!");
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                var           killedEnemiesList  = civilPlayers.Where(x => x.LifePoints == 0);
                int           killedEnemiesCount = killedEnemiesList.Count();
                var           livingEnemiesList  = civilPlayers.Where(x => x.IsAlive);
                int           livingEnemiesCount = livingEnemiesList.Count();


                sb.AppendLine("A fight happened:");
                sb.AppendLine($"Tommy live points: {tommy.LifePoints}!");
                sb.AppendLine($"Tommy has killed: {killedEnemiesCount} players!");
                sb.AppendLine($"Left Civil Players: {livingEnemiesCount}!");

                return(sb.ToString().TrimEnd());
            }
        }
示例#7
0
        public string Fight()
        {
            var mainPlayer   = (MainPlayer)players.FirstOrDefault(x => x.Name == "Tommy Vercetti");
            var civilPlayers = players.Where(x => x.Name != "Tommy Vercetti").ToList();

            StringBuilder sb = new StringBuilder();

            gangNeighbourhood.Action(mainPlayer, civilPlayers);

            bool noOneIsHarmedorDead = true;

            foreach (var civil in players)
            {
                if (civil.IsAlive == false)
                {
                    noOneIsHarmedorDead = false;
                    break;
                }
            }

            if (mainPlayer.LifePoints == 100 && noOneIsHarmedorDead == true)
            {
                return("Everything is okay!");
            }
            else
            {
                sb.AppendLine("A fight happened:");
                sb.AppendLine($"Tommy live points: { mainPlayer.LifePoints}!");
                sb.AppendLine($"Tommy has killed: {civilPlayers.Where(x=>x.IsAlive == false).Count()} players!");
                sb.AppendLine($"Left Civil Players: {civilPlayers.Where(x=>x.IsAlive).Count()}!");
            }
            return(sb.ToString().TrimEnd());
        }
示例#8
0
        public string Fight()
        {
            int  tommysHealthBeforeFight = player.LifePoints;
            bool isEveryBodyFine         = true;

            neighbourhood.Action(player, players);

            //if (!players.Any(x => x.IsAlive) || players.Any(x => x.LifePoints != 50))
            //{
            //	isEveryBodyFine = false;
            //}

            if (player.IsAlive && players.All(x => x.LifePoints == 50) && players.All(x => x.IsAlive) && players.Count != 0)
            {
                return("Everything is okay!");
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                var           killedEnemiesList  = players.Where(x => x.LifePoints == 0);
                int           killedEnemiesCount = killedEnemiesList.Count();
                var           livingEnemiesList  = players.Where(x => x.IsAlive);
                int           livingEnemiesCount = livingEnemiesList.Count();


                sb.AppendLine("A fight happened:");
                sb.AppendLine($"Tommy live points: {player.LifePoints}!");
                sb.AppendLine($"Tommy has killed: {killedEnemiesCount} players!");
                sb.AppendLine($"Left Civil Players: {livingEnemiesCount}!");

                return(sb.ToString().TrimEnd());
                //int killedCivilians = 0;
                //neighbourhood.Action(player, players);
                //foreach (var civilian in players.ToList())
                //{
                //	if (!civilian.IsAlive)
                //	{
                //		players.Remove(civilian);
                //		killedCivilians++;
                //	}
                //}

                //if (player.IsAlive && players.All(x => x.LifePoints == 50) && players.All(x => x.IsAlive) && players.Count != 0)
                //{
                //	return $"Everything is okay!";
                //}
                //else
                //{

                //	StringBuilder sb = new StringBuilder();
                //	sb.AppendLine("A fight happened:")
                //		.AppendLine($"Tommy life points: {player.LifePoints}!")
                //		.AppendLine($"Tommy has killed: {killedCivilians} players!")
                //		.AppendLine($"Left Civil Players: {players.Count}!");

                //	return sb.ToString().TrimEnd();
                //}
            }
        }
示例#9
0
        public string Fight()
        {
            _neighbourhood.Action(mainPlayer, civilPlayers);

            if (mainPlayer.LifePoints == 100 && civilPlayers.All(x => x.LifePoints == 50))
            {
                return("Everything is okay!");
            }

            var sb = new StringBuilder();

            sb.AppendLine($"A fight happened:")
            .AppendLine($"Tommy live points: {mainPlayer.LifePoints}!")
            .AppendLine($"Tommy has killed: {civilPlayers.Count(x => !x.IsAlive)} players!")
            .AppendLine($"Left Civil Players: {civilPlayers.Count(x => x.IsAlive)}!");
            return(sb.ToString().TrimEnd());
        }
示例#10
0
        public string Fight()
        {
            gangNeighbourhood.Action(mainPlayer, (ICollection <IPlayer>)civilPlayers);

            if (mainPlayer.LifePoints == 100 && civilPlayers.Where(p => !p.IsAlive).ToList().Count == 0 && civilPlayers.Sum(p => p.LifePoints) / civilPlayers.Count == 50)
            {
                return("Everything is okay!");
            }

            else /*if (mainPlayer.LifePoints != 100 || civilPlayers.Where(p => !p.IsAlive).ToList().Count != 0 || civilPlayers.Sum(p => p.LifePoints) / civilPlayers.Count != 50)*/
            {
                return("A fight happened:" + Environment.NewLine +
                       $"Tommy live points: {mainPlayer.LifePoints}!" + Environment.NewLine +
                       $"Tommy has killed: {civilPlayers.Where(p => !p.IsAlive).ToList().Count} players!" + Environment.NewLine +
                       $"Left Civil Players: {civilPlayers.Where(p => p.IsAlive).ToList().Count}!");
            }
        }
示例#11
0
        public string Fight()
        {
            hood.Action(mainPlayer, civils);

            if (mainPlayer.IsAlive && civils.All(p => p.IsAlive))
            {
                return("Everything is okay!");
            }
            else
            {
                var sb = new StringBuilder();

                sb.AppendLine("A fight happened:");
                sb.AppendLine($"Tommy live points: {mainPlayer.LifePoints}!");
                sb.AppendLine($"Tommy has killed: {civils.Where(p => !p.IsAlive).Count()} players!");
                sb.AppendLine($"Left Civil Players: {civils.Where(p => p.IsAlive).Count()}!");

                return(sb.ToString().TrimEnd());
            }
        }
示例#12
0
        public string Fight()
        {
            GangNeighbourhood fightScene = new GangNeighbourhood();

            fightScene.Action(mainPlayer, players);

            if (mainPlayer.LifePoints == 100)
            {
                bool isOk = true;
                foreach (var civilian in players)
                {
                    if (civilian.LifePoints < 50)
                    {
                        isOk = false;
                        break;
                    }
                }
                if (isOk)
                {
                    return("Everything is okay!");
                }
            }
            int dead  = 0;
            int alive = 0;

            foreach (var civilian in players)
            {
                if (civilian.IsAlive)
                {
                    alive++;
                }
                else
                {
                    dead++;
                }
            }
            return($"A fight happened:" + Environment.NewLine + $"Tommy live points: {mainPlayer.LifePoints}!"
                   + Environment.NewLine + $"Tommy has killed: {dead} players!" + Environment.NewLine
                   + $"Left Civil Players: {alive}!");
        }
示例#13
0
        public string Fight()
        {
            var civilPlayers     = this.players.Where(x => x is CivilPlayer).ToList();
            var pointsMainPlayer = mainPlayer.LifePoints;

            neighbourhood.Action(mainPlayer, civilPlayers);

            if (mainPlayer.LifePoints == pointsMainPlayer && civilPlayers.Any(x => x.IsAlive))
            {
                return("Everything is okay!");
            }

            StringBuilder sb = new StringBuilder();
            var           deadCivilPlayersCount = civilPlayers.Count(x => !x.IsAlive);

            sb.AppendLine($"A fight happened:");
            sb.AppendLine($"Tommy live points: {mainPlayer.LifePoints}!");
            sb.AppendLine($"Tommy has killed: {deadCivilPlayersCount} players!");
            sb.AppendLine($"Left Civil Players: {civilPlayers.Count}!");

            return(sb.ToString());
        }