Пример #1
0
	public bool CanDrop(string cardsString) {
		TLMBCombination combination = new TLMBCombination(cardsString);

		if (combination.numCards != 1 && combination.type == (int)TLMBCombination.Type.NOTHING) {
			return false;
		}

		return true;
	}
Пример #2
0
	void Start () {
		TLMBCard card = new TLMBCard("3H");
		Debug.Log(card.ToString());

		TLMBCard card2 = new TLMBCard(36);
		Debug.Log(card2.ToString());

		TLMBCombination combination = new TLMBCombination("3S3H3D");
		Debug.Log(combination.ToCardString() + " " + combination.GetTypeName());
	}
Пример #3
0
    public bool CanDrop(string cardsString)
    {
        TLMBCombination combination = new TLMBCombination(cardsString);

        if (combination.numCards != 1 && combination.type == (int)TLMBCombination.Type.NOTHING)
        {
            return(false);
        }

        return(true);
    }
Пример #4
0
    void Start()
    {
        TLMBCard card = new TLMBCard("3H");

        Debug.Log(card.ToString());

        TLMBCard card2 = new TLMBCard(36);

        Debug.Log(card2.ToString());

        TLMBCombination combination = new TLMBCombination("3S3H3D");

        Debug.Log(combination.ToCardString() + " " + combination.GetTypeName());
    }
Пример #5
0
	public int Drop(TLMBCombination lastDroppedCards, string cardsString) {
		if (!hand.Contains(cardsString)) {
			return (int)ErrorCode.TLMB.CARDS_NOT_EXIST;
		} else if (!hand.CanDrop(cardsString)) {
			return (int)ErrorCode.TLMB.CANNOT_DROP;
		}

		if (lastDroppedCards == null || lastDroppedCards.IsEmpty() || 
			TLMBCombination.CanDefeat(new TLMBCombination(cardsString), lastDroppedCards)) {
			return (int)ErrorCode.TLMB.NULL;
		}

		return (int)ErrorCode.TLMB.CANNOT_DEFEAT;
	}
Пример #6
0
	public void Init(JSONObject jsonData) {
		roomId = jsonData.GetString("roomId");
		userGames.Clear();
		JSONArray userGameArray = jsonData.GetArray("userGames");

		for (int i = 0; i < userGameArray.Length; i++) {
			userGames.Add(new TLMBGame(userGameArray[i].Obj));
		}

		droppedCards = new TLMBCombination(jsonData.GetString("droppedCards"));
		roundDroppedCards = new TLMBCombination(jsonData.GetString("roundDroppedCards"));
		activeUserSeatIndex = jsonData.GetInt("activeUserSeatIndex");
		state = (State)jsonData.GetInt("state");
		gameConfig = new TLMBGameConfig(jsonData.GetObject("gameConfig"));
		remainingSeconds = jsonData.GetInt("remainingSeconds");
	}
Пример #7
0
    public void Init(JSONObject jsonData)
    {
        roomId = jsonData.GetString("roomId");
        userGames.Clear();
        JSONArray userGameArray = jsonData.GetArray("userGames");

        for (int i = 0; i < userGameArray.Length; i++)
        {
            userGames.Add(new TLMBGame(userGameArray[i].Obj));
        }

        droppedCards        = new TLMBCombination(jsonData.GetString("droppedCards"));
        roundDroppedCards   = new TLMBCombination(jsonData.GetString("roundDroppedCards"));
        activeUserSeatIndex = jsonData.GetInt("activeUserSeatIndex");
        state            = (State)jsonData.GetInt("state");
        gameConfig       = new TLMBGameConfig(jsonData.GetObject("gameConfig"));
        remainingSeconds = jsonData.GetInt("remainingSeconds");
    }
Пример #8
0
    public int Drop(TLMBCombination lastDroppedCards, string cardsString)
    {
        if (!hand.Contains(cardsString))
        {
            return((int)ErrorCode.TLMB.CARDS_NOT_EXIST);
        }
        else if (!hand.CanDrop(cardsString))
        {
            return((int)ErrorCode.TLMB.CANNOT_DROP);
        }

        if (lastDroppedCards == null || lastDroppedCards.IsEmpty() ||
            TLMBCombination.CanDefeat(new TLMBCombination(cardsString), lastDroppedCards))
        {
            return((int)ErrorCode.TLMB.NULL);
        }

        return((int)ErrorCode.TLMB.CANNOT_DEFEAT);
    }
Пример #9
0
 public static bool CanDefeat(TLMBCombination current, TLMBCombination previous)
 {
     return(current.CanDefeat(previous));
 }
