feat: 实现反应和卡牌信息读取,并编写了测试用卡牌和反应
This commit is contained in:
+4
-1
@@ -10,6 +10,9 @@ def create_app(config_class='config.DevelopmentConfig'):
|
||||
app.register_blueprint(page_bp)
|
||||
|
||||
from app.routes.cards import card_bp
|
||||
app.register_blueprint(card_bp)
|
||||
app.register_blueprint(card_bp, url_prefix="/card")
|
||||
|
||||
from app.routes.reactions import reaction_bp
|
||||
app.register_blueprint(reaction_bp, url_prefix="/reaction")
|
||||
|
||||
return app
|
||||
@@ -0,0 +1,8 @@
|
||||
from flask import Blueprint
|
||||
from ..services import reactions
|
||||
|
||||
reaction_bp = Blueprint("reaction", __name__, "/reaction")
|
||||
|
||||
@reaction_bp.route("/<id>")
|
||||
def search_card(id):
|
||||
return reactions.readReaction(id)
|
||||
@@ -8,4 +8,11 @@ def readCardList() -> dict:
|
||||
return result
|
||||
|
||||
def readCard(id: str):
|
||||
return readCardList().get(id, f"No Card {id}")
|
||||
path = readCardList().get(id, -1)
|
||||
if (path == -1):
|
||||
return {"message": f"No Card {id}"}
|
||||
with open(f"cards/{path}.json", "r", encoding="utf8") as f:
|
||||
text = f.read()
|
||||
result = json.loads(text)
|
||||
|
||||
return {"message": "OK", "content": result}
|
||||
@@ -8,4 +8,11 @@ def readReactionList() -> dict:
|
||||
return result
|
||||
|
||||
def readReaction(id: str):
|
||||
return readReactionList().get(id, -1)
|
||||
path = readReactionList().get(id, -1)
|
||||
if (path == -1):
|
||||
return {"message": f"No Reaction {id}"}
|
||||
with open(f"reactions/{path}.json", "r", encoding="utf8") as f:
|
||||
text = f.read()
|
||||
result = json.loads(text)
|
||||
|
||||
return {"message": "OK", "content": result}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": {
|
||||
"en-US": "Carbon",
|
||||
"zh-CN": "碳"
|
||||
},
|
||||
"number": 6,
|
||||
"mass": 12
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": {
|
||||
"en-US": "Oxygen",
|
||||
"zh-CN": "氧"
|
||||
},
|
||||
"number": 8,
|
||||
"mass": 16
|
||||
}
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
{
|
||||
|
||||
"Carbon": "NonMetal/Carbon",
|
||||
"Oxygen": "NonMetal/Oxygen"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": {
|
||||
"en-US": "Ignite",
|
||||
"zh-CN": "点燃"
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": {
|
||||
"en-US": "Carbon Dioxide",
|
||||
"zh-CN": "二氧化碳"
|
||||
},
|
||||
"mass": 44
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": {
|
||||
"en-US": "Carbon",
|
||||
"zh-CN": "碳"
|
||||
},
|
||||
"number": 6,
|
||||
"mass": 12
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": {
|
||||
"en-US": "Oxygen",
|
||||
"zh-CN": "氧"
|
||||
},
|
||||
"number": 8,
|
||||
"mass": 16
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
{
|
||||
"Carbon": "NonMetal/Carbon",
|
||||
"Oxygen": "NonMetal/Oxygen",
|
||||
|
||||
"Carbon_Dioxide": "Compound/Carbon_Dioxide"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"reactants": [
|
||||
"NonMetal/Carbon",
|
||||
"NonMetal/Oxygen"
|
||||
],
|
||||
"conditions": [
|
||||
"Ignite"
|
||||
],
|
||||
"products": [
|
||||
"Compound/Carbon_Dioxide"
|
||||
]
|
||||
}
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
{
|
||||
|
||||
"CarbonDioxide": "Oxidation/CarbonDioxide"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
'''
|
||||
检查卡牌信息,包括:
|
||||
卡牌列表中的路径是否存在
|
||||
卡牌配置文件是否符合规范
|
||||
'''
|
||||
Reference in New Issue
Block a user