Reorganize cardgen repo by bibles, decks, and revision
This commit is contained in:
@@ -0,0 +1,642 @@
|
||||
# Card Creation and Prebuilt Deck Runbook
|
||||
|
||||
This is the practical runbook for taking a deck from **design document** to **live SOR catalog cards** to a **real prebuilt deck**.
|
||||
|
||||
It exists because the process now works, but there are enough sharp edges that future-you should not have to reconstruct it from chat logs and vibes.
|
||||
|
||||
This runbook is based on the live process used to create and ship:
|
||||
- the Red Shift Exodus card definitions
|
||||
- the Terramorpha retrofit cards
|
||||
- the `Orison Migration Covenant` prebuilt deck
|
||||
|
||||
---
|
||||
|
||||
# 0. Goal
|
||||
|
||||
The full pipeline is:
|
||||
|
||||
1. design the deck
|
||||
2. audit the deck against the current ability system
|
||||
3. redesign any awkward card text to fit the current engine cleanly
|
||||
4. generate machine-usable card definitions
|
||||
5. insert card definitions into the live catalog
|
||||
6. patch card/ability descriptions if needed
|
||||
7. create any missing supporting cards (e.g. Terramorpha package)
|
||||
8. assemble a real prebuilt deck
|
||||
9. verify the final result in admin and in the database
|
||||
|
||||
---
|
||||
|
||||
# 1. Where the source material lives
|
||||
|
||||
## Design-side inputs
|
||||
These usually live in:
|
||||
- `cardgen/`
|
||||
|
||||
Relevant files include:
|
||||
- `set_bible_*.md`
|
||||
- `*_deck_*.md`
|
||||
- `decks-r1/*.md`
|
||||
- `decks-r1_residual_gap_redesigns.md`
|
||||
- `sor_ability_system_gaps_found_via_deck_conversion.md`
|
||||
- `decks-r1_post_revision_residual_gap_synthesis.md`
|
||||
|
||||
## Game-side reference inputs
|
||||
These live in:
|
||||
- `/home/prime/.openclaw/workspace/SOR`
|
||||
|
||||
Most relevant:
|
||||
- `SOR/Shared/context-files/gameplay.md`
|
||||
- `SOR/Shared/context-files/abilities.md`
|
||||
- `SOR/Server/src/SOR.Game/Abilities/*`
|
||||
- `SOR/Server/src/SOR.Database/Entities/Catalog/CardDefinition.cs`
|
||||
- `SOR/Server/src/SOR.Database/Entities/Bazaar/PrebuiltDeck.cs`
|
||||
- `SOR/Server/src/SOR.Database/Entities/Bazaar/PrebuiltDeckCard.cs`
|
||||
- `SOR/Server/src/SOR.Database/Enums/*`
|
||||
|
||||
---
|
||||
|
||||
# 2. Authoring conventions
|
||||
|
||||
These matter a lot.
|
||||
|
||||
## 2.1 Card description vs ability description
|
||||
This was one of the first real schema mistakes we made.
|
||||
|
||||
### Correct rule
|
||||
- **Card `Description`** = the card’s visual/flavor depiction
|
||||
- **Ability `Description`** = the card’s mechanical text for that ability
|
||||
|
||||
### Wrong rule
|
||||
Do **not** put the full card rules summary into the top-level card description.
|
||||
|
||||
That makes admin entries ugly and semantically wrong.
|
||||
|
||||
---
|
||||
|
||||
## 2.2 Use `AbilitiesJson` vs `EffectsJson` correctly
|
||||
Per `CardDefinition.cs`:
|
||||
|
||||
- `AbilitiesJson` → for:
|
||||
- `ArchSpirit`
|
||||
- `Spirit`
|
||||
- `Ruin`
|
||||
- `EffectsJson` → for:
|
||||
- `Repentance`
|
||||
- `Instinct`
|
||||
- `Terramorpha`
|
||||
|
||||
If you violate that, you are fighting the model instead of using it.
|
||||
|
||||
---
|
||||
|
||||
## 2.3 Prefer engine-safe wording over poetic-but-fuzzy wording
|
||||
When writing live cards, prefer:
|
||||
- “if this unit is on Marsh when it attacks”
|
||||
- “if it ends on Marsh”
|
||||
- “target friendly unit gains +1 MP this turn”
|
||||
|
||||
instead of fuzzy text like:
|
||||
- “while moving”
|
||||
- “from or into” terrain unless strongly justified
|
||||
- weird half-realtime language in a turn-based tactics game
|
||||
|
||||
The R1 audit and residual redesign docs exist for exactly this reason.
|
||||
|
||||
---
|
||||
|
||||
## 2.4 ArchSpirit tier chains must be linked
|
||||
For ArchSpirit cards:
|
||||
- Tier 1 has `PreviousTierId = null`
|
||||
- Tier 2+ must point to the previous tier’s catalog card definition id
|
||||
|
||||
This is important when inserting to the live catalog.
|
||||
|
||||
In planning JSON we used:
|
||||
- `previousTierName`
|
||||
|
||||
Then resolved that name into a real `PreviousTierId` during insertion.
|
||||
|
||||
---
|
||||
|
||||
## 2.5 Terramorpha cards are regular catalog cards
|
||||
They are stored in `catalog.card_definitions` like anything else, with:
|
||||
- `CardType = Terramorpha`
|
||||
- `TerramorphaMode = Mono | Di | Tri`
|
||||
- `EffectsJson` containing the tile-affinity actions
|
||||
|
||||
They are **not** some special out-of-band object.
|
||||
|
||||
---
|
||||
|
||||
# 3. Design → machine-usable card plan
|
||||
|
||||
## 3.1 Start from the deck doc
|
||||
A deck doc gives you:
|
||||
- name
|
||||
- affinity
|
||||
- costs
|
||||
- stats
|
||||
- depiction text
|
||||
- intended ability text
|
||||
|
||||
But it is **not yet** insertion-ready.
|
||||
|
||||
## 3.2 Audit against the current engine
|
||||
Before generating live definitions, check:
|
||||
- `decks-r1/<deck>.md`
|
||||
- residual redesign docs
|
||||
- current `SOR.Game/Abilities`
|
||||
|
||||
Questions to resolve:
|
||||
- is this implementable now?
|
||||
- does it need templating cleanup?
|
||||
- does this wording assume a mechanic the game doesn’t actually resolve?
|
||||
|
||||
## 3.3 Produce one definition per unique card
|
||||
The plan file should contain **one object per unique card definition**, not one entry per copy.
|
||||
|
||||
Example:
|
||||
- `Ballast Skiff Tender` once in JSON, not three times
|
||||
- count is handled later in deck assembly
|
||||
|
||||
## 3.4 Write the plan to a real file
|
||||
Do **not** try to shuttle huge JSON blobs through chat/session output if you can avoid it.
|
||||
|
||||
Use a real workspace file, e.g.:
|
||||
- `cardgen/redshift_card_plan.json`
|
||||
|
||||
This avoids truncation and partial-copy nonsense.
|
||||
|
||||
## 3.5 Validate the JSON file before inserting
|
||||
Always parse it first.
|
||||
|
||||
Example:
|
||||
```bash
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
p='cardgen/redshift_card_plan.json'
|
||||
with open(p) as f:
|
||||
data=json.load(f)
|
||||
print('COUNT', len(data))
|
||||
print('FIRST', data[0]['name'])
|
||||
print('LAST', data[-1]['name'])
|
||||
PY
|
||||
```
|
||||
|
||||
If this fails, stop.
|
||||
|
||||
---
|
||||
|
||||
# 4. How to reach the live system
|
||||
|
||||
## 4.1 SOR repo
|
||||
Main repo:
|
||||
- `/home/prime/.openclaw/workspace/SOR`
|
||||
|
||||
## 4.2 Admin portal
|
||||
Live admin portal:
|
||||
- `https://control.aeternalisgames.com`
|
||||
|
||||
## 4.3 The browser caveat
|
||||
Browser automation may **not** be available from the current host.
|
||||
If the browser relay is unavailable, do not pretend you can drive the UI.
|
||||
|
||||
Use:
|
||||
- direct HTTP verification for login when possible
|
||||
- direct DB insertion for the actual catalog/deck changes
|
||||
- admin portal as a verification surface afterward
|
||||
|
||||
---
|
||||
|
||||
# 5. How to get live DB credentials
|
||||
|
||||
In this setup, the working connection string and admin creds were found in Kubernetes secrets.
|
||||
|
||||
## 5.1 Relevant namespace
|
||||
The live SOR app secrets were in:
|
||||
- `stone-server`
|
||||
|
||||
## 5.2 Useful secret
|
||||
- `sor-app-secrets`
|
||||
|
||||
## 5.3 Example retrieval
|
||||
```bash
|
||||
ssh -i /home/prime/.ssh/id_ed25519_prime -o StrictHostKeyChecking=no prime@172.10.1.160 \
|
||||
"sudo -n kubectl -n stone-server get secret sor-app-secrets -o jsonpath='{.data.ConnectionStrings__Default}' | base64 -d"
|
||||
```
|
||||
|
||||
Similarly for admin auth:
|
||||
```bash
|
||||
ssh -i /home/prime/.ssh/id_ed25519_prime -o StrictHostKeyChecking=no prime@172.10.1.160 \
|
||||
"sudo -n kubectl -n stone-server get secret sor-app-secrets -o jsonpath='{.data.Admin__Email}' | base64 -d; echo"
|
||||
|
||||
ssh -i /home/prime/.ssh/id_ed25519_prime -o StrictHostKeyChecking=no prime@172.10.1.160 \
|
||||
"sudo -n kubectl -n stone-server get secret sor-app-secrets -o jsonpath='{.data.Admin__Password}' | base64 -d; echo"
|
||||
```
|
||||
|
||||
## 5.4 Important note
|
||||
Treat these as sensitive operational creds.
|
||||
Do not spray them around casually.
|
||||
|
||||
---
|
||||
|
||||
# 6. Verifying admin access
|
||||
|
||||
Even if you are not driving the UI, verify that admin auth works.
|
||||
|
||||
Example with Python + cookie jar:
|
||||
```python
|
||||
import urllib.request, urllib.parse, http.cookiejar
|
||||
cj = http.cookiejar.CookieJar()
|
||||
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
|
||||
url = 'https://control.aeternalisgames.com/auth/login'
|
||||
data = urllib.parse.urlencode({'email':'<ADMIN_EMAIL>','password':'<ADMIN_PASSWORD>'}).encode()
|
||||
req = urllib.request.Request(url, data=data, method='POST')
|
||||
resp = opener.open(req, timeout=30)
|
||||
print(resp.geturl(), resp.status)
|
||||
```
|
||||
|
||||
Then verify cards page access:
|
||||
```python
|
||||
html = opener.open('https://control.aeternalisgames.com/cards', timeout=30).read().decode('utf-8','ignore')
|
||||
print('Some known card' in html)
|
||||
```
|
||||
|
||||
This proves the portal is alive and the auth path works.
|
||||
|
||||
---
|
||||
|
||||
# 7. Inserting catalog card definitions
|
||||
|
||||
## 7.1 Recommended insertion path
|
||||
Use direct Postgres insertion via Node.js and the `pg` package.
|
||||
|
||||
Why:
|
||||
- `psql` may not be installed
|
||||
- `dotnet` SDK may not be installed locally
|
||||
- Python DB libs may not be available
|
||||
- Node is available and easy to bootstrap ad hoc
|
||||
|
||||
## 7.2 Basic pattern
|
||||
1. load `cardgen/<plan>.json`
|
||||
2. for each card:
|
||||
- check if a card with the same name already exists
|
||||
- if yes, skip or patch depending on intent
|
||||
- if no, insert it
|
||||
3. when inserting Tier 2/3 ArchSpirits:
|
||||
- resolve `previousTierName` → `PreviousTierId`
|
||||
4. serialize `abilitiesJson` / `effectsJson` into JSONB
|
||||
|
||||
## 7.3 Key schema gotcha
|
||||
The database columns are **PascalCase quoted**, not lowercase.
|
||||
|
||||
For example:
|
||||
- `"Id"`
|
||||
- `"Name"`
|
||||
- `"CardType"`
|
||||
- `"Affinity"`
|
||||
- `"SpCost"`
|
||||
|
||||
If you use lowercase unquoted names like `id`, you will get column errors.
|
||||
|
||||
## 7.4 Example shape
|
||||
A typical insert looked like:
|
||||
```sql
|
||||
insert into catalog.card_definitions (
|
||||
"Id","Name","Description","CardType","Affinity","SpCost","StCost",
|
||||
...,
|
||||
"abilities","effects","Rarity","IsPublished","IsRetired","CreatedAt","UpdatedAt"
|
||||
)
|
||||
values (...)
|
||||
```
|
||||
|
||||
## 7.5 Duplicate safety
|
||||
Always check by card name first:
|
||||
```sql
|
||||
select "Id" from catalog.card_definitions where "Name"=$1 limit 1
|
||||
```
|
||||
|
||||
This prevents accidental duplicate card definitions when rerunning scripts.
|
||||
|
||||
---
|
||||
|
||||
# 8. Patching inserted cards
|
||||
|
||||
After the first insertion pass, you may realize you structured something badly.
|
||||
That is normal.
|
||||
|
||||
In our real process, we had to patch:
|
||||
- card descriptions
|
||||
- ability descriptions
|
||||
- one aura-related ability shape
|
||||
|
||||
## 8.1 Typical patch flow
|
||||
1. rewrite the local plan JSON file
|
||||
2. run SQL updates against existing `catalog.card_definitions`
|
||||
3. update:
|
||||
- `"Description"`
|
||||
- `"abilities"`
|
||||
- `"effects"`
|
||||
- `"UpdatedAt"`
|
||||
|
||||
## 8.2 Example of what we fixed live
|
||||
### Wrong
|
||||
- card `Description` contained rules summary
|
||||
|
||||
### Correct
|
||||
- card `Description` became visual depiction text
|
||||
- ability `Description` became readable rules text
|
||||
|
||||
This patch was applied across all 30 inserted Red Shift cards.
|
||||
|
||||
---
|
||||
|
||||
# 9. Creating Terramorpha cards
|
||||
|
||||
## 9.1 Why do it separately?
|
||||
Sometimes the original design doc doesn’t include the final Terramorpha package count or exact card list.
|
||||
|
||||
That’s okay.
|
||||
You can add them later as regular catalog cards.
|
||||
|
||||
## 9.2 Minimal required fields
|
||||
For Terramorpha cards:
|
||||
- `CardType = Terramorpha`
|
||||
- `Affinity = Lake / Field / etc.`
|
||||
- `SpCost`
|
||||
- `StCost`
|
||||
- `TerramorphaMode = Mono | Di | Tri`
|
||||
- `EffectsJson`
|
||||
- `Rarity`
|
||||
- `Description`
|
||||
|
||||
## 9.3 Example package used
|
||||
For the Red Shift deck, we added:
|
||||
- `Lake Monomorpha`
|
||||
- `Field Monomorpha`
|
||||
- `Lake Dimorpha`
|
||||
- `Field Dimorpha`
|
||||
- `Lake Trimorpha`
|
||||
- `Field Trimorpha`
|
||||
|
||||
## 9.4 Effect pattern
|
||||
A Terramorpha effect is just a tile-targeting card effect.
|
||||
Example conceptual form:
|
||||
```json
|
||||
[
|
||||
{
|
||||
"Target": { "Scope": "Battlefield", "Type": "Tile", "Ownership": "Any", "Count": { "N": 1 } },
|
||||
"Effects": [
|
||||
{ "$type": "PushAffinity", "Affinity": { "Fixed": "Lake" } }
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Di/Tri use higher target counts and rely on game-side targeting/legality.
|
||||
|
||||
---
|
||||
|
||||
# 10. Building a prebuilt deck
|
||||
|
||||
## 10.1 Relevant entities
|
||||
See:
|
||||
- `SOR/Server/src/SOR.Database/Entities/Bazaar/PrebuiltDeck.cs`
|
||||
- `SOR/Server/src/SOR.Database/Entities/Bazaar/PrebuiltDeckCard.cs`
|
||||
|
||||
## 10.2 Important structure
|
||||
A prebuilt deck has:
|
||||
- metadata row in `bazaar.prebuilt_decks`
|
||||
- card rows in `bazaar.prebuilt_deck_cards`
|
||||
|
||||
Key fields on the main deck row:
|
||||
- `Name`
|
||||
- `Description`
|
||||
- `IsActive`
|
||||
- `IsStarterDeck`
|
||||
- `IsAvailableInShop`
|
||||
- `ArchSpiritCardDefinitionId`
|
||||
- `ArchSpiritName`
|
||||
|
||||
Card rows need:
|
||||
- `PrebuiltDeckId`
|
||||
- `CardDefinitionId`
|
||||
- `CardName`
|
||||
- `Quantity`
|
||||
|
||||
## 10.3 Workflow
|
||||
1. decide the final 60-card list
|
||||
2. resolve each card name to its live `CardDefinitionId`
|
||||
3. create or update the prebuilt deck row
|
||||
4. delete existing deck-card rows if rebuilding
|
||||
5. insert the fresh `PrebuiltDeckCard` rows
|
||||
6. verify totals
|
||||
|
||||
## 10.4 Verification query
|
||||
Always verify:
|
||||
```sql
|
||||
select count(*)::int as unique_cards,
|
||||
sum("Quantity")::int as total_cards
|
||||
from bazaar.prebuilt_deck_cards
|
||||
where "PrebuiltDeckId"=$1
|
||||
```
|
||||
|
||||
If total is not what you intended, stop and fix it.
|
||||
|
||||
---
|
||||
|
||||
# 11. Real example: Orison Migration Covenant
|
||||
|
||||
## 11.1 First pass mistake
|
||||
The first Terramorpha retrofit prebuilt deck pass landed at:
|
||||
- **63 cards**, not 60
|
||||
|
||||
This happened because the first cut package was incomplete.
|
||||
|
||||
## 11.2 Correct behavior
|
||||
Do not pretend 63 is close enough.
|
||||
Count it, fix it, rerun.
|
||||
|
||||
## 11.3 Final fixed result
|
||||
The final prebuilt deck landed at:
|
||||
- **unique cards:** 29
|
||||
- **total cards:** 60
|
||||
|
||||
Deck:
|
||||
- `Orison Migration Covenant`
|
||||
- Deck ID: `1045ea8d-4f91-4fc0-9be8-6ec9431172e4`
|
||||
|
||||
This is the correct standard: verify, fix, verify again.
|
||||
|
||||
---
|
||||
|
||||
# 12. How to choose cuts when retrofitting a deck
|
||||
|
||||
When adding something like a Terramorpha package later, do not cut randomly.
|
||||
|
||||
## 12.1 Cut philosophy used
|
||||
Prefer cutting from:
|
||||
- slower top-end
|
||||
- redundant reactive pieces
|
||||
- lower-priority support cards
|
||||
- cards whose job is partly replaced by terrain shaping
|
||||
|
||||
Avoid cutting heavily from:
|
||||
- the ArchSpirit line
|
||||
- core low-end glue
|
||||
- the deck’s defining payoff cards
|
||||
- cards that make the deck’s setting identity obvious
|
||||
|
||||
## 12.2 Example Red Shift retrofit logic
|
||||
We preserved:
|
||||
- ArchSpirit line
|
||||
- early glue creatures
|
||||
- Marsh payoffs
|
||||
- logistics/corridor feel
|
||||
|
||||
We cut more from:
|
||||
- some slower / redundant support
|
||||
- some top-end
|
||||
- some extra reactive spell density
|
||||
|
||||
---
|
||||
|
||||
# 13. Recommended verification checklist
|
||||
|
||||
Before calling the job done, verify all of this.
|
||||
|
||||
## 13.1 Catalog card verification
|
||||
- [ ] all expected unique cards exist in `catalog.card_definitions`
|
||||
- [ ] no accidental duplicate names
|
||||
- [ ] top-level card descriptions are depiction text
|
||||
- [ ] ability descriptions contain readable rules text
|
||||
- [ ] ArchSpirit tier chain is linked correctly
|
||||
- [ ] Terramorpha cards have the correct mode
|
||||
- [ ] `AbilitiesJson` / `EffectsJson` landed in the correct field
|
||||
|
||||
## 13.2 Admin verification
|
||||
- [ ] admin login works
|
||||
- [ ] cards appear on `/cards`
|
||||
- [ ] edit links exist
|
||||
- [ ] card pages can be opened
|
||||
|
||||
## 13.3 Prebuilt deck verification
|
||||
- [ ] prebuilt deck row exists in `bazaar.prebuilt_decks`
|
||||
- [ ] `ArchSpiritCardDefinitionId` points to the correct Tier 1 ArchSpirit
|
||||
- [ ] card rows exist in `bazaar.prebuilt_deck_cards`
|
||||
- [ ] unique-card count is expected
|
||||
- [ ] total-card count is expected
|
||||
- [ ] deck is marked active/inactive appropriately
|
||||
|
||||
---
|
||||
|
||||
# 14. Common failure modes
|
||||
|
||||
## 14.1 Chat/session blob truncation
|
||||
Large JSON plans can get truncated if you try to ferry them through assistant/session messages.
|
||||
|
||||
### Fix
|
||||
Write them to a real file and use the file.
|
||||
|
||||
---
|
||||
|
||||
## 14.2 Wrong description semantics
|
||||
Top-level description becoming rules text instead of depiction.
|
||||
|
||||
### Fix
|
||||
Patch live cards and update the local plan file.
|
||||
|
||||
---
|
||||
|
||||
## 14.3 Tier chain not linked
|
||||
Tier 2/3 ArchSpirits inserted without resolving `PreviousTierId`.
|
||||
|
||||
### Fix
|
||||
Resolve previous tier by name before insert.
|
||||
|
||||
---
|
||||
|
||||
## 14.4 Wrong quoted column names
|
||||
Using lowercase column names in SQL instead of the real quoted PascalCase schema.
|
||||
|
||||
### Fix
|
||||
Use the exact schema names.
|
||||
|
||||
---
|
||||
|
||||
## 14.5 Count drift in prebuilt decks
|
||||
First pass deck total ends up 63, 58, etc.
|
||||
|
||||
### Fix
|
||||
Always verify counts and explicitly adjust.
|
||||
|
||||
---
|
||||
|
||||
## 14.6 Pretending browser automation exists when it does not
|
||||
If browser relay is unavailable, don’t fake UI automation.
|
||||
|
||||
### Fix
|
||||
Use:
|
||||
- direct auth verification
|
||||
- direct DB insertion
|
||||
- admin UI as post-fact verification
|
||||
|
||||
---
|
||||
|
||||
# 15. Recommended future improvements
|
||||
|
||||
This runbook works, but the process can still be improved.
|
||||
|
||||
## 15.1 Best next tool improvement
|
||||
Build a proper importer that:
|
||||
- reads a validated JSON card plan
|
||||
- inserts/updates card definitions safely
|
||||
- resolves ArchSpirit previous tiers automatically
|
||||
- optionally creates/updates prebuilt decks
|
||||
- emits a verification report
|
||||
|
||||
That is better than hand-rolled one-off scripts every time.
|
||||
|
||||
## 15.2 Nice second improvement
|
||||
Add a deck-plan schema file so card plan JSON has a stable documented format.
|
||||
|
||||
## 15.3 Nice third improvement
|
||||
Add dry-run validation that checks:
|
||||
- missing referenced cards
|
||||
- malformed ability JSON
|
||||
- non-60 card totals
|
||||
- duplicate names
|
||||
- bad card type / JSON field mismatches
|
||||
|
||||
---
|
||||
|
||||
# 16. Short version
|
||||
|
||||
If you only remember the essentials, remember this:
|
||||
|
||||
1. **Design the deck** in `cardgen`
|
||||
2. **Audit and clean the text** against the live ability system
|
||||
3. **Generate one unique-card JSON plan** to a real file
|
||||
4. **Insert cards into `catalog.card_definitions`** using direct DB access
|
||||
5. **Patch descriptions/abilities** if needed
|
||||
6. **Add missing support cards** like Terramorpha
|
||||
7. **Create/update a prebuilt deck** in `bazaar.prebuilt_decks`
|
||||
8. **Verify counts and admin visibility**
|
||||
|
||||
That is the pipeline.
|
||||
|
||||
---
|
||||
|
||||
# 17. Final note
|
||||
|
||||
This process is real now, not theoretical.
|
||||
It has already been used successfully to:
|
||||
- create live SOR cards
|
||||
- patch those cards
|
||||
- add Terramorpha support cards
|
||||
- assemble a live prebuilt deck
|
||||
|
||||
So future-you does not need to rediscover whether this is possible.
|
||||
It is.
|
||||
The main job is just to follow the steps cleanly and avoid the documented mistakes.
|
||||
@@ -0,0 +1,204 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
OUT = Path('/home/prime/.openclaw/workspace/cardgen/eclipse_frontier_card_plan.json')
|
||||
ISSUE = Path('/home/prime/.openclaw/workspace/cardgen/eclipse_frontier_issue_log.md')
|
||||
|
||||
|
||||
def count(n=1, all=False, upto=False):
|
||||
d = {'N': n}
|
||||
if all: d = {'All': True}
|
||||
if upto: d = {'N': n, 'UpTo': True}
|
||||
return d
|
||||
|
||||
def target(type_, ownership, scope='Battlefield', n=1, all=False, filters=None):
|
||||
t = {'Type': type_, 'Count': count(n=n, all=all), 'Scope': scope, 'Ownership': ownership}
|
||||
if filters:
|
||||
t['Filters'] = filters
|
||||
return t
|
||||
|
||||
def fixed(n): return {'Fixed': n}
|
||||
|
||||
def dur(type_, n=None):
|
||||
d = {'Type': type_}
|
||||
if n is not None: d['N'] = n
|
||||
return d
|
||||
|
||||
def eff_modify(stat, amt, stat_target=None):
|
||||
e = {'$type': f'Modify{stat}', 'Amount': fixed(amt)}
|
||||
if stat_target: e['StatTarget'] = stat_target
|
||||
return e
|
||||
|
||||
def eff_set(flag, value): return {'$type': f'Set{flag}', 'Value': value}
|
||||
def eff_push_aff(aff): return {'$type': 'PushAffinity', 'Affinity': {'Fixed': aff}}
|
||||
def eff_push_final(aff): return {'$type': 'PushFinalAffinity', 'Affinity': {'Fixed': aff}}
|
||||
def cond_on_aff(aff, subject='Target'): return {'$type': 'IsOnTileWithAffinity', 'Subject': subject, 'Affinity': aff}
|
||||
def trig(type_, **kwargs):
|
||||
d = {'$type': type_}
|
||||
d.update(kwargs)
|
||||
return d
|
||||
|
||||
def ability(name, type_, desc, actions, **kwargs):
|
||||
d = {'Name': name, 'Type': type_, 'Actions': actions, 'Description': desc}
|
||||
d.update(kwargs)
|
||||
return d
|
||||
|
||||
def action(target_, effects, conditions=None, duration=None):
|
||||
d = {'Target': target_, 'Effects': effects}
|
||||
if conditions: d['Conditions'] = conditions
|
||||
if duration: d['Duration'] = duration
|
||||
return d
|
||||
|
||||
def unit(name, description, affinity, sp, st, hp, df, dmg, move_type, mp, min_atk, max_atk, genus, rarity, abilities, card_type='Spirit', tier=None, prev=None, requires_los=False, min_channel=None, max_channel=None):
|
||||
attack_type = 'Ranged' if max_atk > 1 else 'Melee'
|
||||
card = {
|
||||
'name': name, 'description': description, 'cardType': card_type, 'affinity': affinity,
|
||||
'spCost': sp, 'stCost': st, 'maxHealth': hp, 'maxDefense': df, 'damage': dmg,
|
||||
'movementType': move_type, 'movementPoints': mp, 'minAttackRange': min_atk, 'maxAttackRange': max_atk,
|
||||
'attackType': attack_type, 'requiresLos': requires_los,
|
||||
'canAttack': True, 'canDefend': True, 'canBeAttacked': True, 'canBeBlocked': True,
|
||||
'canMove': True, 'canBeObstructed': True, 'canUseAbility': True, 'canBeSacrificed': card_type == 'Spirit',
|
||||
'genus': genus, 'rarity': rarity, 'abilitiesJson': abilities,
|
||||
}
|
||||
if min_channel is not None: card['minChannelRange'] = min_channel
|
||||
if max_channel is not None: card['maxChannelRange'] = max_channel
|
||||
if tier is not None: card['tier'] = tier
|
||||
if prev is not None: card['previousTierName'] = prev
|
||||
return card
|
||||
|
||||
def spell(name, description, affinity, sp, rarity, effects, card_type):
|
||||
return {'name': name, 'description': description, 'cardType': card_type, 'affinity': affinity, 'spCost': sp, 'stCost': 0, 'rarity': rarity, 'effectsJson': effects}
|
||||
|
||||
def terr(name, description, affinity, mode, sp, rarity, effects):
|
||||
return {'name': name, 'description': description, 'cardType': 'Terramorpha', 'affinity': affinity, 'spCost': sp, 'stCost': 0, 'terramorphaMode': mode, 'rarity': rarity, 'effectsJson': effects}
|
||||
|
||||
cards = []
|
||||
|
||||
# ArchSpirit line
|
||||
cards += [
|
||||
unit('Serai of the Witness Paths', 'A fox-masked diplomat in layered legal silks stands beneath a cliffside gate grown into the roots of colossal alien trees. Signal ribbons, carved oath-stones, and brass witness chimes sway around her in high jungle wind. One hand touches a luminous boundary-marker sunk into living earth; the other extends in invitation and warning.', 'Fort', 0, 0, 8, 2, 1, 'Walk', 2, 1, 1, ['Kitsune','Sasquatch','Leader'], 'Rare', [
|
||||
ability('Sanctuary Is a Promise — Hill', 'Passive', 'Friendly units on Hill gain +1 Defense.', [action(target('Unit','Owner',all=True), [eff_modify('Defense',1,'Max')], [cond_on_aff('Hill')])]),
|
||||
ability('Sanctuary Is a Promise — Forest', 'Passive', 'Friendly units on Forest gain +1 Defense.', [action(target('Unit','Owner',all=True), [eff_modify('Defense',1,'Max')], [cond_on_aff('Forest')])]),
|
||||
ability('Sanctuary Is a Promise — Fort', 'Passive', 'Friendly units on Fort gain +1 Defense.', [action(target('Unit','Owner',all=True), [eff_modify('Defense',1,'Max')], [cond_on_aff('Fort')])]),
|
||||
ability('Witness Entry', 'Triggered', 'When a friendly Spirit enters the battlefield on Fort, gain 1 SP.', [action(target('Player','Owner',scope='Player'), [{'$type':'ModifySP','Amount':fixed(1)}])], TriggerEvent=trig('OnUnitEnterBattlefield', UnitType='Spirit', Ownership='Owner'), ActivationConditions=[cond_on_aff('Fort')])
|
||||
], card_type='ArchSpirit', tier=1, min_channel=1, max_channel=3),
|
||||
unit('Serai, Covenant of Stone and Root', 'Serai stands atop a fortified ridge where precursor stone arches and jungle rootwork have fused into one living tribunal. Behind her, Hippogriff banners snap in the wind while witness tablets orbit in slow light. The whole scene feels like a court that learned how to survive a siege.', 'Fort', 4, 0, 10, 3, 2, 'Walk', 2, 1, 2, ['Kitsune','Sasquatch','Leader'], 'Epic', [
|
||||
ability('Boundaries with Teeth', 'Passive', 'Friendly Spirits on Fort gain +1 Damage and cannot be blocked.', [action(target('Spirit','Owner',all=True), [eff_modify('Damage',1), eff_set('CanBeBlocked', False)], [cond_on_aff('Fort')])]),
|
||||
ability('Legal Interdiction', 'Active', 'Target enemy loses CanMove until end of turn. If it is on Fort, it also loses CanAttack until end of turn.', [
|
||||
action(target('Unit','Enemy'), [eff_set('CanMove', False)], duration=dur('UntilEndOfTurn')),
|
||||
action(target('Unit','Target'), [eff_set('CanAttack', False)], conditions=[cond_on_aff('Fort')], duration=dur('UntilEndOfTurn'))
|
||||
], Cost=[{'Type':'SpiritPoints','Amount':2}], Range={'Min':1,'Max':4}, UsesPerTurn=1),
|
||||
ability('Tested Claim', 'Triggered', 'When an enemy enters this aura range, deal 1 damage to it unless it is on Fort.', [action(target('Unit','Target'), [{'$type':'DealDamage','Amount':fixed(1),'BypassDefense':False}], conditions=[{'$type':'Or','Conditions':[cond_on_aff(a) for a in ['Hill','Forest','Lake','Marsh','Plains','Steppe','Swamp','Grove','Mountain','Ocean','Island','Jungle']]}])], AuraRange={'Min':1,'Max':2}, TriggerEvent=trig('OnEnterAuraRange', AuraOwnership='Owner', UnitOwnership='Enemy'))
|
||||
], card_type='ArchSpirit', tier=2, prev='Serai of the Witness Paths', min_channel=1, max_channel=4),
|
||||
unit('Serai, Living Charter of Ilyra', 'Fully ascended, Serai appears as the personification of sanctuary law itself: nine spectral tails woven from root-light and brass script, standing upon a high citadel grown from cliffstone, jungle heartwood, and precursor machinery. Around her, the air is full of signed witness-forms, migrating lanterns, and the silhouettes of refugees crossing defended bridges.', 'Fort', 7, 1, 12, 4, 3, 'Walk', 2, 1, 2, ['Kitsune','Sasquatch','Leader'], 'Legendary', [
|
||||
ability('Refuge Cannot Be Taken, Only Kept — Stats', 'Passive', 'Friendly units on Hill, Forest, or Fort gain +1/+1.', [
|
||||
action(target('Unit','Owner',all=True), [eff_modify('Damage',1), eff_modify('Health',1,'Max')], [cond_on_aff('Hill')]),
|
||||
action(target('Unit','Owner',all=True), [eff_modify('Damage',1), eff_modify('Health',1,'Max')], [cond_on_aff('Forest')]),
|
||||
action(target('Unit','Owner',all=True), [eff_modify('Damage',1), eff_modify('Health',1,'Max')], [cond_on_aff('Fort')]),
|
||||
]),
|
||||
ability('Refuge Cannot Be Taken, Only Kept — Fort Passage', 'Passive', 'Friendly units on Fort cannot be obstructed.', [action(target('Unit','Owner',all=True), [eff_set('CanBeObstructed', False)], [cond_on_aff('Fort')])]),
|
||||
ability('Rewrite the Boundary', 'Active', 'Target tile becomes Fort. Then target friendly unit gains +1 MP this turn.', [
|
||||
action(target('Tile','Any'), [eff_push_final('Fort')]),
|
||||
action(target('Unit','Owner'), [eff_modify('MP',1,'Current')], duration=dur('UntilEndOfTurn'))
|
||||
], Cost=[{'Type':'SpiritPoints','Amount':3}], Range={'Min':1,'Max':5}, UsesPerTurn=1)
|
||||
], card_type='ArchSpirit', tier=3, prev='Serai, Covenant of Stone and Root', min_channel=1, max_channel=5),
|
||||
]
|
||||
|
||||
# Terramorpha
|
||||
cards += [
|
||||
terr('Verdant Bastion Monomorpha', 'A pulse of green root-light surges through broken masonry, causing vines and carved stone to fuse into a defensible living wall.', 'Forest', 'Mono', 2, 'Common', [action(target('Tile','Any'), [eff_push_aff('Forest')])]),
|
||||
terr('Escarpment Bastion Dimorpha', 'Two linked ridge-lines of ochre stone erupt from the ground like sleeping battlements remembering their shape.', 'Hill', 'Di', 3, 'Uncommon', [action(target('Tile','Any', n=2), [eff_push_aff('Hill')])]),
|
||||
terr('Witness Rampart Trimorpha', 'A three-point line of living roots, stone buttresses, and glowing legal sigils races across the battlefield, drawing a sanctuary border in real time.', 'Forest', 'Tri', 4, 'Rare', [action(target('Tile','Any', n=3), [eff_push_aff('Forest')])]),
|
||||
]
|
||||
|
||||
# Spirits
|
||||
cards += [
|
||||
unit('Root-Bridge Pathfinder','A furred route-guide moves across woven branch bridges over an abyss of glowing spores and machine roots.','Forest',1,0,2,0,1,'Walk',3,1,1,['Sasquatch','Scout'],'Common',[
|
||||
ability('Root-Bridge Toll','Triggered','When this moves onto Fort, gain 1 SP.', [action(target('Player','Owner',scope='Player'), [{'$type':'ModifySP','Amount':fixed(1)}])], TriggerEvent=trig('OnUnitMove', Ownership='ExactSelf'), ActivationConditions=[cond_on_aff('Fort','Self')])
|
||||
]),
|
||||
unit('Cliffline Warrant Scribe','A masked legal clerk carves glowing boundary clauses into standing stones at the edge of a wind-beaten shelf.','Hill',1,0,1,1,1,'Walk',2,1,1,['Kitsune','Jurist'],'Common',[
|
||||
ability('Warrant Cover','OnChanneled'.replace('OnChanneled','Triggered'),'On channel, a friendly unit gains +1 Defense until end of turn.', [action(target('Unit','Owner'), [eff_modify('Defense',1,'Current')], duration=dur('UntilEndOfTurn'))], TriggerEvent=trig('OnChanneled', CardType='Spirit', Ownership='Owner', Filter={'$type':'IsSelf'}))
|
||||
]),
|
||||
unit('Eyrie Debt Courier','A messenger-rider sweeps between cliff beacons carrying treaty tubes and storm-marked debt seals.','Hill',2,0,2,1,1,'Flight',3,1,1,['Hippogriff','Courier'],'Common',[
|
||||
ability('Forwarded Route','Triggered','When this enters, another friendly unit gains +1 MP this turn.', [action(target('Unit','Owner'), [eff_modify('MP',1,'Current')], duration=dur('UntilEndOfTurn'))], TriggerEvent=trig('OnUnitEnterBattlefield', UnitType='Unit', Ownership='Owner', Filter={'$type':'IsSelf'}))
|
||||
]),
|
||||
unit('Canopy Oathkeeper','A massive guardian leans on a root-grown halberd beneath luminescent leaves and old warning charms.','Forest',2,0,2,2,1,'Walk',2,1,1,['Sasquatch','Warden'],'Uncommon',[
|
||||
ability('Oathkeeper Aura','Aura','Aura 1: friendly units gain +1 Defense.', [action(target('Unit','Owner',all=True), [eff_modify('Defense',1,'Max')])], AuraRange={'Min':1,'Max':1})
|
||||
]),
|
||||
unit('Fortline Mediator','A silver-tongued envoy walks a parapet grown out of cliff roots, foxfire lanterns floating in her wake.','Fort',2,0,2,1,2,'Walk',2,1,1,['Kitsune','Diplomat'],'Uncommon',[
|
||||
ability('Fortline Briefing','Triggered','When this enters on Fort, draw 1 then discard 1.', [action(target('Player','Owner',scope='Player'), [{'$type':'DrawCards','N':1,'Player':'Owner'},{'$type':'DiscardCards','N':1,'Player':'Owner'}])], TriggerEvent=trig('OnUnitEnterBattlefield', UnitType='Unit', Ownership='Owner', Filter={'$type':'IsSelf'}), ActivationConditions=[cond_on_aff('Fort')])
|
||||
]),
|
||||
unit('Storm-Pledge Lancer','An armored sky-lancer dives through ozone haze with a rune-lance leveled toward a contested tower gate.','Hill',3,0,3,1,2,'Flight',3,1,1,['Hippogriff','Soldier'],'Uncommon',[
|
||||
ability('Fort Dive','Triggered','When this attacks while on Fort, it gains +1 Damage until end of turn.', [action(target('Unit','ExactSelf'), [eff_modify('Damage',1)], duration=dur('UntilEndOfTurn'))], TriggerEvent=trig('OnUnitAttack', Ownership='Owner', Filter={'$type':'IsSelf'}), ActivationConditions=[cond_on_aff('Fort','Self')])
|
||||
]),
|
||||
unit('Memory-Root Bailiff','A broad, solemn arbiter listens with one ear to living roots and with the other to frightened settlers.','Forest',3,0,3,2,1,'Walk',2,1,2,['Sasquatch','Jurist'],'Uncommon',[
|
||||
ability('Silence for the Record','Active','Target enemy loses CanAttack until end of turn.', [action(target('Unit','Enemy'), [eff_set('CanAttack',False)], duration=dur('UntilEndOfTurn'))], Range={'Min':1,'Max':2}, UsesPerTurn=1)
|
||||
]),
|
||||
unit('Bastion Verge Ranger','A ridge-runner in barkplate crosses a fortified ravine on rope and root, always one step ahead of the map.','Fort',3,0,3,2,2,'Walk',3,1,1,['Sasquatch','Scout'],'Uncommon',[
|
||||
ability('Verge Momentum','Triggered','When this moves onto Fort, it gains +1 MP this turn.', [action(target('Unit','ExactSelf'), [eff_modify('MP',1,'Current')], duration=dur('UntilEndOfTurn'))], TriggerEvent=trig('OnUnitMove', Ownership='ExactSelf'), ActivationConditions=[cond_on_aff('Fort','Self')])
|
||||
]),
|
||||
unit('Glassfire Deceiver-Advocate','A fox envoy in mirrored lacquer and mourning silk stands inside a courtroom made of rain, reflection, and brass.','Fort',3,0,2,1,2,'Walk',2,1,2,['Kitsune','Diplomat'],'Rare',[
|
||||
ability('Glassfire Exposure','Triggered','On channel, target enemy loses CanUseAbility until end of turn.', [action(target('Unit','Enemy'), [eff_set('CanUseAbility',False)], duration=dur('UntilEndOfTurn'))], TriggerEvent=trig('OnChanneled', CardType='Spirit', Ownership='Owner', Filter={'$type':'IsSelf'}))
|
||||
]),
|
||||
unit('Stormtusk Claim-Breaker','A lean drake with conductive tusks smashes a relay tower while lightning crawls across its plated flanks.','Hill',4,0,4,2,3,'Walk',2,1,1,['Astral Drake stormtusk'],'Rare',[
|
||||
ability('Claim-Breaking Charge','Triggered','On attack, push target 1 tile.', [action(target('Unit','Enemy'), [{'$type':'PushUnit','Tiles':1}])], TriggerEvent=trig('OnUnitAttack', Ownership='Owner', Filter={'$type':'IsSelf'}))
|
||||
]),
|
||||
unit('Shrine-Canopy Witness','A many-headed singer coils through shrine vines, each mouth carrying a different fragment of binding law.','Forest',4,0,4,2,2,'Walk',2,1,2,['Astral Hydra Singer'],'Rare',[
|
||||
ability('Witnessed Approach','Triggered','When a friendly unit enters this aura range, that unit gains +1 Defense until end of turn.', [action(target('Unit','Target'), [eff_modify('Defense',1,'Current')], duration=dur('UntilEndOfTurn'))], AuraRange={'Min':1,'Max':2}, TriggerEvent=trig('OnEnterAuraRange', AuraOwnership='Owner', UnitOwnership='Owner'))
|
||||
]),
|
||||
unit('Mnemosyne Leak-Slime','A translucent remediation pour crawls across archive brass and tree roots, carrying broken memory crystals in its body like stars in gel.','Forest',4,0,4,1,2,'Walk',2,1,1,['Sentient Slime'],'Rare',[
|
||||
ability('Archive Siphon','Triggered','On enter on Fort, draw 2 then discard 1.', [action(target('Player','Owner',scope='Player'), [{'$type':'DrawCards','N':2,'Player':'Owner'},{'$type':'DiscardCards','N':1,'Player':'Owner'}])], TriggerEvent=trig('OnUnitEnterBattlefield', UnitType='Unit', Ownership='Owner', Filter={'$type':'IsSelf'}), ActivationConditions=[cond_on_aff('Fort')])
|
||||
]),
|
||||
unit('Sky-Law Manta','A luminous manta glides above cliff beacons and portal weather, carrying witness-banners between impossible thermal lanes.','Hill',5,0,4,2,3,'Flight',3,2,3,['Nebula Manta'],'Rare',[
|
||||
ability('High Sanctuary Draft','Aura','Friendly Fort units in aura range cannot be obstructed.', [action(target('Unit','Owner',all=True), [eff_set('CanBeObstructed',False)], [cond_on_aff('Fort')])], AuraRange={'Min':1,'Max':2})
|
||||
], requires_los=True),
|
||||
unit('Sunken Tribunal Raykeeper','A tide-priest in reflective armor lifts a relic witness-bowl toward a sun seen only through floodwater.','Fort',5,0,5,2,2,'Walk',2,1,2,['Astral Kraken of the Sun','Jurist'],'Epic',[
|
||||
ability('Tribunal Freeze','Active','Target enemy on Fort loses CanMove and CanAttack until end of turn.', [action(target('Unit','Enemy'), [eff_set('CanMove',False), eff_set('CanAttack',False)], conditions=[cond_on_aff('Fort')], duration=dur('UntilEndOfTurn'))], Range={'Min':1,'Max':2}, UsesPerTurn=1)
|
||||
]),
|
||||
unit('Tusk-Lord of the Audit Storm','A tusk-lord roars atop an electrified mesa while the sky itself seems to judge the city below.','Hill',6,1,6,2,4,'Walk',2,1,1,['Astral Drake stormtusk','Mythic'],'Legendary',[
|
||||
ability('Audit Storm','Triggered','When this attacks a unit, that unit loses CanMove until end of turn.', [action(target('Unit','Enemy'), [eff_set('CanMove',False)], duration=dur('UntilEndOfTurn'))], TriggerEvent=trig('OnUnitAttack', Ownership='Owner', Filter={'$type':'IsSelf'}))
|
||||
]),
|
||||
unit('Polyphonic Sanctuary Hydra','A colossal choir-brood coils across walls and trees at once, its harmonies turning the battlefield into a legal chorus.','Fort',7,1,7,3,3,'Walk',2,1,2,['Astral Hydra Singer','Mythic'],'Legendary',[
|
||||
ability('Polyphonic Sanctuary','Passive','Friendly Fort units gain +1/+1.', [action(target('Unit','Owner',all=True), [eff_modify('Damage',1), eff_modify('Health',1,'Max')], [cond_on_aff('Fort')])]),
|
||||
ability('First Chorus','Triggered','When a friendly unit enters this aura range, draw 1 card.', [action(target('Player','Owner',scope='Player'), [{'$type':'DrawCards','N':1,'Player':'Owner'}])], AuraRange={'Min':1,'Max':2}, TriggerEvent=trig('OnEnterAuraRange', AuraOwnership='Owner', UnitOwnership='Owner'))
|
||||
]),
|
||||
]
|
||||
|
||||
# Repentance
|
||||
cards += [
|
||||
spell('Boundary Injunction','A glowing legal boundary slams down across contested ground, its script anchored in root and stone.','Fort',1,'Common',[action(target('Unit','Owner'), [eff_set('CanBeAttacked',False)], duration=dur('UntilEndOfTurn'))],'Repentance'),
|
||||
spell('Upland Evacuation Route','Beacon towers light in sequence along a cliff road as refugees sprint between switchback shadows.','Hill',2,'Common',[action(target('Unit','Owner'), [eff_modify('MP',2,'Current')], duration=dur('UntilEndOfTurn'))],'Repentance'),
|
||||
spell('Root-Memory Appeal','Vines peel back from old stone to reveal witness-faces and forgotten names in sap-light.','Forest',2,'Uncommon',[action(target('Player','Owner',scope='Player'), [{'$type':'DrawCards','N':2,'Player':'Owner'},{'$type':'DiscardCards','N':1,'Player':'Owner'}])],'Repentance'),
|
||||
spell('Raise the Sanctuary Wall','Jungle roots and uplifted stone interlock into a living barricade etched with glowing refugee marks.','Fort',3,'Uncommon',[
|
||||
action(target('Tile','Any'), [eff_push_final('Fort')]),
|
||||
action(target('Unit','Owner'), [eff_modify('Defense',1,'Current')], duration=dur('UntilEndOfTurn'))
|
||||
],'Repentance'),
|
||||
spell('Charter of Shared Refuge','A many-signatory covenant unfurls over the battlefield while every faction’s seal burns in equal light.','Fort',4,'Rare',[
|
||||
action(target('Unit','Owner',all=True), [eff_modify('Damage',1), eff_modify('Defense',1,'Current'), eff_set('CanUseAbility',True)], conditions=[cond_on_aff('Fort')], duration=dur('UntilEndOfTurn'))
|
||||
],'Repentance'),
|
||||
]
|
||||
|
||||
# Ruin
|
||||
cards += [
|
||||
{
|
||||
'name':'Witness Stone of Ashen Mere','description':'A weathered monolith at the truce-crossing of Ashen Mere, carved with names of those who were allowed through and those who were not.','cardType':'Ruin','affinity':'Fort','spCost':3,'stCost':0,'rarity':'Rare','abilitiesJson':[
|
||||
ability('Ashen Ledger Grant','Triggered','If this Ruin is occupied by a friendly unit when it activates, gain 1 SP.', [action(target('Player','Owner',scope='Player'), [{'$type':'ModifySP','Amount':fixed(1)}])], TriggerEvent=trig('OnRuinActivation', RuinOwnership='Owner', OccupantOwnership='Owner')),
|
||||
ability('Ashen Ledger Sorting','Triggered','If this Ruin is occupied by a friendly unit when it activates, draw 1 then discard 1.', [action(target('Player','Owner',scope='Player'), [{'$type':'DrawCards','N':1,'Player':'Owner'},{'$type':'DiscardCards','N':1,'Player':'Owner'}])], TriggerEvent=trig('OnRuinActivation', RuinOwnership='Owner', OccupantOwnership='Owner')),
|
||||
ability('Ashen Ledger Injunction','Triggered','If this Ruin is occupied by a friendly unit when it activates, target enemy in aura range loses CanAttack until end of turn.', [action(target('Unit','Enemy', filters=[{'$type':'WithinRange','Min':1,'Max':2}]), [eff_set('CanAttack',False)], duration=dur('UntilEndOfTurn'))], TriggerEvent=trig('OnRuinActivation', RuinOwnership='Owner', OccupantOwnership='Owner')),
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
# Instinct
|
||||
cards += [
|
||||
spell('Objection Under Witness','A legal cry rings out across a battlefield tribunal and an attack stalls mid-motion as if the world itself is listening.','Fort',1,'Common',[action(target('Unit','Any'), [eff_set('CanAttack',False)], duration={'Type':'UntilEndOfSequence'})],'Instinct'),
|
||||
spell('Canopy Ambuscade Clause','Jungle shadows fold around an advancing enemy as root-signs flare with old territorial law.','Forest',2,'Common',[action(target('Unit','Any'), [{'$type':'PushUnit','Tiles':1}])],'Instinct'),
|
||||
spell('Highwind Extraction','Hippogriff lines dive through stormlight to snatch the vulnerable out of a collapsing lane.','Hill',2,'Common',[action(target('Unit','Owner'), [eff_set('CanBeAttacked',False)], duration=dur('UntilEndOfTurn'))],'Instinct'),
|
||||
spell('Unwritten Path','The jungle quietly edits the route beneath an enemy’s feet until they are suddenly somewhere much less useful.','Forest',3,'Uncommon',[action(target('Unit','Any'), [eff_set('CanMove',False)], duration=dur('UntilEndOfTurn'))],'Instinct'),
|
||||
]
|
||||
|
||||
OUT.write_text(json.dumps(cards, indent=2))
|
||||
ISSUE.write_text('''# Eclipse Frontier — Live Catalog Issue Log\n\nDeck: **Lattice Witness Compact**\nPlan file: `cardgen/eclipse_frontier_card_plan.json`\n\n## Summary\n- Goal: implement as much of Eclipse Frontier cleanly in the current live SOR catalog as possible.\n- Result of authoring pass: **30 catalog definitions prepared**.\n- Deferred / omitted from live pass: **3 cards** due current engine gaps or poor-fit templating.\n\n## Global choices\n- Used **depiction text** in top-level card descriptions and **mechanical text** inside ability descriptions, matching the runbook.\n- Chose **engine-safe wording** over original poetic/modal wording when exact execution was not clean.\n- Assigned **best-fit provisional rarities** because deck docs do not specify live rarities.\n- Kept cards **outside a set / collector numbering** for now; this should be revisited once the set publishing pipeline is formalized.\n\n## Omitted for now\n- **Serai of the Witness Paths — Mark the Safe Route**: omitted. Needs tile-bound delayed marker memory plus first-friendly-entry consumption semantics.\n- **Serai, Living Charter of Ilyra — Witness-Covenant**: omitted. Needs pre-death replacement / prevention timing.\n- **Gate-Spire Intercessor**: omitted. Needs relational scan like “enemies adjacent to Fort units”.\n\n## Templating / compromise notes by card\n- **Serai, Covenant of Stone and Root / Boundaries with Teeth**: simplified to “on Fort gain +1 Damage and cannot be blocked” instead of the narrower “while moving” rider.\n- **Serai, Covenant of Stone and Root / Tested Claim**: implemented with an explicit positive affinity list as the current practical substitute for a missing NOT-on-Fort condition. Ugly, but deterministic.\n- **Serai, Living Charter of Ilyra / Rewrite the Boundary**: converted the move rider into `+1 MP this turn`.\n- **Eyrie Debt Courier**: converted “another friendly unit may move 1 tile” into `+1 MP this turn`.\n- **Storm-Pledge Lancer**: simplified to “when this attacks while on Fort”.\n- **Bastion Verge Ranger**: simplified extra move into `+1 MP this turn`.\n- **Glassfire Deceiver-Advocate**: locked the modal effect to `CanUseAbility = false`.\n- **Shrine-Canopy Witness**: locked the modal buff to `+1 Defense until end of turn`.\n- **Mnemosyne Leak-Slime**: locked to the Fort branch only: “on enter on Fort, draw 2 then discard 1.”\n- **Sunken Tribunal Raykeeper**: simplified from “on Fort or adjacent to Fort” to just “on Fort”.\n- **Tusk-Lord of the Audit Storm**: simplified from damage-source memory to attack-trigger memory.\n- **Polyphonic Sanctuary Hydra**: kept the draw trigger without a first-time-per-turn cap because that trigger limit is not presently available. This is intentionally logged as balance-risky.\n- **Upland Evacuation Route**: used `+2 MP this turn` instead of effect-move 1-2 tiles.\n- **Root-Memory Appeal**: locked to `Draw 2 then discard 1`.\n- **Canopy Ambuscade Clause**: used a plain 1-tile push.\n- **Highwind Extraction**: locked to temporary untargetability.\n- **Unwritten Path**: expressed as temporary `CanMove = false`.\n- **Witness Stone of Ashen Mere**: the enemy-lock rider uses a simple within-range filter rather than a true aura-specific ruin model; verify in live play.\n\n## Questions / follow-up\n- Confirm whether `UntilEndOfSequence` remains valid in the live engine for Instinct timing; existing live cards suggest yes.\n- Confirm whether current passive stat modifiers should prefer `MaxDefense` vs `CurrentDefense` in final content style; this pass used `Max` for stable board buffs and `Current` for temporary tactical shielding.\n- Revisit the Hydra draw trigger if it proves too snowbally without a per-turn cap.\n- Revisit set assignment / collector numbering / release-state metadata once the broader set pipeline is ready.\n''')
|
||||
print(f'wrote {OUT}')
|
||||
print(f'wrote {ISSUE}')
|
||||
print('count', len(cards))
|
||||
@@ -0,0 +1,504 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
OUT = Path('/home/prime/.openclaw/workspace/cardgen/frosthallow_card_plan.json')
|
||||
|
||||
RARITY = {
|
||||
'arch1': 'Rare',
|
||||
'arch2': 'Epic',
|
||||
'arch3': 'Legendary',
|
||||
'common': 'Common',
|
||||
'uncommon': 'Uncommon',
|
||||
'rare': 'Rare',
|
||||
'legendary': 'Legendary',
|
||||
}
|
||||
|
||||
|
||||
def base_unit(name, description, card_type, affinity, sp, st, hp, defense, damage, move_type, mp, atk_min, atk_max, atk_type, genus, rarity):
|
||||
return {
|
||||
'name': name,
|
||||
'description': description,
|
||||
'cardType': card_type,
|
||||
'affinity': affinity,
|
||||
'spCost': sp,
|
||||
'stCost': st,
|
||||
'maxHealth': hp,
|
||||
'maxDefense': defense,
|
||||
'damage': damage,
|
||||
'movementType': move_type,
|
||||
'movementPoints': mp,
|
||||
'minAttackRange': atk_min,
|
||||
'maxAttackRange': atk_max,
|
||||
'attackType': atk_type,
|
||||
'requiresLos': False,
|
||||
'canAttack': True,
|
||||
'canDefend': True,
|
||||
'canBeAttacked': True,
|
||||
'canBeBlocked': True,
|
||||
'canMove': True,
|
||||
'canBeObstructed': True,
|
||||
'canUseAbility': True,
|
||||
'canBeSacrificed': card_type != 'ArchSpirit',
|
||||
'genus': genus,
|
||||
'rarity': rarity,
|
||||
}
|
||||
|
||||
|
||||
def passive_affinity_stat(name, affinities, effects, desc):
|
||||
return {
|
||||
'Name': name,
|
||||
'Type': 'Passive',
|
||||
'Actions': [
|
||||
{
|
||||
'Target': {'Type': 'Unit', 'Count': {'All': True}, 'Scope': 'Battlefield', 'Ownership': 'Owner'},
|
||||
'Effects': effects,
|
||||
'Conditions': [{'$type': 'IsOnTileWithAffinity', 'Subject': 'Target', 'Affinity': aff}]
|
||||
}
|
||||
for aff in affinities
|
||||
],
|
||||
'Description': desc,
|
||||
}
|
||||
|
||||
|
||||
def until_turn(effects):
|
||||
return {'Effects': effects, 'Duration': {'Type': 'UntilEndOfTurn'}}
|
||||
|
||||
|
||||
plan = []
|
||||
|
||||
# ArchSpirit line
|
||||
c = base_unit(
|
||||
'Ulla, Keeper of the Distress Fires',
|
||||
'A massive yeti matriarch stands beside a distress brazier on a blackwater snow shelf where pine roots claw down into a half-frozen fjord. Wind-driven cinders and aurora light mix in the dark.',
|
||||
'ArchSpirit', 'Swamp', 10, 0, 8, 2, 1, 'Walk', 2, 1, 1, 'Melee', ['Yeti', 'Leader'], RARITY['arch1']
|
||||
)
|
||||
c.update({
|
||||
'minChannelRange': 1, 'maxChannelRange': 3, 'tier': 1,
|
||||
'abilitiesJson': [
|
||||
passive_affinity_stat('Shelter Is Sacred', ['Lake', 'Forest', 'Swamp'], [{'$type': 'ModifyDefense', 'Amount': {'Fixed': 1}, 'StatTarget': 'Max'}], 'Friendly units on Lake, Forest, or Swamp gain +1 Defense.'),
|
||||
{
|
||||
'Name': 'Drag Them to Safety',
|
||||
'Type': 'Active',
|
||||
'Actions': [
|
||||
{
|
||||
'Target': {'Type': 'Unit', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Owner'},
|
||||
'Effects': [{'$type': 'ModifyMP', 'Amount': {'Fixed': 1}, 'StatTarget': 'Current'}],
|
||||
'Duration': {'Type': 'UntilEndOfTurn'}
|
||||
},
|
||||
{
|
||||
'Target': {'Type': 'Unit', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Target'},
|
||||
'Effects': [{'$type': 'HealDamage', 'Amount': {'Fixed': 1}}],
|
||||
'Conditions': [{'$type': 'IsOnTileWithAffinity', 'Subject': 'Target', 'Affinity': 'Swamp'}]
|
||||
}
|
||||
],
|
||||
'Description': 'Target friendly unit gains +1 MP this turn. If it is on Swamp, heal it 1.',
|
||||
'Cost': [{'Type': 'SpiritPoints', 'Amount': 1}],
|
||||
'Range': {'Min': 1, 'Max': 3},
|
||||
'UsesPerTurn': 1,
|
||||
},
|
||||
{
|
||||
'Name': 'Rescue Bell Answered',
|
||||
'Type': 'Triggered',
|
||||
'Actions': [{
|
||||
'Target': {'Type': 'Unit', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Target'},
|
||||
'Effects': [{'$type': 'ModifyDefense', 'Amount': {'Fixed': 1}, 'StatTarget': 'Current'}]
|
||||
}],
|
||||
'Description': 'When a friendly Spirit enters the battlefield in this aura range, it gains +1 current Defense.',
|
||||
'AuraRange': {'Min': 1, 'Max': 3},
|
||||
'TriggerEvent': {'$type': 'OnEnterAuraRange', 'AuraOwnership': 'Owner', 'UnitOwnership': 'Owner', 'Filter': {'$type': 'CardTypeIs', 'CardType': 'Spirit'}},
|
||||
}
|
||||
]
|
||||
})
|
||||
plan.append(c)
|
||||
|
||||
c = base_unit(
|
||||
'Ulla, Shelter in the Storm',
|
||||
'Ulla stands at the mouth of Hollowglass as blizzard curtains swallow the mountainside. Around her, oath ropes, rescue bells, and storm lanterns form a ring of warmth in otherwise lethal white.',
|
||||
'ArchSpirit', 'Swamp', 6, 1, 10, 3, 2, 'Walk', 2, 1, 2, 'Ranged', ['Yeti', 'Leader'], RARITY['arch2']
|
||||
)
|
||||
c.update({
|
||||
'minChannelRange': 1, 'maxChannelRange': 4, 'tier': 2, 'previousTierName': 'Ulla, Keeper of the Distress Fires',
|
||||
'abilitiesJson': [
|
||||
{
|
||||
'Name': 'Mercy Holds the Line',
|
||||
'Type': 'Passive',
|
||||
'Actions': [{
|
||||
'Target': {'Type': 'Spirit', 'Count': {'All': True}, 'Scope': 'Battlefield', 'Ownership': 'Owner'},
|
||||
'Effects': [{'$type': 'ModifyDamage', 'Amount': {'Fixed': 1}}, {'$type': 'SetCanBeBlocked', 'Value': False}],
|
||||
'Conditions': [{'$type': 'IsOnTileWithAffinity', 'Subject': 'Target', 'Affinity': 'Swamp'}]
|
||||
}],
|
||||
'Description': 'Friendly Spirits on Swamp gain +1 Damage and cannot be blocked.'
|
||||
},
|
||||
{
|
||||
'Name': 'White Truce',
|
||||
'Type': 'Active',
|
||||
'Actions': [
|
||||
{
|
||||
'Target': {'Type': 'Unit', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Enemy'},
|
||||
'Effects': [{'$type': 'SetCanAttack', 'Value': False}],
|
||||
'Duration': {'Type': 'UntilEndOfTurn'}
|
||||
},
|
||||
{
|
||||
'Target': {'Type': 'Unit', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Target'},
|
||||
'Effects': [{'$type': 'SetCanMove', 'Value': False}],
|
||||
'Conditions': [{'$type': 'IsOnTileWithAffinity', 'Subject': 'Target', 'Affinity': 'Swamp'}],
|
||||
'Duration': {'Type': 'UntilEndOfTurn'}
|
||||
}
|
||||
],
|
||||
'Description': 'Target enemy loses CanAttack until end of turn. If it is on Swamp, it also loses CanMove until end of turn.',
|
||||
'Cost': [{'Type': 'SpiritPoints', 'Amount': 2}],
|
||||
'Range': {'Min': 1, 'Max': 4},
|
||||
'UsesPerTurn': 1,
|
||||
},
|
||||
{
|
||||
'Name': 'Shared Hearth',
|
||||
'Type': 'Triggered',
|
||||
'Actions': [{
|
||||
'Target': {'Type': 'Unit', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Target'},
|
||||
'Effects': [{'$type': 'HealDamage', 'Amount': {'Fixed': 1}}]
|
||||
}],
|
||||
'Description': 'The first time each turn a friendly unit enters this aura range, heal it 1.',
|
||||
'AuraRange': {'Min': 1, 'Max': 2},
|
||||
'TriggerEvent': {'$type': 'OnEnterAuraRange', 'AuraOwnership': 'Owner', 'UnitOwnership': 'Owner'},
|
||||
'TriggerLimitPerTurn': 1,
|
||||
}
|
||||
]
|
||||
})
|
||||
plan.append(c)
|
||||
|
||||
c = base_unit(
|
||||
'Ulla, Hearth of Hollowglass',
|
||||
'Ascended Ulla appears as a living sanctuary of fur, stone, and firelight, framed by glacier walls and black thawwater. Every bell in Hollowglass seems to ring in answer to her breath.',
|
||||
'ArchSpirit', 'Swamp', 7, 2, 12, 4, 3, 'Walk', 2, 1, 2, 'Ranged', ['Yeti', 'Leader'], RARITY['arch3']
|
||||
)
|
||||
c.update({
|
||||
'minChannelRange': 1, 'maxChannelRange': 5, 'tier': 3, 'previousTierName': 'Ulla, Shelter in the Storm',
|
||||
'abilitiesJson': [
|
||||
passive_affinity_stat('No One Dies Alone in Snow', ['Lake', 'Forest', 'Swamp'], [
|
||||
{'$type': 'ModifyDamage', 'Amount': {'Fixed': 1}},
|
||||
{'$type': 'ModifyHealth', 'Amount': {'Fixed': 1}, 'StatTarget': 'Max'}
|
||||
], 'Friendly units on Lake, Forest, or Swamp gain +1/+1.'),
|
||||
{
|
||||
'Name': 'Mark the Winter Refuge',
|
||||
'Type': 'Active',
|
||||
'Actions': [
|
||||
{
|
||||
'Target': {'Type': 'Tile', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Any'},
|
||||
'Effects': [{'$type': 'PushFinalAffinity', 'Affinity': {'Fixed': 'Swamp'}}]
|
||||
},
|
||||
{
|
||||
'Target': {'Type': 'Unit', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Owner'},
|
||||
'Effects': [{'$type': 'ModifyMP', 'Amount': {'Fixed': 1}, 'StatTarget': 'Current'}],
|
||||
'Duration': {'Type': 'UntilEndOfTurn'}
|
||||
}
|
||||
],
|
||||
'Description': 'Target tile becomes Swamp. Then target friendly unit gains +1 MP this turn.',
|
||||
'Cost': [{'Type': 'SpiritPoints', 'Amount': 3}],
|
||||
'Range': {'Min': 1, 'Max': 5},
|
||||
'UsesPerTurn': 1,
|
||||
},
|
||||
{
|
||||
'Name': 'Covenant of Survival',
|
||||
'Type': 'Triggered',
|
||||
'Actions': [{
|
||||
'Target': {'Type': 'Unit', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Target'},
|
||||
'Effects': [{'$type': 'PreventDeath'}, {'$type': 'SetHealthMinimum', 'Minimum': 1}],
|
||||
'Conditions': [{'$type': 'IsOnTileWithAffinity', 'Subject': 'Target', 'Affinity': 'Swamp'}]
|
||||
}],
|
||||
'Description': 'The first time each turn a friendly unit on Swamp would die, prevent that death and set its health minimum to 1.',
|
||||
'TriggerEvent': {'$type': 'BeforeUnitDeath', 'UnitType': 'Unit', 'Ownership': 'Owner'},
|
||||
'TriggerLimitPerTurn': 1,
|
||||
}
|
||||
]
|
||||
})
|
||||
plan.append(c)
|
||||
|
||||
# Terramorpha from design doc
|
||||
plan += [
|
||||
{
|
||||
'name': 'Blackwater Monomorpha',
|
||||
'description': 'A patch of ice gives way to dark reflective meltwater veined with blue moonlight.',
|
||||
'cardType': 'Terramorpha',
|
||||
'affinity': 'Lake',
|
||||
'spCost': 2,
|
||||
'stCost': 0,
|
||||
'terramorphaMode': 'Mono',
|
||||
'rarity': 'Common',
|
||||
'effectsJson': [{
|
||||
'Target': {'Type': 'Tile', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Any'},
|
||||
'Effects': [{'$type': 'PushAffinity', 'Affinity': {'Fixed': 'Lake'}}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
'name': 'Pine-Hollow Dimorpha',
|
||||
'description': 'Two connected bands of frostbound pine and root-shadow spread across the snow.',
|
||||
'cardType': 'Terramorpha',
|
||||
'affinity': 'Forest',
|
||||
'spCost': 3,
|
||||
'stCost': 0,
|
||||
'terramorphaMode': 'Di',
|
||||
'rarity': 'Common',
|
||||
'effectsJson': [{
|
||||
'Target': {'Type': 'Tile', 'Count': {'N': 2}, 'Scope': 'Battlefield', 'Ownership': 'Any'},
|
||||
'Effects': [{'$type': 'PushAffinity', 'Affinity': {'Fixed': 'Forest'}}]
|
||||
}]
|
||||
}
|
||||
]
|
||||
|
||||
# Spirits
|
||||
spirits = [
|
||||
('Fjord Oath Ferrier','A dark-maned ferrier glides across shelf ice where black water yawns under the crust.','Lake',1,0,2,0,1,'Walk',3,1,1,'Melee',['Kelpie'],'Common',[
|
||||
{'Name':'Thawlane Intake','Type':'Triggered','Actions':[{
|
||||
'Target': {'Type':'Player','Count':{'N':1},'Scope':'Player','Ownership':'Owner'},
|
||||
'Effects':[{'$type':'DrawCards','N':1,'Player':'Owner'},{'$type':'DiscardCards','N':1,'Player':'Owner'}],
|
||||
'Conditions':[{'$type':'IsOnTileWithAffinity','Subject':'Self','Affinity':'Swamp'}]
|
||||
}],'Description':'When this enters on Swamp, draw 1 then discard 1.','TriggerEvent':{'$type':'OnUnitEnterBattlefield','UnitType':'Unit','Ownership':'Owner','Filter':{'$type':'IsSelf'}}}
|
||||
]),
|
||||
('Snowpine Trackguard','A pale-furred tracker reads wind-carved spoor through frozen scrub and pine.','Forest',1,0,2,1,1,'Walk',3,1,1,'Melee',['Werewolf','Scout'],'Common',[
|
||||
{'Name':'Track the Thaw','Type':'Triggered','Actions':[{
|
||||
'Target': {'Type':'Player','Count':{'N':1},'Scope':'Player','Ownership':'Owner'},
|
||||
'Effects':[{'$type':'ModifySP','Amount':{'Fixed':1}}]
|
||||
}],'Description':'When this moves onto Swamp, gain 1 SP.','TriggerEvent':{'$type':'OnUnitMPSpent','Ownership':'Owner','Filter':{'$type':'IsSelf'}},'ActivationConditions':[{'$type':'DestinationTileAffinityIs','Affinity':'Swamp'}]}
|
||||
]),
|
||||
('Bell Loft Witness','A hooded owl archivist peers down from a rimed bell tower over a storm-lit valley.','Forest',2,0,2,1,1,'Flight',2,1,2,'Ranged',['Barn Owl','Witness'],'Common',[
|
||||
{'Name':'Silence Under Bell','Type':'Active','Actions':[{
|
||||
'Target': {'Type':'Unit','Count':{'N':1},'Scope':'Battlefield','Ownership':'Enemy'},
|
||||
'Effects':[{'$type':'SetCanUseAbility','Value':False}],
|
||||
'Duration': {'Type':'UntilEndOfTurn'}
|
||||
}],'Description':'On channel, target enemy loses CanUseAbility until end of turn.','Cost':[{'Type':'SpiritPoints','Amount':1}],'Range':{'Min':1,'Max':2},'UsesPerTurn':1}
|
||||
]),
|
||||
('Ice-Ring Tender','A compact colony guardian shelters chicks and refugees within a windbreak of packed snow.','Lake',2,0,2,2,1,'Walk',2,1,1,'Melee',['Emperor Penguin'],'Common',[
|
||||
{'Name':'Rookery Shelter','Type':'Aura','Actions':[{
|
||||
'Target': {'Type':'Unit','Count':{'All':True},'Scope':'Battlefield','Ownership':'Owner'},
|
||||
'Effects':[{'$type':'ModifyDefense','Amount':{'Fixed':1},'StatTarget':'Max'}]
|
||||
}],'Description':'Aura 1: friendly units gain +1 Defense.','AuraRange':{'Min':1,'Max':1}}
|
||||
]),
|
||||
('Thawland Oathbound','A broad rescue-warden plants an oath staff in wet snow beside a fissured crossing.','Swamp',2,0,2,1,2,'Walk',2,1,1,'Melee',['Yeti','Guardian'],'Uncommon',[
|
||||
{'Name':'Hard Crossing','Type':'Triggered','Actions':[{
|
||||
'Target': {'Type':'Unit','Count':{'N':1},'Scope':'Battlefield','Ownership':'Target'},
|
||||
'Effects':[{'$type':'SetCanAttack','Value':False}],
|
||||
'Duration': {'Type':'UntilEndOfTurn'}
|
||||
}],'Description':'When an enemy enters this aura range on or adjacent to Swamp, it loses CanAttack until end of turn.','AuraRange':{'Min':1,'Max':1},'TriggerEvent':{'$type':'OnEnterAuraRange','AuraOwnership':'Owner','UnitOwnership':'Enemy'},'ActivationConditions':[{'$type':'IsOnOrAdjacentToTileWithAffinity','Subject':'Target','Affinity':'Swamp'}]}
|
||||
]),
|
||||
('Rimefjord Ledger Warden','An iron granary guardian stands before carved fish-oil stores in a cliffside dock monastery.','Lake',3,0,3,2,1,'Walk',2,1,2,'Ranged',['Iron Golem','Warden'],'Uncommon',[
|
||||
{'Name':'Granary Count','Type':'Triggered','Actions':[{
|
||||
'Target': {'Type':'Player','Count':{'N':1},'Scope':'Player','Ownership':'Owner'},
|
||||
'Effects':[{'$type':'ModifySP','Amount':{'Fixed':1}}],
|
||||
'Conditions':[{'$type':'ControlledTileCountWithAffinity','Subject':'Target','Affinity':'Swamp','Comparator':'GreaterThanOrEqual','N':1,'Ownership':'Owner'}]
|
||||
}],'Description':'On enter, gain 1 SP if you control a Swamp tile.','TriggerEvent':{'$type':'OnUnitEnterBattlefield','UnitType':'Unit','Ownership':'Owner','Filter':{'$type':'IsSelf'}}}
|
||||
]),
|
||||
('Whiteout Pack Mediator','A scarred pack envoy paces between armed camps with snow stuck in her coat.','Forest',3,0,3,1,2,'Walk',3,1,1,'Melee',['Werewolf'],'Uncommon',[
|
||||
{'Name':'Freeze the Feud','Type':'Active','Actions':[{
|
||||
'Target': {'Type':'Unit','Count':{'N':1},'Scope':'Battlefield','Ownership':'Enemy'},
|
||||
'Effects':[{'$type':'SetCanMove','Value':False}],
|
||||
'Duration': {'Type':'UntilEndOfTurn'}
|
||||
}],'Description':'Target enemy loses CanMove until end of turn.','Cost':[{'Type':'SpiritPoints','Amount':1}],'Range':{'Min':1,'Max':2},'UsesPerTurn':1}
|
||||
]),
|
||||
('Selene Hollow Covenantor','A valley oath-keeper traces aurora-lit contract circles into thawing ground.','Swamp',3,0,3,2,2,'Walk',2,1,2,'Ranged',['Barn Owl','Monk'],'Uncommon',[
|
||||
{'Name':'Thawland Rite','Type':'Aura','Actions':[{
|
||||
'Target': {'Type':'Unit','Count':{'All':True},'Scope':'Battlefield','Ownership':'Owner'},
|
||||
'Effects':[{'$type':'ModifyDamage','Amount':{'Fixed':1}}],
|
||||
'Conditions':[{'$type':'IsOnTileWithAffinity','Subject':'Target','Affinity':'Swamp'}]
|
||||
}],'Description':'Friendly units on Swamp in aura range gain +1 Damage.','AuraRange':{'Min':1,'Max':2}}
|
||||
]),
|
||||
('Avalanche Bell-Mother','A great-furred rescuer hauls a bell frame through whiteout dark toward trapped lights below.','Forest',4,0,4,2,2,'Walk',2,1,2,'Ranged',['Yeti','Matriarch'],'Rare',[
|
||||
{'Name':'Bell-Mother Respite','Type':'Triggered','Actions':[{
|
||||
'Target': {'Type':'Unit','Count':{'N':1},'Scope':'Battlefield','Ownership':'Target'},
|
||||
'Effects':[{'$type':'HealDamage','Amount':{'Fixed':1}}]
|
||||
}],'Description':'When another friendly unit enters this aura range, heal it 1.','AuraRange':{'Min':1,'Max':2},'TriggerEvent':{'$type':'OnEnterAuraRange','AuraOwnership':'Owner','UnitOwnership':'Owner'}}
|
||||
]),
|
||||
('Blackwater Bargain-Keeper','A sleek fjord spirit rises from moon-slashed water with treaty cords wound around one arm.','Lake',4,0,4,1,3,'Walk',3,1,2,'Ranged',['Kelpie'],'Rare',[
|
||||
{'Name':'Treaty Undertow','Type':'Triggered','Actions':[{
|
||||
'Target': {'Type':'Unit','Count':{'N':1},'Scope':'Battlefield','Ownership':'Enemy'},
|
||||
'Effects':[{'$type':'PullUnit','Tiles':1}]
|
||||
}],'Description':'When this attacks a unit, pull that unit 1 tile.','TriggerEvent':{'$type':'OnUnitAttack','Ownership':'Owner','Filter':{'$type':'IsSelf'}}}
|
||||
]),
|
||||
('Circle of the Seventh Egg','A rookery circle closes around the weak while gale-driven snow sheets over them.','Swamp',4,0,4,3,1,'Walk',2,1,1,'Melee',['Emperor Penguin'],'Rare',[
|
||||
{'Name':'Rookery Circle','Type':'Passive','Actions':[{
|
||||
'Target': {'Type':'Unit','Count':{'All':True},'Scope':'Battlefield','Ownership':'Owner','Filters':[{'$type':'IsAdjacentToSource'}]},
|
||||
'Effects':[{'$type':'SetCanBeAttacked','Value':False}],
|
||||
'Conditions':[{'$type':'IsOwnTurn'}]
|
||||
}],'Description':'Friendly adjacent units cannot be attacked during your turn.'}
|
||||
]),
|
||||
('Glacier Forgebinder','A furnace giant hammers heated chain into frozen anchor points beneath the aurora.','Lake',4,0,4,2,3,'Walk',2,1,1,'Melee',['Fire Giant'],'Rare',[
|
||||
{'Name':'Forgebind the Crossing','Type':'Triggered','Actions':[{
|
||||
'Target': {'Type':'Unit','Count':{'N':1},'Scope':'Battlefield','Ownership':'Enemy'},
|
||||
'Effects':[{'$type':'SetCanMove','Value':False}],
|
||||
'Duration': {'Type':'UntilEndOfTurn'}
|
||||
}],'Description':'When this attacks while on Swamp, the attacked unit loses CanMove until end of turn.','TriggerEvent':{'$type':'OnUnitAttack','Ownership':'Owner','Filter':{'$type':'IsSelf'}},'ActivationConditions':[{'$type':'IsOnTileWithAffinity','Subject':'Self','Affinity':'Swamp'}]}
|
||||
]),
|
||||
('Stormcrown Omen Reader','A towering seer reads snow and lightning across an entire mountain pass from one glacier tower.','Forest',5,0,5,2,2,'Walk',2,1,2,'Ranged',['Cloud Giant'],'Rare',[
|
||||
{'Name':'Read the Drift','Type':'Triggered','Actions':[{
|
||||
'Target': {'Type':'Player','Count':{'N':1},'Scope':'Player','Ownership':'Owner'},
|
||||
'Effects':[{'$type':'DrawCards','N':1,'Player':'Owner'},{'$type':'DiscardCards','N':1,'Player':'Owner'}]
|
||||
}],'Description':'On enter, draw 1 then discard 1.','TriggerEvent':{'$type':'OnUnitEnterBattlefield','UnitType':'Unit','Ownership':'Owner','Filter':{'$type':'IsSelf'}}}
|
||||
]),
|
||||
('Red Snow Witness-Dead','War dead rise from a drift where banners and bones share the same red frost.','Swamp',5,0,5,2,3,'Walk',2,1,2,'Ranged',['Revenant'],'Rare',[
|
||||
{'Name':'Memory of the Slain','Type':'Aura','Actions':[{
|
||||
'Target': {'Type':'Unit','Count':{'All':True},'Scope':'Battlefield','Ownership':'Enemy'},
|
||||
'Effects':[{'$type':'ModifyDamage','Amount':{'Fixed':-1}}]
|
||||
}],'Description':'Enemies in aura range have -1 Damage.','AuraRange':{'Min':1,'Max':2}}
|
||||
]),
|
||||
('Hask, Fang Against the Feud','A white-furred guardian stands between snarling kin and shivering strangers with equal fury.','Forest',5,0,5,2,3,'Walk',4,1,1,'Melee',['Werewolf','Heroic'],'Legendary',[
|
||||
{'Name':'Break the Pursuit','Type':'Triggered','Actions':[{
|
||||
'Target': {'Type':'Unit','Count':{'N':1},'Scope':'Battlefield','Ownership':'Target'},
|
||||
'Effects':[{'$type':'ModifyMP','Amount':{'Fixed':1},'StatTarget':'Current'}],
|
||||
'Duration': {'Type':'UntilEndOfTurn'}
|
||||
}],'Description':'When a friendly unit enters this aura range on Swamp, it gains +1 MP this turn.','AuraRange':{'Min':1,'Max':2},'TriggerEvent':{'$type':'OnEnterAuraRange','AuraOwnership':'Owner','UnitOwnership':'Owner'},'ActivationConditions':[{'$type':'IsOnTileWithAffinity','Subject':'Target','Affinity':'Swamp'}]}
|
||||
]),
|
||||
('Long Night Covenant Whale','A spectral whale-shadow glides under black thawwater and ice glass, its song carrying through the valley.','Swamp',7,1,7,3,3,'Walk',2,1,2,'Ranged',['Mythic Beast'],'Legendary',[
|
||||
{'Name':'Song Through Thawwater','Type':'Passive','Actions':[{
|
||||
'Target': {'Type':'Unit','Count':{'All':True},'Scope':'Battlefield','Ownership':'Owner'},
|
||||
'Effects':[{'$type':'ModifyDamage','Amount':{'Fixed':1}},{'$type':'ModifyHealth','Amount':{'Fixed':1},'StatTarget':'Max'}],
|
||||
'Conditions':[{'$type':'IsOnTileWithAffinity','Subject':'Target','Affinity':'Swamp'}]
|
||||
}],'Description':'Friendly Swamp units gain +1/+1.'},
|
||||
{'Name':'First Song of the Long Night','Type':'Triggered','Actions':[{
|
||||
'Target': {'Type':'Unit','Count':{'N':1},'Scope':'Battlefield','Ownership':'Target'},
|
||||
'Effects':[{'$type':'HealDamage','Amount':{'Fixed':1}}]
|
||||
}],'Description':'The first time each turn a friendly unit enters this aura range, heal it 1.','AuraRange':{'Min':1,'Max':2},'TriggerEvent':{'$type':'OnEnterAuraRange','AuraOwnership':'Owner','UnitOwnership':'Owner'},'TriggerLimitPerTurn':1}
|
||||
]),
|
||||
]
|
||||
for name, desc, aff, sp, st, hp, df, dmg, mt, mp, amin, amax, atype, genus, rarity, abilities in spirits:
|
||||
c = base_unit(name, desc, 'Spirit', aff, sp, st, hp, df, dmg, mt, mp, amin, amax, atype, genus, rarity)
|
||||
c['abilitiesJson'] = abilities
|
||||
plan.append(c)
|
||||
|
||||
# Repentance
|
||||
plan += [
|
||||
{
|
||||
'name': 'Shelter Bell Toll',
|
||||
'description': 'A bronze rescue bell rings through blizzard static and everyone hears the command to stop killing.',
|
||||
'cardType': 'Repentance', 'affinity': 'Forest', 'spCost': 1, 'stCost': 0, 'rarity': 'Common',
|
||||
'effectsJson': [{
|
||||
'Target': {'Type': 'Unit', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Owner'},
|
||||
'Effects': [{'$type': 'SetCanBeAttacked', 'Value': False}],
|
||||
'Duration': {'Type': 'UntilEndOfTurn'}
|
||||
}]
|
||||
},
|
||||
{
|
||||
'name': 'Blackwater Crossing',
|
||||
'description': 'Thin ice cracks open into a route only the sworn know how to cross.',
|
||||
'cardType': 'Repentance', 'affinity': 'Lake', 'spCost': 2, 'stCost': 0, 'rarity': 'Common',
|
||||
'effectsJson': [{
|
||||
'Target': {'Type': 'Unit', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Owner'},
|
||||
'Effects': [{'$type': 'ModifyMP', 'Amount': {'Fixed': 2}, 'StatTarget': 'Current'}],
|
||||
'Duration': {'Type': 'UntilEndOfTurn'}
|
||||
}]
|
||||
},
|
||||
{
|
||||
'name': 'Mercy Before Feud',
|
||||
'description': 'Rivals lower their weapons in the thawland while snow falls into dark water around them.',
|
||||
'cardType': 'Repentance', 'affinity': 'Swamp', 'spCost': 2, 'stCost': 0, 'rarity': 'Uncommon',
|
||||
'effectsJson': [
|
||||
{
|
||||
'Target': {'Type': 'Unit', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Enemy'},
|
||||
'Effects': [{'$type': 'SetCanAttack', 'Value': False}],
|
||||
'Duration': {'Type': 'UntilEndOfTurn'}
|
||||
},
|
||||
{
|
||||
'Target': {'Type': 'Unit', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Target'},
|
||||
'Effects': [{'$type': 'SetCanUseAbility', 'Value': False}],
|
||||
'Conditions': [{'$type': 'IsOnTileWithAffinity', 'Subject': 'Target', 'Affinity': 'Swamp'}],
|
||||
'Duration': {'Type': 'UntilEndOfTurn'}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'Renew the Winter Covenant',
|
||||
'description': 'Aurora-lit oath cords are rewoven around standing stones in Selene Hollow.',
|
||||
'cardType': 'Repentance', 'affinity': 'Swamp', 'spCost': 3, 'stCost': 0, 'rarity': 'Rare',
|
||||
'effectsJson': [
|
||||
{
|
||||
'Target': {'Type': 'Tile', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Any'},
|
||||
'Effects': [{'$type': 'PushFinalAffinity', 'Affinity': {'Fixed': 'Swamp'}}]
|
||||
},
|
||||
{
|
||||
'Target': {'Type': 'Unit', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Owner'},
|
||||
'Effects': [{'$type': 'HealDamage', 'Amount': {'Fixed': 1}}]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'The Circle Holds',
|
||||
'description': 'Refugees, monks, pack guardians, and rookery keepers brace shoulder to shoulder through a killing gale.',
|
||||
'cardType': 'Repentance', 'affinity': 'Swamp', 'spCost': 4, 'stCost': 0, 'rarity': 'Rare',
|
||||
'effectsJson': [{
|
||||
'Target': {'Type': 'Unit', 'Count': {'All': True}, 'Scope': 'Battlefield', 'Ownership': 'Owner'},
|
||||
'Effects': [
|
||||
{'$type': 'ModifyDamage', 'Amount': {'Fixed': 1}},
|
||||
{'$type': 'ModifyHealth', 'Amount': {'Fixed': 1}, 'StatTarget': 'Max'},
|
||||
{'$type': 'SetCanBeBlocked', 'Value': False}
|
||||
],
|
||||
'Conditions': [{'$type': 'IsOnTileWithAffinity', 'Subject': 'Target', 'Affinity': 'Swamp'}],
|
||||
'Duration': {'Type': 'UntilEndOfTurn'}
|
||||
}]
|
||||
}
|
||||
]
|
||||
|
||||
# Ruin
|
||||
plan.append({
|
||||
'name': 'Oathstone Beneath the Drift',
|
||||
'description': 'A treaty stone half-buried in bloody snow glows whenever a sworn survivor stands atop it.',
|
||||
'cardType': 'Ruin', 'affinity': 'Swamp', 'spCost': 3, 'stCost': 0, 'rarity': 'Rare',
|
||||
'abilitiesJson': [
|
||||
{
|
||||
'Name': 'Distress Cache',
|
||||
'Type': 'Triggered',
|
||||
'Actions': [
|
||||
{
|
||||
'Target': {'Type': 'Player', 'Count': {'N': 1}, 'Scope': 'Player', 'Ownership': 'Owner'},
|
||||
'Effects': [{'$type': 'ModifySP', 'Amount': {'Fixed': 1}}]
|
||||
}
|
||||
],
|
||||
'Description': 'If this Ruin is occupied by a friendly unit when it activates, gain 1 SP.',
|
||||
'TriggerEvent': {'$type': 'OnRuinActivation', 'RuinOwnership': 'Owner', 'OccupantOwnership': 'Owner'}
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
# Instinct
|
||||
plan += [
|
||||
{
|
||||
'name': 'Turn Them from the Shelter',
|
||||
'description': 'A rescue staff bars the doorway and even the furious hesitate.',
|
||||
'cardType': 'Instinct', 'affinity': 'Swamp', 'spCost': 1, 'stCost': 0, 'rarity': 'Common',
|
||||
'effectsJson': [{
|
||||
'Target': {'Type': 'Unit', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Any'},
|
||||
'Effects': [{'$type': 'SetCanAttack', 'Value': False}],
|
||||
'Duration': {'Type': 'UntilEndOfSequence'}
|
||||
}]
|
||||
},
|
||||
{
|
||||
'name': 'Whiteout Step',
|
||||
'description': 'A hunted figure vanishes sideways into blowing snow and pine shadow.',
|
||||
'cardType': 'Instinct', 'affinity': 'Forest', 'spCost': 2, 'stCost': 0, 'rarity': 'Common',
|
||||
'effectsJson': [{
|
||||
'Target': {'Type': 'Unit', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Owner'},
|
||||
'Effects': [{'$type': 'SetCanBeAttacked', 'Value': False}],
|
||||
'Duration': {'Type': 'UntilEndOfTurn'}
|
||||
}]
|
||||
},
|
||||
{
|
||||
'name': 'Icewake Undertow',
|
||||
'description': 'A crust of ice gives way and an attacker is dragged off line by black water.',
|
||||
'cardType': 'Instinct', 'affinity': 'Lake', 'spCost': 2, 'stCost': 0, 'rarity': 'Common',
|
||||
'effectsJson': [{
|
||||
'Target': {'Type': 'Unit', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Any'},
|
||||
'Effects': [{'$type': 'PullUnit', 'Tiles': 1}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
'name': 'No Blood on the Oathground',
|
||||
'description': 'Aurora light hardens the air itself against a killing blow in the treaty hollow.',
|
||||
'cardType': 'Instinct', 'affinity': 'Swamp', 'spCost': 3, 'stCost': 0, 'rarity': 'Rare',
|
||||
'effectsJson': [{
|
||||
'Target': {'Type': 'Unit', 'Count': {'N': 1}, 'Scope': 'Battlefield', 'Ownership': 'Owner'},
|
||||
'Effects': [{'$type': 'PreventDeath'}, {'$type': 'SetHealthMinimum', 'Minimum': 1}],
|
||||
'Conditions': [{'$type': 'IsOnTileWithAffinity', 'Subject': 'Target', 'Affinity': 'Swamp'}],
|
||||
'Duration': {'Type': 'UntilEndOfSequence'}
|
||||
}]
|
||||
}
|
||||
]
|
||||
|
||||
OUT.write_text(json.dumps(plan, indent=2) + '\n')
|
||||
print(f'wrote {OUT} with {len(plan)} cards')
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,58 @@
|
||||
const fs=require('fs');
|
||||
const {Client}=require('/home/prime/.openclaw/workspace/tmp_pg/node_modules/pg');
|
||||
const planPath=process.argv[2];
|
||||
const dry=process.argv.includes('--dry');
|
||||
const cs={host:'172.10.1.127',port:5432,database:'SOR',user:'SOR-DBA',password:'G073gxq7VtQaOfnITcxDh3bsibcipe6D',ssl:{rejectUnauthorized:false}};
|
||||
const plan=JSON.parse(fs.readFileSync(planPath,'utf8'));
|
||||
(async()=>{
|
||||
const client=new Client(cs); await client.connect();
|
||||
const existing=new Map();
|
||||
for (const card of plan) {
|
||||
const r=await client.query('select "Id","Name" from catalog.card_definitions where "Name"=$1 limit 1',[card.name]);
|
||||
if (r.rows[0]) existing.set(card.name, r.rows[0].Id);
|
||||
}
|
||||
const inserted=[]; const skipped=[]; const insertedIds=new Map();
|
||||
for (const card of plan) {
|
||||
if (existing.has(card.name)) { skipped.push(card.name); continue; }
|
||||
let prevId=null;
|
||||
if (card.previousTierName) {
|
||||
if (insertedIds.has(card.previousTierName)) prevId = insertedIds.get(card.previousTierName);
|
||||
else { const r=await client.query('select "Id" from catalog.card_definitions where "Name"=$1 limit 1',[card.previousTierName]);
|
||||
if (!r.rows[0]) throw new Error(`Missing previous tier for ${card.name}: ${card.previousTierName}`);
|
||||
prevId=r.rows[0].Id; }
|
||||
}
|
||||
const q=`insert into catalog.card_definitions (
|
||||
"Id","Name","Description","CardType","Affinity","SpCost","StCost","other_costs",
|
||||
"MinChannelRange","MaxChannelRange","AttackType","RequiresLos","MinAttackRange","MaxAttackRange",
|
||||
"CanAttack","Damage","CanDefend","MaxHealth","MaxDefense","CanBeAttacked","CanBeBlocked",
|
||||
"CanMove","MovementType","MovementPoints","CanBeObstructed","CanUseAbility","Genus","CanBeSacrificed",
|
||||
"Tier","PreviousTierId","TerramorphaMode",abilities,effects,"Rarity","SetId","CollectorNumber",
|
||||
"IsPublished","IsRetired","RetiredAt","CreatedAt","UpdatedAt"
|
||||
) values (
|
||||
gen_random_uuid(),$1,$2,$3,$4,$5,$6,null,
|
||||
$7,$8,$9,$10,$11,$12,
|
||||
$13,$14,$15,$16,$17,$18,$19,
|
||||
$20,$21,$22,$23,$24,$25,$26,
|
||||
$27,$28,$29,$30::jsonb,$31::jsonb,$32,null,null,
|
||||
true,false,null,now(),now()
|
||||
) returning "Id"`;
|
||||
const vals=[
|
||||
card.name, card.description, card.cardType, card.affinity, card.spCost, card.stCost,
|
||||
card.minChannelRange ?? null, card.maxChannelRange ?? null, card.attackType ?? null, card.requiresLos ?? null,
|
||||
card.minAttackRange ?? null, card.maxAttackRange ?? null,
|
||||
card.canAttack ?? null, card.damage ?? null, card.canDefend ?? null, card.maxHealth ?? null, card.maxDefense ?? null,
|
||||
card.canBeAttacked ?? null, card.canBeBlocked ?? null, card.canMove ?? null, card.movementType ?? null,
|
||||
card.movementPoints ?? null, card.canBeObstructed ?? null, card.canUseAbility ?? null,
|
||||
card.genus ?? null, card.canBeSacrificed ?? null, card.tier ?? null, prevId, card.terramorphaMode ?? null,
|
||||
card.abilitiesJson ? JSON.stringify(card.abilitiesJson) : null,
|
||||
card.effectsJson ? JSON.stringify(card.effectsJson) : null,
|
||||
card.rarity
|
||||
];
|
||||
if (dry) { const fake=`dry-${inserted.length+1}`; inserted.push(card.name); insertedIds.set(card.name, fake); continue; }
|
||||
const r=await client.query(q, vals);
|
||||
inserted.push({name:card.name,id:r.rows[0].Id});
|
||||
insertedIds.set(card.name, r.rows[0].Id);
|
||||
}
|
||||
console.log(JSON.stringify({dry, inserted, skipped}, null, 2));
|
||||
await client.end();
|
||||
})().catch(e=>{console.error(e); process.exit(1);});
|
||||
@@ -0,0 +1,39 @@
|
||||
const fs=require('fs');
|
||||
const {Client}=require('/home/prime/.openclaw/workspace/tmp_pg/node_modules/pg');
|
||||
const manifest=JSON.parse(fs.readFileSync(process.argv[2],'utf8'));
|
||||
const dry=process.argv.includes('--dry');
|
||||
const cs={host:'172.10.1.127',port:5432,database:'SOR',user:'SOR-DBA',password:'G073gxq7VtQaOfnITcxDh3bsibcipe6D',ssl:{rejectUnauthorized:false}};
|
||||
(async()=>{
|
||||
const client=new Client(cs); await client.connect();
|
||||
const cardNames=manifest.cards.map(c=>c.name);
|
||||
const res=await client.query('select "Id","Name" from catalog.card_definitions where "Name" = any($1)', [cardNames.concat([manifest.archSpiritName])]);
|
||||
const byName=new Map(res.rows.map(r=>[r.Name,r.Id]));
|
||||
for (const c of manifest.cards) if (!byName.has(c.name)) throw new Error('Missing card '+c.name);
|
||||
if (!byName.has(manifest.archSpiritName)) throw new Error('Missing arch spirit '+manifest.archSpiritName);
|
||||
let deckId=null;
|
||||
const existing=await client.query('select "Id" from bazaar.prebuilt_decks where "Name"=$1 limit 1',[manifest.name]);
|
||||
if (existing.rows[0]) deckId=existing.rows[0].Id;
|
||||
const total=manifest.cards.reduce((a,c)=>a+c.quantity,0);
|
||||
if (total!==60) throw new Error(`Deck total ${total} != 60`);
|
||||
if (dry) {
|
||||
console.log(JSON.stringify({dry:true, deckId:deckId||'new', total, unique:manifest.cards.length},null,2));
|
||||
await client.end(); return;
|
||||
}
|
||||
await client.query('begin');
|
||||
try {
|
||||
if (!deckId) {
|
||||
const ins=await client.query(`insert into bazaar.prebuilt_decks ("Id","Name","Description","ImageCdnUrl","OriginPointPrice","UsdPrice","AvailableFrom","AvailableUntil","IsActive","IsStarterDeck","IsAvailableInShop","ArchSpiritCardDefinitionId","ArchSpiritName","CreatedAt","UpdatedAt") values (gen_random_uuid(),$1,$2,null,0,null,null,null,$3,$4,$5,$6,$7,now(),now()) returning "Id"`, [manifest.name, manifest.description, !!manifest.isActive, !!manifest.isStarterDeck, !!manifest.isAvailableInShop, byName.get(manifest.archSpiritName), manifest.archSpiritName]);
|
||||
deckId=ins.rows[0].Id;
|
||||
} else {
|
||||
await client.query(`update bazaar.prebuilt_decks set "Description"=$2,"IsActive"=$3,"IsStarterDeck"=$4,"IsAvailableInShop"=$5,"ArchSpiritCardDefinitionId"=$6,"ArchSpiritName"=$7,"UpdatedAt"=now() where "Id"=$1`, [deckId, manifest.description, !!manifest.isActive, !!manifest.isStarterDeck, !!manifest.isAvailableInShop, byName.get(manifest.archSpiritName), manifest.archSpiritName]);
|
||||
await client.query('delete from bazaar.prebuilt_deck_cards where "PrebuiltDeckId"=$1',[deckId]);
|
||||
}
|
||||
for (const c of manifest.cards) {
|
||||
await client.query(`insert into bazaar.prebuilt_deck_cards ("Id","PrebuiltDeckId","CardDefinitionId","CardName","Quantity") values (gen_random_uuid(),$1,$2,$3,$4)`, [deckId, byName.get(c.name), c.name, c.quantity]);
|
||||
}
|
||||
const verify=await client.query('select count(*)::int as unique_cards, sum("Quantity")::int as total_cards from bazaar.prebuilt_deck_cards where "PrebuiltDeckId"=$1',[deckId]);
|
||||
await client.query('commit');
|
||||
console.log(JSON.stringify({dry:false, deckId, verify:verify.rows[0]},null,2));
|
||||
} catch(e) { await client.query('rollback'); throw e; }
|
||||
await client.end();
|
||||
})().catch(e=>{console.error(e);process.exit(1)});
|
||||
Reference in New Issue
Block a user