public int FindMatch(MemoryCard card) { if (CardMemoryList.Contains(card)) { return(-1); } for (int i = 0; i < CardMemoryList.Count; i++) { // if the cards are different // AND they have the same value, return and forget if (CardMemoryList[i].Value == card.Value) { int match = CardMemoryList[i].Index; AIDebug.PlayLog(this.Name + " - Found from memory " + match + "(" + card.Value + ")"); Forget(card.Value); return(match); } } return(-1); }
public void Forget(int index) { for (int i = 0; i < card_memory_list.Count; i++) { if (CardMemoryList[i].Index == index) { CardMemoryList.RemoveAt(i); AIDebug.PlayLog(this.Name + " - Forgot Card " + index); return; } } }
public void Memorize(MemoryCard card) { // return if the memory is full if (card_memory_list.Count >= MemMax) { return; } if (CardMemoryList.Contains(card)) { return; } AIDebug.PlayLog(this.Name + " - Memorized Card " + card.Index); CardMemoryList.Add(card); }