Пример #1
0
func (t *Table) ValidPlay(c *card.Card, playerIndex int) bool {
	player := t.players[playerIndex]
	if t.firstPlayed == playerIndex {
		if t.firstTrick == false {
			if c.GetSuit() != card.Heart || t.heartsBroken == true {
				return true
			} else {
				if player.HasSuit(card.Club) == false && player.HasSuit(card.Diamond) == false && player.HasSuit(card.Spade) == false {
					return true
				}
			}
		} else if c.GetSuit() == card.Club && c.GetNum() == 2 {
			return true
		}
	} else {
		firstPlayedSuit := t.trick[t.firstPlayed].GetSuit()
		if c.GetSuit() == firstPlayedSuit || player.HasSuit(firstPlayedSuit) == false {
			if t.firstTrick == false {
				return true
			} else if c.GetSuit() == card.Diamond || c.GetSuit() == card.Club || (c.GetSuit() == card.Spade && c.GetNum() != 12) {
				return true
			} else if player.HasAllPoints() == true {
				return true
			}
		}
	}
	return false
}
Пример #2
0
func (t *Table) PlayCard(c *card.Card, playerIndex int) {
	t.trick[playerIndex] = c
	if c.GetSuit() == card.Heart && t.heartsBroken == false {
		t.heartsBroken = true
	}
}