本文整理汇总了Python中models.Player.ships_left方法的典型用法代码示例。如果您正苦于以下问题:Python Player.ships_left方法的具体用法?Python Player.ships_left怎么用?Python Player.ships_left使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Player
的用法示例。
在下文中一共展示了Player.ships_left方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import ships_left [as 别名]
def main():
"""Run the console-based python game"""
# start with a clear screen
clear_screen()
show_banner()
# ask for players names
name1 = ask_player_name("Player 1")
name2 = ask_player_name("Player 2")
# initiate player instances
player1 = Player(name1)
player2 = Player(name2)
input("\nNext you'll each add your ships. {} first. (No peeking {})\n\n"
"Hit ENTER to continue....".format(name1, name2))
# placing ships
clear_screen()
# defind player1's fleet and add to board
define_fleet(player1)
show_banner()
input("Time to add {}'s ships. Hit ENTER to continue....".format(name2))
# define player2's fleet and add to board
define_fleet(player2)
# commense game play
show_banner()
input("Game Time! {} goes first. Hit ENTER to continue....".format(name1))
game_continue = True
while game_continue:
take_turn(player1, player2)
if not player2.ships_left():
show_banner()
input("{} WINS!!! Hit ENTER to see final boards....\n"
"".format(player1.name))
game_continue = False
continue
take_turn(player2, player1)
if not player1.ships_left():
show_banner()
input("{} WINS!!! Hit ENTER to see final boards....\n"
"".format(player2.name))
game_continue = False
# Display final boards
print_all_boards(player1.name, player2.name,
player1.board.get_player_view(),
player2.board.get_player_view())