blob: 7ca3469cf5e2774e3fc243e258315e36aa430875 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#include "pile.h"
#include <kdebug.h>
bool Pile::add_klondikeTarget( const CardList& c2 ) const
{
Card *newone = c2.first();
if (isEmpty())
return (newone->rank() == Card::Ace);
return (newone->rank() == top()->rank() + 1)
&& (top()->suit() == newone->suit());
}
bool Pile::add_klondikeStore( const CardList& c2 ) const
{
Card *newone = c2.first();
if (isEmpty()) {
return (newone->rank() == Card::King);
}
return (newone->rank() == top()->rank() - 1)
&& (top()->isRed() != newone->isRed());
}
bool Pile::add_gypsyStore( const CardList& c2) const
{
Card *newone = c2.first();
if (isEmpty())
return true;
return (newone->rank() == top()->rank() - 1)
&& (top()->isRed() != newone->isRed());
}
bool Pile::add_freeCell( const CardList & cards) const
{
return (cards.count() == 1 && isEmpty());
}
bool Pile::remove_freecellStore( const Card *c) const
{
// ok if just one card
if (c == top())
return true;
// Now we're trying to move two or more cards.
// First, let's check if the column is in valid
// (that is, in sequence, alternated colors).
int index = indexOf(c) + 1;
const Card *before = c;
while (true)
{
c = at(index++);
if (!((c->rank() == (before->rank()-1))
&& (c->isRed() != before->isRed())))
{
kdDebug(11111) << c->name() << " - " << before->name() << endl;
return false;
}
if (c == top())
return true;
before = c;
}
return true;
}
|