Skip to content

Commit

Permalink
Cleaning and refactoring the data (#12)
Browse files Browse the repository at this point in the history
* Add civilizations data given a scenario in a lazy approach

* Handle civ function with int

* Rename civ corefunction

* Move civilization function to CoreData

* Simplify civilization calling

* Add methods for vassality

* Simplify civilization calling

* Remove duplicates of teams and players

* Replace old variables (xml techno)

* Replace old variables (xml unit)

* Fix typo enum

* Replace old variables (xml bonus)

* Fix typo enum (goldenbull)

* Fix typo enum (promotion)

* Fix typo (promotion)

* Rename corporation enum

* Replace old variables (xml wonder)

* Replace old variables (xml building)

* Replace old variables (xml leader)

* Move religious buildings

* Fix settings

* Add required dependencies for development

* Bump ruff version

* Remove remaining civilizations calling for single civ

* Fix has_state_religion

* Add function for religion identifier

* Add method to check if a civilization has a specific state religion

* Refactor state_religion calling

* Refactor lReformationMatrix

* Replace old variable (xml province)

* Replace old variables (xml regions)

* Fix typo (CASTILE

* Fix typo xml

* Fix wonder and building

* Clean provincemanager

* Refacto religious buildings

* Refacto regions

* Refacto timeline tech modifier

* Fix redefinition in imports

* Refacto modifiers

* Replace old variables (consts visible areas)

* Replace old variables (consts broader  areas)

* Remove remaining call of old variable from Consts.py

* Replace old variables (consts areas)

* Rollback to hardcoded birthdate for companies

* Refacto civilization provinces

* Fix typo

* Update Tile and Tiles classes

* Update maps

* Rename province type members

* Update maps

* Switch maps data from tuple to list

* Rename map variables

* Add deepcopy where map variables is used

* Rename map data file

* Refacto AI modifiers

* Rename enum

* Refacto modifiers

* Split ai and human modifiers

* Refacto initial buildings

* Fix typo

* Fix province manager

* Fix civilization for cities

* Fix typo

* Refacto game balance

* Rename balance module

* Isolate external paths

* Refacto event drive provinces modifications

* Move and rename province manager

* Fix respawn event for provinces

* Fix missing members

* Fix filename

* Fix typo civ attr

* Fix area attributes in RFCEMapUtil

* Clean barbs

* Replace old getScenario refs

* Refacto remaining getScenario functions

* Remove unused functions

* Refacto human ID function

* Add is_existing method

* Add step for setup dependencies in workflow

* Refacto isExisting player method

* Refacto getRandomCiv

* Remove unused functions

* Remove unused PyPlayer

* Remove unused functions

* Split map data

* Refacto map data

* Remove unused functions

* Rename map utils

* Refacto and clean human fct

* Refacto in-game random number generations

* Refacto getRandomEntry

* Add weighted_choice function

* Fix formula

* Fix typo

* Improve choices function

* Switch choice to PyUtils choices

* Refacto getRandomByWeight

* Revert "Switch choice to PyUtils choices"

This reverts commit 4b3a66d.

* Fix missing imports

* Fix city name calling function

* Remove coupling between province and riseandfall

* Fix typo

* Can specify scenario in functions

* Rewrite scenario with try except block

* Refacto some rise events

* Move world width and height to corestructures

* Clean the finance advisor

* Add city locations

* Refacto onSpawn province

* Clean province module

* Add line lenght in ruff

* Rollback cities locations to single tuple

* Update import test

* Fix province

* Rename stored data instance

* Switch stored data from dict to attr

* Replace old instance of stored data dict

* Fix typo

* Move company building definition in misc data

* Remove unused functions

* Refacto getStability

* Fix temporary variables in stored data

* Fix colony tab

* Refacto event manager

* Remove unused stored data calls

* Refacto minor wars

* Add try..except for choices calling

* Remove unused variable

* Refacto redundant city locations

* Refacto getCatholicCivs

* Rename province event enum

* Fix lCatholicCivs

* Add method for specific christian religion civs

* Refacto lCatholicCiv

* Add more civilization methods

* Add more civilizations methods

* Refacto lCatholicCiv

* Refacto lReformationNeighbours

* Refacto initial tech

* Remove unused data

* Remove unused variable

* Refacto lCatholicCivs

* Rename set_tech to add_tech

* Remove unused call

* Handle case where weights are not append

* Rename scenario dependent initial conditions

* Update README.md

* Rename scenario dependent data mapper

* Rework initial workers

* Fix initial call functions

* Rename enum

* Fix city tile

* Add transform method

* Refacto initial units

* Refacto additionalUnits

* Remove old code

* Remove old comments

* Move to functions some civilization methods

* Refacto main/minor civ with inner functions

* Separate Collection class in 2

* Add function for not any

* Add shuffle method to collection

* Add some functions from RFC DOC

* Fix Consts

* Fix lithunia victory

* Remove old Tile classes

* Remove old civ properties

* Move the area parser to corefunctions

* Rewrite import for corefunctions

* Switch back from randint to getSorenRandNum

* Rename collection

* Add game info classes

* Add empty method

* Rename functions

* Add classes and functions for handle turn

* Add try..except for info_types

* Add factory for techs

* Rename factory

* Move turn functions and class

* Replace gc.getGame().getGameTurn() with turn function

* Replace CyGame().getGameTurn() with turn function

* Add classes to handle units

* Add classes and functions to handle unit creation

* Replace makeUnit functions

* Add ability to name units

* Rename variable

* Replace old makeUnit function calls

* Improve random entry functions

* Handle case where list is empty

* Fix random_entry with collection

* Fix reformation

* Replace DateTurn with year function in components

* Revert "Replace DateTurn with year function in components"

This reverts commit 24c22e8.

* Add function for showing a message

* Replace popup calling with show and text functions

* Refactor event_popup

* Refacto getText

* Move MessageData to consts

* Add function for showing a announcement

* Add method for check if civ has a specific civic

* Refacto getText

* Refacto colorText

* Fix refacto getText

* Fix refacto getColorText

* Fix turn

* Refacto addMessage

* Replace choices [0]

* Update vscode settings

* Add methods for enrich existing collection

* Add function for getting the closest city

* Add remaining factories

* Add other methods for collections

* Fix collections

* Fix flipCity

* Refacto flipCity

* Refacto DateTurn with year

* Split call of game balance

* Refacto DateTurn with year for tech timeline

* Fix city factory

* Must call the factory

* Remove instance of infos factory

* Remove unused constant

* Move data mapper classes to BaseStructures.py

* Fix location arg

* Refacto getWorldPlotsList

* Apply formatting

* Apply formatting #2

* Bump action versions

* Fix list of minor civs

* Fix pyright settigns

* Fix model

* Add comment

* Refacto getCityList

* Refacto getPlotList and surroundingPlots

* Refacto selectRandomCityAll

* Fix units()

* Fix previousOwner

* Fix surrounding

* Rename apply method

* Remove unused fct

* Add function for province map

* Fix reuse key

* Add pillow

* Fix script for map renderer

* Refacto usage of CITIES_MAP

* Fix undefined variable

* Rename DC methods

* Remove unused fct
  • Loading branch information
VDuchauffour committed Apr 29, 2024
1 parent 081af3f commit b935457
Show file tree
Hide file tree
Showing 350 changed files with 76,125 additions and 70,693 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.1
- name: Install build dependencies
run: |
Invoke-WebRequest http://kael.civfanatics.net/files/VCToolkitSetup.exe -OutFile ${env:TEMP}\VCToolkitSetup.exe
& ${env:TEMP}\VCToolkitSetup.exe /s /v"/qb"
Start-Sleep -s 120
Invoke-WebRequest http://kael.civfanatics.net/files/msvcrt.lib -OutFile "C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003\lib\msvcrt.lib"
Invoke-WebRequest http://kael.civfanatics.net/files/msvcrtd.lib -OutFile "C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003\lib\msvcrtd.lib"
Invoke-WebRequest http://kael.civfanatics.net/files/msvcprt.lib -OutFile "C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003\lib\msvcprt.lib"
- name: Build DLL
run: msbuild CvGameCoreDLL\CvGameCoreDLL.vcxproj -t:rebuild -verbosity:diag -property:Configuration=Release
- name: Upload artifact
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Apply linting and testing
name: CI Pipeline

on:
push:
paths:
- "Assets/Python/**"
pull_request:
paths:
- "Assets/Python/**"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

jobs:
lint:
name: Run linting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install dependencies
run: |
pip install -U pip
pip install black==21.12b0 click==8.0 ruff==0.0.287
- name: Run linting
run: |
make lint
# tests:
# name: Run tests
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Install Python 2.4
# uses: gabrielfalcao/pyenv-action@v11
# with:
# default: "2.4.1"
# command: |
# pyenv version
# - name: Run tests
# run: |
# export PYTHONPATH=$(./export-paths.sh -l)
# echo $PYTHONPATH | tr ':' '\n'
# make test
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ repos:
args: [ --style=InheritParentConfig, -i, --no-diff ]
types_or: [ c++, c ]
exclude: "(CvGameCoreDLL/bin|CvGameCoreDLL/Boost-1.32.0|CvGameCoreDLL/Python24)/.*"
# An extremely fast Python linter, written in Rust
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.287"
hooks:
- id: ruff
# Formatter for python files
- repo: https://github.com/psf/black
rev: 21.12b0
hooks:
- id: black
args: [ "--config", "pyproject.toml", "-C" ]
additional_dependencies:
- click==8.0
24 changes: 22 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,29 @@
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": false
"source.organizeImports": "never"
}
},
"ruff.organizeImports": false,
"black-formatter.importStrategy": "fromEnvironment"
"black-formatter.importStrategy": "fromEnvironment",
"python.analysis.extraPaths": [
"~/.pyenv/versions",
"./Assets/Python",
"./Assets/Python/data",
"./Assets/Python/data/maps",
"./Assets/Python/utils",
"./Assets/Python/models",
"./Assets/Python/components",
"./Assets/Python/EntryPoints",
"./Assets/Python/pyWB",
"./Assets/Python/screens",
"../../Assets/Python",
"../../Assets/Python/EntryPoints",
"../../Assets/Python/pyWB",
"../../Assets/Python/Screens",
"../../Assets/Python/pyUnit",
"../../Assets/Python/pyHelper",
"../../Assets/Python/PitBoss",
"../../../Assets/Python/pyHelper"
]
}
Binary file modified Assets/CvGameCoreDLL.dll
Binary file not shown.

0 comments on commit b935457

Please sign in to comment.