chess_main.py
import chess_tools
# 輸入玩家資訊
chess_tools.input_player()
while chess_tools.end_flag:
for player in chess_tools.player_list:
chess_tools.ironman(player)
input(player["name"]+",請按enter擲骰子")
chess_tools.throw(player)
if chess_tools.judge(player) == 1:
break
chess_tools.hit(player)
chess_tools.speedup(player)
print("")
chess_tools.py
from random import randint
player_list =
end_flag = 1
def input_player():
num = input("資料玩家數量:")
i = 0
while i < int(num):
player_name = input("輸入第" + str(i + 1) + "位玩家名字:")
play_info =
i = i + 1
def throw(player):
"""玩家扔骰子,隨機1-6點
:param player: 當前玩家
:return:
"""points = randint(1,6)
# 首先判定是否起飛
if player["score"] == 0 and points == 6:
player["score"] = 1
print("%d 點,恭喜起飛!當前在第%d格" % (points, player["score"]))
elif player["score"] == 0 and points < 6:
print("%d 點,起飛失敗!" % points)
return
# 分數大於100,要後退,多幾分退幾步
elif player["score"] + points > 100:
player["score"] = player["score"] - (player["score"]+ points) % 100 + 1
print("%d 點,飛過頭了!回到%d格" % (points,player["score"]))
else:
player["score"] += points
print("%d 點!當前在第%d格" % (points, player["score"]))
def judge(player):
global end_flag
if player["score"] == 100:
end_flag = 0
print(player["name"]+"贏了")
return 1
def hit(player):
"""判斷當前玩家是否會將領先的玩家撞回起飛位置
:param player: 當前玩家名字
"""for other_player in player_list:
if player["score"] == other_player["score"] \
and other_player["name"] != player["name"]:
other_player["score"] = 0
def speedup(player):
if player["score"] == 15 or \
player["score"] == 35 or \
player["score"] == 85:
player["score"] += 5
print("加速5格,當前在%d格" % player["score"])
def ironman(player):
"""主角光環,名字中含有指定字元的人可以獲得50分加成
:param player:當前玩家的名字
"""master = player["name"].count("t")
if master > 0 and player["score"] == 0:
player["score"] = 50
print("- i am iron man!賈維斯,先給我加50分。")
print("- 好的,%s 。當前已走到第50格。" % player["name"])
print("")
C 實現簡單的飛行棋遊戲
下面展示 完整 namespace 飛行棋 的士兵用a表示 n的士兵用a表示 playername 0 playername 1 initailmap drawmap while playerpos 0 99 playerpos 1 99 勝利 playername i win console.re...
C 實現飛行棋小遊戲
邏輯圖以下是擲色子的乙個 比較有代表性,裡面的邏輯和內容都已注釋,可通過注釋了解這一方法的運作模式。public static void rowtouzi int playerpos 擲色子 按任意鍵開始擲色子 playernames playerpos 不顯示用ucvnajjk戶按下的任意鍵 co...
飛行棋玩家的建立及主方法的實現
static int step static int map new int 100 static int player player 0 存玩家a的下標,player 1 存玩家b的下標 static string name new string 2 name 0 存玩家a的姓名,name 1 存...