summaryrefslogtreecommitdiff
path: root/csol.c
blob: 1abfcc9525863dccb5f19f8b602233891b2cf2c1 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*

    csol - CURSES solitaire

    Copyright (C) 2018  Ian Cowburn (ianc@noddybox.co.uk)

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    -------------------------------------------------------------------------

    Main

*/
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

#include <curses.h>

#include "deck.h"
#include "pile.h"
#include "util.h"
#include "klondike.h"

int main(int argc, char *argv[])
{
    int key;
    int opt = 1;
    int quit = FALSE;

    srand(time(NULL));

    initscr();
    cbreak();
    noecho();
    keypad(stdscr, TRUE);

    while(!quit)
    {
        erase();

        Centre(1, "CURSES solitaire");
        Centre(3, "1 .. Klondike (draw three)");
        Centre(4, "2 .. Klondike (draw one)");
        Centre(5, "Q .. Quit");

        key = getch();

        switch(key)
        {
            case '1':
                erase();
                Klondike(3);
                break;
            case '2':
                erase();
                Klondike(1);
                break;
            case 'q':
            case 'Q':
                quit = TRUE;
                break;
            case '?':
                erase();
                Centre(2, "Press the indicated key to select the menu item.");
                Centre(4, "Press SPACE to continue.");
                refresh();
                while(getch() != ' ');
                break;
            default:
                break;
        }
    }

    erase();
    refresh();
    endwin();

    return EXIT_SUCCESS;
}

/*
vim: ai sw=4 ts=8 expandtab
*/