25 lines
652 B
Python
25 lines
652 B
Python
import json
|
|
import random
|
|
|
|
import flask
|
|
|
|
from . import core
|
|
|
|
def dice_roll(min=0, max=100, modifiers=[]):
|
|
result = random.randint(min, max)
|
|
for _, mod in modifiers:
|
|
result += mod
|
|
|
|
return result
|
|
|
|
@core.app.route("/act/steal/<resource>/<target>", methods=["POST"])
|
|
def steal_resource(resource, target):
|
|
return flask.Response(json.dumps({
|
|
"success": (dice_roll() >= 50)
|
|
}), status=200, content_type="application/json")
|
|
|
|
@core.app.route("/act/recruit", methods=["POST"])
|
|
def recruit():
|
|
return flask.Response(json.dumps({
|
|
"success": (dice_roll() >= 65)
|
|
}), status=200, content_type="application/json") |