Compare commits
17 Commits
19bc27c36e
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 0cc776becb | |||
| fbbfc74f6f | |||
| 1ac892e15f | |||
| 0643975115 | |||
| b3ce44e057 | |||
| 4a2031fcce | |||
| a87c141011 | |||
| 9f29d073d0 | |||
| 2a93a7813f | |||
| 85740b1d5f | |||
| ec6437448e | |||
| fce222a63f | |||
| 89d1f6076a | |||
| 379b31fb5b | |||
| b20040abc1 | |||
| 6b7af1301f | |||
| 8455dc7924 |
@@ -620,18 +620,7 @@ copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
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.>
|
||||
Paper Chemis Community
|
||||
Copyright (C) 2026 Tiger
|
||||
|
||||
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
|
||||
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>.
|
||||
|
||||
@@ -29,6 +29,7 @@ backend/
|
||||
- matters.py
|
||||
- reactions.py
|
||||
- resources/
|
||||
- description.json
|
||||
- assets/
|
||||
- index.json
|
||||
- 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
|
||||
|
||||
`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`)。
|
||||
|
||||
@@ -3,6 +3,7 @@ from flask import Flask
|
||||
def create_app(config_class='config.Config'):
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(config_class)
|
||||
app.json.ensure_ascii = False # type: ignore
|
||||
|
||||
# 注册蓝图
|
||||
from app.routes.pages import page_bp
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
'''
|
||||
资源文件读取路由
|
||||
'''
|
||||
from flask import Blueprint, send_file
|
||||
from flask import Blueprint, send_file, jsonify
|
||||
from ..utils import assets
|
||||
|
||||
asset_bp = Blueprint("asset", __name__, "/asset")
|
||||
asset_bp = Blueprint("asset", __name__, url_prefix="/asset")
|
||||
|
||||
@asset_bp.route("/list")
|
||||
def asset_list():
|
||||
return assets.readAssetsList()
|
||||
return jsonify(assets.readAssetsList())
|
||||
|
||||
@asset_bp.route("/pic/<id>")
|
||||
def find_pic(id: str):
|
||||
|
||||
+4
-4
@@ -1,15 +1,15 @@
|
||||
'''
|
||||
卡牌定义文件读取路由
|
||||
'''
|
||||
from flask import Blueprint
|
||||
from flask import Blueprint, jsonify
|
||||
from ..utils import cards
|
||||
|
||||
card_bp = Blueprint("card", __name__, "/card")
|
||||
card_bp = Blueprint("card", __name__, url_prefix="/card")
|
||||
|
||||
@card_bp.route("/list")
|
||||
def card_list():
|
||||
return cards.readCardList()
|
||||
return jsonify(cards.readCardList())
|
||||
|
||||
@card_bp.route("/id/<id>")
|
||||
def search_card(id):
|
||||
return cards.readCard(id)
|
||||
return jsonify(cards.readCard(id))
|
||||
@@ -1,15 +1,15 @@
|
||||
'''
|
||||
物质定义文件读取路由
|
||||
'''
|
||||
from flask import Blueprint
|
||||
from flask import Blueprint, jsonify
|
||||
from ..utils import matters
|
||||
|
||||
matter_bp = Blueprint("matter", __name__, "/matter")
|
||||
matter_bp = Blueprint("matter", __name__, url_prefix="/matter")
|
||||
|
||||
@matter_bp.route("/list")
|
||||
def matter_list():
|
||||
return matters.readMatterList()
|
||||
return jsonify(matters.readMatterList())
|
||||
|
||||
@matter_bp.route("/id/<id>")
|
||||
def search_matter(id):
|
||||
return matters.readMatter(id)
|
||||
return jsonify(matters.readMatter(id))
|
||||
+8
-3
@@ -2,9 +2,14 @@
|
||||
网页路由
|
||||
'''
|
||||
from flask import Blueprint, jsonify
|
||||
from ..utils import index
|
||||
|
||||
page_bp = Blueprint("page", __name__, "/")
|
||||
page_bp = Blueprint("page", __name__, url_prefix="/")
|
||||
|
||||
@page_bp.route("/")
|
||||
def index():
|
||||
return jsonify({"code": "200", "message": "Service normal"})
|
||||
def index_page():
|
||||
return jsonify({"code": "200", "message": "Service normal"})
|
||||
|
||||
@page_bp.route("/index")
|
||||
def description():
|
||||
return jsonify(index.readIndex())
|
||||
@@ -1,23 +1,23 @@
|
||||
'''
|
||||
反应定义文件读取路由
|
||||
'''
|
||||
from flask import Blueprint
|
||||
from flask import Blueprint, jsonify
|
||||
from ..utils import reactions
|
||||
|
||||
reaction_bp = Blueprint("reaction", __name__, "/reaction")
|
||||
reaction_bp = Blueprint("reaction", __name__, url_prefix="/reaction")
|
||||
|
||||
@reaction_bp.route("list")
|
||||
def reaction_list():
|
||||
return reactions.readReactionList()
|
||||
return jsonify(reactions.readReactionList())
|
||||
|
||||
@reaction_bp.route("/match")
|
||||
def match_list():
|
||||
return reactions.readMatchList()
|
||||
return jsonify(reactions.readMatchList())
|
||||
|
||||
@reaction_bp.route("/id/<id>")
|
||||
def search_reaction(id):
|
||||
return reactions.readReaction(id)
|
||||
return jsonify(reactions.readReaction(id))
|
||||
|
||||
@reaction_bp.route("/match/<id>")
|
||||
def select_reaction(id):
|
||||
return reactions.selectReaction(id)
|
||||
return jsonify(reactions.selectReaction(id))
|
||||
@@ -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
|
||||
@@ -3,6 +3,7 @@
|
||||
"en-US": "Carbon",
|
||||
"zh-CN": "碳"
|
||||
},
|
||||
"type": "Element/Solid",
|
||||
"number": 6,
|
||||
"mass": 12
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
"en-US": "Oxygen",
|
||||
"zh-CN": "氧"
|
||||
},
|
||||
"type": "Element/Solid",
|
||||
"number": 8,
|
||||
"mass": 16
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"name": {
|
||||
"en-US": "Ignite",
|
||||
"zh-CN": "点燃"
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"Ignite": "Ignite"
|
||||
}
|
||||
@@ -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",
|
||||
"zh-CN": "二氧化碳"
|
||||
},
|
||||
"type": "Compound/Gas",
|
||||
"mass": 44
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
"en-US": "Carbon",
|
||||
"zh-CN": "碳"
|
||||
},
|
||||
"type": "Element/Solid",
|
||||
"number": 6,
|
||||
"mass": 12
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
"en-US": "Oxygen",
|
||||
"zh-CN": "氧"
|
||||
},
|
||||
"type": "Element/Solid",
|
||||
"number": 8,
|
||||
"mass": 16
|
||||
}
|
||||
Reference in New Issue
Block a user