public void LaunchGame()
        {
            var playerCount = PlayerCount;
            var fascistCount = playerCount % 2 == 0 ? playerCount / 2 - 1 : playerCount / 2;
            var liberalCount = playerCount - fascistCount;

            //Generate Decks

            PlayerHand[] decks = new PlayerHand[playerCount];
            var j = 0;
            for (var i = 0; i < fascistCount; i++, j++)
                decks[j] = new PlayerHand(new CardSecretRoleFascist(i), new CardMembershipFascist());
            for (var i = 0; i < liberalCount; i++, j++)
                decks[j] = new PlayerHand(new CardSecretRoleLiberal(i), new CardMembershipLiberal());

            Player hitler = null;
            var fascists = new List<Player>();
            //Shuffle and hand out decks
            decks.Shuffle();
            var sendMsgs = new ServerResponse();
            StartGame();
            for (var i = 0; i < playerCount; i++)
            {
                var player = SeatedPlayers[i];
                player.Dead = false;
                player.Hand = decks[i];
                var sendToPlayer = new NetworkCardObject(ServerCommands.AnnounceCard, decks[i].Membership, decks[i].Role, decks[i].Yes, decks[i].No);
                if (decks[i].Role.IsFascist)
                    fascists.Add(player);
                if (decks[i].Role.IsHitler)
                    hitler = player;
                sendMsgs.AddObject(sendToPlayer, player);
                //Announce decks to player
            }
            var rand = new Random(Environment.TickCount * 5);
            var president = SeatedPlayers[rand.Next(playerCount)];
            SetPresident(president);
            var presidentMsg = new NetworkPlayerObject(ServerCommands.AnnouncePresident, president);
            sendMsgs.AddObject(presidentMsg);
            //Announce Fascists to other party members
            for (var i = 0; i < playerCount; i++)
            {
                var player = SeatedPlayers[i];
                if (player.Hand.Membership.IsFascist && (playerCount <= 6 || !player.Hand.Role.IsHitler))
                    foreach (Player announcePlayer in fascists)
                        if (player != announcePlayer)
                            sendMsgs.AddObject(new NetworkRevealRoleObject(announcePlayer), player);
            }
            Server.SendResponse(sendMsgs);
            FascistActions = FascistAction.GetActionsForPlayers(playerCount);
        }
Exemple #2
0
        private void DefineLocations(PlayerHand hand)
        {
            int yLoc = Location.Y + Size.Height - Card.DEFAULTCARDSIZE.Height;
            int xSpacing = (Size.Width - Card.DEFAULTCARDSIZE.Width * 4) / 3 + Card.DEFAULTCARDSIZE.Width;
            hand.Membership.Location = new Point(Location.X, yLoc);
            hand.Role.Location = new Point(Location.X + xSpacing, yLoc);
            hand.Yes.Location = new Point(Location.X + xSpacing * 2, yLoc);
            hand.No.Location = new Point(Location.X + xSpacing * 3, yLoc);

            CurrentPlacardLoc = new Point(Location.X, Location.Y);
            PreviousPlacardLoc = new Point(Location.X + Size.Width - Placard.DEFAULTSIZE.Width, Location.Y);
            if (ID <= 3)
                rotateType = RotateType.None;
            else if (ID <= 7)
                rotateType = RotateType.Half;
            else if (ID == 8)
                rotateType = RotateType.Left;
            else //9
                rotateType = RotateType.Right;

        }
Exemple #3
0
 private Player(string name)
 {
     Name = name;
     Hand = new PlayerHand(new CardSecretRoleUnknown() { Flipped = true }, new CardMembershipUnknown() { Flipped = true}, true);
 }