Skip to content

Commit 6ed9f10

Browse files
committed
Card catalogue loading fixes
1 parent ef859fd commit 6ed9f10

13 files changed

Lines changed: 430 additions & 385 deletions

File tree

spellsource-client/src/unity

Submodule unity updated from f4a1faa to 35482fb

spellsource-graphql/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ new JsonSlurper().parseText(file('package.json').text).scripts.each { String scr
5555

5656
tasks.named("yarnRunCodegen").configure {
5757
inputs.file("schema.graphql")
58-
inputs.dir("graphql/web")
5958
inputs.dir("graphql/shared")
6059

6160
mustRunAfter ":spellsource-server:generateSchema"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
fragment art on Art {
2+
body {
3+
vertex {
4+
r
5+
g
6+
b
7+
a
8+
}
9+
}
10+
highlight {
11+
r
12+
g
13+
b
14+
a
15+
}
16+
loop {
17+
named
18+
}
19+
missile {
20+
named
21+
}
22+
onCast {
23+
named
24+
}
25+
onHit {
26+
named
27+
}
28+
primary {
29+
r
30+
g
31+
b
32+
a
33+
}
34+
secondary {
35+
r
36+
g
37+
b
38+
a
39+
}
40+
shadow {
41+
r
42+
g
43+
b
44+
a
45+
}
46+
spell {
47+
named
48+
}
49+
sprite {
50+
named
51+
}
52+
spriteShadow {
53+
named
54+
}
55+
}

spellsource-graphql/graphql/shared/fragments/entity.graphql

Lines changed: 2 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,11 @@
11
fragment entity on Entity {
2-
id
3-
name
4-
description
5-
cardId
6-
cardType
7-
entityType
8-
rarity
2+
...entitySummary
93
location {
10-
index
11-
zone
12-
player
4+
...entityLocation
135
}
14-
art {
15-
body {
16-
vertex {
17-
r
18-
g
19-
b
20-
a
21-
}
22-
}
23-
highlight {
24-
r
25-
g
26-
b
27-
a
28-
}
29-
loop {
30-
named
31-
}
32-
missile {
33-
named
34-
}
35-
onCast {
36-
named
37-
}
38-
onHit {
39-
named
40-
}
41-
primary {
42-
r
43-
g
44-
b
45-
a
46-
}
47-
secondary {
48-
r
49-
g
50-
b
51-
a
52-
}
53-
shadow {
54-
r
55-
g
56-
b
57-
a
58-
}
59-
spell {
60-
named
61-
}
62-
sprite {
63-
named
64-
}
65-
spriteShadow {
66-
named
67-
}
68-
}
69-
owner
706
boardPosition
71-
attack
727
baseAttack
73-
hp
748
baseHp
75-
maxHp
76-
armor
77-
manaCost
789
baseManaCost
7910
durability
8011
spellDamage
@@ -83,48 +14,34 @@ fragment entity on Entity {
8314
mana
8415
maxMana
8516
lockedMana
86-
battlecry
8717
cannotAttack
88-
charge
8918
chooseOne
90-
collectible
9119
combo
9220
conditionMet
93-
deathrattles
9421
deflect
9522
destroyed
9623
discarded
97-
divineShield
9824
enraged
9925
frozen
10026
gameStarted
10127
gold
10228
hostsTrigger
10329
immune
10430
isStartingTurn
105-
lifesteal
10631
permanent
107-
playable
108-
poisonous
10932
roasted
110-
rush
11133
silenced
112-
stealth
11334
summoningSickness
114-
taunt
11535
uncensored
11636
underAura
11737
untargetableBySpells
118-
windfury
11938
charges
12039
countUntilCast
12140
fires
12241
host
123-
heroClasses
12442
cardSet
12543
cardSets
12644
enchantmentType
127-
tribes
12845
tooltips {
12946
text
13047
keywords
Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
fragment entitySummary on Entity {
2-
id
3-
name
4-
description
5-
cardId
6-
cardType
7-
entityType
8-
rarity
9-
owner
10-
manaCost
11-
attack
12-
hp
13-
maxHp
14-
armor
15-
playable
16-
taunt
17-
charge
18-
rush
19-
divineShield
20-
stealth
21-
lifesteal
22-
poisonous
23-
deathrattles
24-
battlecry
25-
windfury
26-
collectible
27-
heroClasses
28-
tribes
2+
id
3+
name
4+
description
5+
cardId
6+
cardType
7+
entityType
8+
rarity
9+
owner
10+
manaCost
11+
attack
12+
hp
13+
maxHp
14+
armor
15+
playable
16+
taunt
17+
charge
18+
rush
19+
divineShield
20+
stealth
21+
lifesteal
22+
poisonous
23+
deathrattles
24+
battlecry
25+
windfury
26+
collectible
27+
heroClasses
28+
tribes
29+
art {
30+
...art
31+
}
2932
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fragment entityLocation on EntityLocation {
2+
index
3+
player
4+
zone
5+
}

spellsource-graphql/src/apollo-server.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { ApolloServer } from "@apollo/server";
22
import { expressMiddleware } from "@apollo/server/express4";
3-
import { ApolloServerPluginLandingPageDisabled } from "@apollo/server/plugin/disabled";
3+
import {
4+
ApolloServerPluginLandingPageLocalDefault,
5+
ApolloServerPluginLandingPageProductionDefault,
6+
} from "@apollo/server/plugin/landingPage/default";
47
import express, { Application, NextFunction, Request, Response } from "express";
58
import { createFullSchema } from "./schema/stitching";
69
import { AuthRequest } from "./auth";
@@ -54,7 +57,9 @@ export const setupApolloServer = async (app: Application, httpServer: Server): P
5457
const apolloServer = new ApolloServer({
5558
schema,
5659
plugins: [
57-
ApolloServerPluginLandingPageDisabled(),
60+
process.env.NODE_ENV === "production"
61+
? ApolloServerPluginLandingPageProductionDefault()
62+
: ApolloServerPluginLandingPageLocalDefault({ embed: true }),
5863
ApolloServerPluginDrainHttpServer({ httpServer }),
5964
{
6065
async serverWillStart() {
@@ -75,7 +80,7 @@ export const setupApolloServer = async (app: Application, httpServer: Server): P
7580
}
7681
app.use(
7782
"/graphql",
78-
express.json(),
83+
express.json({ limit: "10mb" }),
7984
expressMiddleware(apolloServer, {
8085
context: async ({ req }) => req as AuthRequest,
8186
}),

spellsource-private/src/secrets

spellsource-server/src/main/java/com/hiddenswitch/framework/GraphQL.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public Long parseLiteral(Object input) throws CoercingParseLiteralException {
9999
var handler = GraphQLHandler.create(gql);
100100

101101
router.post("/graphql")
102-
.handler(BodyHandler.create())
102+
.handler(BodyHandler.create().setBodyLimit(10 * 1024 * 1024))
103103
.handler(JWTAuthHandler.create(jwtAuth, realm.toRepresentation().getRealm()))
104104
.handler(VirtualThreadRoutingContextHandler.create(ctx -> handler.handle(RoutingContext.newInstance(ctx))))
105105
.failureHandler(ctx -> {

spellsource-server/src/main/java/com/hiddenswitch/framework/impl/GraphQLMutationResolverImpl.java

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@ public Future<DecksGetResponse> updateDeck(DecksUpdateInput input) throws Except
211211
var updateCommand = protoRequest.getUpdateCommand();
212212
var futs = new java.util.ArrayList<Future<?>>();
213213

214-
return queryExecutor.execute(dsl -> dsl
214+
return queryExecutor.findOneRow(dsl -> dsl
215215
.select(com.hiddenswitch.framework.schema.spellsource.tables.Decks.DECKS.ID)
216216
.from(com.hiddenswitch.framework.schema.spellsource.tables.Decks.DECKS)
217217
.where(com.hiddenswitch.framework.schema.spellsource.tables.Decks.DECKS.ID.eq(deckId)
218218
.and(com.hiddenswitch.framework.schema.spellsource.tables.Decks.DECKS.CREATED_BY.eq(userId)))
219219
.limit(1))
220-
.compose(authedCount -> {
221-
if (authedCount < 1) {
220+
.compose(row -> {
221+
if (row == null) {
222222
return Future.failedFuture("not authorized to edit this deck");
223223
}
224224

@@ -328,9 +328,27 @@ public Future<DecksGetResponse> duplicateDeck(String deckId) throws Exception {
328328
if (cardCatalogue == null) {
329329
return Future.failedFuture("card catalogue not initialized");
330330
}
331-
// Delegate to Legacy's static duplicate logic via the proto-based path
332-
// This is complex enough that reusing the existing impl is the safest approach
333-
return Future.failedFuture("not yet implemented — requires transaction refactoring");
331+
332+
// Fetch the source deck, then create a copy owned by the current user
333+
return Legacy.getDeck(cardCatalogue, deckId, userId)
334+
.compose(sourceDeck -> {
335+
var coll = sourceDeck.getCollection();
336+
var cardIds = coll.getInventoryList().stream()
337+
.map(Spellsource.CardRecord::getEntity)
338+
.map(Spellsource.Entity::getCardId)
339+
.collect(Collectors.toList());
340+
341+
var createRequest = new DeckCreateRequest()
342+
.withName(coll.getName() + " Copy")
343+
.withHeroClass(coll.getHeroClass())
344+
.withFormat(coll.getFormat())
345+
.withCardIds(cardIds);
346+
347+
return Legacy.createDeck(cardCatalogue, userId, createRequest);
348+
})
349+
.map(putResponse -> new DecksGetResponse.Builder()
350+
.setCollection(protoToGraphqlCollection(putResponse.getCollection()))
351+
.build());
334352
}
335353

336354
// ── drafts ───────────────────────────────────────────────

0 commit comments

Comments
 (0)