Пример #10
0
    public bool CanDefeat(TLMBCombination another)
    {
        switch ((Type)another.type)
        {
        case Type.NOTHING:
            switch ((Type)type)
            {
            case Type.NOTHING:
                return(numCards == 1 && At(0).HasSameSuit(another.At(0)) && At(0).GetRank() > another.At(0).GetRank());

            default: return(type == (int)Type.TWO);
            }
            break;

        case Type.TWO:
            switch ((Type)type)
            {
            case Type.TWO: return(At(0).GetSuit() > another.At(0).GetSuit());

            case Type.QUAD:
            case Type.THREE_COUPLES:
            case Type.FOUR_COUPLES:
            case Type.FIVE_COUPLES:
            case Type.SIX_COUPLES:
                return(true);

            default: return(false);
            }
            break;

        case Type.COUPLE:
            switch ((Type)type)
            {
            case Type.COUPLE:
                if (another.hasTwoAdvantage)
                {
                    return(hasTwoAdvantage && At(1).GetSuit() == (int)Card.Suit.HEART);
                }
                else
                {
                    return(hasTwoAdvantage || (At(0).HasSameColor(another.At(0)) && At(0).GetRank() > another.At(0).GetRank()));
                }
                break;

            case Type.QUAD: return(another.hasTwoAdvantage && hasAceAdvantage);

            case Type.FOUR_COUPLES:
            case Type.FIVE_COUPLES:
            case Type.SIX_COUPLES:
            case Type.DOUBLE_QUAD:
                return(another.hasTwoAdvantage);

            default: return(false);
            }
            break;

        case Type.TRIPLE:
            return(type == (int)Type.TRIPLE && At(0).GetRank() > another.At(0).GetRank() &&
                   At(0).GetSuit() == another.At(0).GetSuit() && At(1).GetSuit() == another.At(1).GetSuit() &&
                   At(2).GetSuit() == another.At(2).GetSuit());

        case Type.QUAD:
            return(type == (int)Type.QUAD && At(0).GetRank() > another.At(0).GetRank());

        case Type.STRAIGHT:
            return(type == (int)Type.STRAIGHT && numCards >= another.numCards &&
                   At(0).GetSuit() == another.At(0).GetSuit() && At(0).GetRank() > another.At(another.numCards - 1).GetRank());

        case Type.THREE_COUPLES:
            return(type == (int)Type.THREE_COUPLES && At(0).HasSameColor(another.At(0)) && At(0).GetRank() > another.At(0).GetRank());

        case Type.DOUBLE_QUAD:
            return(type == (int)Type.DOUBLE_QUAD && At(0).GetRank() > another.At(0).GetRank() && At(4).GetRank() > another.At(4).GetRank());

        default:
            return(false);
        }
    }
Пример #11
0
	public static bool CanDefeat(TLMBCombination current, TLMBCombination previous) {
		return current.CanDefeat(previous);
	}
Пример #12
0
	public bool CanDefeat(TLMBCombination another) {
		switch ((Type)another.type) {
			case Type.NOTHING:
				switch ((Type)type) {
					case Type.NOTHING:
						return numCards == 1 && At(0).HasSameSuit(another.At(0)) && At(0).GetRank() > another.At(0).GetRank();
					default: return type == (int)Type.TWO;
				}
			break;
			case Type.TWO:
				switch ((Type)type) {
					case Type.TWO: return At(0).GetSuit() > another.At(0).GetSuit();
					case Type.QUAD:
					case Type.THREE_COUPLES:
					case Type.FOUR_COUPLES:
					case Type.FIVE_COUPLES:
					case Type.SIX_COUPLES:
						return true;
					default: return false;
				}
			break;
			case Type.COUPLE:
				switch ((Type)type) {
					case Type.COUPLE:
						if (another.hasTwoAdvantage) {
							return hasTwoAdvantage && At(1).GetSuit() == (int)Card.Suit.HEART;
						} else {
							return hasTwoAdvantage || (At(0).HasSameColor(another.At(0)) && At(0).GetRank() > another.At(0).GetRank());
						}
					break;
					case Type.QUAD: return another.hasTwoAdvantage && hasAceAdvantage;
					case Type.FOUR_COUPLES:
					case Type.FIVE_COUPLES:
					case Type.SIX_COUPLES:
					case Type.DOUBLE_QUAD:
						return another.hasTwoAdvantage;
					default: return false;
				}
			break;
			case Type.TRIPLE:
				return type == (int)Type.TRIPLE && At(0).GetRank() > another.At(0).GetRank() &&
						At(0).GetSuit() == another.At(0).GetSuit() && At(1).GetSuit() == another.At(1).GetSuit() && 
						At(2).GetSuit() == another.At(2).GetSuit();
			case Type.QUAD:
				return type == (int)Type.QUAD && At(0).GetRank() > another.At(0).GetRank();
			case Type.STRAIGHT:
				return type == (int)Type.STRAIGHT && numCards >= another.numCards && 
						At(0).GetSuit() == another.At(0).GetSuit() && At(0).GetRank() > another.At(another.numCards - 1).GetRank();
			case Type.THREE_COUPLES:
				return type == (int)Type.THREE_COUPLES && At(0).HasSameColor(another.At(0)) && At(0).GetRank() > another.At(0).GetRank();
			case Type.DOUBLE_QUAD:
				return type == (int)Type.DOUBLE_QUAD && At(0).GetRank() > another.At(0).GetRank() && At(4).GetRank() > another.At(4).GetRank();
			default:
				return false;
		}

	}