| summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'data')
| -rw-r--r-- | data/examples/blackjack/cards.fate | 21 | ||||
| -rw-r--r-- | data/examples/blackjack/global.fate | 10 | ||||
| -rw-r--r-- | data/examples/blackjack/main.fate | 6 | ||||
| -rw-r--r-- | data/examples/blackjack/play.fate | 17 |
4 files changed, 23 insertions, 31 deletions
diff --git a/data/examples/blackjack/cards.fate b/data/examples/blackjack/cards.fate index 7245436..f9c734f 100644 --- a/data/examples/blackjack/cards.fate +++ b/data/examples/blackjack/cards.fate @@ -41,21 +41,26 @@ (global (list card) deck_template) -(list:add_all! (eval card_generator Hearts) deck_template) -(list:add_all! (eval card_generator Spades) deck_template) -(list:add_all! (eval card_generator Diamonds) deck_template) -(list:add_all! (eval card_generator Clubs) deck_template) +(list:add_all! + (eval card_generator Hearts) + (eval card_generator Spades) + (eval card_generator Diamonds) + (eval card_generator Clubs) + deck_template +) + + (define_sequence compute_score (((ptr (list card)) deck) ((ptr int) result)) - (local int aces_count) - (local int maybe_better_score) + (local int aces_count 0) + (local int maybe_better_score 0) (set! (at result) 0) (foreach (at deck) card (set! (at result) (+ card.score (at result))) (if (= (var card.number) 1) - (set! aces_count (+ aces_count 1)) + (++! aces_count) ) ) @@ -64,6 +69,6 @@ (if (=< maybe_better_score 21) (set! (at result) (var maybe_better_score)) ) - (set! aces_count (- aces_count 1)) + (--! aces_count) ) ) diff --git a/data/examples/blackjack/global.fate b/data/examples/blackjack/global.fate index acf054e..d08706b 100644 --- a/data/examples/blackjack/global.fate +++ b/data/examples/blackjack/global.fate @@ -15,12 +15,8 @@ ) ) -(global int marker_0) - (declare_text_effect action_description) -(global int marker_1) - (define_sequence money_acquisition ((int amount)) (set! player.money (+ player.money amount)) (if (> amount 0) @@ -30,8 +26,6 @@ ) ) -(global int marker_2) - (define_sequence money_loss ((int amount)) (set! player.money (- player.money amount)) (if (> amount 0) @@ -41,8 +35,4 @@ ) ) -(global int marker_3) - (declare_input_event escape) - -(global int marker_4) diff --git a/data/examples/blackjack/main.fate b/data/examples/blackjack/main.fate index 170ef29..2738ce3 100644 --- a/data/examples/blackjack/main.fate +++ b/data/examples/blackjack/main.fate @@ -19,7 +19,7 @@ you some coins. Just between you and me, someone left those laying around, they aren't mine. (visit! money_acquisition (+ 100 (rand 0 100))) -(set! original_amount (var player.money)) +(set! original_amount player.money) Now, you're all set to go... unless you don't know how to play? @@ -72,8 +72,8 @@ Now, you're all set to go... unless you don't know how to play? ) (text_effect action_description - You walk out, having turned (eval coins_word (var original_amount)) into - (eval coins_word (var player.money)). + You walk out, having turned (eval coins_word original_amount) into + (eval coins_word player.money). ) (end!) diff --git a/data/examples/blackjack/play.fate b/data/examples/blackjack/play.fate index fd4d65c..76b9e2b 100644 --- a/data/examples/blackjack/play.fate +++ b/data/examples/blackjack/play.fate @@ -4,14 +4,12 @@ (require global.fate) (require cards.fate) -(global bool has_played) +(global bool has_played (false)) (global (list card) current_deck) (global (list card) dealer_hand) (global int bet) (global bool has_doubled) -(set! has_played (false)) - (define_sequence play_a_game () (local card new_card) @@ -29,7 +27,7 @@ (prompt_integer! (ptr bet) 1 - (var player.money) + player.money How much would you like to bet? ) (text_effect action_description @@ -41,7 +39,7 @@ (set! current_deck (list:shuffle deck_template)) (list:pop_left! current_deck new_card) - (list:add! (var new_card) player.hand) + (list:add! new_card player.hand) (text_effect action_description You have been dealt the (var new_card.name). @@ -49,7 +47,7 @@ ) (list:pop_left! current_deck new_card) - (list:add! (var new_card) dealer_hand) + (list:add! new_card dealer_hand) (text_effect action_description The dealer has drawn the (var new_card.name). @@ -57,7 +55,7 @@ ) (list:pop_left! current_deck new_card) - (list:add! (var new_card) player.hand) + (list:add! new_card player.hand) (text_effect action_description You have been dealt the (var new_card.name). @@ -67,7 +65,7 @@ (newline) (list:pop_left! current_deck new_card) - (list:add! (var new_card) dealer_hand) + (list:add! new_card dealer_hand) (text_effect action_description The dealer has drawn a card, face down. @@ -76,8 +74,7 @@ (visit! initial_draw) - (list:clear! dealer_hand) - (list:clear! player.hand) + (list:clear! dealer_hand player.hand) (newline) Interesting. Would you like to go again? |


