Beispiel #1
0
        public string Fight()
        {
            IPlayer mainPlayer = this.players.FirstOrDefault(p => p.Name == "Tommy Vercetti");

            List <IPlayer> civilPlayers = this.players
                                          .Where(p => p.GetType().Name != nameof(MainPlayer))
                                          .ToList();

            neighbourhood.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());
        }
        public string Fight()
        {
            var mainPlayerPointsAtBegining   = mainPlayer.LifePoints;
            var civilPlayersPointsAtBegining = civilPlayers.Sum(x => x.LifePoints);

            gangNeighbourhood.Action(mainPlayer, civilPlayers);

            var civilPlayersPointsAtTheEnd = civilPlayers.Sum(x => x.LifePoints);

            if (mainPlayerPointsAtBegining == mainPlayer.LifePoints && civilPlayersPointsAtBegining == civilPlayersPointsAtTheEnd)
            {
                return("Everything is okay!");
            }

            var deadCivilPlayers = civilPlayers.Where(x => !x.IsAlive).ToList().Count;
            var leftCivilPlayers = civilPlayers.Where(x => x.IsAlive).ToList().Count;

            return("A fight happened:"
                   + Environment.NewLine
                   + $"Tommy live points: {mainPlayer.LifePoints}!"
                   + Environment.NewLine
                   + $"Tommy has killed: {deadCivilPlayers} players!"
                   + Environment.NewLine
                   + $"Left Civil Players: {leftCivilPlayers}!");
        }
Beispiel #3
0
        public string Fight()
        {
            int civilPlayersCount = this.players.Count;

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

            if (somethingCanHappen)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("A fight happened:");
                sb.AppendLine($"Tommy live points: {mainPlayer.LifePoints}!");
                int tommyKills = civilPlayersCount - this.players.Count;
                sb.AppendLine($"Tommy has killed: {tommyKills} players!");
                sb.AppendLine($"Left Civil Players: {this.players.Count}!");

                return(sb.ToString().TrimEnd());
            }
            else
            {
                return("Everything is okay!");
            }
        }
        public string Fight()
        {
            neighbourhood.Action(mainPlayer, civilPlayers);

            var deadCivils  = this.civilPlayers.Where(p => p.IsAlive == false);
            var aliveCivils = this.civilPlayers.Where(p => p.IsAlive == true);

            if (deadCivils.Count() == 0 && mainPlayer.LifePoints == 100)
            {
                return("Everything is okay!");
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("A fight happened:");
                sb.AppendLine($"Tommy live points: {this.mainPlayer.LifePoints}!");
                sb.AppendLine($"Tommy has killed: {deadCivils.Count()} players!");
                sb.Append($"Left Civil Players: {aliveCivils.Count()}!");

                return(sb.ToString());
            }
        }
Beispiel #5
0
        public string Fight()
        {
            StringBuilder result            = new StringBuilder();
            int           mainPlayerLP      = main.LifePoints;
            int           civilsTotalHealth = civils.Sum(x => x.LifePoints);
            int           civilsBefore      = civils.Count;

            neighourhood.Action(main, civils);
            int mainPlayerLPAfter = main.LifePoints;

            if (mainPlayerLP == mainPlayerLPAfter && civilsTotalHealth == civils.Sum(x => x.LifePoints))
            {
                return(result.AppendLine("Everything is okay").ToString().TrimEnd());
            }
            else
            {
                result.AppendLine("A fight happened:");
                result.AppendLine($"Tommy live points: {main.LifePoints}!");
                result.AppendLine($"Tommy has killed: {civilsBefore - civils.Count} players!");
                result.AppendLine($"Left Civil Players: {civils.Count}!");
            }

            return(result.ToString().TrimEnd());
        }