![]() ![]() That player should type in a number 1 - 7 to indicate the row to place their checker. Then the code will randomly choose one player to go first, and send a message saying eg. To play assuming you are using the keyboards, the buttons follow similarly, each player should type 'reset' and send it via their keyboard. check all diagonal combos down and to the right from the top left cornerĭigiline_send(mem.player_scr,"\n\n\n\n\nYou Won!")ĭigiline_send(mem.player_scr],"\n\n\n\n\nPlayer ".winner."has won!")ĭigiline_send(mem.player_scr],"\n\n\n\nIt is the other\nplayer's turn.")ĭigiline_send(mem.player_scr,"\n\n\n\nIt is your turn.")ĭigiline_send('6','the code was run bc: '.event.type) -debug channelĭigiline_send('6','with iid: '.event.iid) -debug channelĭigiline_send('6','with channel: '.event.channel) -debug channelĭigiline_send('6','and msg: '.event.msg) -debug channelĭigiline_send('6','game state:'.mem.state) -debug channel check all diagonal combos up and to the right, from the bottom left corner Winner = 0 - no winner detected yet - changed to player number if win switch mem.turn and change state to turn so we can wait for input if there is a win, go to the win state and code. if we didnt move a checker, then, check for a win. (and we shouldnt do anything else - check that) if we moved a checker, we will run this again. If mem.board ~= 0 and mem.board = 0 then - if the location has a checker, and the location under it is empty If event.type = 'interrupt' and event.iid = 'settle' then digiline_send(mem.large_screen,mem.string) if event.type = 'interrupt' and event.iid = 'drawboard' then lets try implementing the switch turn here. add the player's checker to the board, at the top If (mem.board = 0) then - if the input is coming from the player whose turn it is, and the checker can be placed, If event.type = 'digiline' and event.msg = '1' or event.msg = '2' or event.msg = '3' or event.msg = '4' or event.msg = '5' or event.msg = '6' or event.msg = '7' and mem.state = 'turn' then -I hope that this will allow me to check if the input is accept input from the player whose turn it is, call the settle function everybody's ready, the board is initialized, the turn is inited already too, setting up the game state.ĭigiline_send(mem.player_scr,"\nGame is starting,\nYou go first.")ĭigiline_send(mem.player_scr],"\nGame is starting,\nPlayer ".mem.turn." goes first.")ĭigiline_send(mem.large_screen,mem.string) If mem.pl1_ready = true and mem.pl2_ready = true then If mem.pl2_ready = false and mem.pl1_ready = false then - update message if and only if it hasnt been updated already and if the other player isnt ready.ĭigiline_send(mem.player_scr,"\nPlayer 2 is ready,\nwaiting for you.")ĭigiline_send(mem.player_scr,"\nWaiting for player\n1.")ĭigiline_send(mem.large_screen,'/fWAITING/0O /f4 /8O/fPLAYER1/0O/f 2 /8OO/fPRESS/0OO/fREADY/8O') If event.channel = mem.player_key then - if the ready message came from pl2 If mem.pl1_ready = false and mem.pl2_ready = false then - update message if and only if it hasnt been updated already, and if the other player isnt ready.ĭigiline_send(mem.player_scr,"\nWaiting for player\n2.")ĭigiline_send(mem.player_scr,"\nPlayer 1 is ready,\nwaiting for you.")ĭigiline_send(mem.large_screen,'/fWAITING/0O /f4 /8O/fPLAYER2/0O/f 2 /8OO/fPRESS/0OO/fREADY/8O') If event.channel = mem.player_key then - if the ready message came from pl1 here we get players ready states and set them, and send waiting messages if the other player isnt ready. If event.type = 'digiline' and (event.msg = 'ready' or event.msg = 'READY' or event.msg = 'Ready') and mem.state = 'pregame' then get player's ready messages, switch state to turn if they are ready ![]() Mem.board = - this means that player 1's keyboard is channel 1, and player 2's keyboard is channel 3ĭigiline_send(mem.player_scr,'\n\n\n\nPress READY to play\nas player 1')ĭigiline_send(mem.player_scr,'\n\n\n\nPress READY to play\nas player 2')ĭigiline_send(mem.large_screen,'/fCONNECT/0O /f4 /8OO/fPRESS/0OO/fREADY/8OO /f2 /0OO/fBEGIN/8O') Mem.state = 'pregame' - can be: pregame, turn, settle, win Mem.pl2_ready = false -is pl2 ready to start the game? Mem.pl1_ready = false -is pl1 ready to start the game? If event.type = 'program' or (event.type = 'digiline' and (event.msg = 'RESET' or event.msg = 'Reset' or event.msg = 'reset' )) then ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |