Skip to content

Commit

Permalink
cleaner source code
Browse files Browse the repository at this point in the history
  • Loading branch information
cl4cnam authored Aug 9, 2023
1 parent b1c0b11 commit 4498e85
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions memory.fg
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ distributeCards(cardDeck)
#=======================

# transform JavaScript Array into FuncSug "parallel list"
var anyCard := listToPar(cardDeck)
# now, anyCard is a "parallel list" of all cards placed on the table
var allRemainingCards := listToPar(cardDeck)
# now, allRemainingCards is a "parallel list" of all cards placed on the table

while not isNovalue(anyCard):
while not isNovalue(allRemainingCards):

# choose numberOfCopy cards
#--------------------------
Expand All @@ -78,7 +78,7 @@ while not isNovalue(anyCard):
# and when <number> branches (called "selected branches") have reached the end of <instructions1>, all others branches are definitively interrupted
# When all the "selected branches" are finished, the block finished and return an union of the returns of all the "selected branches"

var anyClickedCard := parallel(forEachValueOf anyCard, select numberOfCopy):
var allClickedCards := parallel(for anyCard in allRemainingCards, select numberOfCopy):
# In the following code, anyCard is only a single card
select:
awaitClickBeep(anyCard.cardElement)
Expand All @@ -87,19 +87,19 @@ while not isNovalue(anyCard):

# show the face of the clicked card
showFace(anyCard)
# return the clicked card (which is then "union-ed" to anyClickedCard by "anyClickedCard := parallelOfSelected...")
# return the clicked card (which is then "union-ed" to allClickedCards by "allClickedCards := parallelOfSelected...")
anyCard

# Compare visible faces
#----------------------
if allEqual(anyClickedCard.face):
if allEqual(allClickedCards.face):
print('OK')
js (anyClickedCard):
anyClickedCard.cardElement.classList.add('OK')
anyCard := valuesFrom(anyCard, 'butNotFrom', anyClickedCard)
js (allClickedCards):
allClickedCards.cardElement.classList.add('OK')
allRemainingCards := valuesFrom(allRemainingCards, 'butNotFrom', allClickedCards)
else:
print('Missed')
waitSeconds(3)
showBack(anyClickedCard)
showBack(allClickedCards)

displayNewMessage('Congratulations, you have found all identical cards!')

0 comments on commit 4498e85

Please sign in to comment.