Exemplo n.º 1
0
        private bool CanPlayCard(Game game, DrawCardEvent drawEvent, int playerTeamIndex, int targetTeamIndex)
        {
            if (targetTeamIndex == 0)
            {
                return true;
            }

            var targetTeamState = GetTeamState(game, targetTeamIndex);
            var card = CardDefinitions.Cards
                .Single(cd => cd.CardId == drawEvent.CardIndex);

            switch (card.CardType)
            {
                case CardType.VALUE:
                {
                    if (playerTeamIndex != targetTeamIndex)
                    {
                        return false;
                    }

                    if (targetTeamState.CanGo && !targetTeamState.CurrentlyBrokenDown)
                    {
                        bool canPlayCard = true;
                        if (targetTeamState.IsUnderSpeedLimit)
                        {
                            canPlayCard = card.Value <= 50;
                        }

                        if (!canPlayCard)
                        {
                            return false;
                        }

                        return (targetTeamState.DistanceTraveled + card.Value) <= 1000;
                    }
                    else
                    {
                        return false;
                    }
                }
                case CardType.EFFECT_POSITIVE:
                {
                    if (playerTeamIndex != targetTeamIndex)
                    {
                        return false;
                    }

                    switch (card.EffectType)
                    {
                        case EffectCardType.ACCIDENT:
                        {
                            return targetTeamState.HasAccident;
                        }
                        case EffectCardType.FUEL:
                        {
                            return targetTeamState.IsOutOfFuel;
                        }
                        case EffectCardType.TIRE:
                        {
                            return targetTeamState.HasFlatTire;
                        }
                        case EffectCardType.SPEED_LIMIT:
                        {
                            return targetTeamState.IsUnderSpeedLimit;
                        }
                        case EffectCardType.TRAFFIC_LIGHT:
                        {
                            return !targetTeamState.CanGo && !targetTeamState.CurrentlyBrokenDown;
                        }
                        case EffectCardType.NONE:
                        default:
                        {
                            return false;
                        }
                    }
                }
                case CardType.EFFECT_NEGATIVE:
                {
                    if (playerTeamIndex == targetTeamIndex)
                    {
                        return false;
                    }

                    switch (card.EffectType)
                    {
                        case EffectCardType.ACCIDENT:
                        {
                            return !targetTeamState.CurrentlyBrokenDown &&
                                !targetTeamState.InvincibleToAccidents;
                        }
                        case EffectCardType.FUEL:
                        {
                            return !targetTeamState.CurrentlyBrokenDown &&
                                !targetTeamState.InvincibleToFuel;
                        }
                        case EffectCardType.TIRE:
                        {
                            return !targetTeamState.CurrentlyBrokenDown &&
                                !targetTeamState.InvincibleToTire;
                        }
                        case EffectCardType.SPEED_LIMIT:
                        {
                            return !targetTeamState.IsUnderSpeedLimit &&
                                !targetTeamState.InvinciblePriority;
                        }
                        case EffectCardType.TRAFFIC_LIGHT:
                        {
                            return targetTeamState.CanGo &&
                                !targetTeamState.InvinciblePriority;
                        }
                        case EffectCardType.NONE:
                        default:
                        {
                            return false;
                        }
                    }
                }
                case CardType.EFFECT_INVINCIBLE:
                {
                    switch (card.EffectType)
                    {
                        case EffectCardType.ACCIDENT:
                        {
                            return !targetTeamState.InvincibleToAccidents;
                        }
                        case EffectCardType.FUEL:
                        {
                            return !targetTeamState.InvincibleToFuel;
                        }
                        case EffectCardType.TIRE:
                        {
                            return !targetTeamState.InvincibleToTire;
                        }
                        case EffectCardType.SPEED_LIMIT | EffectCardType.TRAFFIC_LIGHT:
                        {
                            return !targetTeamState.InvinciblePriority;
                        }
                        case EffectCardType.NONE:
                        default:
                        {
                            return false;
                        }
                    }
                }
                default:
                {
                    return false;
                }
            }
        }
Exemplo n.º 2
0
        private void PlayCardInGame(Game game, DrawCardEvent drawEvent, int targetTeamIndex)
        {
            game.GameEvent.Add(new PlayCardEvent()
            {
                ServerEvent = false,
                Date = DateTime.UtcNow,
                Type = GameEventType.PLAY_CARD,

                TargetTeamIndex = targetTeamIndex,
                DrawCardEventId = drawEvent.GameEventId
            });
        }