Anonymous user
Go Fish: Difference between revisions
→{{header|Red}}
Line 476:
return new-deck
]
show-cards: does [▼
clear-and-show 0 ""▼
print [newline "Player cards:" newline sort phand newline]▼
print ["Computer books:" cbooks]▼
print ["Player books:" pbooks newline]▼
]▼
shuffle: function [deck [block!]] [deck: random deck]
;------------- end of helper functions -----------------
check-for-books: func [▼
{▼
Checks for a book in a players hand.▼
Increments the players book score, and▼
discards the book from the players hand▼
}▼
hand "from or to hand"▼
kind "rank of cards"▼
/local ▼
c "collected"▼
][▼
c: collect [▼
forall hand [keep find hand/1 kind]▼
]▼
remove-each i c [none = i] ▼
if 4 = length? c [▼
either hand = phand [pbooks: pbooks + 1][cbooks: cbooks + 1]▼
remove-each i hand [if find/only c i [i]] ;-- remove book from hand▼
forall c [append pile c/1] ;-- append discarded book to the pile▼
]▼
]▼
transfer-cards: func [
Line 543 ⟶ 573:
go-fish 1 thand
]
▲]
▲check-for-books: func [
▲ {
▲ Checks for a book in a players hand.
▲ Increments the players book score, and
▲ discards the book from the players hand
▲ }
▲ hand "from or to hand"
▲ kind "rank of cards"
▲ /local
▲ c "collected"
▲][
▲ c: collect [
▲ forall hand [keep find hand/1 kind]
▲ ]
▲ remove-each i c [none = i]
▲ if 4 = length? c [
▲ either hand = phand [pbooks: pbooks + 1][cbooks: cbooks + 1]
▲ remove-each i hand [if find/only c i [i]] ;-- remove book from hand
▲ forall c [append pile c/1] ;-- append discarded book to the pile
▲ ]
▲]
▲show-cards: does [
▲ clear-and-show 0 ""
▲ print [newline "Player cards:" newline sort phand newline]
▲ print ["Computer books:" cbooks]
▲ print ["Player books:" pbooks newline]
]
Line 605 ⟶ 606:
]
deck: shuffle make-deck
deal-cards 9 chand
Line 618 ⟶ 619:
]
main
</lang>
|