του εδωσα δηλαδή αυτό:
Κώδικας: Επιλογή όλων
game={
score:0,
round:1,
step:{
order:['A','2','3','4','5','6','7','8','9','10','J','Q','K'],
no:1,
},
pile:{
flow:['Q','10','5','4','9','Q','3','3','9','6','J','5','A','8','J','3','4','4','A','K','8','6','10','2','K','Q','K','2','9','5','2','A','2','10','10','J','7','J','8','6','K','9','7','6','5','7','4','A','Q','3','7','8']
temporary:[],
scoring:[],
discard:[]
},
play:function(debug){
if (game.pile.flow[0]){
if (debug) console.log('Round :'+game.round+', Step :'+game.step.order[game.step.no-1]+',Card :'+game.pile.flow[0]);
if (game.pile.flow[0]==game.step.order[game.step.no-1]){
if (debug) console.log('match found!');
game.pile.scoring.push(game.pile.flow[0]); //add card to scoring pile
game.pile.flow.shift(); //remove card from flow pile
game.pile.flow=game.pile.flow.concat(game.pile.temporary); //move temporary to end of flow pile
game.pile.temporary=[]; //empty temporary pile
game.step.no=1; //reset step
game.round++; //increase round number
}else{
if (debug) console.log('no match');
game.pile.temporary.push(game.pile.flow[0]); //add card to temporary pile
game.pile.flow.shift(); //remove card from flow pile
if (game.step.no ==13) {
game.pile.discard=game.pile.discard.concat(game.pile.temporary); //move temporary pile to end of discard pile
game.pile.temporary=[]; //empty temporary pile
game.step.no=1;//reset step
game.round++; //increase round number
}else game.step.no++;//increment step
}
setTimeout(()=>{game.play(debug?1:0);},10);
} else game.end(debug?1:0);
},
end:function(debug){
game.pile.scoring.forEach( (entry)=> {
if (debug) console.log(entry,game.score);
if (entry=="J"||entry=="Q"||entry=="K")
game.score=game.score+10;
else if (entry=="A")
game.score=game.score+1;
else
game.score=game.score+Number(entry);
});
console.log('score :'+game.score);
}
};
και το μετέφρασε ετσι, μετα το επαιξε και με λιγη βοήθεια τα καταφερε:
The game starts with a deck of cards, divided into four piles: the flow pile, the temporary pile, the scoring pile, and the discard pile.
The game progresses in rounds. In each round, the player checks the top card of the flow pile against a specific card from a predefined order. Use the following steps order:('A','2','3','4','5','6','7','8','9','10','J','Q','K').
If the top card of the flow pile matches the current step's card, the card is moved to the scoring pile, also the cards from the temporary pile are placed to the end of the flow pile, and the temporaty pile is cleared, and finaly the round and step are reset. Else, the card is moved to the end of the temporary pile, then the game continues to the next step order.
If the player reaches the end of the step order (all 13 cards have been checked), the temporary pile is moved to the discard pile, and the round and step are reset.
The game continues until the flow pile is empty. Once the flow pile is empty, the game ends, and the score is calculated based on the cards in the scoring pile. The score is calculated by adding up the values of the cards. Face cards (J, Q, K) are worth 10 points each, and the Ace is worth 1 point. The rest of the cards are worth their face value. The player's goal is to get the highest score possible by matching the cards in the correct order.