Commit 71d256b7 authored by Rosanna Yuen's avatar Rosanna Yuen Committed by Jonathan Blandford

fixed undo so it now works (many game files changed to allow undo to work)

1999-03-14  Rosanna Yuen <rwsy@mit.edu>

	* sol.scm: fixed undo so it now works  (many game files changed to
	allow undo to work)
	* events.c: fixed event handling so that it makes sense.
	* menu.c: fixed about box
	* yukon.scm: finished hint
parent 79a93f3d
Jonathan Blandford (jrb@MIT.EDU)
\ No newline at end of file
Jonathan Blandford (jrb@alum.mit.edu)
Felix Bellaby (felix@pooh.u-net.com)
Rosanna Yuen (rwsy@mit.edu)
\ No newline at end of file
1999-03-14 Rosanna Yuen <rwsy@mit.edu>
* sol.scm: fixed undo so it now works (many game files changed to
allow undo to work)
* events.c: fixed event handling so that it makes sense.
* menu.c: fixed about box
* yukon.scm: finished hint
1999-03-11 Ian Peters <itp@gnu.org>
* menu.c: Killed the periods at the end of the tooltips.
......
......@@ -58,7 +58,6 @@ types_DATA = \
neighbor.scm \
odessa.scm \
osmosis.scm \
plait.scm \
royal_east.scm \
sol.scm \
scorpion.scm \
......@@ -73,7 +72,7 @@ cardimage_DATA = baize.png splash.png
icon_DATA = gnome-aisleriot.png
EXTRA_DIST = TODO FIXME AUTHORS $(types_DATA) $(cardimage_DATA) \
EXTRA_DIST = AUTHORS $(types_DATA) $(cardimage_DATA) \
$(icon_DATA) sol.desktop SCHEME_GAMES.h
sysdir = $(datadir)/gnome/apps/Games
......
......@@ -41,11 +41,14 @@
(add-card! 3 (make-visible (make-card ace heart)))
(add-card! 4 (make-visible (make-card ace spade)))
(set-statusbar-message (get-stock-no-string))
(give-status-message)
(list 6 2)
)
(define (give-status-message)
(set-statusbar-message (get-stock-no-string)))
(define (get-stock-no-string)
(string-append "Stock left: "
(number->string (length (get-cards 0)))))
......@@ -77,7 +80,6 @@
(if (< slot2 4)
(check-end-slot? slot1 (+ 1 slot2))
#f)))
(define (button-double-clicked slot-id)
(and (> slot-id 4)
......@@ -88,7 +90,7 @@
(get-hint)))
(define (game-won)
(set-statusbar-message (get-stock-no-string))
(give-status-message)
(and (empty-slot? 0)
(empty-slot? 5)
(empty-slot? 6)
......
......@@ -75,10 +75,13 @@
8 9 10 11 12 13 14 15))
(check-for-kings 8)
(set-statusbar-message (get-stock-no-string))
(give-status-message)
(list 10 3))
(define (give-status-message)
(set-statusbar-message (get-stock-no-string)))
(define (get-stock-no-string)
(string-append "Stock left: "
(number->string (length (get-cards 0)))))
......@@ -147,7 +150,7 @@
#f)
(define (game-continuable)
(set-statusbar-message (get-stock-no-string))
(give-status-message)
(and (not (game-won))
(get-hint)))
......
......@@ -65,16 +65,18 @@
(set! add-stage #t)
(set! fill-count 0)
(set-statusbar-message (get-stock-no-string))
(give-status-message)
(list 6 4)
)
(define (give-status-message)
(set-statusbar-message (get-stock-no-string)))
(define (get-stock-no-string)
(string-append "Stock left: "
(number->string (length (get-cards 16)))))
(define (button-pressed slot-id card-list)
(and (not (empty-slot? slot-id))
(if (= slot-id 17)
......@@ -208,7 +210,7 @@
(#t "an empty slot")))
(define (game-over)
(set-statusbar-message (get-stock-no-string))
(give-status-message)
(if (or (= fill-count 16)
(and (empty-slot? 16) (empty-slot? 17)))
(begin
......@@ -225,6 +227,16 @@
(find-match (list-cards 0)))
(list 0 "Deal a new card from the deck")))
(define (undo-func data)
(set-score! (car data))
(set! add-stage (cadr data))
(set! fill-count (caddr data)))
(define (record-move slot-id old-cards)
(set! MOVE (list undo-func
(list (get-score) add-stage fill-count)
(snapshot-board 0 slot-id old-cards))))
(define (get-options) #f)
(define (apply-options options) #f)
......
......@@ -51,17 +51,20 @@
(set! BASE-VAL (get-value (get-top-card 2)))
(set-statusbar-message (string-append (get-stock-no-string)
" "
(get-reserve-no-string)
" "
(get-base-string)))
(give-status-message)
(add-to-score! 1)
(list 7 4)
)
(define (give-status-message)
(set-statusbar-message (string-append (get-stock-no-string)
" "
(get-reserve-no-string)
" "
(get-base-string))))
(define (get-stock-no-string)
(string-append "Stock left: "
(number->string (length (get-cards 0)))))
......@@ -201,11 +204,7 @@
(place-found slot top-card 2)))))
(define (game-over)
(set-statusbar-message (string-append (get-stock-no-string)
" "
(get-reserve-no-string)
" "
(get-base-string)))
(give-status-message)
(if (and (empty-slot? 0)
(empty-slot? 1)
(empty-slot? 6)
......
......@@ -126,7 +126,8 @@
#f))
(define (button-double-clicked slot)
(if (transaction-good? slot (get-cards 6))
(if (and (not (= slot 6))
(transaction-good? slot (get-cards 6)))
(if (= slot 6)
(set-cards! 6 (cons (car (reverse (get-cards 6)))
(reverse (cdr (reverse (get-cards 6))))))
......@@ -202,7 +203,8 @@
(define (game-over)
(not (and (is-visible? (car (reverse (get-cards 6))))
(= (get-value (get-top-card 6)) king))))
(= (get-value (get-top-card 6)) king)
(make-all-visible 0))))
(define (nth-item list n)
(if (= 0 n)
......
......@@ -27,7 +27,7 @@ help_SGML = aisleriot.sgml definitions.sgml gpl.sgml
neighbor.sgml odessa.sgml osmosis.sgml spider.sgml \
yukon.sgml westhaven.sgml royal-east.sgml \
beleaguered-castle.sgml thirteen.sgml thieves.sgml \
freecell.sgml scorpion.sgml
freecell.sgml scorpion.sgml
EXTRA_DIST = $(help_DATA) $(help_SGML)
......
<chapter id=plait>
<docinfo><copyright><year>1999</year><holder>W. Borgert</holder></copyright>
<author><firstname>W.</firstname><surname>Borgert</surname></author>
<address><email>debacle@debian.org</email></address></docinfo>
<title>Plait</title>
<para>written by W. Borgert</para>
<bridgehead>Setup</bridgehead>
<informaltable><tgroup cols="2"><tbody>
<row><entry>Type of Deck</entry><entry>
Double Deck</entry></row>
<row><entry>Stock</entry><entry>
Third row from the right side in the middle. Two redeals are
allowed.
</entry></row>
<row><entry>Waste</entry><entry>
Fourth row from the right in the middle, directly left of the stock.
</entry></row>
<row><entry>Foundation</entry><entry>
Right eight piles. One card is already there at start. This is the
base card. All fields have to be started with this card.
</entry></row>
<row><entry>Plait</entry><entry>
The group of cards in the middle of the table. Starts with 20
cards. Only the one top level card can be moved.
</entry></row>
<row><entry>Edges</entry><entry>
The four fields at the top and bottom, left and right of the plait.
These are automatically refilled from the plait.
</entry></row>
<row><entry>Tableau</entry><entry>
The eight fields left and right of the plait, between the edge fields.
Only one card per pile is possible.
</entry></row>
</tbody></tgroup></informaltable>
<bridgehead>Goal</bridgehead>
<para>
Move all cards to Foundations.
</para>
<bridgehead>Rules</bridgehead>
<para>
All eight Foundations have to be started with the same card value.
At the beginning you can choose, whether to build up or down.
You can take cards from the plait in the middle of
the tableau, from the eight free fields left and right of the plait,
from the four edges around the plait, and from the waste.
</para>
<para>
The game is lost, if no available cards can be moved on to the
Foundation piles and the Stock is empty.
</para>
<bridgehead>Options</bridgehead>
<para>None</para>
<bridgehead>Scoring</bridgehead>
<para>
</para>
<bridgehead>Strategy</bridgehead>
<para>
</para>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
sgml-default-dtd-file: "/usr/lib/sgml/cdtd/docbook.ced"
End:
-->
......@@ -27,7 +27,7 @@ help_SGML = aisleriot.sgml definitions.sgml gpl.sgml
neighbor.sgml odessa.sgml osmosis.sgml spider.sgml \
yukon.sgml westhaven.sgml royal-east.sgml \
beleaguered-castle.sgml thirteen.sgml thieves.sgml \
freecell.sgml scorpion.sgml
freecell.sgml scorpion.sgml
EXTRA_DIST = $(help_DATA) $(help_SGML)
......
<chapter id=plait>
<docinfo><copyright><year>1999</year><holder>W. Borgert</holder></copyright>
<author><firstname>W.</firstname><surname>Borgert</surname></author>
<address><email>debacle@debian.org</email></address></docinfo>
<title>Plait</title>
<para>written by W. Borgert</para>
<bridgehead>Setup</bridgehead>
<informaltable><tgroup cols="2"><tbody>
<row><entry>Type of Deck</entry><entry>
Double Deck</entry></row>
<row><entry>Stock</entry><entry>
Third row from the right side in the middle. Two redeals are
allowed.
</entry></row>
<row><entry>Waste</entry><entry>
Fourth row from the right in the middle, directly left of the stock.
</entry></row>
<row><entry>Foundation</entry><entry>
Right eight piles. One card is already there at start. This is the
base card. All fields have to be started with this card.
</entry></row>
<row><entry>Plait</entry><entry>
The group of cards in the middle of the table. Starts with 20
cards. Only the one top level card can be moved.
</entry></row>
<row><entry>Edges</entry><entry>
The four fields at the top and bottom, left and right of the plait.
These are automatically refilled from the plait.
</entry></row>
<row><entry>Tableau</entry><entry>
The eight fields left and right of the plait, between the edge fields.
Only one card per pile is possible.
</entry></row>
</tbody></tgroup></informaltable>
<bridgehead>Goal</bridgehead>
<para>
Move all cards to Foundations.
</para>
<bridgehead>Rules</bridgehead>
<para>
All eight Foundations have to be started with the same card value.
At the beginning you can choose, whether to build up or down.
You can take cards from the plait in the middle of
the tableau, from the eight free fields left and right of the plait,
from the four edges around the plait, and from the waste.
</para>
<para>
The game is lost, if no available cards can be moved on to the
Foundation piles and the Stock is empty.
</para>
<bridgehead>Options</bridgehead>
<para>None</para>
<bridgehead>Scoring</bridgehead>
<para>
</para>
<bridgehead>Strategy</bridgehead>
<para>
</para>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
sgml-default-dtd-file: "/usr/lib/sgml/cdtd/docbook.ced"
End:
-->
......@@ -53,11 +53,14 @@
(add-to-score! 1)
(set-statusbar-message (get-stock-no-string))
(give-status-message)
(list 6 3)
)
(define (give-status-message)
(set-statusbar-message (get-stock-no-string)))
(define (get-stock-no-string)
(string-append "Stock left: "
(number->string (length (get-cards 0)))))
......@@ -130,7 +133,7 @@
#f)))
(define (game-over)
(set-statusbar-message (get-stock-no-string))
(give-status-message)
(or (< FLIP-COUNTER 2)
(not (empty-slot? 0))
(check-move 1)))
......
......@@ -69,13 +69,16 @@
(add-to-score! 1)
(set! BASE-VAL (get-value (get-top-card 2)))
(give-status-message)
(list 9 3))
(define (give-status-message)
(set-statusbar-message (string-append (get-stock-no-string)
" "
(get-reserve-no-string)
" "
(get-base-string)))
(list 9 3))
(get-base-string))))
(define (get-stock-no-string)
(string-append "Stock left: "
......@@ -149,11 +152,7 @@
(if (= slot-id 0)
(begin
(flip-stock 0 1 2)
(set-statusbar-message (string-append (get-stock-no-string)
" "
(get-reserve-no-string)
" "
(get-base-string))))
(give-status-message))
#f))
(define (button-double-clicked slot)
......
......@@ -85,11 +85,15 @@
(deal-cards 0 '(2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22))
(deal-cards-face-up 0 '(23 24 25 26 27 28 29))
(set-statusbar-message (get-stock-no-string))
(give-status-message)
(list 5 4)
)
(define (give-status-message)
(set-statusbar-message (get-stock-no-string)))
(define (get-stock-no-string)
(string-append "Stock left: "
(number->string (length (get-cards 0)))))
......@@ -327,7 +331,7 @@
(playable? (+ 1 check-slot)))))
(define (game-continuable)
(set-statusbar-message (get-stock-no-string))
(give-status-message)
(and (not (game-won))
(get-hint)))
......
......@@ -48,6 +48,7 @@ void end_of_game_test() {
if (game_over) {
timer_stop ();
game_won = gh_scm2bool (gh_call0 (game_data->winning_game_lambda));
refresh_screen ();
show_game_over_dialog ();
}
}
......@@ -136,7 +137,6 @@ gint button_press_event (GtkWidget *widget, GdkEventButton *event, void *d)
if (gdk_time_get() > first_press + dbl_click_time)
press_data->status = STATUS_NONE;
#endif
slot_pressed(event->x, event->y, &hslot, &cardid);
if (!hslot)
......@@ -152,8 +152,13 @@ gint button_press_event (GtkWidget *widget, GdkEventButton *event, void *d)
#ifdef SINGLE_ACTION
gtk_timeout_remove (timer_click);
#endif
gh_call1 (game_data->button_double_clicked_lambda,
gh_long2scm (hslot->id));
gh_call2 (gh_eval_str ("record-move"), gh_long2scm (-1),
SCM_EOL);
if (gh_scm2bool (gh_call1 (game_data->button_double_clicked_lambda,
gh_long2scm (hslot->id))))
gh_call0 (gh_eval_str ("end-move"));
else
gh_call0 (gh_eval_str ("discard-move"));
refresh_screen ();
end_of_game_test ();
return TRUE;
......@@ -167,7 +172,7 @@ gint button_press_event (GtkWidget *widget, GdkEventButton *event, void *d)
#endif
}
}
else if (event->button == 3 && cardid > 0) {
else if (event->button == 3 && cardid > 0 && press_data->status == STATUS_NONE) {
hcard_type card = g_list_nth(hslot->cards, cardid - 1)->data;
if (card->direction == UP) {
......@@ -212,8 +217,13 @@ gint button_release_event (GtkWidget *widget, GdkEventButton *event, void *d)
case STATUS_NOT_DRAG:
press_data->status = STATUS_CLICK;
#ifndef SINGLE_ACTION
gh_call1 (game_data->button_clicked_lambda,
gh_long2scm (press_data->hslot->id));
gh_call2 (gh_eval_str ("record-move"), gh_long2scm (-1),
SCM_EOL);
if (gh_scm2bool (gh_call1 (game_data->button_clicked_lambda,
gh_long2scm (press_data->hslot->id))))
gh_call0 (gh_eval_str ("end-move"));
else
gh_call0 (gh_eval_str ("discard-move"));
refresh_screen();
end_of_game_test();
#endif
......@@ -228,7 +238,9 @@ gint button_release_event (GtkWidget *widget, GdkEventButton *event, void *d)
gint motion_notify_event (GtkWidget *widget, GdkEventMotion *event)
{
/*g_print ("move\n");*/
if (press_data->status == STATUS_IS_DRAG) {
/*g_print ("keep movin\n");*/
gdk_window_move(press_data->moving_cards,
event->x - press_data->xoffset,
event->y - press_data->yoffset);
......@@ -240,6 +252,7 @@ gint motion_notify_event (GtkWidget *widget, GdkEventMotion *event)
hslot_type hslot = press_data->hslot;
GList* glist = g_list_nth(hslot->cards, press_data->cardid - 1);
SCM cardlist = SCM_EOL;
/*g_print ("maybe move\n");*/
for (; glist; glist = glist->next)
cardlist = gh_cons(make_card((hcard_type)glist->data), cardlist);
......
......@@ -31,11 +31,14 @@
(add-extended-slot '() down)
(add-extended-slot '() down)
(set-statusbar-message (get-stock-no-string))
(give-status-message)
(list 6 3)
)
(define (give-status-message)
(set-statusbar-message (get-stock-no-string)))
(define (get-stock-no-string)
(string-append "Stock left: "
(number->string (length (get-cards 0)))))
......@@ -101,7 +104,7 @@
(= 1 (length (get-cards 4)))))
(define (game-over)
(set-statusbar-message (get-stock-no-string))
(give-status-message)
(not (and (empty-slot? 0)
(and (not (empty-slot? 1))
(not (empty-slot? 2))
......
......@@ -297,12 +297,14 @@
#f)
(define (get-options)
'(("Auto move to homecell" option-auto-move)
("Move one by one" option-one-by-one)))
#f)
; '(("Auto move to homecell" option-auto-move)
; ("Move one by one" option-one-by-one)))
(define (apply-options options)
(set! option-auto-move (cadar options))
(set! option-auto-move (cadadr options)))
#f)
; (set! option-auto-move (cadar options))
; (set! option-auto-move (cadadr options)))
(define (timeout)
; (FIXME)
......
<chapter id=plait>
<docinfo><copyright><year>1999</year><holder>W. Borgert</holder></copyright>
<author><firstname>W.</firstname><surname>Borgert</surname></author>
<address><email>debacle@debian.org</email></address></docinfo>
<title>Plait</title>
<para>written by W. Borgert</para>
<bridgehead>Setup</bridgehead>
<informaltable><tgroup cols="2"><tbody>
<row><entry>Type of Deck</entry><entry>
Double Deck</entry></row>
<row><entry>Stock</entry><entry>
Third row from the right side in the middle. Two redeals are
allowed.
</entry></row>
<row><entry>Waste</entry><entry>
Fourth row from the right in the middle, directly left of the stock.
</entry></row>
<row><entry>Foundation</entry><entry>
Right eight piles. One card is already there at start. This is the
base card. All fields have to be started with this card.
</entry></row>
<row><entry>Plait</entry><entry>
The group of cards in the middle of the table. Starts with 20
cards. Only the one top level card can be moved.
</entry></row>
<row><entry>Edges</entry><entry>
The four fields at the top and bottom, left and right of the plait.
These are automatically refilled from the plait.
</entry></row>
<row><entry>Tableau</entry><entry>
The eight fields left and right of the plait, between the edge fields.
Only one card per pile is possible.
</entry></row>
</tbody></tgroup></informaltable>
<bridgehead>Goal</bridgehead>
<para>
Move all cards to Foundations.
</para>
<bridgehead>Rules</bridgehead>
<para>
All eight Foundations have to be started with the same card value.
At the beginning you can choose, whether to build up or down.
You can take cards from the plait in the middle of
the tableau, from the eight free fields left and right of the plait,
from the four edges around the plait, and from the waste.
</para>
<para>
The game is lost, if no available cards can be moved on to the
Foundation piles and the Stock is empty.
</para>
<bridgehead>Options</bridgehead>
<para>None</para>
<bridgehead>Scoring</bridgehead>
<para>
</para>
<bridgehead>Strategy</bridgehead>
<para>
</para>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
sgml-default-dtd-file: "/usr/lib/sgml/cdtd/docbook.ced"
End:
-->
......@@ -44,10 +44,13 @@
(add-card! 4 (make-visible (make-card 3 club)))
(add-card! 5 (make-visible (make-card 4 club)))
(set-statusbar-message (get-stock-no-string))
(give-status-message)
(list 7 4))
(define (give-status-message)
(set-statusbar-message (get-stock-no-string)))
(define (get-stock-no-string)
(string-append "Stock left: "
(number->string (length (get-cards 0)))))
......@@ -107,7 +110,7 @@
#f)
(define (game-continuable)
(set-statusbar-message (get-stock-no-string))
(give-status-message)
(and (not (game-won))
(get-hint)))
......
......@@ -55,11 +55,14 @@
(map flip-top-card tableau)
(set-statusbar-message (get-stock-no-string))
(give-status-message)
(list 7 3)
)
(define (give-status-message)
(set-statusbar-message (get-stock-no-string)))
(define (get-stock-no-string)
(string-append "Stock left: "
(number->string (length (get-cards 0)))))
......@@ -217,7 +220,7 @@
; so we must NOT report game-over when they run out.
(define (game-over)
(set-statusbar-message (get-stock-no-string))
(give-status-message)
(not (game-won)))
(define (get-options)
......
......@@ -68,8 +68,9 @@ void help_about_callback ()
N_(" Felix Bellaby (felix@pooh.u-net.com)"),
N_(" Rosanna Yuen (rwsy@mit.edu)"),
N_("Card Games: Jonathan Blandford (jrb@alum.mit.edu)"),
N_(" Robert Brady <rwb197@ecs.soton.ac.uk>"),
N_(" Nick Lamb <njl195@zepler.org.uk>"),
N_(" W. Borgert (debacle@debian.org)"),
N_(" Robert Brady (rwb197@ecs.soton.ac.uk)"),
N_(" Nick Lamb (njl195@zepler.org.uk)"),
N_(" Changwoo Ryu (cwryu@adam.kaist.ac.kr)"),
N_(" Rosanna Yuen (rwsy@mit.edu)"),
NULL
......@@ -91,8 +92,8 @@ void help_about_callback ()
_("(C) 1998 Jonathan Blandford (jrb@alum.mit.edu)"),
(const char **)authors,
/* another comments */
_("AisleRiot provides a rule-based, "
"solitaire, card engine that allows many different games to be played"),
_("AisleRiot provides a rule-based "
"solitaire card engine that allows many different games to be played"),
NULL);
gtk_signal_connect (GTK_OBJECT (about),
"destroy",
......@@ -112,13 +113,13 @@ GnomeUIInfo file_menu[] = {
GnomeUIInfo settings_menu[] = {
#if 0
GNOMEUIINFO_ITEM_STOCK(N_("Game _options..."),
N_("Modify the options for this game"),
show_rules_options_dialog, GNOME_STOCK_MENU_PREF),
GNOMEUIINFO_SEPARATOR,
#endif
GNOMEUIINFO_MENU_PREFERENCES_ITEM(show_preferences_dialog, NULL),
GNOMEUIINFO_END
......@@ -162,13 +163,13 @@ GnomeUIInfo game_menu[] = {
show_property_dialog, GNOME_STOCK_MENU_PREF), */
GNOMEUIINFO_SEPARATOR,
#if 0
GNOMEUIINFO_MENU_SCORES_ITEM(show_global_stats_dialog, NULL),
/* GNOMEUIINFO_ITEM_STOCK(N_("S_tatistics..."), NULL,
show_global_stats_dialog, GNOME_STOCK_MENU_BOOK_BLUE), */
GNOMEUIINFO_SEPARATOR,
#endif
GNOMEUIINFO_MENU_EXIT_ITEM(quit_app, NULL),
GNOMEUIINFO_END
......
......@@ -64,10 +64,12 @@
(deal-cards-face-up 0 '(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))
(set-statusbar-message (get-stock-no-string))
(give-status-message)
(list 6 5)
)
(list 6 5))
(define (give-status-message)