feat: Loksyu & TinJi standalone AppV2 apps with chat buttons and dice automation
- CDELoksyuApp: standalone HandlebarsApplicationMixin(ApplicationV2) app - 5-element Wu Xing grid with yin/yang inputs per element - Per-element reset buttons + global reset-all - Auto-refresh via updateActor hook - CDETinjiApp: standalone AppV2 for the collective Tin Ji dice pool - Large neon counter with +/- buttons and direct input - Spend button sends a chat message with remaining count - singletons.js: shared utilities - getSingletonActor: find or auto-create singleton actor - updateLoksyuFromRoll: compute lokAspect from Wu Xing cycle, update yin/yang - updateTinjiFromRoll: add tinji face count to value - rolling.js: auto-update both singletons after every dice roll (weapon path + main roll path) - system.js: renderChatLog hook injects Loksyu/TinJi footer buttons in the chat sidebar - loksyu.js / tinji.js: actor sheets redirect to standalone apps when opened via the sidebar - CSS: .cde-loksyu-standalone, .cde-tinji-standalone, .cde-chat-app-buttons, .cde-tinji-spend-msg styles added - i18n: new keys in fr-cde.json and en-cde.json for all new UI strings (LoksyuNotFound, TinjiNotFound, Reset, ResetAll, SpendTinji, etc.) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -981,6 +981,346 @@ section.npc .cde-neon-tabs .item.active {
|
||||
.cde-npc-tracks .cde-track-note input {
|
||||
width: 100%;
|
||||
}
|
||||
.cde-chat-app-buttons {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
padding: 6px 8px 4px;
|
||||
border-top: 1px solid #1a2436;
|
||||
}
|
||||
.cde-chat-app-buttons .cde-chat-btn {
|
||||
flex: 1 1 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
padding: 5px 8px;
|
||||
font-size: 11px;
|
||||
font-family: "Orbitron", "Averia", sans-serif;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
background: #101622;
|
||||
border: 1px solid #1a2436;
|
||||
border-radius: 4px;
|
||||
color: #7d94b8;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.cde-chat-app-buttons .cde-chat-btn i {
|
||||
font-size: 12px;
|
||||
}
|
||||
.cde-chat-app-buttons .cde-chat-btn:hover {
|
||||
background: rgba(74, 158, 255, 0.1);
|
||||
border-color: #4a9eff;
|
||||
color: #4a9eff;
|
||||
box-shadow: 0 0 8px rgba(74, 158, 255, 0.3);
|
||||
}
|
||||
.cde-chat-app-buttons .cde-chat-btn--tinji:hover {
|
||||
background: rgba(255, 61, 90, 0.1);
|
||||
border-color: #ff3d5a;
|
||||
color: #ff3d5a;
|
||||
box-shadow: 0 0 8px rgba(255, 61, 90, 0.3);
|
||||
}
|
||||
.cde-loksyu-standalone .cde-loksyu-app-body {
|
||||
padding: 12px;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-loksyu-elements {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-card {
|
||||
background: rgba(16, 22, 34, 0.8);
|
||||
border: 1px solid #1a2436;
|
||||
border-radius: 6px;
|
||||
padding: 8px 6px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-card--wood:hover {
|
||||
border-color: #4a9e3f;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-card--wood .cde-lok-input:focus {
|
||||
border-bottom-color: #4a9e3f;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-card--fire:hover {
|
||||
border-color: #ff3d5a;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-card--fire .cde-lok-input:focus {
|
||||
border-bottom-color: #ff3d5a;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-card--earth:hover {
|
||||
border-color: #c88a3a;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-card--earth .cde-lok-input:focus {
|
||||
border-bottom-color: #c88a3a;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-card--metal:hover {
|
||||
border-color: #7d94b8;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-card--metal .cde-lok-input:focus {
|
||||
border-bottom-color: #7d94b8;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-card--water:hover {
|
||||
border-color: #4a9eff;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-card--water .cde-lok-input:focus {
|
||||
border-bottom-color: #4a9eff;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-header img.cde-lok-icon {
|
||||
border-radius: 4px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-titles {
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-titles .cde-lok-name {
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
color: #e2e8f4;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-titles .cde-lok-qual {
|
||||
font-size: 9px;
|
||||
color: #7d94b8;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-reset {
|
||||
color: #7d94b8;
|
||||
font-size: 11px;
|
||||
flex-shrink: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-reset:hover {
|
||||
color: #e2e8f4;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-values {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-polarity {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-polarity .cde-lok-pol-label {
|
||||
font-size: 9px;
|
||||
color: #7d94b8;
|
||||
width: 30px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-polarity--yang .cde-lok-pol-label {
|
||||
color: #e2e8f4;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-input {
|
||||
flex: 1 1 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-bottom: 1px solid #1a2436;
|
||||
color: #e2e8f4;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
padding: 2px 0;
|
||||
transition: border-bottom-color 0.2s;
|
||||
width: 100%;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-input:focus {
|
||||
outline: none;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-input[disabled] {
|
||||
opacity: 0.5;
|
||||
cursor: default;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-loksyu-visual-row {
|
||||
text-align: center;
|
||||
margin: 6px 0;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-loksyu-visual-row .cde-lok-visual {
|
||||
max-width: 100%;
|
||||
max-height: 80px;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-footer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding-top: 6px;
|
||||
border-top: 1px solid #1a2436;
|
||||
margin-top: 6px;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-reset-all {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 5px 14px;
|
||||
font-size: 11px;
|
||||
background: rgba(255, 61, 90, 0.12);
|
||||
border: 1px solid rgba(255, 61, 90, 0.3);
|
||||
border-radius: 4px;
|
||||
color: #7d94b8;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.cde-loksyu-standalone .cde-lok-reset-all:hover {
|
||||
background: rgba(255, 61, 90, 0.2);
|
||||
border-color: #ff3d5a;
|
||||
color: #e2e8f4;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-app-body {
|
||||
padding: 16px 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-display {
|
||||
flex: 1 1 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-chinese-large {
|
||||
font-size: 40px;
|
||||
color: #ff3d5a;
|
||||
text-shadow: 0 0 20px rgba(255, 61, 90, 0.6);
|
||||
line-height: 1;
|
||||
font-family: serif;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-label {
|
||||
font-size: 10px;
|
||||
font-family: "Orbitron", sans-serif;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.12em;
|
||||
color: #7d94b8;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-counter {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 4px 0;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-step {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
background: #101622;
|
||||
border: 1px solid #1a2436;
|
||||
border-radius: 50%;
|
||||
color: #7d94b8;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.2s;
|
||||
line-height: 1;
|
||||
padding: 0;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-step:hover {
|
||||
background: rgba(255, 61, 90, 0.15);
|
||||
border-color: #ff3d5a;
|
||||
color: #ff3d5a;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-direct {
|
||||
width: 72px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-bottom: 2px solid #ff3d5a;
|
||||
color: #ff3d5a;
|
||||
font-size: 36px;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
text-shadow: 0 0 12px rgba(255, 61, 90, 0.5);
|
||||
padding: 0;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-direct:focus {
|
||||
outline: none;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-direct[disabled] {
|
||||
opacity: 0.7;
|
||||
cursor: default;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-hint {
|
||||
font-size: 10px;
|
||||
color: #7d94b8;
|
||||
text-align: center;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-actions {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-spend-btn,
|
||||
.cde-tinji-standalone .cde-tinji-reset-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 5px 12px;
|
||||
font-size: 11px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-spend-btn {
|
||||
background: rgba(255, 61, 90, 0.15);
|
||||
border: 1px solid #ff3d5a;
|
||||
color: #ff3d5a;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-spend-btn:hover {
|
||||
background: rgba(255, 61, 90, 0.3);
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-spend-btn[disabled] {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
pointer-events: none;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-reset-btn {
|
||||
background: #101622;
|
||||
border: 1px solid #1a2436;
|
||||
color: #7d94b8;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-reset-btn:hover {
|
||||
border-color: #e2e8f4;
|
||||
color: #e2e8f4;
|
||||
}
|
||||
.cde-tinji-standalone .cde-tinji-visual {
|
||||
width: 90px;
|
||||
height: auto;
|
||||
opacity: 0.6;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.cde-tinji-spend-msg {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
padding: 6px 8px;
|
||||
background: rgba(255, 61, 90, 0.08);
|
||||
border-left: 3px solid #ff3d5a;
|
||||
border-radius: 4px;
|
||||
color: #e2e8f4;
|
||||
}
|
||||
.cde-tinji-spend-msg i {
|
||||
color: #ff3d5a;
|
||||
}
|
||||
.cde-tinji-spend-msg .cde-tinji-remain {
|
||||
margin-left: auto;
|
||||
font-size: 10px;
|
||||
color: #7d94b8;
|
||||
}
|
||||
.cde-loksyu-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
|
||||
@@ -1032,6 +1032,351 @@ section.npc .cde-neon-tabs .item.active { color: @cde-supernatural; borde
|
||||
// ============================================================
|
||||
// Loksyu — 5 elemental cards grid
|
||||
// ============================================================
|
||||
// ============================================================
|
||||
// Chat buttons — Loksyu / TinJi quick-access
|
||||
// ============================================================
|
||||
.cde-chat-app-buttons {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
padding: 6px 8px 4px;
|
||||
border-top: 1px solid @cde-border;
|
||||
|
||||
.cde-chat-btn {
|
||||
flex: 1 1 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
padding: 5px 8px;
|
||||
font-size: 11px;
|
||||
font-family: "Orbitron", "Averia", sans-serif;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
background: @cde-surface;
|
||||
border: 1px solid @cde-border;
|
||||
border-radius: 4px;
|
||||
color: @cde-muted;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
|
||||
i { font-size: 12px; }
|
||||
|
||||
&:hover {
|
||||
background: fade(@cde-spell, 10%);
|
||||
border-color: @cde-spell;
|
||||
color: @cde-spell;
|
||||
box-shadow: 0 0 8px fade(@cde-spell, 30%);
|
||||
}
|
||||
|
||||
&--tinji:hover {
|
||||
background: fade(@cde-kungfu, 10%);
|
||||
border-color: @cde-kungfu;
|
||||
color: @cde-kungfu;
|
||||
box-shadow: 0 0 8px fade(@cde-kungfu, 30%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Loksyu standalone app
|
||||
// ============================================================
|
||||
.cde-loksyu-standalone {
|
||||
.cde-loksyu-app-body {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.cde-loksyu-elements {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.cde-lok-card {
|
||||
background: fade(@cde-surface, 80%);
|
||||
border: 1px solid @cde-border;
|
||||
border-radius: 6px;
|
||||
padding: 8px 6px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
transition: border-color 0.2s;
|
||||
|
||||
&--wood { &:hover { border-color: #4a9e3f; } .cde-lok-input:focus { border-bottom-color: #4a9e3f; } }
|
||||
&--fire { &:hover { border-color: @cde-kungfu; } .cde-lok-input:focus { border-bottom-color: @cde-kungfu; } }
|
||||
&--earth { &:hover { border-color: #c88a3a; } .cde-lok-input:focus { border-bottom-color: #c88a3a; } }
|
||||
&--metal { &:hover { border-color: @cde-muted; } .cde-lok-input:focus { border-bottom-color: @cde-muted; } }
|
||||
&--water { &:hover { border-color: @cde-spell; } .cde-lok-input:focus { border-bottom-color: @cde-spell; } }
|
||||
}
|
||||
|
||||
.cde-lok-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
|
||||
img.cde-lok-icon { border-radius: 4px; flex-shrink: 0; }
|
||||
}
|
||||
|
||||
.cde-lok-titles {
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.cde-lok-name {
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
color: @cde-text;
|
||||
}
|
||||
|
||||
.cde-lok-qual {
|
||||
font-size: 9px;
|
||||
color: @cde-muted;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
|
||||
.cde-lok-reset {
|
||||
color: @cde-muted;
|
||||
font-size: 11px;
|
||||
flex-shrink: 0;
|
||||
cursor: pointer;
|
||||
&:hover { color: @cde-text; }
|
||||
}
|
||||
|
||||
.cde-lok-values {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.cde-lok-polarity {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
|
||||
.cde-lok-pol-label {
|
||||
font-size: 9px;
|
||||
color: @cde-muted;
|
||||
width: 30px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&--yang .cde-lok-pol-label { color: @cde-text; }
|
||||
}
|
||||
|
||||
.cde-lok-input {
|
||||
flex: 1 1 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-bottom: 1px solid @cde-border;
|
||||
color: @cde-text;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
padding: 2px 0;
|
||||
transition: border-bottom-color 0.2s;
|
||||
width: 100%;
|
||||
|
||||
&:focus { outline: none; }
|
||||
&[disabled] { opacity: 0.5; cursor: default; }
|
||||
}
|
||||
|
||||
.cde-loksyu-visual-row {
|
||||
text-align: center;
|
||||
margin: 6px 0;
|
||||
|
||||
.cde-lok-visual {
|
||||
max-width: 100%;
|
||||
max-height: 80px;
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
|
||||
.cde-lok-footer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding-top: 6px;
|
||||
border-top: 1px solid @cde-border;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.cde-lok-reset-all {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 5px 14px;
|
||||
font-size: 11px;
|
||||
background: fade(@cde-kungfu, 12%);
|
||||
border: 1px solid fade(@cde-kungfu, 30%);
|
||||
border-radius: 4px;
|
||||
color: @cde-muted;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: fade(@cde-kungfu, 20%);
|
||||
border-color: @cde-kungfu;
|
||||
color: @cde-text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// TinJi standalone app
|
||||
// ============================================================
|
||||
.cde-tinji-standalone {
|
||||
.cde-tinji-app-body {
|
||||
padding: 16px 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.cde-tinji-display {
|
||||
flex: 1 1 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.cde-tinji-chinese-large {
|
||||
font-size: 40px;
|
||||
color: @cde-kungfu;
|
||||
text-shadow: 0 0 20px fade(@cde-kungfu, 60%);
|
||||
line-height: 1;
|
||||
font-family: serif;
|
||||
}
|
||||
|
||||
.cde-tinji-label {
|
||||
font-size: 10px;
|
||||
font-family: "Orbitron", sans-serif;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.12em;
|
||||
color: @cde-muted;
|
||||
}
|
||||
|
||||
.cde-tinji-counter {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 4px 0;
|
||||
}
|
||||
|
||||
.cde-tinji-step {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
background: @cde-surface;
|
||||
border: 1px solid @cde-border;
|
||||
border-radius: 50%;
|
||||
color: @cde-muted;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.2s;
|
||||
line-height: 1;
|
||||
padding: 0;
|
||||
|
||||
&:hover {
|
||||
background: fade(@cde-kungfu, 15%);
|
||||
border-color: @cde-kungfu;
|
||||
color: @cde-kungfu;
|
||||
}
|
||||
}
|
||||
|
||||
.cde-tinji-direct {
|
||||
width: 72px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-bottom: 2px solid @cde-kungfu;
|
||||
color: @cde-kungfu;
|
||||
font-size: 36px;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
text-shadow: 0 0 12px fade(@cde-kungfu, 50%);
|
||||
padding: 0;
|
||||
|
||||
&:focus { outline: none; }
|
||||
&[disabled] { opacity: 0.7; cursor: default; }
|
||||
}
|
||||
|
||||
.cde-tinji-hint {
|
||||
font-size: 10px;
|
||||
color: @cde-muted;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.cde-tinji-actions {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.cde-tinji-spend-btn,
|
||||
.cde-tinji-reset-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 5px 12px;
|
||||
font-size: 11px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.cde-tinji-spend-btn {
|
||||
background: fade(@cde-kungfu, 15%);
|
||||
border: 1px solid @cde-kungfu;
|
||||
color: @cde-kungfu;
|
||||
|
||||
&:hover { background: fade(@cde-kungfu, 30%); }
|
||||
&[disabled] { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
|
||||
}
|
||||
|
||||
.cde-tinji-reset-btn {
|
||||
background: @cde-surface;
|
||||
border: 1px solid @cde-border;
|
||||
color: @cde-muted;
|
||||
|
||||
&:hover { border-color: @cde-text; color: @cde-text; }
|
||||
}
|
||||
|
||||
.cde-tinji-visual {
|
||||
width: 90px;
|
||||
height: auto;
|
||||
opacity: 0.6;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Chat Tin Ji spend message
|
||||
.cde-tinji-spend-msg {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
padding: 6px 8px;
|
||||
background: fade(@cde-kungfu, 8%);
|
||||
border-left: 3px solid @cde-kungfu;
|
||||
border-radius: 4px;
|
||||
color: @cde-text;
|
||||
|
||||
i { color: @cde-kungfu; }
|
||||
|
||||
.cde-tinji-remain {
|
||||
margin-left: auto;
|
||||
font-size: 10px;
|
||||
color: @cde-muted;
|
||||
}
|
||||
}
|
||||
|
||||
.cde-loksyu-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
|
||||
328
dist/system.js
vendored
328
dist/system.js
vendored
@@ -100,7 +100,9 @@ var TEMPLATE_PARTIALS = [
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/actor/parts/cde-npc-supernaturals.html",
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/actor/parts/cde-npc-spells.html",
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/actor/parts/cde-npc-kungfus.html",
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/actor/parts/cde-npc-items.html"
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/actor/parts/cde-npc-items.html",
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/apps/cde-loksyu-app.html",
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/apps/cde-tinji-app.html"
|
||||
];
|
||||
|
||||
// src/config/localize.js
|
||||
@@ -927,6 +929,61 @@ async function rollInitiativeNPC(actor) {
|
||||
});
|
||||
}
|
||||
|
||||
// src/ui/apps/singletons.js
|
||||
var WU_XING_CYCLE = {
|
||||
wood: ["wood", "fire", "water", "earth", "metal"],
|
||||
fire: ["fire", "earth", "wood", "metal", "water"],
|
||||
earth: ["earth", "metal", "fire", "water", "wood"],
|
||||
metal: ["metal", "water", "earth", "wood", "fire"],
|
||||
water: ["water", "wood", "metal", "fire", "earth"]
|
||||
};
|
||||
var ASPECT_FACES = {
|
||||
metal: [3, 8],
|
||||
water: [1, 6],
|
||||
earth: [0, 5],
|
||||
fire: [2, 7],
|
||||
wood: [4, 9]
|
||||
};
|
||||
async function getSingletonActor(type) {
|
||||
const existing = game.actors.find((a) => a.type === type);
|
||||
if (existing) return existing;
|
||||
if (!game.user.isGM) {
|
||||
ui.notifications.warn(game.i18n.localize(type === ACTOR_TYPES.loksyu ? "CDE.LoksyuNotFound" : "CDE.TinjiNotFound"));
|
||||
return null;
|
||||
}
|
||||
const nameKey = type === ACTOR_TYPES.loksyu ? "CDE.UpperCaseLoksyu" : "CDE.UpperCaseTinJi";
|
||||
const actor = await Actor.create({
|
||||
name: game.i18n.localize(nameKey),
|
||||
type,
|
||||
img: type === ACTOR_TYPES.loksyu ? "systems/fvtt-chroniques-de-l-etrange/images/loksyu_long.webp" : "systems/fvtt-chroniques-de-l-etrange/images/tinji.webp"
|
||||
});
|
||||
return actor ?? null;
|
||||
}
|
||||
async function updateLoksyuFromRoll(activeAspect, faces) {
|
||||
const cycle = WU_XING_CYCLE[activeAspect];
|
||||
if (!cycle) return;
|
||||
const lokAspect = cycle[3];
|
||||
const [yinFace, yangFace] = ASPECT_FACES[lokAspect] ?? [];
|
||||
if (yinFace === void 0) return;
|
||||
const yinCount = faces[yinFace] ?? 0;
|
||||
const yangCount = faces[yangFace] ?? 0;
|
||||
if (yinCount === 0 && yangCount === 0) return;
|
||||
const actor = await getSingletonActor(ACTOR_TYPES.loksyu);
|
||||
if (!actor) return;
|
||||
const current = actor.system[lokAspect] ?? { yin: { value: 0 }, yang: { value: 0 } };
|
||||
await actor.update({
|
||||
[`system.${lokAspect}.yin.value`]: (current.yin.value ?? 0) + yinCount,
|
||||
[`system.${lokAspect}.yang.value`]: (current.yang.value ?? 0) + yangCount
|
||||
});
|
||||
}
|
||||
async function updateTinjiFromRoll(count) {
|
||||
if (!count || count <= 0) return;
|
||||
const actor = await getSingletonActor(ACTOR_TYPES.tinji);
|
||||
if (!actor) return;
|
||||
const current = actor.system.value ?? 0;
|
||||
await actor.update({ "system.value": current + count });
|
||||
}
|
||||
|
||||
// src/ui/rolling.js
|
||||
var RESULT_TEMPLATE2 = "systems/fvtt-chroniques-de-l-etrange/templates/form/cde-dice-result.html";
|
||||
var SKILL_PROMPT_TEMPLATE = "systems/fvtt-chroniques-de-l-etrange/templates/form/cde-skill-dice-prompt.html";
|
||||
@@ -955,7 +1012,7 @@ var ASPECT_ICONS = {
|
||||
fire: "systems/fvtt-chroniques-de-l-etrange/images/cde_feu.webp",
|
||||
wood: "systems/fvtt-chroniques-de-l-etrange/images/cde_bois.webp"
|
||||
};
|
||||
var ASPECT_FACES = {
|
||||
var ASPECT_FACES2 = {
|
||||
metal: [3, 8],
|
||||
water: [1, 6],
|
||||
earth: [0, 5],
|
||||
@@ -963,7 +1020,7 @@ var ASPECT_FACES = {
|
||||
fire: [2, 7],
|
||||
wood: [4, 9]
|
||||
};
|
||||
var WU_XING_CYCLE = {
|
||||
var WU_XING_CYCLE2 = {
|
||||
wood: ["wood", "fire", "water", "earth", "metal"],
|
||||
fire: ["fire", "earth", "wood", "metal", "water"],
|
||||
earth: ["earth", "metal", "fire", "water", "wood"],
|
||||
@@ -993,14 +1050,14 @@ function countFaces(rollResults) {
|
||||
return counts;
|
||||
}
|
||||
function computeWuXingResults(faces, aspectName, bonusAuspicious = 0) {
|
||||
const cycle = WU_XING_CYCLE[aspectName];
|
||||
const cycle = WU_XING_CYCLE2[aspectName];
|
||||
if (!cycle) return null;
|
||||
const [succAspect, ausAspect, noxAspect, lokAspect, tinAspect] = cycle;
|
||||
const [succYin, succYang] = ASPECT_FACES[succAspect];
|
||||
const [ausYin, ausYang] = ASPECT_FACES[ausAspect];
|
||||
const [noxYin, noxYang] = ASPECT_FACES[noxAspect];
|
||||
const [lokYin, lokYang] = ASPECT_FACES[lokAspect];
|
||||
const [tinYin, tinYang] = ASPECT_FACES[tinAspect];
|
||||
const [succYin, succYang] = ASPECT_FACES2[succAspect];
|
||||
const [ausYin, ausYang] = ASPECT_FACES2[ausAspect];
|
||||
const [noxYin, noxYang] = ASPECT_FACES2[noxAspect];
|
||||
const [lokYin, lokYang] = ASPECT_FACES2[lokAspect];
|
||||
const [tinYin, tinYang] = ASPECT_FACES2[tinAspect];
|
||||
const yin = game.i18n.localize("CDE.Yin");
|
||||
const yang = game.i18n.localize("CDE.Yang");
|
||||
return {
|
||||
@@ -1296,6 +1353,8 @@ async function rollForActor(actor, rollKey) {
|
||||
if (game.modules.get("dice-so-nice")?.active && wpMsg?.id) {
|
||||
await game.dice3d.waitFor3DAnimationByMessageID(wpMsg.id);
|
||||
}
|
||||
if ((wpResults.loksyudice ?? 0) > 0) await updateLoksyuFromRoll(wpAspectName, wpFaces);
|
||||
if ((wpResults.tinjidice ?? 0) > 0) await updateTinjiFromRoll(wpResults.tinjidice);
|
||||
return;
|
||||
}
|
||||
default:
|
||||
@@ -1449,6 +1508,8 @@ async function rollForActor(actor, rollKey) {
|
||||
if (game.modules.get("dice-so-nice")?.active && msg?.id) {
|
||||
await game.dice3d.waitFor3DAnimationByMessageID(msg.id);
|
||||
}
|
||||
if ((results.loksyudice ?? 0) > 0) await updateLoksyuFromRoll(wuXingAspectName, faces);
|
||||
if ((results.tinjidice ?? 0) > 0) await updateTinjiFromRoll(results.tinjidice);
|
||||
}
|
||||
|
||||
// src/ui/sheets/actors/base.js
|
||||
@@ -1769,6 +1830,118 @@ var CDENpcSheet = class extends CDEBaseActorSheet {
|
||||
}
|
||||
};
|
||||
|
||||
// src/ui/apps/tinji-app.js
|
||||
var SYSTEM_ID2 = "fvtt-chroniques-de-l-etrange";
|
||||
var CDETinjiApp = class _CDETinjiApp extends foundry.applications.api.HandlebarsApplicationMixin(
|
||||
foundry.applications.api.ApplicationV2
|
||||
) {
|
||||
static DEFAULT_OPTIONS = {
|
||||
id: "cde-tinji-app",
|
||||
tag: "div",
|
||||
window: {
|
||||
title: "CDE.TinJi2",
|
||||
icon: "fas fa-star",
|
||||
resizable: false
|
||||
},
|
||||
classes: ["cde-app", "cde-tinji-standalone"],
|
||||
position: { width: 320, height: "auto" },
|
||||
actions: {
|
||||
increment: _CDETinjiApp.#onIncrement,
|
||||
decrement: _CDETinjiApp.#onDecrement,
|
||||
reset: _CDETinjiApp.#onReset,
|
||||
spend: _CDETinjiApp.#onSpend
|
||||
}
|
||||
};
|
||||
static PARTS = {
|
||||
main: {
|
||||
template: `systems/${SYSTEM_ID2}/templates/apps/cde-tinji-app.html`
|
||||
}
|
||||
};
|
||||
/** @type {Actor|null} */
|
||||
#actor = null;
|
||||
/** @type {Function|null} */
|
||||
#updateHook = null;
|
||||
static open() {
|
||||
const existing = Object.values(foundry.applications.instances ?? {}).find(
|
||||
(app2) => app2 instanceof _CDETinjiApp
|
||||
);
|
||||
if (existing) {
|
||||
existing.bringToFront();
|
||||
return existing;
|
||||
}
|
||||
const app = new _CDETinjiApp();
|
||||
app.render(true);
|
||||
return app;
|
||||
}
|
||||
async _prepareContext() {
|
||||
this.#actor = await getSingletonActor(ACTOR_TYPES.tinji);
|
||||
if (!this.#actor) return { hasActor: false, value: 0 };
|
||||
return {
|
||||
hasActor: true,
|
||||
canEdit: this.#actor.isOwner,
|
||||
value: this.#actor.system.value ?? 0
|
||||
};
|
||||
}
|
||||
_onRender(context, options) {
|
||||
super._onRender(context, options);
|
||||
this.#bindDirectInput();
|
||||
this.#updateHook = Hooks.on("updateActor", (actor) => {
|
||||
if (actor.id === this.#actor?.id) this.render();
|
||||
});
|
||||
}
|
||||
_onClose(options) {
|
||||
if (this.#updateHook !== null) {
|
||||
Hooks.off("updateActor", this.#updateHook);
|
||||
this.#updateHook = null;
|
||||
}
|
||||
super._onClose(options);
|
||||
}
|
||||
#bindDirectInput() {
|
||||
const input = this.element?.querySelector("input.cde-tinji-direct");
|
||||
if (!input) return;
|
||||
input.addEventListener("change", async (ev) => {
|
||||
const val = parseInt(ev.currentTarget.value, 10);
|
||||
if (!isNaN(val) && this.#actor) {
|
||||
await this.#actor.update({ "system.value": Math.max(0, val) });
|
||||
}
|
||||
});
|
||||
}
|
||||
static async #onIncrement() {
|
||||
if (!this.#actor) return;
|
||||
const current = this.#actor.system.value ?? 0;
|
||||
await this.#actor.update({ "system.value": current + 1 });
|
||||
}
|
||||
static async #onDecrement() {
|
||||
if (!this.#actor) return;
|
||||
const current = this.#actor.system.value ?? 0;
|
||||
if (current <= 0) return;
|
||||
await this.#actor.update({ "system.value": current - 1 });
|
||||
}
|
||||
static async #onReset() {
|
||||
if (!this.#actor) return;
|
||||
await this.#actor.update({ "system.value": 0 });
|
||||
}
|
||||
/** Spend 1 Tin Ji die and announce it in chat */
|
||||
static async #onSpend() {
|
||||
if (!this.#actor) return;
|
||||
const current = this.#actor.system.value ?? 0;
|
||||
if (current <= 0) {
|
||||
ui.notifications.warn(game.i18n.localize("CDE.TinjiEmpty"));
|
||||
return;
|
||||
}
|
||||
await this.#actor.update({ "system.value": current - 1 });
|
||||
ChatMessage.create({
|
||||
user: game.user.id,
|
||||
content: `<div class="cde-tinji-spend-msg">
|
||||
<i class="fas fa-star"></i>
|
||||
<strong>${game.i18n.localize("CDE.TinJi2")}</strong>
|
||||
${game.i18n.format("CDE.TinjiSpent", { name: game.user.name })}
|
||||
<span class="cde-tinji-remain">(${current - 1} ${game.i18n.localize("CDE.TinjiRemaining")})</span>
|
||||
</div>`
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// src/ui/sheets/actors/tinji.js
|
||||
var CDETinjiSheet = class extends CDEBaseActorSheet {
|
||||
static DEFAULT_OPTIONS = {
|
||||
@@ -1778,6 +1951,120 @@ var CDETinjiSheet = class extends CDEBaseActorSheet {
|
||||
main: { template: "systems/fvtt-chroniques-de-l-etrange/templates/actor/cde-tinji-sheet.html" }
|
||||
};
|
||||
tabGroups = { primary: "tinji" };
|
||||
/** Redirect any direct actor-sheet open to the standalone app instead */
|
||||
async _onFirstRender(context, options) {
|
||||
await this.close({ animate: false });
|
||||
CDETinjiApp.open();
|
||||
}
|
||||
};
|
||||
|
||||
// src/ui/apps/loksyu-app.js
|
||||
var SYSTEM_ID3 = "fvtt-chroniques-de-l-etrange";
|
||||
var CDELoksyuApp = class _CDELoksyuApp extends foundry.applications.api.HandlebarsApplicationMixin(
|
||||
foundry.applications.api.ApplicationV2
|
||||
) {
|
||||
static DEFAULT_OPTIONS = {
|
||||
id: "cde-loksyu-app",
|
||||
tag: "div",
|
||||
window: {
|
||||
title: "CDE.Loksyu",
|
||||
icon: "fas fa-yin-yang",
|
||||
resizable: false
|
||||
},
|
||||
classes: ["cde-app", "cde-loksyu-standalone"],
|
||||
position: { width: 540, height: "auto" },
|
||||
actions: {
|
||||
resetElement: _CDELoksyuApp.#onResetElement,
|
||||
resetAll: _CDELoksyuApp.#onResetAll
|
||||
}
|
||||
};
|
||||
static PARTS = {
|
||||
main: {
|
||||
template: `systems/${SYSTEM_ID3}/templates/apps/cde-loksyu-app.html`
|
||||
}
|
||||
};
|
||||
/** @type {Actor|null} */
|
||||
#actor = null;
|
||||
/** @type {Function|null} bound hook handler */
|
||||
#updateHook = null;
|
||||
/** Singleton accessor — open or bring to front */
|
||||
static open() {
|
||||
const existing = Object.values(foundry.applications.instances ?? {}).find(
|
||||
(app2) => app2 instanceof _CDELoksyuApp
|
||||
);
|
||||
if (existing) {
|
||||
existing.bringToFront();
|
||||
return existing;
|
||||
}
|
||||
const app = new _CDELoksyuApp();
|
||||
app.render(true);
|
||||
return app;
|
||||
}
|
||||
async _prepareContext() {
|
||||
this.#actor = await getSingletonActor(ACTOR_TYPES.loksyu);
|
||||
if (!this.#actor) return { hasActor: false };
|
||||
const sys = this.#actor.system;
|
||||
const ELEMENTS = [
|
||||
{ key: "wood", nameKey: "CDE.Wood", qualKey: "CDE.WoodQualities", img: `systems/${SYSTEM_ID3}/images/cde_bois.webp` },
|
||||
{ key: "fire", nameKey: "CDE.Fire", qualKey: "CDE.FireQualities", img: `systems/${SYSTEM_ID3}/images/cde_feu.webp` },
|
||||
{ key: "earth", nameKey: "CDE.Earth", qualKey: "CDE.EarthQualities", img: `systems/${SYSTEM_ID3}/images/cde_terre.webp` },
|
||||
{ key: "metal", nameKey: "CDE.Metal", qualKey: "CDE.MetalQualities", img: `systems/${SYSTEM_ID3}/images/cde_metal.webp` },
|
||||
{ key: "water", nameKey: "CDE.Water", qualKey: "CDE.WaterQualities", img: `systems/${SYSTEM_ID3}/images/cde_eau.webp` }
|
||||
];
|
||||
return {
|
||||
hasActor: true,
|
||||
canEdit: this.#actor.isOwner,
|
||||
elements: ELEMENTS.map((el) => ({
|
||||
...el,
|
||||
yang: sys[el.key]?.yang?.value ?? 0,
|
||||
yin: sys[el.key]?.yin?.value ?? 0
|
||||
}))
|
||||
};
|
||||
}
|
||||
_onRender(context, options) {
|
||||
super._onRender(context, options);
|
||||
this.#bindInputs();
|
||||
this.#updateHook = Hooks.on("updateActor", (actor) => {
|
||||
if (actor.id === this.#actor?.id) this.render();
|
||||
});
|
||||
}
|
||||
_onClose(options) {
|
||||
if (this.#updateHook !== null) {
|
||||
Hooks.off("updateActor", this.#updateHook);
|
||||
this.#updateHook = null;
|
||||
}
|
||||
super._onClose(options);
|
||||
}
|
||||
#bindInputs() {
|
||||
const inputs = this.element?.querySelectorAll("input[data-field]");
|
||||
if (!inputs?.length) return;
|
||||
inputs.forEach((input) => {
|
||||
input.addEventListener("change", async (ev) => {
|
||||
const field = ev.currentTarget.dataset.field;
|
||||
const val = parseInt(ev.currentTarget.value, 10);
|
||||
if (!field || isNaN(val)) return;
|
||||
await this.#actor?.update({ [field]: Math.max(0, val) });
|
||||
});
|
||||
});
|
||||
}
|
||||
static async #onResetElement(event, target) {
|
||||
const key = target.dataset.element;
|
||||
if (!key || !this.#actor) return;
|
||||
await this.#actor.update({
|
||||
[`system.${key}.yin.value`]: 0,
|
||||
[`system.${key}.yang.value`]: 0
|
||||
});
|
||||
}
|
||||
static async #onResetAll(_event, _target) {
|
||||
if (!this.#actor) return;
|
||||
const KEYS = ["wood", "fire", "earth", "metal", "water"];
|
||||
const update = {};
|
||||
for (const k of KEYS) {
|
||||
update[`system.${k}.yin.value`] = 0;
|
||||
update[`system.${k}.yang.value`] = 0;
|
||||
}
|
||||
await this.#actor.update(update);
|
||||
}
|
||||
};
|
||||
|
||||
// src/ui/sheets/actors/loksyu.js
|
||||
@@ -1789,6 +2076,11 @@ var CDELoksyuSheet = class extends CDEBaseActorSheet {
|
||||
main: { template: "systems/fvtt-chroniques-de-l-etrange/templates/actor/cde-loksyu-sheet.html" }
|
||||
};
|
||||
tabGroups = { primary: "loksyu" };
|
||||
/** Redirect any direct actor-sheet open to the standalone app instead */
|
||||
async _onFirstRender(context, options) {
|
||||
await this.close({ animate: false });
|
||||
CDELoksyuApp.open();
|
||||
}
|
||||
};
|
||||
|
||||
// src/ui/sheets/items/base.js
|
||||
@@ -2177,6 +2469,24 @@ Hooks.once("init", async () => {
|
||||
Hooks.once("ready", async () => {
|
||||
await migrateIfNeeded();
|
||||
});
|
||||
Hooks.on("renderChatLog", (_app, html) => {
|
||||
const el = html instanceof HTMLElement ? html : html[0];
|
||||
const controls = el?.querySelector?.(".chat-controls");
|
||||
if (!controls) return;
|
||||
const wrapper = document.createElement("div");
|
||||
wrapper.classList.add("cde-chat-app-buttons");
|
||||
wrapper.innerHTML = `
|
||||
<button class="cde-chat-btn cde-chat-btn--loksyu" title="${game.i18n.localize("CDE.Loksyu")}">
|
||||
<i class="fas fa-yin-yang"></i> ${game.i18n.localize("CDE.Loksyu")}
|
||||
</button>
|
||||
<button class="cde-chat-btn cde-chat-btn--tinji" title="${game.i18n.localize("CDE.TinJi2")}">
|
||||
<i class="fas fa-star"></i> ${game.i18n.localize("CDE.TinJi2")}
|
||||
</button>
|
||||
`;
|
||||
controls.appendChild(wrapper);
|
||||
wrapper.querySelector(".cde-chat-btn--loksyu")?.addEventListener("click", () => CDELoksyuApp.open());
|
||||
wrapper.querySelector(".cde-chat-btn--tinji")?.addEventListener("click", () => CDETinjiApp.open());
|
||||
});
|
||||
function injectCompendiumLink(html) {
|
||||
const header = html[0]?.querySelector?.("h4.divider");
|
||||
if (!header) return;
|
||||
|
||||
8
dist/system.js.map
vendored
8
dist/system.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -242,6 +242,7 @@
|
||||
|
||||
"CDE.LoksyuName": "Loksyu Name",
|
||||
"CDE.Loksyu": "Loksyu",
|
||||
"CDE.LoksyuNotFound": "No Loksyu actor found. The Game Master must create one.",
|
||||
"CDE.MetalYang": "㊎ Yang Metal (3)",
|
||||
"CDE.MetalYin": "㊎ Yin Metal (8)",
|
||||
"CDE.WaterYang": "㊌ Yang Water (1)",
|
||||
@@ -302,6 +303,15 @@
|
||||
|
||||
"CDE.TinJiName": "Tin Ji Name",
|
||||
"CDE.TinJi2": "Tin Ji",
|
||||
"CDE.TinjiNotFound": "No Tin Ji actor found. The Game Master must create one.",
|
||||
"CDE.TinjiEmpty": "No Tin Ji dice remaining.",
|
||||
"CDE.TinjiSpent": "{name} spends 1 Tin Ji die.",
|
||||
"CDE.TinjiRemaining": "remaining",
|
||||
"CDE.SpendTinji": "Spend a die",
|
||||
"CDE.Reset": "Reset",
|
||||
"CDE.ResetAll": "Reset all",
|
||||
"CDE.Decrement": "Decrease",
|
||||
"CDE.Increment": "Increase",
|
||||
|
||||
"CDE.UpperCaseSuccesses": "SUCCESSES",
|
||||
"CDE.UpperCaseAuspiciousDice": "AUSPICIOUS-DICE",
|
||||
|
||||
@@ -151,6 +151,7 @@
|
||||
"CDE.Loksyu": "Loksyu",
|
||||
"CDE.Loksyu2": "Loksyu :",
|
||||
"CDE.LoksyuName": "Nom du Loksyu",
|
||||
"CDE.LoksyuNotFound": "Aucun acteur Loksyu trouvé. Le Maître du Jeu doit en créer un.",
|
||||
"CDE.MagicPromptName": "Jet de Magie",
|
||||
"CDE.Magics": "Magies",
|
||||
"CDE.Manipulation": "Manipulation",
|
||||
@@ -281,6 +282,15 @@
|
||||
"CDE.TinJi": "Tin Ji :",
|
||||
"CDE.TinJi2": "Tin Ji",
|
||||
"CDE.TinJiName": "Nom de la Tin Ji",
|
||||
"CDE.TinjiNotFound": "Aucun acteur Tin Ji trouvé. Le Maître du Jeu doit en créer un.",
|
||||
"CDE.TinjiEmpty": "Il n'y a plus de dés de Tin Ji disponibles.",
|
||||
"CDE.TinjiSpent": "{name} dépense 1 dé de Tin Ji.",
|
||||
"CDE.TinjiRemaining": "restant(s)",
|
||||
"CDE.SpendTinji": "Dépenser un dé",
|
||||
"CDE.Reset": "Réinitialiser",
|
||||
"CDE.ResetAll": "Tout réinitialiser",
|
||||
"CDE.Decrement": "Diminuer",
|
||||
"CDE.Increment": "Augmenter",
|
||||
"CDE.Total": "Total",
|
||||
"CDE.Total-Present": "Total ● Actuel",
|
||||
"CDE.Tracking": "Traque",
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
2026/03/30-08:26:03.921273 7f4bd9fec6c0 Recovering log #68
|
||||
2026/03/30-08:26:03.931083 7f4bd9fec6c0 Delete type=3 #66
|
||||
2026/03/30-08:26:03.931138 7f4bd9fec6c0 Delete type=0 #68
|
||||
2026/03/30-09:43:28.098488 7f4bd8fea6c0 Level-0 table #73: started
|
||||
2026/03/30-09:43:28.098511 7f4bd8fea6c0 Level-0 table #73: 0 bytes OK
|
||||
2026/03/30-09:43:28.104264 7f4bd8fea6c0 Delete type=0 #71
|
||||
2026/03/30-09:43:28.117464 7f4bd8fea6c0 Manual compaction at level-0 from '!journal!ZWBHiWW5QlUeseAX' @ 72057594037927935 : 1 .. '!journal.pages!ZWBHiWW5QlUeseAX.jtQXIqLfyet8Nlte' @ 0 : 0; will stop at (end)
|
||||
|
||||
Binary file not shown.
@@ -1,3 +1,8 @@
|
||||
2026/03/30-08:26:03.909166 7f4bdafee6c0 Recovering log #184
|
||||
2026/03/30-08:26:03.919289 7f4bdafee6c0 Delete type=3 #182
|
||||
2026/03/30-08:26:03.919342 7f4bdafee6c0 Delete type=0 #184
|
||||
2026/03/30-09:43:28.079081 7f4bd8fea6c0 Level-0 table #189: started
|
||||
2026/03/30-09:43:28.079103 7f4bd8fea6c0 Level-0 table #189: 0 bytes OK
|
||||
2026/03/30-09:43:28.086060 7f4bd8fea6c0 Delete type=0 #187
|
||||
2026/03/30-09:43:28.092246 7f4bd8fea6c0 Manual compaction at level-0 from '!journal!TniC3ok9W0hDYxJS' @ 72057594037927935 : 1 .. '!journal.pages!yZsG9QaBHT3cUfNd.AHcfBcO96nUCELxv' @ 0 : 0; will stop at (end)
|
||||
2026/03/30-09:43:28.092280 7f4bd8fea6c0 Manual compaction at level-1 from '!journal!TniC3ok9W0hDYxJS' @ 72057594037927935 : 1 .. '!journal.pages!yZsG9QaBHT3cUfNd.AHcfBcO96nUCELxv' @ 0 : 0; will stop at (end)
|
||||
|
||||
Binary file not shown.
@@ -1,3 +1,8 @@
|
||||
2026/03/30-08:26:03.896176 7f4bd97eb6c0 Recovering log #756
|
||||
2026/03/30-08:26:03.907046 7f4bd97eb6c0 Delete type=3 #754
|
||||
2026/03/30-08:26:03.907119 7f4bd97eb6c0 Delete type=0 #756
|
||||
2026/03/30-09:43:28.086148 7f4bd8fea6c0 Level-0 table #761: started
|
||||
2026/03/30-09:43:28.086168 7f4bd8fea6c0 Level-0 table #761: 0 bytes OK
|
||||
2026/03/30-09:43:28.092174 7f4bd8fea6c0 Delete type=0 #759
|
||||
2026/03/30-09:43:28.092256 7f4bd8fea6c0 Manual compaction at level-0 from '!journal!f6UhPlIUh2O0F36q' @ 72057594037927935 : 1 .. '!journal.pages!f6UhPlIUh2O0F36q.keqszrb6FAI7CVZx' @ 0 : 0; will stop at (end)
|
||||
2026/03/30-09:43:28.092274 7f4bd8fea6c0 Manual compaction at level-1 from '!journal!f6UhPlIUh2O0F36q' @ 72057594037927935 : 1 .. '!journal.pages!f6UhPlIUh2O0F36q.keqszrb6FAI7CVZx' @ 0 : 0; will stop at (end)
|
||||
|
||||
Binary file not shown.
@@ -1,3 +1,7 @@
|
||||
2026/03/30-08:26:03.870788 7f4bd9fec6c0 Recovering log #4377
|
||||
2026/03/30-08:26:03.881274 7f4bd9fec6c0 Delete type=3 #4375
|
||||
2026/03/30-08:26:03.881332 7f4bd9fec6c0 Delete type=0 #4377
|
||||
2026/03/30-09:43:28.073001 7f4bd8fea6c0 Level-0 table #4382: started
|
||||
2026/03/30-09:43:28.073024 7f4bd8fea6c0 Level-0 table #4382: 0 bytes OK
|
||||
2026/03/30-09:43:28.078972 7f4bd8fea6c0 Delete type=0 #4380
|
||||
2026/03/30-09:43:28.092238 7f4bd8fea6c0 Manual compaction at level-0 from '!journal!0lxwWrzKsdTBQhH0' @ 72057594037927935 : 1 .. '!journal.pages!wgSyae4GTJDkmBOm.6Ql0lgquUCTrMyTZ' @ 0 : 0; will stop at (end)
|
||||
|
||||
Binary file not shown.
@@ -1,3 +1,8 @@
|
||||
2026/03/30-08:26:03.960135 7f4bdafee6c0 Recovering log #97
|
||||
2026/03/30-08:26:03.970139 7f4bdafee6c0 Delete type=3 #95
|
||||
2026/03/30-08:26:03.970187 7f4bdafee6c0 Delete type=0 #97
|
||||
2026/03/30-09:43:28.104316 7f4bd8fea6c0 Level-0 table #102: started
|
||||
2026/03/30-09:43:28.104333 7f4bd8fea6c0 Level-0 table #102: 0 bytes OK
|
||||
2026/03/30-09:43:28.111378 7f4bd8fea6c0 Delete type=0 #100
|
||||
2026/03/30-09:43:28.117472 7f4bd8fea6c0 Manual compaction at level-0 from '!tables!J9VdvrwkbyKxMAT7' @ 72057594037927935 : 1 .. '!tables.results!jGKjfCyk4ROSy9fU.zRzADzATtijaBdNX' @ 0 : 0; will stop at (end)
|
||||
2026/03/30-09:43:28.117505 7f4bd8fea6c0 Manual compaction at level-1 from '!tables!J9VdvrwkbyKxMAT7' @ 72057594037927935 : 1 .. '!tables.results!jGKjfCyk4ROSy9fU.zRzADzATtijaBdNX' @ 0 : 0; will stop at (end)
|
||||
|
||||
Binary file not shown.
@@ -1,3 +1,8 @@
|
||||
2026/03/30-08:26:03.946656 7f4bd9fec6c0 Recovering log #78
|
||||
2026/03/30-08:26:03.958209 7f4bd9fec6c0 Delete type=3 #76
|
||||
2026/03/30-08:26:03.958276 7f4bd9fec6c0 Delete type=0 #78
|
||||
2026/03/30-09:43:28.111476 7f4bd8fea6c0 Level-0 table #83: started
|
||||
2026/03/30-09:43:28.111506 7f4bd8fea6c0 Level-0 table #83: 0 bytes OK
|
||||
2026/03/30-09:43:28.117383 7f4bd8fea6c0 Delete type=0 #81
|
||||
2026/03/30-09:43:28.117483 7f4bd8fea6c0 Manual compaction at level-0 from '!macros!apyHJT40enTKFUfX' @ 72057594037927935 : 1 .. '!macros!suexsLbORUfE9ptz' @ 0 : 0; will stop at (end)
|
||||
2026/03/30-09:43:28.117499 7f4bd8fea6c0 Manual compaction at level-1 from '!macros!apyHJT40enTKFUfX' @ 72057594037927935 : 1 .. '!macros!suexsLbORUfE9ptz' @ 0 : 0; will stop at (end)
|
||||
|
||||
Binary file not shown.
@@ -1,3 +1,8 @@
|
||||
2026/03/30-08:26:03.934190 7f4bd97eb6c0 Recovering log #256
|
||||
2026/03/30-08:26:03.945052 7f4bd97eb6c0 Delete type=3 #254
|
||||
2026/03/30-08:26:03.945123 7f4bd97eb6c0 Delete type=0 #256
|
||||
2026/03/30-09:43:28.092357 7f4bd8fea6c0 Level-0 table #261: started
|
||||
2026/03/30-09:43:28.092374 7f4bd8fea6c0 Level-0 table #261: 0 bytes OK
|
||||
2026/03/30-09:43:28.098362 7f4bd8fea6c0 Delete type=0 #259
|
||||
2026/03/30-09:43:28.117455 7f4bd8fea6c0 Manual compaction at level-0 from '!macros!Admg6zBHid4mfbJY' @ 72057594037927935 : 1 .. '!macros!wY3tga12higX7soz' @ 0 : 0; will stop at (end)
|
||||
2026/03/30-09:43:28.117478 7f4bd8fea6c0 Manual compaction at level-1 from '!macros!Admg6zBHid4mfbJY' @ 72057594037927935 : 1 .. '!macros!wY3tga12higX7soz' @ 0 : 0; will stop at (end)
|
||||
|
||||
Binary file not shown.
@@ -1,3 +1,8 @@
|
||||
2026/03/30-08:26:03.884089 7f4bda7ed6c0 Recovering log #998
|
||||
2026/03/30-08:26:03.894023 7f4bda7ed6c0 Delete type=3 #996
|
||||
2026/03/30-08:26:03.894104 7f4bda7ed6c0 Delete type=0 #998
|
||||
2026/03/30-09:43:28.067084 7f4bd8fea6c0 Level-0 table #1003: started
|
||||
2026/03/30-09:43:28.067126 7f4bd8fea6c0 Level-0 table #1003: 0 bytes OK
|
||||
2026/03/30-09:43:28.072914 7f4bd8fea6c0 Delete type=0 #1001
|
||||
2026/03/30-09:43:28.092224 7f4bd8fea6c0 Manual compaction at level-0 from '!journal!OgzOugwIXfHtijaY' @ 72057594037927935 : 1 .. '!journal.pages!OgzOugwIXfHtijaY.OOev7kj2KoMOGoMD' @ 0 : 0; will stop at (end)
|
||||
2026/03/30-09:43:28.092251 7f4bd8fea6c0 Manual compaction at level-1 from '!journal!OgzOugwIXfHtijaY' @ 72057594037927935 : 1 .. '!journal.pages!OgzOugwIXfHtijaY.OOev7kj2KoMOGoMD' @ 0 : 0; will stop at (end)
|
||||
|
||||
Binary file not shown.
@@ -105,4 +105,6 @@ export const TEMPLATE_PARTIALS = [
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/actor/parts/cde-npc-spells.html",
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/actor/parts/cde-npc-kungfus.html",
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/actor/parts/cde-npc-items.html",
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/apps/cde-loksyu-app.html",
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/apps/cde-tinji-app.html",
|
||||
]
|
||||
|
||||
@@ -11,6 +11,8 @@ import { registerHandlebarsHelpers } from "./ui/helpers.js"
|
||||
import { preloadPartials } from "./ui/templates.js"
|
||||
import { CDELoksyuSheet, CDECharacterSheet, CDENpcSheet, CDETinjiSheet } from "./ui/sheets/actors/index.js"
|
||||
import { CDEItemSheet, CDEKungfuSheet, CDESpellSheet, CDESupernaturalSheet, CDEWeaponSheet, CDEArmorSheet, CDESanheiSheet, CDEIngredientSheet } from "./ui/sheets/items/index.js"
|
||||
import { CDELoksyuApp } from "./ui/apps/loksyu-app.js"
|
||||
import { CDETinjiApp } from "./ui/apps/tinji-app.js"
|
||||
import { migrateIfNeeded, registerSettings } from "./migration.js"
|
||||
|
||||
Hooks.once("i18nInit", preLocalizeConfig)
|
||||
@@ -122,6 +124,28 @@ Hooks.once("ready", async () => {
|
||||
await migrateIfNeeded()
|
||||
})
|
||||
|
||||
/** Add Loksyu + Tin Ji quick-access buttons to the chat footer */
|
||||
Hooks.on("renderChatLog", (_app, html) => {
|
||||
const el = html instanceof HTMLElement ? html : html[0]
|
||||
const controls = el?.querySelector?.(".chat-controls")
|
||||
if (!controls) return
|
||||
|
||||
const wrapper = document.createElement("div")
|
||||
wrapper.classList.add("cde-chat-app-buttons")
|
||||
wrapper.innerHTML = `
|
||||
<button class="cde-chat-btn cde-chat-btn--loksyu" title="${game.i18n.localize("CDE.Loksyu")}">
|
||||
<i class="fas fa-yin-yang"></i> ${game.i18n.localize("CDE.Loksyu")}
|
||||
</button>
|
||||
<button class="cde-chat-btn cde-chat-btn--tinji" title="${game.i18n.localize("CDE.TinJi2")}">
|
||||
<i class="fas fa-star"></i> ${game.i18n.localize("CDE.TinJi2")}
|
||||
</button>
|
||||
`
|
||||
controls.appendChild(wrapper)
|
||||
|
||||
wrapper.querySelector(".cde-chat-btn--loksyu")?.addEventListener("click", () => CDELoksyuApp.open())
|
||||
wrapper.querySelector(".cde-chat-btn--tinji")?.addEventListener("click", () => CDETinjiApp.open())
|
||||
})
|
||||
|
||||
function injectCompendiumLink(html) {
|
||||
const header = html[0]?.querySelector?.("h4.divider")
|
||||
if (!header) return
|
||||
|
||||
3
src/ui/apps/index.js
Normal file
3
src/ui/apps/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export { CDELoksyuApp } from "./loksyu-app.js"
|
||||
export { CDETinjiApp } from "./tinji-app.js"
|
||||
export { getSingletonActor, updateLoksyuFromRoll, updateTinjiFromRoll } from "./singletons.js"
|
||||
121
src/ui/apps/loksyu-app.js
Normal file
121
src/ui/apps/loksyu-app.js
Normal file
@@ -0,0 +1,121 @@
|
||||
import { getSingletonActor } from "./singletons.js"
|
||||
import { ACTOR_TYPES } from "../../config/constants.js"
|
||||
|
||||
const SYSTEM_ID = "fvtt-chroniques-de-l-etrange"
|
||||
|
||||
export class CDELoksyuApp extends foundry.applications.api.HandlebarsApplicationMixin(
|
||||
foundry.applications.api.ApplicationV2
|
||||
) {
|
||||
static DEFAULT_OPTIONS = {
|
||||
id: "cde-loksyu-app",
|
||||
tag: "div",
|
||||
window: {
|
||||
title: "CDE.Loksyu",
|
||||
icon: "fas fa-yin-yang",
|
||||
resizable: false,
|
||||
},
|
||||
classes: ["cde-app", "cde-loksyu-standalone"],
|
||||
position: { width: 540, height: "auto" },
|
||||
actions: {
|
||||
resetElement: CDELoksyuApp.#onResetElement,
|
||||
resetAll: CDELoksyuApp.#onResetAll,
|
||||
},
|
||||
}
|
||||
|
||||
static PARTS = {
|
||||
main: {
|
||||
template: `systems/${SYSTEM_ID}/templates/apps/cde-loksyu-app.html`,
|
||||
},
|
||||
}
|
||||
|
||||
/** @type {Actor|null} */
|
||||
#actor = null
|
||||
/** @type {Function|null} bound hook handler */
|
||||
#updateHook = null
|
||||
|
||||
/** Singleton accessor — open or bring to front */
|
||||
static open() {
|
||||
const existing = Object.values(foundry.applications.instances ?? {}).find(
|
||||
(app) => app instanceof CDELoksyuApp
|
||||
)
|
||||
if (existing) { existing.bringToFront(); return existing }
|
||||
const app = new CDELoksyuApp()
|
||||
app.render(true)
|
||||
return app
|
||||
}
|
||||
|
||||
async _prepareContext() {
|
||||
this.#actor = await getSingletonActor(ACTOR_TYPES.loksyu)
|
||||
if (!this.#actor) return { hasActor: false }
|
||||
|
||||
const sys = this.#actor.system
|
||||
const ELEMENTS = [
|
||||
{ key: "wood", nameKey: "CDE.Wood", qualKey: "CDE.WoodQualities", img: `systems/${SYSTEM_ID}/images/cde_bois.webp` },
|
||||
{ key: "fire", nameKey: "CDE.Fire", qualKey: "CDE.FireQualities", img: `systems/${SYSTEM_ID}/images/cde_feu.webp` },
|
||||
{ key: "earth", nameKey: "CDE.Earth", qualKey: "CDE.EarthQualities", img: `systems/${SYSTEM_ID}/images/cde_terre.webp` },
|
||||
{ key: "metal", nameKey: "CDE.Metal", qualKey: "CDE.MetalQualities", img: `systems/${SYSTEM_ID}/images/cde_metal.webp` },
|
||||
{ key: "water", nameKey: "CDE.Water", qualKey: "CDE.WaterQualities", img: `systems/${SYSTEM_ID}/images/cde_eau.webp` },
|
||||
]
|
||||
|
||||
return {
|
||||
hasActor: true,
|
||||
canEdit: this.#actor.isOwner,
|
||||
elements: ELEMENTS.map((el) => ({
|
||||
...el,
|
||||
yang: sys[el.key]?.yang?.value ?? 0,
|
||||
yin: sys[el.key]?.yin?.value ?? 0,
|
||||
})),
|
||||
}
|
||||
}
|
||||
|
||||
_onRender(context, options) {
|
||||
super._onRender(context, options)
|
||||
this.#bindInputs()
|
||||
|
||||
// Subscribe to actor updates to keep the app live
|
||||
this.#updateHook = Hooks.on("updateActor", (actor) => {
|
||||
if (actor.id === this.#actor?.id) this.render()
|
||||
})
|
||||
}
|
||||
|
||||
_onClose(options) {
|
||||
if (this.#updateHook !== null) {
|
||||
Hooks.off("updateActor", this.#updateHook)
|
||||
this.#updateHook = null
|
||||
}
|
||||
super._onClose(options)
|
||||
}
|
||||
|
||||
#bindInputs() {
|
||||
const inputs = this.element?.querySelectorAll("input[data-field]")
|
||||
if (!inputs?.length) return
|
||||
inputs.forEach((input) => {
|
||||
input.addEventListener("change", async (ev) => {
|
||||
const field = ev.currentTarget.dataset.field
|
||||
const val = parseInt(ev.currentTarget.value, 10)
|
||||
if (!field || isNaN(val)) return
|
||||
await this.#actor?.update({ [field]: Math.max(0, val) })
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
static async #onResetElement(event, target) {
|
||||
const key = target.dataset.element
|
||||
if (!key || !this.#actor) return
|
||||
await this.#actor.update({
|
||||
[`system.${key}.yin.value`]: 0,
|
||||
[`system.${key}.yang.value`]: 0,
|
||||
})
|
||||
}
|
||||
|
||||
static async #onResetAll(_event, _target) {
|
||||
if (!this.#actor) return
|
||||
const KEYS = ["wood", "fire", "earth", "metal", "water"]
|
||||
const update = {}
|
||||
for (const k of KEYS) {
|
||||
update[`system.${k}.yin.value`] = 0
|
||||
update[`system.${k}.yang.value`] = 0
|
||||
}
|
||||
await this.#actor.update(update)
|
||||
}
|
||||
}
|
||||
99
src/ui/apps/singletons.js
Normal file
99
src/ui/apps/singletons.js
Normal file
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* Singleton actor utilities for Loksyu and Tin Ji.
|
||||
*
|
||||
* Both are world-level shared trackers backed by a singleton Actor document
|
||||
* of type "loksyu" / "tinji". GMs can create them via the Actors sidebar;
|
||||
* the apps find the first one or offer to create it.
|
||||
*/
|
||||
|
||||
import { ACTOR_TYPES } from "../../config/constants.js"
|
||||
|
||||
/** Wu Xing generating cycle — [successes, auspicious, noxious, loksyu, tinji] */
|
||||
const WU_XING_CYCLE = {
|
||||
wood: ["wood", "fire", "water", "earth", "metal"],
|
||||
fire: ["fire", "earth", "wood", "metal", "water"],
|
||||
earth: ["earth", "metal", "fire", "water", "wood"],
|
||||
metal: ["metal", "water", "earth", "wood", "fire"],
|
||||
water: ["water", "wood", "metal", "fire", "earth"],
|
||||
}
|
||||
|
||||
/** Die face pairs [yin, yang] per aspect (0 = face "10") */
|
||||
const ASPECT_FACES = {
|
||||
metal: [3, 8],
|
||||
water: [1, 6],
|
||||
earth: [0, 5],
|
||||
fire: [2, 7],
|
||||
wood: [4, 9],
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the first actor of the given type in the world, or create one if the
|
||||
* current user is a GM and none exists.
|
||||
*
|
||||
* @param {"loksyu"|"tinji"} type
|
||||
* @returns {Promise<Actor|null>}
|
||||
*/
|
||||
export async function getSingletonActor(type) {
|
||||
const existing = game.actors.find((a) => a.type === type)
|
||||
if (existing) return existing
|
||||
|
||||
if (!game.user.isGM) {
|
||||
ui.notifications.warn(game.i18n.localize(type === ACTOR_TYPES.loksyu ? "CDE.LoksyuNotFound" : "CDE.TinjiNotFound"))
|
||||
return null
|
||||
}
|
||||
|
||||
// Auto-create the singleton when the GM opens the app for the first time.
|
||||
const nameKey = type === ACTOR_TYPES.loksyu ? "CDE.UpperCaseLoksyu" : "CDE.UpperCaseTinJi"
|
||||
const actor = await Actor.create({
|
||||
name: game.i18n.localize(nameKey),
|
||||
type,
|
||||
img: type === ACTOR_TYPES.loksyu
|
||||
? "systems/fvtt-chroniques-de-l-etrange/images/loksyu_long.webp"
|
||||
: "systems/fvtt-chroniques-de-l-etrange/images/tinji.webp",
|
||||
})
|
||||
return actor ?? null
|
||||
}
|
||||
|
||||
/**
|
||||
* After a WuXing roll, add the loksyu faces (yin + yang) of the relevant
|
||||
* aspect to the singleton Loksyu actor.
|
||||
*
|
||||
* @param {string} activeAspect - The aspect used for the roll (e.g. "fire")
|
||||
* @param {Object} faces - Die face counts { 0: n, 1: n, …, 9: n }
|
||||
*/
|
||||
export async function updateLoksyuFromRoll(activeAspect, faces) {
|
||||
const cycle = WU_XING_CYCLE[activeAspect]
|
||||
if (!cycle) return
|
||||
|
||||
const lokAspect = cycle[3]
|
||||
const [yinFace, yangFace] = ASPECT_FACES[lokAspect] ?? []
|
||||
if (yinFace === undefined) return
|
||||
|
||||
const yinCount = faces[yinFace] ?? 0
|
||||
const yangCount = faces[yangFace] ?? 0
|
||||
if (yinCount === 0 && yangCount === 0) return
|
||||
|
||||
const actor = await getSingletonActor(ACTOR_TYPES.loksyu)
|
||||
if (!actor) return
|
||||
|
||||
const current = actor.system[lokAspect] ?? { yin: { value: 0 }, yang: { value: 0 } }
|
||||
await actor.update({
|
||||
[`system.${lokAspect}.yin.value`]: (current.yin.value ?? 0) + yinCount,
|
||||
[`system.${lokAspect}.yang.value`]: (current.yang.value ?? 0) + yangCount,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* After a WuXing roll, add tinji faces to the singleton TinJi actor.
|
||||
*
|
||||
* @param {number} count - Number of tinji faces rolled
|
||||
*/
|
||||
export async function updateTinjiFromRoll(count) {
|
||||
if (!count || count <= 0) return
|
||||
|
||||
const actor = await getSingletonActor(ACTOR_TYPES.tinji)
|
||||
if (!actor) return
|
||||
|
||||
const current = actor.system.value ?? 0
|
||||
await actor.update({ "system.value": current + count })
|
||||
}
|
||||
124
src/ui/apps/tinji-app.js
Normal file
124
src/ui/apps/tinji-app.js
Normal file
@@ -0,0 +1,124 @@
|
||||
import { getSingletonActor } from "./singletons.js"
|
||||
import { ACTOR_TYPES } from "../../config/constants.js"
|
||||
|
||||
const SYSTEM_ID = "fvtt-chroniques-de-l-etrange"
|
||||
|
||||
export class CDETinjiApp extends foundry.applications.api.HandlebarsApplicationMixin(
|
||||
foundry.applications.api.ApplicationV2
|
||||
) {
|
||||
static DEFAULT_OPTIONS = {
|
||||
id: "cde-tinji-app",
|
||||
tag: "div",
|
||||
window: {
|
||||
title: "CDE.TinJi2",
|
||||
icon: "fas fa-star",
|
||||
resizable: false,
|
||||
},
|
||||
classes: ["cde-app", "cde-tinji-standalone"],
|
||||
position: { width: 320, height: "auto" },
|
||||
actions: {
|
||||
increment: CDETinjiApp.#onIncrement,
|
||||
decrement: CDETinjiApp.#onDecrement,
|
||||
reset: CDETinjiApp.#onReset,
|
||||
spend: CDETinjiApp.#onSpend,
|
||||
},
|
||||
}
|
||||
|
||||
static PARTS = {
|
||||
main: {
|
||||
template: `systems/${SYSTEM_ID}/templates/apps/cde-tinji-app.html`,
|
||||
},
|
||||
}
|
||||
|
||||
/** @type {Actor|null} */
|
||||
#actor = null
|
||||
/** @type {Function|null} */
|
||||
#updateHook = null
|
||||
|
||||
static open() {
|
||||
const existing = Object.values(foundry.applications.instances ?? {}).find(
|
||||
(app) => app instanceof CDETinjiApp
|
||||
)
|
||||
if (existing) { existing.bringToFront(); return existing }
|
||||
const app = new CDETinjiApp()
|
||||
app.render(true)
|
||||
return app
|
||||
}
|
||||
|
||||
async _prepareContext() {
|
||||
this.#actor = await getSingletonActor(ACTOR_TYPES.tinji)
|
||||
if (!this.#actor) return { hasActor: false, value: 0 }
|
||||
|
||||
return {
|
||||
hasActor: true,
|
||||
canEdit: this.#actor.isOwner,
|
||||
value: this.#actor.system.value ?? 0,
|
||||
}
|
||||
}
|
||||
|
||||
_onRender(context, options) {
|
||||
super._onRender(context, options)
|
||||
this.#bindDirectInput()
|
||||
|
||||
this.#updateHook = Hooks.on("updateActor", (actor) => {
|
||||
if (actor.id === this.#actor?.id) this.render()
|
||||
})
|
||||
}
|
||||
|
||||
_onClose(options) {
|
||||
if (this.#updateHook !== null) {
|
||||
Hooks.off("updateActor", this.#updateHook)
|
||||
this.#updateHook = null
|
||||
}
|
||||
super._onClose(options)
|
||||
}
|
||||
|
||||
#bindDirectInput() {
|
||||
const input = this.element?.querySelector("input.cde-tinji-direct")
|
||||
if (!input) return
|
||||
input.addEventListener("change", async (ev) => {
|
||||
const val = parseInt(ev.currentTarget.value, 10)
|
||||
if (!isNaN(val) && this.#actor) {
|
||||
await this.#actor.update({ "system.value": Math.max(0, val) })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
static async #onIncrement() {
|
||||
if (!this.#actor) return
|
||||
const current = this.#actor.system.value ?? 0
|
||||
await this.#actor.update({ "system.value": current + 1 })
|
||||
}
|
||||
|
||||
static async #onDecrement() {
|
||||
if (!this.#actor) return
|
||||
const current = this.#actor.system.value ?? 0
|
||||
if (current <= 0) return
|
||||
await this.#actor.update({ "system.value": current - 1 })
|
||||
}
|
||||
|
||||
static async #onReset() {
|
||||
if (!this.#actor) return
|
||||
await this.#actor.update({ "system.value": 0 })
|
||||
}
|
||||
|
||||
/** Spend 1 Tin Ji die and announce it in chat */
|
||||
static async #onSpend() {
|
||||
if (!this.#actor) return
|
||||
const current = this.#actor.system.value ?? 0
|
||||
if (current <= 0) {
|
||||
ui.notifications.warn(game.i18n.localize("CDE.TinjiEmpty"))
|
||||
return
|
||||
}
|
||||
await this.#actor.update({ "system.value": current - 1 })
|
||||
ChatMessage.create({
|
||||
user: game.user.id,
|
||||
content: `<div class="cde-tinji-spend-msg">
|
||||
<i class="fas fa-star"></i>
|
||||
<strong>${game.i18n.localize("CDE.TinJi2")}</strong>
|
||||
${game.i18n.format("CDE.TinjiSpent", { name: game.user.name })}
|
||||
<span class="cde-tinji-remain">(${current - 1} ${game.i18n.localize("CDE.TinjiRemaining")})</span>
|
||||
</div>`,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
import { MAGICS } from "../config/constants.js"
|
||||
import { updateLoksyuFromRoll, updateTinjiFromRoll } from "./apps/singletons.js"
|
||||
|
||||
const RESULT_TEMPLATE = "systems/fvtt-chroniques-de-l-etrange/templates/form/cde-dice-result.html"
|
||||
const SKILL_PROMPT_TEMPLATE = "systems/fvtt-chroniques-de-l-etrange/templates/form/cde-skill-dice-prompt.html"
|
||||
@@ -445,6 +446,9 @@ export async function rollForActor(actor, rollKey) {
|
||||
if (game.modules.get("dice-so-nice")?.active && wpMsg?.id) {
|
||||
await game.dice3d.waitFor3DAnimationByMessageID(wpMsg.id)
|
||||
}
|
||||
// Auto-update Loksyu/TinJi singletons from weapon roll faces
|
||||
if ((wpResults.loksyudice ?? 0) > 0) await updateLoksyuFromRoll(wpAspectName, wpFaces)
|
||||
if ((wpResults.tinjidice ?? 0) > 0) await updateTinjiFromRoll(wpResults.tinjidice)
|
||||
return
|
||||
}
|
||||
default:
|
||||
@@ -625,4 +629,8 @@ export async function rollForActor(actor, rollKey) {
|
||||
if (game.modules.get("dice-so-nice")?.active && msg?.id) {
|
||||
await game.dice3d.waitFor3DAnimationByMessageID(msg.id)
|
||||
}
|
||||
|
||||
// ---- Auto-update Loksyu / TinJi singletons ----
|
||||
if ((results.loksyudice ?? 0) > 0) await updateLoksyuFromRoll(wuXingAspectName, faces)
|
||||
if ((results.tinjidice ?? 0) > 0) await updateTinjiFromRoll(results.tinjidice)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { CDEBaseActorSheet } from "./base.js"
|
||||
import { CDELoksyuApp } from "../../apps/loksyu-app.js"
|
||||
|
||||
export class CDELoksyuSheet extends CDEBaseActorSheet {
|
||||
static DEFAULT_OPTIONS = {
|
||||
@@ -10,4 +11,11 @@ export class CDELoksyuSheet extends CDEBaseActorSheet {
|
||||
}
|
||||
|
||||
tabGroups = { primary: "loksyu" }
|
||||
|
||||
/** Redirect any direct actor-sheet open to the standalone app instead */
|
||||
async _onFirstRender(context, options) {
|
||||
// Close this actor sheet immediately and open the standalone app
|
||||
await this.close({ animate: false })
|
||||
CDELoksyuApp.open()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { CDEBaseActorSheet } from "./base.js"
|
||||
import { CDETinjiApp } from "../../apps/tinji-app.js"
|
||||
|
||||
export class CDETinjiSheet extends CDEBaseActorSheet {
|
||||
static DEFAULT_OPTIONS = {
|
||||
@@ -10,4 +11,10 @@ export class CDETinjiSheet extends CDEBaseActorSheet {
|
||||
}
|
||||
|
||||
tabGroups = { primary: "tinji" }
|
||||
|
||||
/** Redirect any direct actor-sheet open to the standalone app instead */
|
||||
async _onFirstRender(context, options) {
|
||||
await this.close({ animate: false })
|
||||
CDETinjiApp.open()
|
||||
}
|
||||
}
|
||||
|
||||
55
templates/apps/cde-loksyu-app.html
Normal file
55
templates/apps/cde-loksyu-app.html
Normal file
@@ -0,0 +1,55 @@
|
||||
{{!-- Loksyu standalone app --}}
|
||||
<div class="cde-loksyu-app-body">
|
||||
|
||||
{{#unless hasActor}}
|
||||
<p class="cde-empty-list"><i class="fas fa-exclamation-triangle"></i> {{ localize "CDE.LoksyuNotFound" }}</p>
|
||||
{{/unless}}
|
||||
|
||||
{{#if hasActor}}
|
||||
<div class="cde-loksyu-elements">
|
||||
{{#each elements as |el|}}
|
||||
<div class="cde-lok-card cde-lok-card--{{el.key}}">
|
||||
<div class="cde-lok-header">
|
||||
<img class="cde-lok-icon" src="{{el.img}}" alt="{{localize el.nameKey}}" width="32" height="32" />
|
||||
<div class="cde-lok-titles">
|
||||
<span class="cde-lok-name">{{ localize el.nameKey }}</span>
|
||||
<span class="cde-lok-qual">{{ localize el.qualKey }}</span>
|
||||
</div>
|
||||
<a class="cde-lok-reset" data-action="resetElement" data-element="{{el.key}}" title="{{ localize 'CDE.Reset' }}">
|
||||
<i class="fas fa-rotate-left"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="cde-lok-values">
|
||||
<div class="cde-lok-polarity cde-lok-polarity--yang">
|
||||
<span class="cde-lok-pol-label">○ {{ localize "CDE.Yang" }}</span>
|
||||
<input class="cde-lok-input" type="number" min="0"
|
||||
data-field="system.{{el.key}}.yang.value"
|
||||
value="{{el.yang}}"
|
||||
{{#unless ../canEdit}}disabled{{/unless}} />
|
||||
</div>
|
||||
<div class="cde-lok-polarity cde-lok-polarity--yin">
|
||||
<span class="cde-lok-pol-label">● {{ localize "CDE.Yin" }}</span>
|
||||
<input class="cde-lok-input" type="number" min="0"
|
||||
data-field="system.{{el.key}}.yin.value"
|
||||
value="{{el.yin}}"
|
||||
{{#unless ../canEdit}}disabled{{/unless}} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
|
||||
<div class="cde-loksyu-visual-row">
|
||||
<img class="cde-lok-visual" src="systems/fvtt-chroniques-de-l-etrange/images/loksyu_long.webp" alt="Loksyu" />
|
||||
</div>
|
||||
|
||||
{{#if canEdit}}
|
||||
<div class="cde-lok-footer">
|
||||
<button class="cde-lok-reset-all" data-action="resetAll">
|
||||
<i class="fas fa-rotate-left"></i> {{ localize "CDE.ResetAll" }}
|
||||
</button>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
</div>
|
||||
41
templates/apps/cde-tinji-app.html
Normal file
41
templates/apps/cde-tinji-app.html
Normal file
@@ -0,0 +1,41 @@
|
||||
{{!-- Tin Ji standalone app --}}
|
||||
<div class="cde-tinji-app-body">
|
||||
|
||||
{{#unless hasActor}}
|
||||
<p class="cde-empty-list"><i class="fas fa-exclamation-triangle"></i> {{ localize "CDE.TinjiNotFound" }}</p>
|
||||
{{/unless}}
|
||||
|
||||
{{#if hasActor}}
|
||||
<div class="cde-tinji-display">
|
||||
<div class="cde-tinji-chinese-large">天機</div>
|
||||
<div class="cde-tinji-label">{{ localize "CDE.UpperCaseTinJi" }}</div>
|
||||
|
||||
<div class="cde-tinji-counter">
|
||||
{{#if canEdit}}
|
||||
<button class="cde-tinji-step" data-action="decrement" title="{{ localize 'CDE.Decrement' }}">−</button>
|
||||
{{/if}}
|
||||
<input class="cde-tinji-direct" type="number" min="0" value="{{value}}"
|
||||
{{#unless canEdit}}disabled{{/unless}} />
|
||||
{{#if canEdit}}
|
||||
<button class="cde-tinji-step" data-action="increment" title="{{ localize 'CDE.Increment' }}">+</button>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
<div class="cde-tinji-hint">{{ localize "CDE.AuspiciousDice" }}</div>
|
||||
|
||||
<div class="cde-tinji-actions">
|
||||
<button class="cde-tinji-spend-btn" data-action="spend" {{#unless value}}disabled{{/unless}}>
|
||||
<i class="fas fa-star"></i> {{ localize "CDE.SpendTinji" }}
|
||||
</button>
|
||||
{{#if canEdit}}
|
||||
<button class="cde-tinji-reset-btn" data-action="reset">
|
||||
<i class="fas fa-rotate-left"></i> {{ localize "CDE.Reset" }}
|
||||
</button>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<img class="cde-tinji-visual" src="systems/fvtt-chroniques-de-l-etrange/images/tinji.webp" alt="Tin Ji" />
|
||||
{{/if}}
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user