From ff5387c3f533c745e679d66833f27c4166b4c774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Sun, 12 Jun 2022 16:32:21 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=B0=86pr=E6=9E=84=E5=BB=BA=E4=B8=8Ecommi?= =?UTF-8?q?t=E6=9E=84=E5=BB=BA=E5=88=86=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-pr.yml | 89 ++++++++++++++++++++++++++++++++++ .github/workflows/build.yml | 1 - 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-pr.yml diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml new file mode 100644 index 0000000..e51370b --- /dev/null +++ b/.github/workflows/build-pr.yml @@ -0,0 +1,89 @@ +name: Build + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + pull_request: + +jobs: + windows: + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + python_version: + - '3.10' + name: Windows Python ${{ matrix.python_version }} + steps: + - uses: actions/checkout@v2 + + - uses: ilammy/msvc-dev-cmd@v1 + + - name: Use Python ${{ matrix.python_version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python_version }} + + - name: 🧳 Install dependencies + run: | + echo y | pip install --no-python-version-warning --disable-pip-version-check pyinstaller + echo y | pip install --no-python-version-warning --disable-pip-version-check nuitka + echo y | pip install --no-python-version-warning --disable-pip-version-check zstandard + echo y | pip install --no-python-version-warning --disable-pip-version-check pygame + echo y | pip install --no-python-version-warning --disable-pip-version-check ordered-set + + # 使用pyinstaller构建 + - name: Build pypvz with pyinstaller + run: | + pyinstaller -F main.py ` + -n pypvz-with-python${{ matrix.python_version }}-pyinstaller-x64.exe ` + --distpath ./out ` + --noconsole ` + --add-data="resources;./resources" ` + --add-data="pypvz-exec-logo.png;./pypvz-exec-logo.png" ` + -i ./pypvz.ico + + # 使用Nuitka构建 + - name: Show nuitka version + run: | + Get-ChildItem env: + python -m nuitka --version + + - name: Build pypvz with Nuitka + run: | + echo y | python -m nuitka --standalone ` + --onefile ` + --show-progress ` + --show-memory ` + --output-dir=out ` + --windows-icon-from-ico=pypvz.ico ` + --include-data-dir=resources=resources ` + --include-data-file=c:\hostedtoolcache\windows\python\${{ matrix.python_version }}*\x64\lib\site-packages\pygame\libogg-0.dll=libogg-0.dll ` + --include-data-file=c:\hostedtoolcache\windows\python\${{ matrix.python_version }}*\x64\lib\site-packages\pygame\libopus-0.dll=libopus-0.dll ` + --include-data-file=c:\hostedtoolcache\windows\python\${{ matrix.python_version }}*\x64\lib\site-packages\pygame\libopusfile-0.dll=libopusfile-0.dll ` + --include-data-file=c:\hostedtoolcache\windows\python\${{ matrix.python_version }}*\x64\lib\site-packages\pygame\libvorbisfile-3.dll=libvorbisfile-3.dll ` + --include-data-file=c:\hostedtoolcache\windows\python\${{ matrix.python_version }}*\x64\lib\site-packages\pygame\libvorbis-0.dll=libvorbis-0.dll ` + --windows-disable-console ` + -o ./out/pypvz-with-python${{ matrix.python_version }}-nuitka-msvc-x64.exe ` + main.py + + # artifact压缩包处上传包含exe和运行环境的文件夹 + - name: "Upload binarie directory" + uses: actions/upload-artifact@v2 + with: + name: DIR-python-${{ matrix.python_version }} + path: ./out/*.dist + + - name: "Upload binaries of pyinstaller" + uses: actions/upload-artifact@v2 + with: + name: pyinstaller-python-${{ matrix.python_version }} + path: ./out/*pyinstaller*.exe + + - name: "Upload binaries of pyinstaller" + uses: actions/upload-artifact@v2 + with: + name: nuitka-python-${{ matrix.python_version }} + path: ./out/*nuitka*.exe diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 83fde3b..cb5250f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,6 @@ concurrency: cancel-in-progress: true on: - pull_request: push: branches: - master From 82b24951b1e17c1250efb6915158e6836cb310eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Sun, 12 Jun 2022 16:33:18 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index e51370b..0492261 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -1,4 +1,4 @@ -name: Build +name: "Build for PR" concurrency: group: ${{ github.workflow }}-${{ github.ref }} From 6a22c51231c03bed2eea392eb366a2298e5acd0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Sun, 12 Jun 2022 17:36:04 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/state/level.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/source/state/level.py b/source/state/level.py index 4c37b62..499a2a4 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -24,7 +24,13 @@ class Level(tool.State): self.showLittleMenu = False # 导入地图参数 - self.loadMap() + # 这些注释内容是将来增加通过界面后的容错设计,以保证直接通关时不会闪退 + # 现在为了明确一开始就没有正确导入地图的错误,没有启用这些设定 + # if self.loadMap(): # 表示导入成功 + # self.map = map.Map(self.map_data[c.BACKGROUND_TYPE]) + # self.map_y_len = self.map.height + # self.setupBackground() + # self.initState() self.map = map.Map(self.map_data[c.BACKGROUND_TYPE]) self.map_y_len = self.map.height self.setupBackground() @@ -32,9 +38,9 @@ class Level(tool.State): def loadMap(self): if self.game_info[c.GAME_MODE] == c.MODE_LITTLEGAME: - map_file = 'littleGame_' + str(self.game_info[c.LITTLEGAME_NUM]) + '.json' + map_file = f'littleGame_{self.game_info[c.LITTLEGAME_NUM]}.json' elif self.game_info[c.GAME_MODE] == c.MODE_ADVENTURE: - map_file = 'level_' + str(self.game_info[c.LEVEL_NUM]) + '.json' + map_file = f'level_{self.game_info[c.LEVEL_NUM]}.json' file_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))),'resources' , 'data', 'map', map_file) # 最后一关之后应该结束了 try: @@ -55,6 +61,7 @@ class Level(tool.State): return # 是否有铲子的信息:无铲子时为0,有铲子时为1,故直接赋值即可 self.hasShovel = self.map_data[c.SHOVEL] + return True # 同时指定音乐 # 缺省音乐为进入的音乐,方便发现错误 @@ -321,6 +328,9 @@ class Level(tool.State): # 更新函数每帧被调用,将鼠标事件传入给状态处理函数 def update(self, surface, current_time, mouse_pos, mouse_click): + # 这些注释内容是将来增加通过界面后的容错设计,以保证直接通关时不会闪退 + # if self.done: + # return self.current_time = self.game_info[c.CURRENT_TIME] = self.pvzTime(current_time) if self.state == c.CHOOSE: self.choose(mouse_pos, mouse_click) From 5422c371ff35153560702976854b1eace33afe52 Mon Sep 17 00:00:00 2001 From: wszqkzqk Date: Tue, 14 Jun 2022 00:58:45 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9C=AA=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=9C=B0=E5=9B=BE=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/state/level.py | 1 + 1 file changed, 1 insertion(+) diff --git a/source/state/level.py b/source/state/level.py index 499a2a4..758e49b 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -31,6 +31,7 @@ class Level(tool.State): # self.map_y_len = self.map.height # self.setupBackground() # self.initState() + self.loadMap() self.map = map.Map(self.map_data[c.BACKGROUND_TYPE]) self.map_y_len = self.map.height self.setupBackground() From c041894f9739b26f28dd665558a9abec39a4c90a Mon Sep 17 00:00:00 2001 From: wszqkzqk Date: Tue, 14 Jun 2022 01:00:39 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbgm=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/state/level.py | 1 - 1 file changed, 1 deletion(-) diff --git a/source/state/level.py b/source/state/level.py index 758e49b..febdad2 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -62,7 +62,6 @@ class Level(tool.State): return # 是否有铲子的信息:无铲子时为0,有铲子时为1,故直接赋值即可 self.hasShovel = self.map_data[c.SHOVEL] - return True # 同时指定音乐 # 缺省音乐为进入的音乐,方便发现错误