Merge pull request #118 from ThomasRubini/get_reaction
This commit is contained in:
commit
7d27561697
@ -1,3 +1,5 @@
|
|||||||
|
import uuid
|
||||||
|
|
||||||
from sqlalchemy import Column, Integer, VARCHAR, Text, LargeBinary, ForeignKey
|
from sqlalchemy import Column, Integer, VARCHAR, Text, LargeBinary, ForeignKey
|
||||||
from sqlalchemy.orm import relationship, declarative_base
|
from sqlalchemy.orm import relationship, declarative_base
|
||||||
|
|
||||||
@ -198,14 +200,16 @@ class Reaction(Base):
|
|||||||
IMG = Column(LargeBinary(length=2**24), comment="Binary data of the image associated to this npc and trait")
|
IMG = Column(LargeBinary(length=2**24), comment="Binary data of the image associated to this npc and trait")
|
||||||
NPC = relationship("Npc")
|
NPC = relationship("Npc")
|
||||||
TRAIT = relationship("Trait")
|
TRAIT = relationship("Trait")
|
||||||
|
REACTION_UUID = Column(VARCHAR(255), unique=True, comment="ID of this reaction")
|
||||||
|
|
||||||
def __init__(self, REACTION_ID, NPC_ID, TRAIT_ID):
|
def __init__(self, REACTION_ID, NPC_ID, TRAIT_ID):
|
||||||
self.REACTION_ID = REACTION_ID
|
self.REACTION_ID = REACTION_ID
|
||||||
self.NPC_ID = NPC_ID
|
self.NPC_ID = NPC_ID
|
||||||
self.TRAIT_ID = TRAIT_ID
|
self.TRAIT_ID = TRAIT_ID
|
||||||
|
self.REACTION_UUID = uuid.uuid4()
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f"Reaction(REACTION_ID={self.REACTION_ID}, NPC_ID={self.NPC_ID}, TRAIT_ID={self.TRAIT_ID})"
|
return f"Reaction(REACTION_ID={self.REACTION_ID}, NPC_ID={self.NPC_ID}, TRAIT_ID={self.TRAIT_ID}, REACTION_UUID={self.REACTION_UUID})"
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return self.__str__()
|
return self.__str__()
|
@ -1,7 +1,11 @@
|
|||||||
import json
|
import json
|
||||||
import json
|
import io
|
||||||
import flask
|
|
||||||
|
|
||||||
|
import flask
|
||||||
|
from sqlalchemy import select
|
||||||
|
|
||||||
|
from truthinquiry.ext.database.models import *
|
||||||
|
from truthinquiry.ext.database.fsa import db
|
||||||
from truthinquiry.ext.discord_bot import discord_bot
|
from truthinquiry.ext.discord_bot import discord_bot
|
||||||
from truthinquiry.ext.socketio import socket_io
|
from truthinquiry.ext.socketio import socket_io
|
||||||
from truthinquiry.logic import game_logic
|
from truthinquiry.logic import game_logic
|
||||||
@ -154,6 +158,20 @@ def get_npc_reaction():
|
|||||||
'Content-Disposition', 'attachment', filename='reaction.png')
|
'Content-Disposition', 'attachment', filename='reaction.png')
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@routes_api.route("/getReaction", methods=["GET", "POST"])
|
||||||
|
def get_reaction():
|
||||||
|
input_uuid = flask.request.values.get("uuid")
|
||||||
|
results = db.session.execute(select(Reaction).where(Reaction.REACTION_UUID==input_uuid))
|
||||||
|
|
||||||
|
row = results.first()
|
||||||
|
if row == None:
|
||||||
|
return {"error": 1, "msg": "No such reaction"}
|
||||||
|
reaction_obj = row[0]
|
||||||
|
|
||||||
|
return flask.send_file(io.BytesIO(reaction_obj.IMG), mimetype='image/png')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@routes_api.route("/gameProgress", methods=["GET", "POST"])
|
@routes_api.route("/gameProgress", methods=["GET", "POST"])
|
||||||
def game_progress():
|
def game_progress():
|
||||||
|
Loading…
Reference in New Issue
Block a user