-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
123 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,6 @@ Bug fix and Exception handles | |
|
||
## chessboard 1.0.14 | ||
Bug fix | ||
|
||
## chessboard 1.1.0 | ||
Add color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Metadata-Version: 1.2 | ||
Name: chessboardCLI | ||
Version: 1.1.0 | ||
Summary: Chessboard generator in command line | ||
Home-page: https://github.com/houluy/chessboard | ||
Author: Houlu | ||
Author-email: houlu8674@bupt.edu.cn | ||
License: MIT | ||
Description: UNKNOWN | ||
Keywords: chessboard | ||
Platform: UNKNOWN | ||
Classifier: Development Status :: 5 - Production/Stable | ||
Classifier: Intended Audience :: Developers | ||
Classifier: Topic :: Software Development :: Libraries :: Python Modules | ||
Classifier: Programming Language :: Python :: 3 | ||
Classifier: Programming Language :: Python :: 3.3 | ||
Classifier: Programming Language :: Python :: 3.4 | ||
Classifier: Programming Language :: Python :: 3.5 | ||
Classifier: Programming Language :: Python :: 3.6 | ||
Requires-Python: >=3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
README.md | ||
setup.py | ||
chessboard/__init__.py | ||
chessboardCLI.egg-info/PKG-INFO | ||
chessboardCLI.egg-info/SOURCES.txt | ||
chessboardCLI.egg-info/dependency_links.txt | ||
chessboardCLI.egg-info/requires.txt | ||
chessboardCLI.egg-info/top_level.txt | ||
test/test.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
colorline>=1.0.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
chessboard |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import sys | ||
from chessboard import Chessboard | ||
from colorline import cprint | ||
|
||
def play_game(): | ||
while True: | ||
game_name = input('Please input the game name: ') | ||
try: | ||
board = Chessboard(game_name=game_name) | ||
except ValueError as e: | ||
cprint(e) | ||
continue | ||
else: | ||
break | ||
|
||
board.print_pos() | ||
while True: | ||
try: | ||
ipt = input('Input:') | ||
except: | ||
cprint('Input Error: try again.', color='g') | ||
continue | ||
if game_name != 'fourinarow': | ||
try: | ||
a = board.handle_input(ipt, check=True) | ||
except Exception as e: | ||
cprint(e, color='g') | ||
board.print_pos() | ||
continue | ||
else: | ||
a = board.handle_input(ipt, place=False) | ||
if a is None: | ||
board.print_pos() | ||
continue | ||
column_num = int(a[0]) | ||
current_col = [_[column_num - 1] for _ in board.pos] | ||
current_row = board.get_not_num(current_col) | ||
if current_row == 0: | ||
cprint('No place to put your chess!', color='g') | ||
continue | ||
else: | ||
try: | ||
a = board.set_pos(x=current_row, y=column_num, check=True) | ||
except (PositionError, Exception) as e: | ||
cprint(e, color='g') | ||
continue | ||
if a is True: | ||
cprint('player {} wins'.format(board.get_player()), color='y', bcolor='b') | ||
board.print_pos() | ||
sys.exit(0) | ||
board.print_pos(coordinates=a) | ||
#print(str(board)) | ||
|
||
if __name__ == '__main__': | ||
play_game() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters