Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…zons-Modpack into lanth-quests
  • Loading branch information
Elisis committed Jun 15, 2022
2 parents 0137959 + 92018ed commit 8bb08d4
Show file tree
Hide file tree
Showing 20 changed files with 15,028 additions and 3,334 deletions.
60 changes: 60 additions & 0 deletions .github/scripts/questbook-i18n.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import json
from typing import TextIO
from abc import ABCMeta

DEFAULT_QUESTS_PATH = 'config/betterquesting/DefaultQuests.json'
EN_US_LANG_PATH = 'resources/minecraft/lang/en_US.lang'
DEFAULT_QUESTS_US_PATH = 'config/betterquesting/DefaultQuests-us.json'


class Thing(metaclass=ABCMeta):
def __init__(self, obj: dict, id_key: str, title: str, infix: str):
self.obj: dict = obj
self.id: str = obj[id_key]
self.name: str = obj['properties:10']['betterquesting:10']['name:8'].replace('\n', '%n')
self.desc: str = obj['properties:10']['betterquesting:10']['desc:8'].replace('\n', '%n')
self.title = title
self.name_key = f'gtnh.{infix}{self.id}.name'
self.desc_key = f'gtnh.{infix}{self.id}.desc'

def update_properties(self):
self.obj['properties:10']['betterquesting:10']['name:8'] = self.name_key
self.obj['properties:10']['betterquesting:10']['desc:8'] = self.desc_key

def write_to_lang_file(self, lang_file: TextIO):
lang_file.writelines([
'\n',
f'# {self.title}.{self.id} - {self.name}\n',
f'{self.name_key}={self.name}\n',
f'{self.desc_key}={self.desc}\n',
])


class Quest(Thing):
def __init__(self, obj: dict):
super().__init__(obj, 'questID:3', 'Quest', 'quest')


class QuestLine(Thing):
def __init__(self, obj: dict):
super().__init__(obj, 'lineID:3', 'QuestLine', 'line')


if __name__ == '__main__':
with open(DEFAULT_QUESTS_PATH) as dq:
defaultQuests = json.load(dq)

quests = [Quest(_) for _ in defaultQuests['questDatabase:9'].values()]
quest_lines = [QuestLine(_) for _ in defaultQuests['questLines:9'].values()]

with open(EN_US_LANG_PATH, 'w') as lang:
lang.write('#################################Quests#################################\n')
[_.write_to_lang_file(lang) for _ in quests]
lang.write('\n##################################Line##################################\n')
[_.write_to_lang_file(lang) for _ in quest_lines]
lang.write('\n')

[_.update_properties() for _ in quests]
[_.update_properties() for _ in quest_lines]
with open(DEFAULT_QUESTS_US_PATH, 'w') as dq_us:
json.dump(defaultQuests, dq_us, indent=2, ensure_ascii=False)
34 changes: 34 additions & 0 deletions .github/workflows/questbook-i18n.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Quest Book I18N

on:
push:
branches:
- master
paths:
- config/betterquesting/DefaultQuests.json
workflow_dispatch: { }

jobs:
i18n:
name: Generate Quest Book I18N Files
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Generate Quest Book I18N Files
run: python .github/scripts/questbook-i18n.py
- name: Create PR
uses: peter-evans/create-pull-request@v4.0.0
with:
title: Update Quest Book I18N
body: Automated changes by Quest Book I18N workflow.
commit-message: Update Quest Book I18N
delete-branch: true
branch: quest-book-i18n/patch
1 change: 0 additions & 1 deletion config/EnhancedLootBags/LootBags.xml
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@
<Loot Identifier="0ef801b1-1b39-4864-973f-4204f2955af8" ItemName="TConstruct:heartCanister:6" Amount="1" NBTTag="" Chance="1" ItemGroup="" LimitedDropCount="10" RandomAmount="false"/>
<Loot Identifier="ff263b56-39cb-4dc6-aa40-389eb8d22b77" ItemName="gregtech:gt.metaitem.01:32714" Amount="3" NBTTag="" Chance="100" LimitedDropCount="0" RandomAmount="false"/>
<Loot Identifier="11de8e54-d5a1-4c9a-a70e-0acd87f2c357" ItemName="gregtech:gt.blockores:324" Amount="32" NBTTag="" Chance="80" LimitedDropCount="0" RandomAmount="true"/>
<Loot Identifier="2dea00b0-a44a-46a7-9fdf-e9262638ef28" ItemName="gregtech:gt.blockmachines:1150" Amount="1" NBTTag="" Chance="50" LimitedDropCount="4" RandomAmount="false"/>
<Loot Identifier="b17218f9-6275-4de0-9b91-9a982b7adf91" ItemName="EnderIO:blockTransceiver" Amount="2" NBTTag="" Chance="50" LimitedDropCount="0" RandomAmount="false"/>
<Loot Identifier="3a6a65fc-d45e-4532-aa61-3b39de548f10" ItemName="EnderStorage:enderChest" Amount="2" NBTTag="" Chance="50" ItemGroup="" LimitedDropCount="0" RandomAmount="false"/>
<Loot Identifier="a7bc9dcc-4f45-4c8b-b24c-c6e7ff34c23d" ItemName="EnderStorage:enderChest:4096" Amount="2" NBTTag="" Chance="50" ItemGroup="" LimitedDropCount="0" RandomAmount="false"/>
Expand Down
Loading

0 comments on commit 8bb08d4

Please sign in to comment.