connectfour/controller: Prevent list access by negative indexing.

Currently, if a user does 'move 0', he moves to column 6(last column)
in connect_four which is unwanted behaviour and happening due to
list getting accessed through negative index (-1).

Added a check for that in controller.py file.

Fixes #343
This commit is contained in:
Ricky 2018-03-15 23:42:58 +05:30 committed by showell
parent 9c5eaa2f1b
commit 15cc35cb82

View file

@ -47,7 +47,7 @@ class ConnectFourBotHandler(GameAdapter):
bot_name = 'connect_four' bot_name = 'connect_four'
move_help_message = '* To make your move during a game, type\n' \ move_help_message = '* To make your move during a game, type\n' \
'```move <column-number>``` or ```<column-number>```' '```move <column-number>``` or ```<column-number>```'
move_regex = '(move (\d)$)|((\d)$)' move_regex = '(move ([1-7])$)|(([1-7])$)'
model = ConnectFourModel model = ConnectFourModel
gameMessageHandler = ConnectFourMessageHandler gameMessageHandler = ConnectFourMessageHandler