private void AnalyzeRules()
        {
            int extraAmount   = _gameContainer !.IncreaseAmount();
            int possibleBonus = extraAmount + 1;

            if (_gameContainer.SaveRoot !.RuleList.Any(items => items.Deck == EnumRuleText.PoorBonus))
            {
                if (_gameContainer.SaveRoot.DrawBonus < possibleBonus && _gameContainer.HasFewestKeepers())
                {
                    _gameContainer.SaveRoot.DrawBonus = possibleBonus;
                }
            }
            if (_gameContainer.SaveRoot.RuleList.Any(items => items.Deck == EnumRuleText.RichBonus))
            {
                if (_gameContainer.SaveRoot.PlayBonus < possibleBonus && _gameContainer.HasMostKeepers())
                {
                    _gameContainer.SaveRoot.PlayBonus = possibleBonus;
                }
            }
            RuleCard thisRule;

            thisRule = _gameContainer.SaveRoot.RuleList.Where(items => items.Category == EnumRuleCategory.Draw).SingleOrDefault();
            if (thisRule == null)
            {
                _gameContainer.SaveRoot.DrawRules = possibleBonus;
            }
            else
            {
                if (thisRule.HowMany == 0)
                {
                    throw new BasicBlankException("Cannot be 0");
                }
                _gameContainer.SaveRoot.DrawRules = extraAmount + thisRule.HowMany;
            }
            thisRule = _gameContainer.SaveRoot.RuleList.Where(items => items.Category == EnumRuleCategory.Play).SingleOrDefault();
            if (thisRule == null)
            {
                _gameContainer.SaveRoot.PlayLimit = possibleBonus;
            }
            else if (thisRule.HowMany == -1)
            {
                _gameContainer.SaveRoot.PlayLimit = -1; //means unlimited.
            }
            else
            {
                if (thisRule.HowMany == 0)
                {
                    throw new BasicBlankException("Cannot be 0");
                }
                _gameContainer.SaveRoot.PlayLimit = extraAmount + thisRule.HowMany;
            }
            thisRule = _gameContainer.SaveRoot.RuleList.Where(items => items.Category == EnumRuleCategory.Hand).SingleOrDefault();
            if (thisRule == null)
            {
                _gameContainer.SaveRoot.HandLimit = -1; //means unlimited
            }
            else
            {
                _gameContainer.SaveRoot.HandLimit = extraAmount + thisRule.HowMany;
            }
            thisRule = _gameContainer.SaveRoot.RuleList.Where(items => items.Category == EnumRuleCategory.Keeper).SingleOrDefault();
            if (thisRule == null)
            {
                _gameContainer.SaveRoot.KeeperLimit = -1; //means unlimited
            }
            else
            {
                _gameContainer.SaveRoot.KeeperLimit = extraAmount + thisRule.HowMany;
            }
            if (_gameContainer.SaveRoot.PlayLimit == -1)
            {
                _gameContainer.SaveRoot.PlaysLeft = _gameContainer.SingleInfo !.MainHandList.Count;
            }
            else
            {
                _gameContainer.SaveRoot.PlaysLeft = _gameContainer.SaveRoot.PlayLimit + _gameContainer.SaveRoot.PlayBonus - _gameContainer.SaveRoot.CardsPlayed;
            }
            if (_gameContainer.SaveRoot.PlaysLeft < 0)
            {
                _gameContainer.SaveRoot.PlaysLeft = 0;
            }
            if (_gameContainer.SaveRoot.PlaysLeft > _gameContainer.SingleInfo !.MainHandList.Count)
            {
                _gameContainer.SaveRoot.PlaysLeft = _gameContainer.SingleInfo.MainHandList.Count;
            }
            _gameContainer.LeftToDraw = ExtraCardsToDraw();
            if (_gameContainer.LeftToDraw > 0)
            {
                _gameContainer.SaveRoot.CardsDrawn += _gameContainer.LeftToDraw;
            }
        }
Beispiel #2
0
 private bool CanExecuteCheck(object state)
 {
     return(RuleList.Any(x => x.IsSelected));
 }