Example #1
0
File: Game.cs Project: TomasMike/TG
        public void DuringDay()
        {
            // if all passed go to end of day
            if (playersWhoPassedThisDay.Count == Players.Count)
            {
                TGLogger.LogToConsole("All players passed. Jumping to end of day phase.");
                EndOfDay();
            }
            else
            {
                Round++;

                if (Players.Count > 1)
                {
                    // ries kto bol toto kolo, ked vsetci zacni dalsie kolo a kto passol uz
                    var possiblePlayersToBeActivePlayer = Players.Select(_ => _.PlayerNumber).ToList();
                    possiblePlayersToBeActivePlayer.RemoveAll(_ => playersWhoActedThisRound.Contains(_));
                    possiblePlayersToBeActivePlayer.RemoveAll(_ => playersWhoPassedThisDay.Contains(_));

                    if (possiblePlayersToBeActivePlayer.Count == 0)
                    {
                        //next round
                        playersWhoActedThisRound.Clear();
                        TGLogger.LogToConsole("All players who didnt pass, acted this round. Next round starts.");
                        DuringDay();
                        return;
                    }
                    else if (possiblePlayersToBeActivePlayer.Count == 1)
                    {
                        Instance.ActivePlayerNumber = possiblePlayersToBeActivePlayer[0];
                        TGLogger.LogToConsole($"{Instance.ActivePlayerNumber} is the last player who didnt act this round, hes the active player now.");
                    }
                    else
                    {
                        Instance.ActivePlayerNumber =
                            Asker.Ask(
                                "Who will be next active player?",
                                possiblePlayersToBeActivePlayer.Select(_ => new Option <PlayerNumber>(_))).InnerOption;
                    }
                    //
                }
                else
                {
                    //singleplayer
                    Instance.ActivePlayerNumber = PlayerNumber.Player1;
                    //MessageBox.Show("SinglePlayer");
                }
                _MainForm.Instance.Text = $"Active Player:{Instance.ActivePlayer.Name}";
                StartNextPlayerTurn();
            }
        }
Example #2
0
        public static void StartExploration(ExplorationScenario scenario)
        {
            Action <ScenarioParagraph> loop = null;

            loop = (par) =>
            {
                ParagraphOption pickedParagraphOption;

                if (par.ForcedOptions?.Any(_ => _.Check(null)) ?? false)
                {
                    MessageBox.Show(par.Text + (string.IsNullOrEmpty(par.AdditionalText) ? "" : "\r\n" + par.AdditionalText));

                    var fo = par.ForcedOptions.First(_ => _.Check(null));
                    if (fo is ForceScenarioParagraphForcedOption)
                    {
                        pickedParagraphOption = par.ParagraphOptions
                                                .First(_ => _.ParagraphNumToRedirectToAfter == ((ForceScenarioParagraphForcedOption)fo).RedirectToParagraphNum);
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }
                else
                {
                    //par.PreParagraphChoiceEffect?.

                    //if ()
                    pickedParagraphOption = Asker.Ask(par.Text, par.ParagraphOptions
                                                      .Where(po => po.OptionCondition == null ? true : po.OptionCondition(GetEventArgs)));
                }

                var nextParagraph = pickedParagraphOption.ParagraphNumToRedirectToAfter;

                if (nextParagraph == -1)
                {
                    //end
                }
                else
                {
                    loop(nextParagraph == 0 ? scenario.IntroParagraph : scenario.Options.First(_ => _.VerseNumber == nextParagraph));
                }
            };

            loop(scenario.IntroParagraph);
        }