Compare commits

..

17 Commits

Author SHA1 Message Date
Tiger 0cc776becb Merge branch 'develop' into 'master'
同步代码

See merge request paper-chemis-community/backend!6
2026-02-13 12:32:40 +08:00
Tiger fbbfc74f6f feat: 重新为develop分支添加LICENSE 2026-02-13 12:32:08 +08:00
Tiger 1ac892e15f Merge branch 'develop' into 'master'
同步代码

See merge request paper-chemis-community/backend!5
2026-02-13 12:30:26 +08:00
Tiger 0643975115 feat: 完善了README 2026-02-13 12:30:10 +08:00
Tiger b3ce44e057 Edit LICENSE. 2026-02-13 12:28:01 +08:00
Tiger 4a2031fcce Merge branch 'develop' into 'master'
同步代码

See merge request paper-chemis-community/backend!4
2026-02-13 12:27:11 +08:00
Tiger a87c141011 feat: 在develop分支删除LICENSE 2026-02-13 12:26:57 +08:00
Tiger 9f29d073d0 feat: 同步master分支的LICENSE 2026-02-13 12:21:34 +08:00
Tiger 2a93a7813f feat: 更新LICENSE 2026-02-13 12:19:27 +08:00
Tiger 85740b1d5f Merge branch 'develop' into 'master'
基本完成数据后端功能

