Ejemplo n.º 1
0
        public bool CanPlayEvolvedVirus(BodyItem item, Card virus)
        {
            if (item.Organ.Color == Card.CardColor.Bionic)
            {
                return(false);
            }

            // Same color of organn (or wildcard) and medicine of the same color of the mediccine (or wildcard)
            if (Referee.SameColorOrWildcard(item.Organ.Color, virus.Color) ||
                (item.Status == BodyItem.State.Vaccinated &&
                 Referee.SameColorOrWildcard(item.Modifiers[0].Color, virus.Color)))
            {
                switch (item.Status)
                {
                case BodyItem.State.Free:
                case BodyItem.State.Vaccinated:
                case BodyItem.State.Infected:
                    return(true);

                default:
                    return(false);
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        public bool CanPlayEvolvedMedicine(BodyItem item, Card medicine)
        {
            if (item.Organ.Color == Card.CardColor.Bionic)
            {
                return(false);
            }

            if (Referee.SameColorOrWildcard(item.Organ.Color, medicine.Color) ||
                (item.Status == BodyItem.State.Infected &&
                 Referee.SameColorOrWildcard(item.Modifiers[0].Color, medicine.Color)))
            {
                switch (item.Status)
                {
                case BodyItem.State.Free:
                case BodyItem.State.Vaccinated:
                    return(true);

                case BodyItem.State.Infected:
                    return(true);

                default:
                    return(false);
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
        public void PlayQuarantine(Player player, string move)
        {
            BodyItem item  = player.Body.Items[Scheduler.GetStringInt(move, 2)];
            Card     virus = item.Modifiers[0];

            item.Modifiers.Remove(virus);

            WriteToLog(player.Nickname + " has set in quarantine the " + virus + " that belonged to his " + item.ToString());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets a string overview of the game.
        /// </summary>
        /// <returns>String overview of the game.</returns>
        public override string ToString()
        {
            string res = String.Empty;

            res += "+------------+------------+----------------+-------------------------------+" + Environment.NewLine;

            res += String.Format("| #Turn: {0,3} | #Deck: {1,3} | #Discards: {2,3} | #Total Cards: {3,3}             |",
                                 Turn, Deck.Count, Discards.Count, TotalCardsInGame.Count) + Environment.NewLine;
            res += "+------------+------------+----------------+-------------------------------+" + Environment.NewLine;


            for (int x = 0; x < Players.Count; x++)
            {
                Player p = Players[x];

                res += String.Format("| {0,10} | {1,20} | AI: {2,11} | Body Pts: <{3,6}> |",
                                     (CurrentTurn == x ? "<My Turn>" : ""),
                                     p.Nickname,
                                     p.AI.ToString(),
                                     p.Body.Points) + Environment.NewLine;

                for (int y = 0; y < p.Body.Items.Count; y++)
                {
                    BodyItem item = p.Body.Items[y];
                    res += String.Format("| {0,1}.         | ", (y + 1));

                    if (item.Status == BodyItem.State.Immunized)
                    {
                        res += "[+] ";
                    }
                    else
                    {
                        res += "    ";
                    }

                    res += String.Format("{0,14}: ", item.Organ.ToString());
                    res += item.GetModifiers();

                    int padd = (5 * item.Modifiers.Count);

                    while (padd < 29)
                    {
                        res += " ";
                        padd++;
                    }

                    res += String.Format("  +={0,6} |", item.Points) + Environment.NewLine;
                }


                res += "+------------+-------------------------------------------------------------+" + Environment.NewLine;
            }

            return(res);
        }
Ejemplo n.º 5
0
        public void SetEvolvedVirus(Card virus, int index, Game game)
        {
            BodyItem item = Items[index];

            string message = item.NewEvolvedVirus(virus, game);

            // if when we added the virus, the body item has more than one virus, we have to
            // remove them from the whole body.
            if (message != null && message.Equals(BodyItem.RULE_DELETEBODY))
            {
                Items.Remove(item);
                game.WriteToLog("The " + item + " has been removed from the body.");
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Steal one body item to one player.
        /// </summary>
        /// <param name="me">Player to receive the new body item</param>
        /// <param name="move">Move that indicates who and what to steal</param>
        /// <returns>Error message if there is</returns>
        public void PlayOrganThief(Player me, Card myCard, string move, List <string> wholemoves)
        {
            try
            {
                if (!ProtectiveSuitScenario(me, myCard, move, wholemoves))
                {
                    Player   rival  = Players[Scheduler.GetStringInt(move, 0)];
                    BodyItem stolen = rival.Body.Items[Scheduler.GetStringInt(move, 2)];
                    rival.Body.Items.Remove(stolen);

                    me.Body.Items.Add(stolen);

                    WriteToLog(me.Nickname + " has stolen the " + rival.Nickname + "'s organ " + stolen);
                }
            }
            catch (Exception)
            {}
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates a new body item if the body doesn't contain a body item of the appropiate color.
        /// </summary>
        /// <param name="organ">Card of the organ.</param>
        /// <returns>String with the error message if it couldn't be added. Null in other case.</returns>
        public bool SetOrgan(Card organ)
        {
            if (HaveThisOrgan(organ.Color))
            {
                return(false);
            }
            else
            {
                BodyItem item = new BodyItem(organ);
                if (organ.Color == Card.CardColor.Wildcard)
                {
                    // A Wildcard organ could substitute anyone. It's better valued.
                    item.Points += (Scheduler.POINTS_ORGAN / 5);
                }
                if (organ.Color == Card.CardColor.Bionic)
                {
                    item.Points += (Scheduler.POINTS_ORGAN / 4);
                }
                Items.Add(item);

                return(true);
            }
        }
Ejemplo n.º 8
0
        public void PrintCurrentGameState()
        {
            /*int j = 1;
             * foreach (var p in TopPlayers())
             * {
             *  Console.Write("[" + j + "][" + String.Format("{0,20}", p.ShortDescription) + "]" + Environment.NewLine);
             *  j++;
             * }
             * Console.Write(Environment.NewLine);*/

            Console.Write("+------------+------------+----------------+-------------------------------+" + Environment.NewLine);

            Console.Write(String.Format("| #Turn: {0,3} | #Deck: {1,3} | #Discards: {2,3} | #Total Cards: {3,3}             |",
                                        Turn, Deck.Count, Discards.Count, TotalCardsInGame.Count) + Environment.NewLine);
            Console.Write("+------------+------------+----------------+-------------------------------+" + Environment.NewLine);


            for (int x = 0; x < Players.Count; x++)
            {
                Player p = Players[x];

                ConsoleColor f = (CurrentTurn == x ? ConsoleColor.Yellow : ConsoleColor.White);

                Scheduler.ChangeConsoleOutput(foreground: f);

                Console.Write(String.Format("| {0,10} | {1,20} | AI: {2,11} | Body Pts: <{3,6}> |",
                                            (CurrentTurn == x ? "<My Turn>"  : ""),
                                            p.Nickname,
                                            p.AI.ToString(),
                                            p.Body.Points) + Environment.NewLine);

                for (int y = 0; y < p.Body.Items.Count; y++)
                {
                    BodyItem item = p.Body.Items[y];
                    //printed += "+------------+------------+----------------+-------------------------------+" + Environment.NewLine;
                    Console.Write(String.Format("| {0,1}.         | ", (y + 1)));


                    if (item.Status == BodyItem.State.Immunized)
                    {
                        Console.Write("[+] ");
                    }
                    else
                    {
                        Console.Write("    ");
                    }

                    Scheduler.ChangeConsoleOutput(item.Organ.Color);
                    Console.Write(String.Format("{0,14}: ", item.Organ.ToString()));


                    item.PrintModifiers();
                    Scheduler.ChangeConsoleOutput(foreground: f);

                    int padd = (5 * item.Modifiers.Count);

                    Scheduler.ChangeConsoleOutput(foreground: f);
                    while (padd < 29)
                    {
                        Console.Write(" ");
                        padd++;
                    }

                    Console.Write(String.Format("  +={0,6} |", item.Points) + Environment.NewLine);
                }


                Console.Write("+------------+-------------------------------------------------------------+" + Environment.NewLine);

                Scheduler.ChangeConsoleOutput();
            }
        }