Exemplo n.º 1
0
        private async void Start()
        {
            if (_tempResultsFolder == null)
            {
                _tempResultsFolder = await ApplicationData.Current.TemporaryFolder.CreateFolderAsync("Results", CreationCollisionOption.OpenIfExists);

                _sourceHostConfigsFolder = await _expectedFolder.CreateFolderAsync("SourceHostConfigs", CreationCollisionOption.OpenIfExists);

                _sourceCardsFolder = await _expectedFolder.CreateFolderAsync("SourceCards", CreationCollisionOption.OpenIfExists);
            }

            CurrentCardVisual = null;

            // If no cards left
            if (RemainingCards.Count == 0)
            {
                RemainingHostConfigs.RemoveAt(0);

                // If also no host configs left, done
                if (RemainingHostConfigs.Count == 0)
                {
                    GoToDoneState();
                    return;
                }

                // Otherwise reset the cards and pop off the current host config
                foreach (var c in _originalCards)
                {
                    RemainingCards.Add(c);
                }
            }

            CurrentCard       = RemainingCards.First().Name;
            CurrentHostConfig = RemainingHostConfigs.First().Name;

            // Delay a bit to allow UI thread to update, otherwise user would never see an update
            await Task.Delay(10);

            var testResult = await TestCard(RemainingCards.First(), RemainingHostConfigs.First());

            Results.Add(testResult);

            RemainingCards.RemoveAt(0);

            // And start the process again
            Start();
        }
Exemplo n.º 2
0
        public void ProceedAfterVote()
        {
            try
            {
                if (CurrentRound.VoteResults.Result)
                {
                    //Update round:
                    CurrentRound.ElectChancellor();
                    if (FascistCardsOnBoard >= 3 && playersDict[CurrentRound.ChancellorId].Role == Role.Hitler)
                    {
                        CurrentRound.RoundState = RoundState.End;
                        GameResult = new GameResult()
                        {
                            Fascists    = Players.Where(p => p.Role != Role.Liberal).ToList(),
                            WinningTeam = CardType.Fascist,
                            Reason      = "Hitler elected after three fascit Cards Placed on Board"
                        };
                    }
                    else
                    {
                        if (RemainingCards.Count < 3)
                        {
                            DiscardedCards.Shuffle();
                            RemainingCards.AddRange(DiscardedCards);
                            DiscardedCards.Clear();
                        }
                        var cards = new List <Card>()
                        {
                            RemainingCards[0], RemainingCards[1], RemainingCards[2]
                        };
                        RemainingCards.RemoveRange(0, 3);
                        CurrentRound.PreparePresidentToDiscard(cards);
                    }
                }
                else
                {
                    CurrentRound.NbreOfFailedVotes++;
                    if (CurrentRound.NbreOfFailedVotes == 3)
                    {
                        if (RemainingCards.Count < 1)
                        {
                            DiscardedCards.Shuffle();
                            RemainingCards.AddRange(DiscardedCards);
                            DiscardedCards.Clear();
                        }
                        Card card = RemainingCards[0];

                        RemainingCards.RemoveAt(0);
                        CardsOnBoard.Add(card);

                        CurrentRound.NbreOfFailedVotes = 0;
                        MakeActionBeforeEnd();
                    }
                    else
                    {
                        MoveToNextTurn();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ProceedAfterVote.ex : " + ex.Message);
            }
        }