「奇夢之星」是一款受歡迎的線上遊戲,玩家在遊戲中需要根據角色的職業和戰鬥風格來分配屬性點。以下是一個簡單的配點程式設計思路,幫助玩家根據需求進行配點:
# 職業與基礎配點建議
class_profiles = {
"戰士": {"力量": 50, "敏捷": 20, "體力": 30, "智力": 10},
"法師": {"力量": 10, "敏捷": 20, "體力": 20, "智力": 50},
"弓箭手": {"力量": 20, "敏捷": 50, "體力": 20, "智力": 10},
# 可根據遊戲需求擴充其他職業
}
def allocate_points(character_class):
if character_class not in class_profiles:
print("職業不存在,請重新選擇!")
return
# 顯示基礎配點建議
print(f"{character_class} 的基礎配點建議:")
for stat, value in class_profiles[character_class].items():
print(f"{stat}: {value}")
# 玩家手動調整配點
total_points = 100 # 假設總配點上限為100
allocated_points = 0
custom_stats = {}
print("\n請手動調整配點:")
for stat in class_profiles[character_class]:
while True:
try:
points = int(input(f"請輸入 {stat} 的點數:"))
if points < 0:
print("點數不能為負數,請重新輸入!")
continue
allocated_points += points
if allocated_points > total_points:
print("總配點超過上限,請重新分配!")
allocated_points -= points
else:
custom_stats[stat] = points
break
except ValueError:
print("請輸入有效的數字!")
# 顯示最終配點結果
print("\n最終配點結果:")
for stat, value in custom_stats.items():
print(f"{stat}: {value}")
# 檢查配點是否合理
if allocated_points < total_points:
print(f"警告:尚有 {total_points - allocated_points} 點未分配!")
else:
print("配點完成!")
# 主程式
if __name__ == "__main__":
character_class = input("請輸入角色職業(如戰士、法師、弓箭手):")
allocate_points(character_class)
希望這個程式能幫助玩家更輕鬆地進行角色配點!