Skip to content

Commit

Permalink
VaesenHQ: Add title to upgrades.
Browse files Browse the repository at this point in the history
  • Loading branch information
gregersn committed Jan 27, 2025
1 parent 4542293 commit 0a8e387
Show file tree
Hide file tree
Showing 13 changed files with 419 additions and 16 deletions.
5 changes: 3 additions & 2 deletions src/whathappened/core/sheets/schema/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from pydantic import BaseModel, ConfigDict

CURRENT_SCHEMA_VERSION_TYPE = Literal["0.0.8"]
CURRENT_SCHEMA_VERSION = "0.0.8"
CURRENT_SCHEMA_VERSION_TYPE = Literal["0.0.9"]
CURRENT_SCHEMA_VERSION = "0.0.9"


@dataclass
Expand Down Expand Up @@ -48,6 +48,7 @@ def v005_to_004(data):
Migration("0.0.5", "0.0.6"),
Migration("0.0.6", "0.0.7"),
Migration("0.0.7", "0.0.8"),
Migration("0.0.8", "0.0.9"),
]


Expand Down
35 changes: 31 additions & 4 deletions src/whathappened/core/sheets/schema/vaesenhq.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,34 @@ def v005_to_v004(data):
return data


def v008_to_v009(data):
data["version"] = "0.0.9"

upgrades = ["contacts", "discovered_facilities", "facilities", "personell"]

for upgrade in upgrades:
for added in data["character_sheet"]["upgrades"][upgrade]:
if "title" not in added:
added["title"] = "No title"

return data


def v009_to_v008(data):
data["version"] = "0.0.8"

upgrades = ["contacts", "discovered_facilities", "facilities", "personell"]

for upgrade in upgrades:
for added in data["character_sheet"]["upgrades"][upgrade]:
if "title" in added:
del added["title"]
return data


migrations = [
Migration("0.0.4", "0.0.5", v004_to_v005, v005_to_v004),
Migration("0.0.8", "0.0.9", v008_to_v009, v009_to_v008),
]


Expand Down Expand Up @@ -48,6 +74,7 @@ class Information(BaseModel):
class Upgrade(BaseModel):
"""Information about an upgrade."""

title: str = "No title"
function: str = "No function"
asset: str = "No asset"

Expand All @@ -56,16 +83,16 @@ class Upgrades(BaseModel):
"""Upgrades to headquarters."""

facilities: list[Upgrade] = Field(
default=[], json_schema_extra={"widget": "table", "header": True}
default=[], json_schema_extra={"widget": "table", "header": False}
)
discovered_facilities: list[Upgrade] = Field(
default=[], json_schema_extra={"widget": "table", "header": True}
default=[], json_schema_extra={"widget": "table", "header": False}
)
contacts: list[Upgrade] = Field(
default=[], json_schema_extra={"widget": "table", "header": True}
default=[], json_schema_extra={"widget": "table", "header": False}
)
personell: list[Upgrade] = Field(
default=[], json_schema_extra={"widget": "table", "header": True}
default=[], json_schema_extra={"widget": "table", "header": False}
)


Expand Down
2 changes: 1 addition & 1 deletion tests/games/schemas/expected/coc7e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ properties:
title: System
type: string
version:
default: 0.0.8
default: 0.0.9
title: Version
type: string
required:
Expand Down
2 changes: 1 addition & 1 deletion tests/games/schemas/expected/dod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ properties:
title: System
type: string
version:
default: 0.0.8
default: 0.0.9
title: Version
type: string
required:
Expand Down
2 changes: 1 addition & 1 deletion tests/games/schemas/expected/landf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ properties:
title: System
type: string
version:
default: 0.0.8
default: 0.0.9
title: Version
type: string
required:
Expand Down
2 changes: 1 addition & 1 deletion tests/games/schemas/expected/tftl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ properties:
title: System
type: string
version:
default: 0.0.8
default: 0.0.9
title: Version
type: string
required:
Expand Down
2 changes: 1 addition & 1 deletion tests/games/schemas/expected/vaesen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ properties:
title: System
type: string
version:
default: 0.0.8
default: 0.0.9
title: Version
type: string
required:
Expand Down
14 changes: 9 additions & 5 deletions tests/games/schemas/expected/vaesenhq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,38 +64,42 @@ $defs:
default: No function
title: Function
type: string
title:
default: No title
title: Title
type: string
title: Upgrade
type: object
Upgrades:
description: Upgrades to headquarters.
properties:
contacts:
default: []
header: true
header: false
items:
$ref: '#/$defs/Upgrade'
title: Contacts
type: array
widget: table
discovered_facilities:
default: []
header: true
header: false
items:
$ref: '#/$defs/Upgrade'
title: Discovered Facilities
type: array
widget: table
facilities:
default: []
header: true
header: false
items:
$ref: '#/$defs/Upgrade'
title: Facilities
type: array
widget: table
personell:
default: []
header: true
header: false
items:
$ref: '#/$defs/Upgrade'
title: Personell
Expand All @@ -119,7 +123,7 @@ properties:
title: System
type: string
version:
default: 0.0.8
default: 0.0.9
title: Version
type: string
required:
Expand Down
Loading

0 comments on commit 0a8e387

Please sign in to comment.