[aisleriot] api: Add helper to shuffle the cards on a slot
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aisleriot] api: Add helper to shuffle the cards on a slot
- Date: Thu, 10 Oct 2019 19:28:23 +0000 (UTC)
commit 69bc35719cc006d2314484f29bb485fb93df0f13
Author: Christian Persch <chpe src gnome org>
Date: Thu Oct 10 21:28:22 2019 +0200
api: Add helper to shuffle the cards on a slot
https://gitlab.gnome.org/GNOME/aisleriot/issues/6
games/api.scm | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/games/api.scm b/games/api.scm
index 7ecf75d6..309c1371 100644
--- a/games/api.scm
+++ b/games/api.scm
@@ -143,14 +143,20 @@
(cons (make-card value suit)
(make-deck-list-ace-high init-value (+ 1 value) suit))))
-
+; shuffle the card list
+(define (shuffle-card-list card-list)
+ (let* ((vec (list->vector card-list))
+ (len (vector-length vec)))
+ (shuffle-deck-helper vec '() 0 len)))
; shuffle the card list in DECK
(define-public (shuffle-deck)
- (let* ((vec (list->vector DECK))
- (len (vector-length vec)))
- (set! DECK (shuffle-deck-helper vec '() 0 len))))
-
+ (set! DECK (shuffle-card-list DECK)))
+
+; shuffle the card list in slot
+(define-public (shuffle-slot slot-id)
+ (set-cards! slot-id (shuffle-card-list (get-cards slot-id))))
+
; The playing area is divided into slots, where cards can be placed.
; Each slot can hold any amount of cards. The slots are identified
; using numbers assigned in order of their creation. The deck of cards
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]