This file contains hidden or 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
# file path: server/run/server/player-a.json | |
{ | |
"name": "Mr. X", | |
"id": "x", | |
"connection_id": 29, | |
"gender": "male", | |
"stat": { | |
"chr": 10, | |
"con": 10, | |
"dex": 10, |
This file contains hidden or 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
# help for https://www.reddit.com/r/learnpython/comments/z86k01/im_trying_to_make_a_chose_your_own_adventure_game/ | |
# game rewritten to use functions for areas, and a simple state machine: | |
def ask_to_play(): | |
while True: | |
answer = input("would you like to play (yes/no) ") | |
if answer.lower().strip() == "yes": | |
state = "forest path" | |
# exit while loop |
This file contains hidden or 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
# if '__name__' == '__main__': | |
import logging | |
flag = [ | |
{'name': 'dungeon_master', | |
'status': True, | |
'type': 'yes/no'}, | |
{'name': "room_descriptions", | |
'status': True, |
This file contains hidden or 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
""" | |
A note about positional parameters: | |
https://www.reddit.com/r/learnpython/comments/yptsyp/comment/ivkydz0/?utm_source=share&utm_medium=web2x&context=3 | |
""" | |
import random | |
from datetime import datetime | |
from dataclasses import dataclass | |
from typing import Tuple |
This file contains hidden or 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
""" | |
A note about positional parameters: | |
https://www.reddit.com/r/learnpython/comments/yptsyp/comment/ivkydz0/?utm_source=share&utm_medium=web2x&context=3 | |
""" | |
from dataclasses import dataclass | |
from typing import Tuple | |
This file contains hidden or 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
import random | |
def ask_name(): | |
is_ok = False | |
while is_ok is False: | |
my_name = input("What is your name? ") | |
if my_name.lower() == "michelle": | |
print("You answered correctly!") | |
return my_name.title() | |
else: |
This file contains hidden or 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
import doctest | |
import logging | |
def add_two_numbers(a, b): | |
""" | |
Add two numbers, a and b, together. Return the total. | |
:param a: first number to add | |
:param b: second number to add |
This file contains hidden or 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
C:\Users\ryan-\AppData\Local\Programs\Python\Python38\python.exe "D:\Program Files\JetBrains\PyCharm Community Edition 2020.3.2\plugins\python-ce\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 56514 --file D:/Documents/C64/TADA/server/client.py | |
Connected to pydev debugger (build 213.6777.50) | |
client connected (localhost:5000) | |
Welcome to: | |
Totally | |
Awesome | |
Dungeon | |
Adventure | |
Please log in. | |
user? >? a |
This file contains hidden or 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
#!/bin/env python3 | |
# + encode map data as JSON. why: | |
# + don't need to write own parser, | |
# + flexible for adding/changing fields (including optional fields) | |
# + use 'dataclass' for Room. why: | |
# + convenient for class with many fields mostly stored as data | |
# + use 'textwrap' for formatting multiline text. why: | |
# + can store text without all the format |
This file contains hidden or 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
{ | |
"id": "x", | |
"name": "Mr. X", | |
"map_level": 1, | |
"room": 1, | |
"money": 1000, | |
"health": 100, | |
"xp": 100, | |
"flag": { | |
"room_descs": true, |