mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-Nonebot.git
synced 2026-04-01 22:04:51 +00:00
feat(tarot): 新增六芒星牌阵支持
- 新增A1Hexagram.html模板文件 - 调整A1CelticCross.html样式,移除背景图片并微调布局 - 更新tarot.py中的牌阵配置,增加html_name字段 - 修改fortune.py,支持六芒星牌阵选项
This commit is contained in:
parent
aa4749bbd9
commit
72d344ca11
5 changed files with 181 additions and 12 deletions
|
|
@ -127,10 +127,10 @@ class TarotExtractLog(Model):
|
|||
cards = []
|
||||
deck = []
|
||||
spread_config = {
|
||||
4: {"name":"三角牌阵","count": 3, "positions": ["过去", "现在", "未来"]},
|
||||
5: {"name":"六芒星牌阵","count": 6, "positions": ["现状", "挑战", "建议", "根源", "希望", "结果"]},
|
||||
6: {"name":"凯尔特十字牌阵","count": 10,"positions": ["核心", "阻碍", "过去", "现在", "未来", "潜在", "态度", "环境", "希望", "结果"]},
|
||||
7: {"name":"恋人牌阵","count": 5, "positions": ["自我状态", "对方状态", "关系现状", "挑战", "未来"]}
|
||||
4: {"name":"三角牌阵","html_name":"A1CelticCross.html","count": 3, "positions": ["过去", "现在", "未来"]},
|
||||
5: {"name":"六芒星牌阵","html_name":"A1Hexagram.html","count": 6, "positions": ["过去", "现在", "未来", "潜在", "外部", "结果"]},
|
||||
6: {"name":"凯尔特十字牌阵","html_name":"","count": 10,"positions": ["核心", "阻碍", "过去", "现在", "未来", "潜在", "态度", "环境", "希望", "结果"]},
|
||||
7: {"name":"恋人牌阵","html_name":"","count": 5, "positions": ["自我状态", "对方状态", "关系现状", "挑战", "未来"]}
|
||||
}
|
||||
deck = await MajorArcana.all() + await MinorArcana.all()
|
||||
# 防止重复抽牌
|
||||
|
|
@ -149,7 +149,8 @@ class TarotExtractLog(Model):
|
|||
"orientation": orientation,
|
||||
"position_meaning": spread_config[extract_type]["positions"][len(cards)]
|
||||
})
|
||||
file_path = temp_path + user_id + f"{spread_config[extract_type]['name']}{datetime.now().date()}.png"
|
||||
file_path = temp_path + user_id + f"{spread_config[extract_type]['name']}{datetime.now().date()}.jpeg"
|
||||
template_name = f"{spread_config[extract_type]['html_name']}"
|
||||
# 创建记录
|
||||
log = await cls.create(
|
||||
user_id=user_id,
|
||||
|
|
@ -163,13 +164,15 @@ class TarotExtractLog(Model):
|
|||
)
|
||||
image_bytes = await template_to_pic(
|
||||
template_path = tarots_img_path,
|
||||
template_name="A1CelticCross.html",
|
||||
template_name = template_name,
|
||||
templates={"data": log.spread_data.get("cards")},
|
||||
quality=80,
|
||||
type="jpeg",
|
||||
pages={
|
||||
"viewport": {"width": 980, "height": 900},
|
||||
"viewport": {"width": 1100, "height": 1200},
|
||||
"base_url": f"file://{getcwd()}",
|
||||
},
|
||||
wait=2,
|
||||
wait=10,
|
||||
)
|
||||
with open(file_path, "wb") as file:
|
||||
file.write(image_bytes)
|
||||
|
|
|
|||
|
|
@ -40,12 +40,13 @@ tarot = on_command("今日塔罗", rule=to_me(), priority=10, block=True)
|
|||
async def get_tarot(message: MessageEvent):
|
||||
#extract_type : 1大阿尔克纳牌 2小阿尔克纳牌 3 混合牌组 4三角牌阵 5六芒星牌阵 6凯尔特十字牌阵 7恋人牌阵
|
||||
value = message.get_plaintext().strip().split(" ")
|
||||
if len(value) < 2 or len(value) > 2 or value[1] == "" or value[1] not in ["1","2","3","4"]:
|
||||
if len(value) < 2 or len(value) > 2 or value[1] == "" or value[1] not in ["1","2","3","4","5"]:
|
||||
await tarot.finish("请输入正确的指令格式:/今日塔罗 + 数字(1-7) \n"
|
||||
"1 大阿尔克纳牌 \n"
|
||||
"2 小阿尔克纳牌 \n"
|
||||
"3 混合牌组 \n"
|
||||
"4 三角牌阵 "
|
||||
"4 三角牌阵 \n"
|
||||
"5 六芒星牌阵 "
|
||||
)
|
||||
result = await TarotExtractLog.tarotChoice(int(value[1]),message.get_user_id())
|
||||
if result.extract_type in [1,2,3]:
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 869 KiB |
|
|
@ -13,7 +13,6 @@
|
|||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
background: url('1.jpg') center/cover fixed;
|
||||
font-family: '华文楷体', serif;
|
||||
color: #f0e6d6;
|
||||
display: grid;
|
||||
|
|
@ -54,7 +53,7 @@
|
|||
}
|
||||
|
||||
#present {
|
||||
bottom: -180px;
|
||||
bottom: -165px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
|
@ -96,6 +95,7 @@
|
|||
padding: 0 10px;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
165
src/resources/image/tarot/TarotImages/A1Hexagram.html
Normal file
165
src/resources/image/tarot/TarotImages/A1Hexagram.html
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>六芒星塔罗牌阵</title>
|
||||
<style>
|
||||
:root {
|
||||
--card-width: 200px;
|
||||
--card-height: 320px;
|
||||
--spacing: 40px;
|
||||
--star-size: calc(3 * var(--card-width) + 2 * var(--spacing));
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
font-family: '华文楷体', cursive;
|
||||
color: #f0e6d6;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.star-container {
|
||||
position: relative;
|
||||
width: var(--star-size);
|
||||
height: calc(var(--star-size) * 0.866);
|
||||
margin: 2rem;
|
||||
}
|
||||
|
||||
.card {
|
||||
position: absolute;
|
||||
width: var(--card-width);
|
||||
height: 680px;
|
||||
background: rgba(0,0,0,0.9);
|
||||
border-radius: 15px;
|
||||
padding: 1.2rem;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.5);
|
||||
border: 2px solid #635944;
|
||||
transition: transform 0.3s ease;
|
||||
backdrop-filter: blur(3px);
|
||||
}
|
||||
|
||||
/* 六芒星定位公式 */
|
||||
#card1 {
|
||||
top: -20%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
#card2 {
|
||||
bottom: -150%;
|
||||
right: -15%;
|
||||
}
|
||||
|
||||
#card3 {
|
||||
top: 0;
|
||||
bottom: 25%;
|
||||
right: -15%;
|
||||
}
|
||||
|
||||
#card4 {
|
||||
bottom: -180%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
#card5 {
|
||||
bottom: -150%;
|
||||
left: -15%;
|
||||
}
|
||||
|
||||
#card6 {
|
||||
top: 0;
|
||||
bottom: 25%;
|
||||
left: -15%;
|
||||
}
|
||||
|
||||
.card img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
object-fit: cover;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 1rem;
|
||||
border: 1px solid #786642;
|
||||
}
|
||||
|
||||
.card h3 {
|
||||
margin: 0 0 0.8rem;
|
||||
color: #d4af37;
|
||||
font-size: 1.4rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.card-position {
|
||||
color: #b89068;
|
||||
font-size: 1rem;
|
||||
text-align: center;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.card p {
|
||||
line-height: 1.5;
|
||||
font-size: 0.8rem;
|
||||
padding: 0 1rem;
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="star-container">
|
||||
|
||||
<!-- 2. 现在 -->
|
||||
<div class="card" id="card1">
|
||||
<img src="{{data[1].image}}" >
|
||||
<h3>{{data[1].name}}</h3>
|
||||
<div class="card-position">▶ 现在 ▶</div>
|
||||
<p>{{data[1].meaning}}</p>
|
||||
</div>
|
||||
|
||||
<!-- 3.未来 -->
|
||||
<div class="card" id="card2">
|
||||
<img src="{{data[2].image}}" >
|
||||
<h3>{{data[2].name}}</h3>
|
||||
<div class="card-position">▲ 未来 ▲</div>
|
||||
<p>{{data[2].meaning}}</p>
|
||||
</div>
|
||||
|
||||
<!-- 5. 外部 -->
|
||||
<div class="card" id="card3">
|
||||
<img src="{{data[4].image}}" alt="外部">
|
||||
<h3>{{data[4].name}}</h3>
|
||||
<div class="card-position">▲ 外部 ▲</div>
|
||||
<p>{{data[4].meaning}}</p>
|
||||
</div>
|
||||
|
||||
<!-- 6. 结果 -->
|
||||
<div class="card" id="card4">
|
||||
<img src="{{data[5].image}}" alt="结果">
|
||||
<h3>{{data[5].name}}</h3>
|
||||
<div class="card-position">◆ 结果 ◆</div>
|
||||
<p>{{data[5].meaning}}</p>
|
||||
</div>
|
||||
|
||||
<!-- 1.过去 -->
|
||||
<div class="card" id="card5">
|
||||
<img src="{{data[0].image}}" alt="环境">
|
||||
<h3>{{data[0].name}}</h3>
|
||||
<div class="card-position"> ▼ 过去 ▼ </div>
|
||||
<p>{{data[0].meaning}}</p>
|
||||
</div>
|
||||
|
||||
<!-- 4. 内在 -->
|
||||
<div class="card" id="card6">
|
||||
<img src="{{data[3].image}}" alt="内在">
|
||||
<h3>{{data[3].name}}</h3>
|
||||
<div class="card-position">◆ 潜在 ◆</div>
|
||||
<p>{{data[3].meaning}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in a new issue