import random import math import os #the begining def start(): Q1 = (input("press Y or N and enter for the respected answer ")) if Q1 == ("Y") or Q1 == ("y"): str(data_test()) elif Q1 == ("N") or Q1 == ("n"): print ("termanating...") else: print ("invalid input") str(start()) #test for task two data def data_test(): global name1 global name2 global ski1 global str1 global ski2 global str2 name1 = ("player 1") name2 = ("player 2") ski1 = 10 str1 = 10 ski2 = 10 str2 = 10 ski_mod = 0 str_mod = 0 if os.path.exists('D&D A.txt') == True: print ("Their is saved data already in this file do you want to use this data?") Q2 = (input("press Y or N and enter for the respected answer ")) if Q2 == ("Y") or Q2 == ("y"): print ("Loading data...") str(load_player_data()) elif Q2 == ("N") or Q2 == ("n"): print("ok Proceeding to manually entering player data") str(set_player_name()) else: print("Invalided input") str(data_test()) else: print ("No saved data detected proceeding to manually inputting player data") str(set_player_name()) #loads task two data def load_player_data(): #fill me in later print("this fecher is currently unavalable") str(set_player_name()) #incase task two data is now found def set_player_name(): global name1 global name2 print ("lets give names to our caricters") print ("ok now give a name to caricter one") name1 = (input("input name of caricter one ")) print ("good now lets give the second caricter a name") name2 = (input("input name of caricter two ")) print("") print ("now both caricters have names lets give them attributes") print ("how we do this is") print ("Each attribute is initially set to 10") print ("then we roll two dice") print ("The score on the 12 sided dice is divided by ") print ("the score on the 4 sided dice and rounded down.") print ("then we repeat the proces for each caricters attributes") str(set_player_1_ski()) #dose what the name sais and sets player 1 skill def set_player_1_ski(): global ski1 global name1 Q3 = input((name1)+(" press r to roll the 12 and 4 sided dice to determen your 'SKILL' ")) if Q3 == ("r") or Q3 == ("R"): roll12 = random.randint(1,12) roll4 = random.randint (1,4) print ("the 12 sided rolled:") print (roll12) print ("and the 4 sided rolled:") print (roll4) print ("good thet makes your 'SKILL':") ski1 = math.floor(((roll12)/(roll4))+(ski1)) print (ski1) str(set_player_1_str()) else: print ("invalid input") str(set_player_1_ski()) #dos this neede a comment if so: sets player 1 strength def set_player_1_str(): global name1 global str1 global ski1 Q4 = input ((name1)+(" press 'r' agen to roll the dice to determan your 'STRENGHT'")) if Q4 == ("r") or Q3 == ("R"): roll12 = random.randint(1,12) roll4 = random.randint (1,4) print ("the 12 sided rolled:") print (roll12) print ("and the 4 sided rolled:") print (roll4) str1 = math.floor(((roll12)/(roll4))+(str1)) print ("now your 'STRENGTH' is:") print (str1) print ("good "+ str(name1) + " and your 'SKILL' is " + str(ski1)) str(set_player_2_ski()) else: print ("invalid input") str(set_player_1_str()) #sets player 2 skill def set_player_2_ski(): print("") global name2 global ski2 print ((name2)+(" now its your tern to roll the dice")) Q5 = input(" press 'r' to roll the dice to determan your 'SKILL'") if Q5 == ("r") or Q2 == ("R"): roll12 = random.randint(1,12) roll4 = random.randint (1,4) print ("the 12 sided rolled:") print (roll12) print ("and the 4 sided rolled:") print (roll4) print ("good thet makes your 'SKILL':") ski2 = math.floor(((roll12)/(roll4))+(ski2)) print (ski2) print ("press r agen to roll for your'STRENGTH'") str(set_player_2_str()) else: print ("invalid input") str(set_player_2_ski()) #sets player 2 strentgh def set_player_2_str(): print("") global name2 global str2 roll12 = random.randint(1,12) roll4 = random.randint (1,4) Q5 = input("press 'r' agen to roll the dice to determan your 'STRENGHT'") if Q5 == ("r") or Q3 == ("R"): print ("the 12 sided rolled:") print (roll12) print ("and the 4 sided rolled:") print (roll4) str2 = math.floor(((roll12)/(roll4))+(str2)) print ("now your 'STRENGTH' is:") print (str2) print ("good "+ str(name2) + " and your 'SKILL' is " + str(ski2)) print ("now that the atrabuts have been set do you whant to do, move on to the modifirers or reroll them") str(player_RR_or_MO()) else: print ("invalid input") str(set_player_2_str()) #asks the player if thay whant to reroll ther atrabuts def player_RR_or_MO(): Q6 = input("to set the modifires press 'm' or to reroll the atrabutes press 'r' ") if Q6 == ("m") or Q6 == ("M"): print("moving on to modifiers...") str(set_mod_ski()) elif Q6 == ("r") or Q6 == ("R"): print("reseting...") str(set_player_1_ski()) else: print ("invalid input") str(player_RR_or_MO()) #sets the skill modifier def set_mod_ski(): global name1 global name2 global ski1 global str1 global ski2 global str2 global ski_mod print("calculating modifires...") if ski1 > ski2: ski_mod = ski1 - ski2 elif ski2 > ski1: ski_mod = ski2 - ski1 str(set_mod_srt()) #sets the strength def set_mod_srt(): global name1 global name2 global ski1 global str1 global ski2 global str2 global ski_mod global str_mod if str1 > str2: str_mod = str1 - str2 elif str2 > str1: str_mod = str2 - str1 print("calculation compleat") print("the results are:") print("strength modifirer:") print(ski_mod) print("skill modifirer:") print(str_mod) str(battel_start()) #start the battel off def battel_start(): print ("to win the battel you need to decreas your oponents atrabutes to '0' and to do so") print("you need to roll a dice for each player and wichever player has the lowest score") print("has thair atrabutes decreased by the modifirersand this proces continues untill thair is awinner") str(battel_main()) #tells the player what evrythink is def battel_main(): global name1 global name2 global ski1 global str1 global ski2 global str2 global ski_mod global str_mod print(str(name1)+" your skill is: ") print(str(ski1)) print("and your stregth is: ") print(str1) print(str(name2)+" your skill is: ") print(str(ski2)) print("and your strength is: ") print(str2) print("and the modifires are: ") print("skill mod: "+str(ski_mod)) print("strength mod: "+str(str_mod)) str(battel_test()) #test if the player has whon def battel_test(): global ski1 global str1 global ski2 global str2 if ski1 < 0 and str1 < 0: str(battel_p2_win()) elif ski2 < 0 and str2 < 0: str(battel_p1_win()) else: str(battel_attack()) #resets the modifires def battel_reset_mods(): global ski1 global str1 global ski2 global str2 global ski_mod global str_mod if str1 > str2: str_mod = str1 - str2 elif str2 > str1: str_mod = str2 - str1 if ski1 > ski2: ski_mod = ski1 - ski2 elif ski2 > ski1: ski_mod = ski2 - ski1 str(battel_main()) #makes the players attack def battel_attack(): global name1 global name2 global ski1 global str1 global ski2 global str2 global ski_mod global str_mod print("") print(str(name1)+", "+ str(name2)+" press 'R' to roll your attack") Q7 = input("please input your answer ") if Q7 == ("r")or Q7 ("R"): p1_atk_roll = random.randint(1,6) p2_atk_roll = random.randint(1,6) print(str(name1) + " rolled: " + str(p1_atk_roll)) print(str(name2) + " rolled: " + str(p2_atk_roll)) else: str(battel_attack()) if p1_atk_roll < p2_atk_roll: print(str(name1)+" was hit") str(battel_p1_hit()) elif p2_atk_roll < p1_atk_roll: print(str(name2)+" was hit") str(battel_p2_hit()) else: print("the roll was a draw please reroll") str(battel_attack()) #when player 1 is hit def battel_p1_hit(): global ski1 global str1 global ski2 global str2 global ski_mod global str_mod ski1 = ski1 - ski_mod str1 = str1 - str_mod print("") str(battel_reset_mods()) #when player two is hit def battel_p2_hit(): global ski1 global str1 global ski2 global str2 global ski_mod global str_mod ski2 = ski2 - ski_mod str2 = str2 - str_mod print("") str(battel_reset_mods()) #when plyer 1 wins def battel_p1_win(): global name1 global name2 print("congratulations " + str(name1) + " you have win") str(play_again()) #when player 2 win def battel_p2_win(): global name1 global name2 print("congratulations " + str(name2) + " you have win") str(play_again()) #it playes again def play_again(): print ("do you want to play again?") str(start()) #the begining at the end print("welcom are you ready to play dungeon and dragons?") str(start())
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question