Contact me to be added to this repository. Push the creations you make for D&D, and they will be displayed in a nice website. See the website for how to contribute.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

54 lines
1.1 KiB

from flask import Flask, request, jsonify
from combat import Combat, CombatEntity
app = Flask(__name__)
combats = {}
@app.route("/test",methods=["GET","POST"])
def test():
j = request.json
print(j)
return "Good job"
@app.route("/cli/begin_combat",methods=["GET","POST"])
def begin_combat():
j = request.json
"""
Example JSON format:
{
"ents": [
{
"name" : "dude 1",
"hp" : "20",
"init" : "1"
},
{
"name" : "dude 2",
"hp" : "16"
"init" : "2"
}
]
}
"""
n = len(combats)
numCombats = str(n)
ents = []
for e in j.ents:
ents.append(CombatEntity(e.name,e.hp,e.init))
combats[numCombats] = Combat(ents)
print("Combat created: ")
print(combats[numCombats])
return numCombats
@app.route("/cli/run_combat/<id>",methods=["GET","POST"])
def runCombat(id_):
#c = combats[id_]
j = request.json
"""
Example JSON format
"""
if __name__ == "__main__":
app.run()