示例#1
0
文件: auth.py 项目: lexpar/CTeam
def create_example_actor(user):
    """Create some example actors tied to the user's account."""
    suicide_script = """if nearest(WATER) == MY_LOCATION then
do
    walk(NORTH);
done
else
do
    walk(direction(nearest(WATER)));
done
endif"""
    north_sleeper = """if MY_ENERGY < 80 then
do
    sleep();
done
else
do
    walk(NORTH);
done
endif"""
    a1 = GameActorModel(title="Suicide Guy", creator=user, behaviour_script=suicide_script)
    a2 = GameActorModel(title="Sleep Walker", creator=user, behaviour_script=north_sleeper)
    a1.save()
    a2.save()
示例#2
0
 def post(self, request, *args, **kwargs):
     inpt = request.POST
     d = {"title": inpt["title"], "behaviour_script": inpt["behaviour_script"], "creator": request.user}
     g = GameActorModel(**d)
     g.save()
     return Response(status=HTTP_201_CREATED)