コード例 #1
0
ファイル: Game.cs プロジェクト: bsguedes/ItsLunchTime
        private void ChooseRestaurant(DayOfWeek day)
        {
            List <PreferenceHistogram> last = null;

            for (int i = 0; i < 3; i++)
            {
                List <PreferenceHistogram> curr = new List <PreferenceHistogram>();
                foreach (PlayerBase player in this.Players)
                {
                    PreferenceHistogram pref = player.GetPreferenceHistogram(this.PublicBoard, i, last == null ? last : last.Where(x => x.Player != player));
                    pref.Player = player;
                    curr.Add(pref);
                }
                last = curr;
            }
            foreach (PreferenceHistogram pref in last)
            {
                Place choice = pref.Preferences.First(x => x.Value == pref.Preferences.Values.Max()).Key;
                if (!(choice is Home) && PublicBoard.RestaurantHasModifierForThisDay <Closed>((choice as RestaurantPlace).Identifier, day))
                {
                    throw new InvalidRestaurantException();
                }
                if (!(choice is Home))
                {
                    int cost = choice.Cost;
                    cost += PublicBoard.RestaurantHasModifierForThisDay <OneDollarIncrease>((choice as RestaurantPlace).Identifier, day) ? 1 : 0;
                    cost += PublicBoard.RestaurantHasModifierForThisDay <OneDollarDiscount>((choice as RestaurantPlace).Identifier, day) ? -1 : 0;
                    if (cost > PublicBoard.PlayerCash[pref.Player])
                    {
                        choice = PublicBoard.Home;
                    }
                }
                this.PublicBoard.VisitPlace(pref.Player, day, choice);
            }
        }
コード例 #2
0
ファイル: Game.cs プロジェクト: bsguedes/ItsLunchTime
 private void PayForLunchAndSetMarkers(DayOfWeek day)
 {
     foreach (PlayerBase player in Players)
     {
         int   cost         = 0;
         Place visitedPlace = PublicBoard.VisitedPlaces[player][day];
         if (visitedPlace is RestaurantPlace)
         {
             RestaurantPlace restaurant = visitedPlace as RestaurantPlace;
             if (PublicBoard.RestaurantHasModifierForThisDay <OneDollarIncrease>(restaurant.Identifier, day))
             {
                 cost++;
             }
             if (PublicBoard.RestaurantHasModifierForThisDay <OneDollarDiscount>(restaurant.Identifier, day))
             {
                 cost--;
             }
             cost += restaurant.Cost;
             if (cost >= 4 && player.Character == Character.CEO)
             {
                 cost--;
             }
         }
         PublicBoard.AddCashToPlayer(-cost, player);
     }
     ;
 }
コード例 #3
0
ファイル: Game.cs プロジェクト: bsguedes/ItsLunchTime
 private void ScoreDailyModifiers(DayOfWeek day)
 {
     foreach (Restaurant restaurant in Extensions.Restaurants)
     {
         if (PublicBoard.RestaurantHasModifierForThisDay <OneTeamPointIfMajority>(restaurant, day) && PublicBoard.HasMajority(day))
         {
             PublicBoard.AddTeamScore(1);
         }
         if (PublicBoard.RestaurantHasModifierForThisDay <OneVictoryPointBonus>(restaurant, day))
         {
             foreach (PlayerBase player in PublicBoard.Restaurants[restaurant].Visitors[day])
             {
                 PublicBoard.AddVictoryPointsToPlayer(1, player, VictoryPointsSource.DailyModifier);
             }
         }
     }
 }
コード例 #4
0
ファイル: Game.cs プロジェクト: bsguedes/ItsLunchTime
 private void AdvanceRestaurantTracks(DayOfWeek day)
 {
     foreach (PlayerBase player in this.Players)
     {
         Place place = PublicBoard.VisitedPlaces[player][day];
         if (place is RestaurantPlace &&
             !PublicBoard.RestaurantHasModifierForThisDay <DoesNotAdvanceTrackPlus2VictoryPoints>((place as RestaurantPlace).Identifier, day))
         {
             if (this.PublicBoard.RestaurantTracks[(place as RestaurantPlace).Identifier].AdvancePlayer(player))
             {
                 List <DessertCard> cards           = new List <DessertCard>();
                 List <int>         chosenCardIndex = player.ChooseDessert(this.PublicBoard, this.DessertBuffet.TakeChoices(this.PublicBoard.RestaurantTracks[(place as RestaurantPlace).Identifier].CardAmount), 1);
                 List <DessertCard> chosenCards     = this.DessertBuffet.RemoveDessertAtIndexes(chosenCardIndex);
                 _dessertCards[player].AddRange(chosenCards);
             }
         }
         else if (place is RestaurantPlace && PublicBoard.RestaurantHasModifierForThisDay <DoesNotAdvanceTrackPlus2VictoryPoints>((place as RestaurantPlace).Identifier, day))
         {
             PublicBoard.AddVictoryPointsToPlayer(2, player, VictoryPointsSource.DailyModifier);
         }
     }
 }