See merge request paper-chemis-community/backend!2
2026-02-13 12:18:08 +08:00
Tiger ec6437448e feat: 为解决合并冲突,临时删除LICENSE 2026-02-13 12:17:51 +08:00
Tiger fce222a63f feat: 增加LICENSE 2026-02-13 12:12:48 +08:00
Tiger 89d1f6076a feat: 在description.json增加rules部分 2026-02-13 10:57:28 +08:00
Tiger 379b31fb5b feat: 补充url_prefix属性 2026-02-12 17:15:03 +08:00
Tiger b20040abc1 feat: 补充description.json的README内容 2026-02-08 21:01:46 +08:00
Tiger 6b7af1301f feat: 增加description.py,修复中文问题 2026-02-08 20:55:19 +08:00
Tiger 8455dc7924 feat: 完善文件结构,方便游戏本体读取 2026-01-22 11:59:36 +08:00
18 changed files with 75 additions and 68 deletions
+1 -38
View File
@@ -620,18 +620,7 @@ copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs Paper Chemis Community
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 2026 Tiger Copyright (C) 2026 Tiger
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
@@ -646,29 +635,3 @@ the "copyright" line and a pointer to where the full notice is found.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) 2026 Tiger
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+22 -1
View File
@@ -29,6 +29,7 @@ backend/
- matters.py - matters.py
- reactions.py - reactions.py
- resources/ - resources/
- description.json
- assets/ - assets/
- index.json - index.json
- pics/ - pics/
@@ -46,6 +47,22 @@ backend/
## 部分文件格式 ## 部分文件格式
### description.json
`resources` 目录下直属的 `description.json` 是整个源的介绍文件应当包含源的名字、作者和唯一UUID以及规则。其中UUID不带横杠`-`)。下面给出一个示例:
```json
{
"name": "Offical Example",
"author": "Paper Chemis Community Team",
"uuid": "6b3d2702c1c345499fc8617d664b3627",
"rules": {
"common": true // common 代表通常的纸片化学玩法
}
}
```
### list.json ### list.json
`cards` `matters``reactions` `conditions` 下的 `list.json` 有相同的格式。每个文件中都只有一个对象。对象的键的内容均是字符串,代表 ID。对象的值的内容均是字符串代表对应JSON文件的相对路径不用加 `.json` 后缀名。例如: `cards` `matters``reactions` `conditions` 下的 `list.json` 有相同的格式。每个文件中都只有一个对象。对象的键的内容均是字符串,代表 ID。对象的值的内容均是字符串代表对应JSON文件的相对路径不用加 `.json` 后缀名。例如:
@@ -100,6 +117,10 @@ backend/
## 最佳实践 ## 最佳实践
对于路径和 ID均应当使用英文字母、下划线和数字不应当使用包括中文和短横杠在内的其他字符。由此引发的问题后果自负。 不遵守此部分内容引发的问题后果自负。
对于同一物质/卡牌,其在各处的 ID 应该相同,即在 `cards` `matters` `reactions` `assets` 中的 ID 都应该相同,否则游戏本体将无法读取。
对于路径和 ID均应当使用英文字母、下划线和数字不应当使用包括中文和短横杠在内的其他字符。
所有 JSON 文件中的缩进均应当使用 2 个或 4 个空格,而非制表符(`\t`)。 所有 JSON 文件中的缩进均应当使用 2 个或 4 个空格,而非制表符(`\t`)。
+1
View File
@@ -3,6 +3,7 @@ from flask import Flask
def create_app(config_class='config.Config'): def create_app(config_class='config.Config'):
app = Flask(__name__) app = Flask(__name__)
app.config.from_object(config_class) app.config.from_object(config_class)
app.json.ensure_ascii = False # type: ignore
# 注册蓝图 # 注册蓝图
from app.routes.pages import page_bp from app.routes.pages import page_bp
View File
+3 -3
View File
@@ -1,14 +1,14 @@
''' '''
资源文件读取路由 资源文件读取路由
''' '''
from flask import Blueprint, send_file from flask import Blueprint, send_file, jsonify
from ..utils import assets from ..utils import assets
asset_bp = Blueprint("asset", __name__, "/asset") asset_bp = Blueprint("asset", __name__, url_prefix="/asset")
@asset_bp.route("/list") @asset_bp.route("/list")
def asset_list(): def asset_list():
return assets.readAssetsList() return jsonify(assets.readAssetsList())
@asset_bp.route("/pic/<id>") @asset_bp.route("/pic/<id>")
def find_pic(id: str): def find_pic(id: str):
+4 -4
View File
@@ -1,15 +1,15 @@
''' '''
卡牌定义文件读取路由 卡牌定义文件读取路由
''' '''
from flask import Blueprint from flask import Blueprint, jsonify
from ..utils import cards from ..utils import cards
card_bp = Blueprint("card", __name__, "/card") card_bp = Blueprint("card", __name__, url_prefix="/card")
@card_bp.route("/list") @card_bp.route("/list")
def card_list(): def card_list():
return cards.readCardList() return jsonify(cards.readCardList())
@card_bp.route("/id/<id>") @card_bp.route("/id/<id>")
def search_card(id): def search_card(id):
return cards.readCard(id) return jsonify(cards.readCard(id))
+4 -4
View File
@@ -1,15 +1,15 @@
''' '''
物质定义文件读取路由 物质定义文件读取路由
''' '''
from flask import Blueprint from flask import Blueprint, jsonify
from ..utils import matters from ..utils import matters
matter_bp = Blueprint("matter", __name__, "/matter") matter_bp = Blueprint("matter", __name__, url_prefix="/matter")
@matter_bp.route("/list") @matter_bp.route("/list")
def matter_list(): def matter_list():
return matters.readMatterList() return jsonify(matters.readMatterList())
@matter_bp.route("/id/<id>") @matter_bp.route("/id/<id>")
def search_matter(id): def search_matter(id):
return matters.readMatter(id) return jsonify(matters.readMatter(id))
+8 -3
View File
@@ -2,9 +2,14 @@
网页路由 网页路由
''' '''
from flask import Blueprint, jsonify from flask import Blueprint, jsonify
from ..utils import index
page_bp = Blueprint("page", __name__, "/") page_bp = Blueprint("page", __name__, url_prefix="/")
@page_bp.route("/") @page_bp.route("/")
def index(): def index_page():
return jsonify({"code": "200", "message": "Service normal"}) return jsonify({"code": "200", "message": "Service normal"})
@page_bp.route("/index")
def description():
return jsonify(index.readIndex())
+6 -6
View File
@@ -1,23 +1,23 @@
''' '''
反应定义文件读取路由 反应定义文件读取路由
''' '''
from flask import Blueprint from flask import Blueprint, jsonify
from ..utils import reactions from ..utils import reactions
reaction_bp = Blueprint("reaction", __name__, "/reaction") reaction_bp = Blueprint("reaction", __name__, url_prefix="/reaction")
@reaction_bp.route("list") @reaction_bp.route("list")
def reaction_list(): def reaction_list():
return reactions.readReactionList() return jsonify(reactions.readReactionList())
@reaction_bp.route("/match") @reaction_bp.route("/match")
def match_list(): def match_list():
return reactions.readMatchList() return jsonify(reactions.readMatchList())
@reaction_bp.route("/id/<id>") @reaction_bp.route("/id/<id>")
def search_reaction(id): def search_reaction(id):
return reactions.readReaction(id) return jsonify(reactions.readReaction(id))
@reaction_bp.route("/match/<id>") @reaction_bp.route("/match/<id>")
def select_reaction(id): def select_reaction(id):
return reactions.selectReaction(id) return jsonify(reactions.selectReaction(id))
+12
View File
@@ -0,0 +1,12 @@
'''
读取 description.json 的内容
'''
import json
def readIndex() -> dict:
with open("resources/description.json", "r", encoding="utf8") as f:
text = f.read()
result = json.loads(text)
return result
+1
View File
@@ -3,6 +3,7 @@
"en-US": "Carbon", "en-US": "Carbon",
"zh-CN": "碳" "zh-CN": "碳"
}, },
"type": "Element/Solid",
"number": 6, "number": 6,
"mass": 12 "mass": 12
} }
+1
View File
@@ -3,6 +3,7 @@
"en-US": "Oxygen", "en-US": "Oxygen",
"zh-CN": "氧" "zh-CN": "氧"
}, },
"type": "Element/Solid",
"number": 8, "number": 8,
"mass": 16 "mass": 16
} }
-6
View File
@@ -1,6 +0,0 @@
{
"name": {
"en-US": "Ignite",
"zh-CN": "点燃"
}
}
-3
View File
@@ -1,3 +0,0 @@
{
"Ignite": "Ignite"
}
+9
View File
@@ -0,0 +1,9 @@
{
"name": "Offical Example",
"author": "Paper Chemis Community Team",
"uuid": "6b3d2702c1c345499fc8617d664b3627",
"rules": {
"common": true
}
}
@@ -3,5 +3,6 @@
"en-US": "Carbon Dioxide", "en-US": "Carbon Dioxide",
"zh-CN": "二氧化碳" "zh-CN": "二氧化碳"
}, },
"type": "Compound/Gas",
"mass": 44 "mass": 44
} }
+1
View File
@@ -3,6 +3,7 @@
"en-US": "Carbon", "en-US": "Carbon",
"zh-CN": "碳" "zh-CN": "碳"
}, },
"type": "Element/Solid",
"number": 6, "number": 6,
"mass": 12 "mass": 12
} }
+1
View File
@@ -3,6 +3,7 @@
"en-US": "Oxygen", "en-US": "Oxygen",
"zh-CN": "氧" "zh-CN": "氧"
}, },
"type": "Element/Solid",
"number": 8, "number": 8,
"mass": 16 "mass": 16
} }