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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#include "clock.h"
#include <klocale.h>
#include "deck.h"
#include <assert.h>
#include "cardmaps.h"
Clock::Clock( KMainWindow* tqparent, const char *name )
: Dealer( tqparent, name )
{
const int dist_x = cardMap::CARDX() * 11 / 10 + 1;
const int dist_y = cardMap::CARDY() * 11 / 10 + 1;
deck = Deck::new_deck(this);
deck->move(10, 10+dist_y*3);
deck->hide();
for (int i=0; i<12; i++) {
target[i] = new Pile(i+1, this);
const double ys[12] = { 0./96, 15./96, 52./96, 158./96, 264./96, 301./96, 316./96, 301./96, 264./96, 158./96, 52./96, 15./96};
const double xs[12] = { 200./72, 280./72, 360./72, 400./72, 360./72, 280./72, 200./72, 120./72, 40./72, 0./72, 40./72, 120./72};
target[i]->move(15 + cardMap::CARDX() * 24 / 5 + xs[i] * cardMap::CARDX(), 10 + ys[i] * cardMap::CARDY());
target[i]->setCheckIndex(1);
target[i]->setTarget(true);
target[i]->setRemoveFlags(Pile::disallow);
}
for (int i=0; i<8; i++) {
store[i] = new Pile(14+i, this);
store[i]->move(15+dist_x*(i%4), 10 + cardMap::CARDY() * 5 / 2 * (i/4));
store[i]->setAddFlags(Pile::addSpread);
store[i]->setCheckIndex(0);
}
setActions(Dealer::Hint | Dealer::Demo);
}
void Clock::restart()
{
deck->collectAndShuffle();
deal();
}
bool Clock::checkAdd( int ci, const Pile *c1, const CardList& c2) const
{
Card *newone = c2.first();
if (ci == 0) {
if (c1->isEmpty())
return true;
return (newone->rank() == c1->top()->rank() - 1);
} else {
if (c1->top()->suit() != newone->suit())
return false;
if (c1->top()->rank() == Card::King)
return (newone->rank() == Card::Ace);
return (newone->rank() == c1->top()->rank() + 1);
}
}
void Clock::deal() {
static const Card::Suit suits[12] = { Card::Diamonds, Card::Spades, Card::Hearts, Card::Clubs,
Card::Diamonds, Card::Spades, Card::Hearts, Card::Clubs,
Card::Diamonds, Card::Spades, Card::Hearts, Card::Clubs, };
static const Card::Rank ranks[12] = { Card::Nine, Card::Ten, Card::Jack, Card::Queen,
Card::King, Card::Two, Card::Three, Card::Four,
Card::Five, Card::Six, Card::Seven, Card::Eight};
int j = 0;
while (!deck->isEmpty()) {
Card *c = deck->nextCard();
for (int i = 0; i < 12; i++)
if (c->rank() == ranks[i] && c->suit() == suits[i]) {
target[i]->add(c, false, true);
c = 0;
break;
}
if (c)
store[j++]->add(c, false, true);
if (j == 8)
j = 0;
}
}
static class LocalDealerInfo11 : public DealerInfo
{
public:
LocalDealerInfo11() : DealerInfo(I18N_NOOP("G&randfather's Clock"), 11) {}
virtual Dealer *createGame(KMainWindow *tqparent) { return new Clock(tqparent); }
} gfi11;
#include "clock.moc"
|