Skip to content

Instantly share code, notes, and snippets.

@chizmw
Created July 2, 2015 14:29
Show Gist options
  • Save chizmw/c558dcd80d66404ca82e to your computer and use it in GitHub Desktop.
Save chizmw/c558dcd80d66404ca82e to your computer and use it in GitHub Desktop.
Star Realms : Counting The Cards

Star Realms : Counting The Cards

Create the Base Set

CREATE  (sr:Game  { name:'Star Realms' }),
        (trd:Card { name:'Trade Card' }),
        (pdv:Card { name:'Viper' }),
        (pds:Card { name:'Scout' }),
        (exp:Card { name:'Explorer' }),
        (aut:Card { name:'Authority' }),

        (sr)-[:CONTAINS_CARDS {quantity:80}]->(trd),
        (sr)-[:CONTAINS_CARDS {quantity:4 }]->(pdv),
        (sr)-[:CONTAINS_CARDS {quantity:16}]->(pds),
        (sr)-[:CONTAINS_CARDS {quantity:10}]->(exp),
        (sr)-[:CONTAINS_CARDS {quantity:18}]->(aut)
RETURN *

Create the Expansions

MATCH   (trd:Card { name:'Trade Card' })
CREATE  (g:Expansion { name:'Bases and Battleships' }),
        (g)-[:CONTAINS_CARDS {quantity:12}]->(trd)
WITH trd
CREATE  (g:Expansion { name:'Fleets and Fortresses' }),
        (g)-[:CONTAINS_CARDS {quantity:12}]->(trd)
WITH trd
CREATE  (g:Expansion { name:'Heroes' }),
        (g)-[:CONTAINS_CARDS {quantity:12}]->(trd)
WITH trd
CREATE  (g:Expansion { name:'Events' }),
        (g)-[:CONTAINS_CARDS {quantity:12}]->(trd)
RETURN trd;

Quantities by Game or Expansion

MATCH (g)-[rel:CONTAINS_CARDS]->(c:Card)
WHERE g:Game or g:Expansion
RETURN g.name,labels(g),SUM(rel.quantity) ORDER BY SUM(rel.quantity) DESC;

Total Number of Cards

MATCH (g)-[rel:CONTAINS_CARDS]->(c:Card)
WHERE g:Game or g:Expansion
RETURN SUM(rel.quantity);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment