Compare commits
1 Commits
cleaveKeyw
...
forge-1.6.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3032628b7 |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -4,7 +4,6 @@ about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
type: 'Bug'
|
||||
|
||||
---
|
||||
|
||||
@@ -32,6 +31,7 @@ If applicable, add screenshots to help explain your problem.
|
||||
**Smartphone (please complete the following information):**
|
||||
- Device: [e.g. iPhone6]
|
||||
- OS: [e.g. iOS8.1]
|
||||
- Browser [e.g. stock browser, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
|
||||
1
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -4,7 +4,6 @@ about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
type: 'Feature'
|
||||
|
||||
---
|
||||
|
||||
|
||||
145
.github/workflows/maven-publish.yml
vendored
@@ -2,21 +2,10 @@ name: Publish Desktop Forge
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
debug_enabled:
|
||||
type: boolean
|
||||
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
|
||||
required: false
|
||||
default: false
|
||||
release_android:
|
||||
type: boolean
|
||||
description: 'Also try to release android build'
|
||||
required: false
|
||||
default: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if: github.repository_owner == 'Card-Forge'
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -25,10 +14,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 17
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
java-version: '11'
|
||||
distribution: 'temurin'
|
||||
cache: 'maven'
|
||||
server-id: cardforge-repo
|
||||
@@ -43,134 +32,10 @@ jobs:
|
||||
run: |
|
||||
git config user.email "actions@github.com"
|
||||
git config user.name "GitHub Actions"
|
||||
|
||||
- name: Install old maven (3.8.1)
|
||||
run: |
|
||||
curl -o apache-maven-3.8.1-bin.tar.gz https://archive.apache.org/dist/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz
|
||||
tar xf apache-maven-3.8.1-bin.tar.gz
|
||||
export PATH=$PWD/apache-maven-3.8.1/bin:$PATH
|
||||
export MAVEN_HOME=$PWD/apache-maven-3.8.1
|
||||
mvn --version
|
||||
|
||||
- name: Setup tmate session
|
||||
uses: mxschmitt/action-tmate@v3
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
|
||||
|
||||
- name: Setup android requirements
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && inputs.release_android }}
|
||||
run: |
|
||||
JAVA_HOME=${JAVA_HOME_17_X64} ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "build-tools;35.0.0" "platform-tools" "platforms;android-35"
|
||||
cd forge-gui-android
|
||||
echo "${{ secrets.FORGE_KEYSTORE }}" > forge.keystore.asc
|
||||
gpg -d --passphrase "${{ secrets.FORGE_KEYSTORE_PASSPHRASE }}" --batch forge.keystore.asc > forge.keystore
|
||||
cd -
|
||||
mkdir -p ~/.m2/repository/com/simpligility/maven/plugins/android-maven-plugin/4.6.2
|
||||
cd ~/.m2/repository/com/simpligility/maven/plugins/android-maven-plugin/4.6.2
|
||||
curl -L -o android-maven-plugin-4.6.2.jar https://github.com/Card-Forge/android-maven-plugin/releases/download/4.6.2/android-maven-plugin-4.6.2.jar
|
||||
curl -L -o android-maven-plugin-4.6.2.pom https://github.com/Card-Forge/android-maven-plugin/releases/download/4.6.2/android-maven-plugin-4.6.2.pom
|
||||
cd -
|
||||
mvn install -Dmaven.test.skip=true
|
||||
mvn dependency:tree
|
||||
|
||||
|
||||
- name: Build/Install/Publish Desktop to GitHub Packages Apache Maven
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.release_android }}
|
||||
- name: Build/Install/Publish to GitHub Packages Apache Maven
|
||||
run: |
|
||||
export DISPLAY=":1"
|
||||
Xvfb :1 -screen 0 800x600x8 &
|
||||
export _JAVA_OPTIONS="-Xmx2g"
|
||||
d=$(date +%m.%d)
|
||||
# build only desktop and only try to move desktop files
|
||||
mvn -U -B clean -P windows-linux install -DskipTests -Dskip.flatten=true -e -T 1C release:clean release:prepare release:perform
|
||||
mkdir izpack
|
||||
# move bz2 and jar from work dir to izpack dir
|
||||
mv /home/runner/work/forge/forge/forge-installer/*/*.{bz2,jar} izpack/
|
||||
# move desktop build.txt and version.txt to izpack
|
||||
mv /home/runner/work/forge/forge/forge-gui-desktop/target/classes/*.txt izpack/
|
||||
cd izpack
|
||||
ls
|
||||
echo "GIT_TAG=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV
|
||||
mvn -U -B clean -P windows-linux install release:clean release:prepare release:perform -T 1C -Dcardforge-repo.username=${{ secrets.FTP_USERNAME }} -Dcardforge-repo.password=${{ secrets.FTP_PASSWORD }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: Build/Install/Publish Desktop+Android to GitHub Packages Apache Maven
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && inputs.release_android }}
|
||||
run: |
|
||||
export DISPLAY=":1"
|
||||
Xvfb :1 -screen 0 800x600x8 &
|
||||
export _JAVA_OPTIONS="-Xmx2g"
|
||||
d=$(date +%m.%d)
|
||||
# build both desktop and android
|
||||
mvn -U -B clean -P windows-linux,android-release-build install -e -Dcardforge-repo.username=${{ secrets.FTP_USERNAME }} -Dcardforge-repo.password=${{ secrets.FTP_PASSWORD }} -Dandroid.sdk.path=/usr/local/lib/android/sdk -Dandroid.buildToolsVersion=35.0.0
|
||||
mkdir izpack
|
||||
# move bz2 and jar from work dir to izpack dir
|
||||
mv /home/runner/work/forge/forge/forge-installer/*/*.{bz2,jar} izpack/
|
||||
# move desktop build.txt and version.txt to izpack
|
||||
mv /home/runner/work/forge/forge/forge-gui-desktop/target/classes/*.txt izpack/
|
||||
# move android apk and assets.zip
|
||||
mv /home/runner/work/forge/forge/forge-gui-android/target/*-signed-aligned.apk izpack/
|
||||
mv /home/runner/work/forge/forge/forge-gui-android/target/assets.zip izpack/
|
||||
cd izpack
|
||||
ls
|
||||
echo "GIT_TAG=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: Upload snapshot to GitHub Prerelease
|
||||
uses: ncipollo/release-action@v1
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
name: Release ${{ env.GIT_TAG }}
|
||||
tag: ${{ env.GIT_TAG }}
|
||||
artifacts: izpack/*
|
||||
allowUpdates: true
|
||||
removeArtifacts: true
|
||||
makeLatest: true
|
||||
|
||||
- name: 🔧 Install XML tools
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libxml2-utils
|
||||
|
||||
- name: 🔼 Bump versionCode in root POM
|
||||
id: bump_version
|
||||
run: |
|
||||
cd /home/runner/work/forge/forge/
|
||||
|
||||
current_version=$(xmllint --xpath "//*[local-name()='versionCode']/text()" pom.xml)
|
||||
echo "Current versionCode: $current_version"
|
||||
|
||||
IFS='.' read -r major minor patch <<< "${current_version}"
|
||||
new_patch=$(printf "%02d" $((10#$patch + 1)))
|
||||
new_version="${major}.${minor}.${new_patch}"
|
||||
|
||||
sed -i -E "s|<versionCode>.*</versionCode>|<versionCode>${new_version}</versionCode>|" pom.xml
|
||||
|
||||
echo "version_code=${new_version}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: ♻️ Restore {revision} in child POMs
|
||||
run: |
|
||||
find . -name pom.xml ! -path "./pom.xml" | while read -r pom; do
|
||||
sed -i -E 's|<version>2\.0+\.[0-9]+(-SNAPSHOT)?</version>|<version>${revision}</version>|' "$pom"
|
||||
done
|
||||
|
||||
- name: 💾 Commit restored {revision}
|
||||
run: |
|
||||
# Add only pom.xml files
|
||||
find . -name pom.xml -exec git add {} \;
|
||||
|
||||
# Commit if there are changes
|
||||
if git diff --cached --quiet; then
|
||||
echo "No pom.xml changes to commit."
|
||||
else
|
||||
git commit -m "Restore POM files for preparation of next release" || echo "No changes to commit"
|
||||
git push
|
||||
fi
|
||||
|
||||
- name: Send failure notification to Discord
|
||||
if: failure() # This step runs only if the job fails
|
||||
run: |
|
||||
curl -X POST -H "Content-Type: application/json" \
|
||||
-d "{\"content\": \"🔴 Release Build Failed in branch: \`${{ github.ref_name }}\` by \`${{ github.actor }}\`.\nCheck logs: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" \
|
||||
${{ secrets.DISCORD_AUTOMATION_WEBHOOK }}
|
||||
|
||||
30
.github/workflows/publish-android.yml
vendored
@@ -20,10 +20,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 17
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
java-version: '8'
|
||||
distribution: 'temurin'
|
||||
cache: 'maven'
|
||||
server-id: cardforge-repo
|
||||
@@ -31,20 +31,20 @@ jobs:
|
||||
server-password: ${{ secrets.FTP_PASSWORD }}
|
||||
settings-path: ${{ github.workspace }} # location for the settings.xml file
|
||||
|
||||
- name: Install old maven (3.8.1)
|
||||
- name: Install old maven (3.6.3)
|
||||
run: |
|
||||
curl -o apache-maven-3.8.1-bin.tar.gz https://archive.apache.org/dist/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz
|
||||
tar xf apache-maven-3.8.1-bin.tar.gz
|
||||
export PATH=$PWD/apache-maven-3.8.1/bin:$PATH
|
||||
export MAVEN_HOME=$PWD/apache-maven-3.8.1
|
||||
curl -o apache-maven-3.6.3-bin.tar.gz https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
|
||||
tar xf apache-maven-3.6.3-bin.tar.gz
|
||||
export PATH=$PWD/apache-maven-3.6.3/bin:$PATH
|
||||
export MAVEN_HOME=$PWD/apache-maven-3.6.3
|
||||
mvn --version
|
||||
|
||||
- name: Install android SDK
|
||||
uses: maxim-lobanov/setup-android-tools@v1
|
||||
with:
|
||||
packages: |
|
||||
platforms;android-35
|
||||
build-tools;35.0.0
|
||||
platforms;android-26
|
||||
build-tools;30.0.3
|
||||
|
||||
- name: Install virtual framebuffer (if not available) to allow running GUI on a headless server
|
||||
run: |
|
||||
@@ -71,11 +71,11 @@ jobs:
|
||||
|
||||
- name: Install Android maven plugin
|
||||
run: |
|
||||
mkdir -p ~/.m2/repository/com/simpligility/maven/plugins/android-maven-plugin/4.6.2
|
||||
cd ~/.m2/repository/com/simpligility/maven/plugins/android-maven-plugin/4.6.2
|
||||
curl -L -o android-maven-plugin-4.6.2.jar https://github.com/Card-Forge/android-maven-plugin/releases/download/4.6.2/android-maven-plugin-4.6.2.jar
|
||||
curl -L -o android-maven-plugin-4.6.2.pom https://github.com/Card-Forge/android-maven-plugin/releases/download/4.6.2/android-maven-plugin-4.6.2.pom
|
||||
#mvn install:install-file -Dfile=android-maven-plugin-4.6.2.jar -DgroupId=com.simpligility.maven.plugins -DartifactId=android-maven-plugin -Dversion=4.6.2 -Dpackaging=jar
|
||||
mkdir -p ~/.m2/repository/com/simpligility/maven/plugins/android-maven-plugin/4.6.1
|
||||
cd ~/.m2/repository/com/simpligility/maven/plugins/android-maven-plugin/4.6.1
|
||||
curl -L -o android-maven-plugin-4.6.1.jar https://github.com/Card-Forge/android-maven-plugin/releases/download/4.6.1/android-maven-plugin-4.6.1.jar
|
||||
curl -L -o android-maven-plugin-4.6.1.pom https://github.com/Card-Forge/android-maven-plugin/releases/download/4.6.1/android-maven-plugin-4.6.1.pom
|
||||
#mvn install:install-file -Dfile=android-maven-plugin-4.6.1.jar -DgroupId=com.simpligility.maven.plugins -DartifactId=android-maven-plugin -Dversion=4.6.1 -Dpackaging=jar
|
||||
cd -
|
||||
mvn install -Dmaven.test.skip=true
|
||||
mvn dependency:tree
|
||||
@@ -83,7 +83,7 @@ jobs:
|
||||
- name: Build/Install/Publish to GitHub Packages Apache Maven
|
||||
run: |
|
||||
export _JAVA_OPTIONS="-Xmx2g"
|
||||
mvn -U -B -P android-release-build,android-release-upload install -e -Dcardforge-repo.username=${{ secrets.FTP_USERNAME }} -Dcardforge-repo.password=${{ secrets.FTP_PASSWORD }} -Dandroid.sdk.path=/usr/local/lib/android/sdk -Dandroid.buildToolsVersion=35.0.0 -Dmaven.test.skip=true
|
||||
mvn -U -B -P android-release-build,android-release-sign,android-release-upload install -e -Dsign.keystore=forge.keystore -Dsign.alias=Forge -Dsign.storepass=${{ secrets.SIGN_STORE_PASS }} -Dsign.keypass=${{ secrets.SIGN_STORE_PASS }} -Dcardforge-repo.username=${{ secrets.FTP_USERNAME }} -Dcardforge-repo.password=${{ secrets.FTP_PASSWORD }} -Dandroid.sdk.path=/usr/local/lib/android/sdk -Dandroid.buildToolsVersion=30.0.3 -Dmaven.test.skip=true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
|
||||
19
.github/workflows/remove-stale-branches.yml
vendored
@@ -1,19 +0,0 @@
|
||||
name: Remove stale branches
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "0 0 * * *" # Everday at midnight
|
||||
|
||||
jobs:
|
||||
remove-stale-branches:
|
||||
if: github.repository_owner == 'Card-Forge'
|
||||
name: Remove Stale Branches
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: fpicalausa/remove-stale-branches@v2.1.0
|
||||
with:
|
||||
dry-run: false # Check out the console output before setting this to false
|
||||
ignore-unknown-authors: true
|
||||
ignore-branches-with-open-prs: true
|
||||
default-recipient: tehdiplomat
|
||||
132
.github/workflows/snapshot-both-pc-android.yml
vendored
@@ -1,132 +0,0 @@
|
||||
name: Create Snapshot Desktop and Android
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
debug_enabled:
|
||||
type: boolean
|
||||
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
|
||||
required: false
|
||||
default: false
|
||||
schedule:
|
||||
# * is a special character in YAML so you have to quote this string
|
||||
- cron: '00 18 * * *'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if: github.repository_owner == 'Card-Forge'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
deployments: write
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
cache: 'maven'
|
||||
server-id: cardforge-repo
|
||||
server-username: ${{ secrets.FTP_USERNAME }}
|
||||
server-password: ${{ secrets.FTP_PASSWORD }}
|
||||
settings-path: ${{ github.workspace }} # location for the settings.xml file
|
||||
|
||||
- name: Install virtual framebuffer (if not available) to allow running GUI on a headless server
|
||||
run: command -v Xvfb >/dev/null 2>&1 || { sudo apt update && sudo apt install -y xvfb; }
|
||||
|
||||
- name: Configure Git User
|
||||
run: |
|
||||
git config user.email "actions@github.com"
|
||||
git config user.name "GitHub Actions"
|
||||
|
||||
- name: Install old maven (3.8.1)
|
||||
run: |
|
||||
curl -o apache-maven-3.8.1-bin.tar.gz https://archive.apache.org/dist/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz
|
||||
tar xf apache-maven-3.8.1-bin.tar.gz
|
||||
export PATH=$PWD/apache-maven-3.8.1/bin:$PATH
|
||||
export MAVEN_HOME=$PWD/apache-maven-3.8.1
|
||||
mvn --version
|
||||
|
||||
- name: Set Up Android tools
|
||||
run: |
|
||||
JAVA_HOME=${JAVA_HOME_17_X64} ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "build-tools;35.0.0" "platform-tools" "platforms;android-35"
|
||||
|
||||
- name: Extract Android keystore
|
||||
run: |
|
||||
ls
|
||||
cd forge-gui-android
|
||||
echo "${{ secrets.FORGE_KEYSTORE }}" > forge.keystore.asc
|
||||
gpg -d --passphrase "${{ secrets.FORGE_KEYSTORE_PASSPHRASE }}" --batch forge.keystore.asc > forge.keystore
|
||||
cd -
|
||||
|
||||
- name: Setup tmate session
|
||||
uses: mxschmitt/action-tmate@v3
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
|
||||
|
||||
- name: Install Android maven plugin
|
||||
run: |
|
||||
mkdir -p ~/.m2/repository/com/simpligility/maven/plugins/android-maven-plugin/4.6.2
|
||||
cd ~/.m2/repository/com/simpligility/maven/plugins/android-maven-plugin/4.6.2
|
||||
curl -L -o android-maven-plugin-4.6.2.jar https://github.com/Card-Forge/android-maven-plugin/releases/download/4.6.2/android-maven-plugin-4.6.2.jar
|
||||
curl -L -o android-maven-plugin-4.6.2.pom https://github.com/Card-Forge/android-maven-plugin/releases/download/4.6.2/android-maven-plugin-4.6.2.pom
|
||||
#mvn install:install-file -Dfile=android-maven-plugin-4.6.2.jar -DgroupId=com.simpligility.maven.plugins -DartifactId=android-maven-plugin -Dversion=4.6.2 -Dpackaging=jar
|
||||
cd -
|
||||
mvn install -Dmaven.test.skip=true
|
||||
mvn dependency:tree
|
||||
|
||||
- name: Build/Install/Publish to GitHub Packages Apache Maven
|
||||
run: |
|
||||
export DISPLAY=":1"
|
||||
Xvfb :1 -screen 0 800x600x8 &
|
||||
export _JAVA_OPTIONS="-Xmx2g"
|
||||
d=$(date +%m.%d)
|
||||
# build both desktop and android
|
||||
mvn -U -B clean -P windows-linux,android-release-build install -e -Dcardforge-repo.username=${{ secrets.FTP_USERNAME }} -Dcardforge-repo.password=${{ secrets.FTP_PASSWORD }} -Dandroid.sdk.path=/usr/local/lib/android/sdk -Dandroid.buildToolsVersion=35.0.0
|
||||
mkdir izpack
|
||||
# move bz2 and jar from work dir to izpack dir
|
||||
mv /home/runner/work/forge/forge/forge-installer/*/*.{bz2,jar} izpack/
|
||||
# move desktop build.txt and version.txt to izpack
|
||||
mv /home/runner/work/forge/forge/forge-gui-desktop/target/classes/*.txt izpack/
|
||||
# move android apk and assets.zip
|
||||
mv /home/runner/work/forge/forge/forge-gui-android/target/*-signed-aligned.apk izpack/
|
||||
mv /home/runner/work/forge/forge/forge-gui-android/target/assets.zip izpack/
|
||||
cd izpack
|
||||
# rename files and append date
|
||||
for file in *.jar; do
|
||||
bname="${file%.*}"
|
||||
echo "file renamed to ${bname}-${d}.jar"
|
||||
mv "${bname}.jar" "${bname}-${d}.jar"
|
||||
done
|
||||
for file in *.bz2; do
|
||||
# remove .bz2
|
||||
fname="${file%.*}"
|
||||
# remove .tar
|
||||
bname="${fname%.*}"
|
||||
echo "file renamed to ${bname}-${d}.tar.bz2"
|
||||
mv "${fname}.bz2" "${bname}-${d}.tar.bz2"
|
||||
done
|
||||
ls
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: Upload snapshot to GitHub Prerelease
|
||||
uses: ncipollo/release-action@v1
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
name: Daily Snapshot
|
||||
tag: daily-snapshots
|
||||
prerelease: true
|
||||
artifacts: izpack/*
|
||||
allowUpdates: true
|
||||
removeArtifacts: true
|
||||
|
||||
- name: Send failure notification to Discord
|
||||
if: failure() # This step runs only if the job fails
|
||||
run: |
|
||||
curl -X POST -H "Content-Type: application/json" \
|
||||
-d "{\"content\": \"🔴 Snapshot Build Failed in branch: \`${{ github.ref_name }}\` by \`${{ github.actor }}\`.\nCheck logs: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" \
|
||||
${{ secrets.DISCORD_AUTOMATION_WEBHOOK }}
|
||||
77
.github/workflows/snapshots-android.yml
vendored
@@ -8,11 +8,10 @@ on:
|
||||
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
|
||||
required: false
|
||||
default: false
|
||||
#upload_package:
|
||||
# type: boolean
|
||||
# description: 'Upload the completed Android package'
|
||||
# required: false
|
||||
# default: true
|
||||
schedule:
|
||||
# * is a special character in YAML so you have to quote this string
|
||||
- cron: '00 19 * * *'
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -25,10 +24,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 17
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
java-version: '8'
|
||||
distribution: 'temurin'
|
||||
cache: 'maven'
|
||||
server-id: cardforge-repo
|
||||
@@ -36,17 +35,19 @@ jobs:
|
||||
server-password: ${{ secrets.FTP_PASSWORD }}
|
||||
settings-path: ${{ github.workspace }} # location for the settings.xml file
|
||||
|
||||
- name: Install old maven (3.8.1)
|
||||
- name: Install old maven (3.6.3)
|
||||
run: |
|
||||
curl -o apache-maven-3.8.1-bin.tar.gz https://archive.apache.org/dist/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz
|
||||
tar xf apache-maven-3.8.1-bin.tar.gz
|
||||
export PATH=$PWD/apache-maven-3.8.1/bin:$PATH
|
||||
export MAVEN_HOME=$PWD/apache-maven-3.8.1
|
||||
curl -o apache-maven-3.6.3-bin.tar.gz https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
|
||||
tar xf apache-maven-3.6.3-bin.tar.gz
|
||||
export PATH=$PWD/apache-maven-3.6.3/bin:$PATH
|
||||
export MAVEN_HOME=$PWD/apache-maven-3.6.3
|
||||
mvn --version
|
||||
|
||||
- name: Set Up Android tools
|
||||
run: |
|
||||
JAVA_HOME=${JAVA_HOME_17_X64} ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "build-tools;35.0.0" "platform-tools" "platforms;android-35"
|
||||
JAVA_HOME=${JAVA_HOME_11_X64} ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT "platform-tools"
|
||||
JAVA_HOME=${JAVA_HOME_11_X64} ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "platforms;android-26"
|
||||
JAVA_HOME=${JAVA_HOME_11_X64} ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "build-tools;30.0.3"
|
||||
|
||||
- name: Install virtual framebuffer (if not available) to allow running GUI on a headless server
|
||||
run: |
|
||||
@@ -73,11 +74,11 @@ jobs:
|
||||
|
||||
- name: Install Android maven plugin
|
||||
run: |
|
||||
mkdir -p ~/.m2/repository/com/simpligility/maven/plugins/android-maven-plugin/4.6.2
|
||||
cd ~/.m2/repository/com/simpligility/maven/plugins/android-maven-plugin/4.6.2
|
||||
curl -L -o android-maven-plugin-4.6.2.jar https://github.com/Card-Forge/android-maven-plugin/releases/download/4.6.2/android-maven-plugin-4.6.2.jar
|
||||
curl -L -o android-maven-plugin-4.6.2.pom https://github.com/Card-Forge/android-maven-plugin/releases/download/4.6.2/android-maven-plugin-4.6.2.pom
|
||||
#mvn install:install-file -Dfile=android-maven-plugin-4.6.2.jar -DgroupId=com.simpligility.maven.plugins -DartifactId=android-maven-plugin -Dversion=4.6.2 -Dpackaging=jar
|
||||
mkdir -p ~/.m2/repository/com/simpligility/maven/plugins/android-maven-plugin/4.6.1
|
||||
cd ~/.m2/repository/com/simpligility/maven/plugins/android-maven-plugin/4.6.1
|
||||
curl -L -o android-maven-plugin-4.6.1.jar https://github.com/Card-Forge/android-maven-plugin/releases/download/4.6.1/android-maven-plugin-4.6.1.jar
|
||||
curl -L -o android-maven-plugin-4.6.1.pom https://github.com/Card-Forge/android-maven-plugin/releases/download/4.6.1/android-maven-plugin-4.6.1.pom
|
||||
#mvn install:install-file -Dfile=android-maven-plugin-4.6.1.jar -DgroupId=com.simpligility.maven.plugins -DartifactId=android-maven-plugin -Dversion=4.6.1 -Dpackaging=jar
|
||||
cd -
|
||||
mvn install -Dmaven.test.skip=true
|
||||
mvn dependency:tree
|
||||
@@ -85,30 +86,40 @@ jobs:
|
||||
- name: Build/Install/Publish to GitHub Packages Apache Maven
|
||||
run: |
|
||||
export _JAVA_OPTIONS="-Xmx2g"
|
||||
mvn -U -B -P android-release-build install -e -Dcardforge-repo.username=${{ secrets.FTP_USERNAME }} -Dcardforge-repo.password=${{ secrets.FTP_PASSWORD }} -Dandroid.sdk.path=/usr/local/lib/android/sdk -Dandroid.buildToolsVersion=35.0.0 -Dmaven.test.skip=true
|
||||
mkdir upload
|
||||
mv /home/runner/work/forge/forge/forge-gui-android/target/*-signed-aligned.apk upload/
|
||||
mv /home/runner/work/forge/forge/forge-gui-android/target/assets.zip upload/
|
||||
mv /home/runner/work/forge/forge/forge-gui-android/target/classes/assets/version.txt upload/
|
||||
cd upload
|
||||
d=$(date +%m-%d)
|
||||
# Replace date in forge-gui-mobile/src/forge/Forge.java
|
||||
sed -i -e "s/-SNAPSHOT/-SNAPSHOT-${d}/g" forge-gui-mobile/src/forge/Forge.java
|
||||
mvn -U -B -P android-release-build,android-release-sign install -e -Dsign.keystore=forge.keystore -Dsign.alias=Forge -Dsign.storepass=${{ secrets.SIGN_STORE_PASS }} -Dsign.keypass=${{ secrets.SIGN_STORE_PASS }} -Dcardforge-repo.username=${{ secrets.FTP_USERNAME }} -Dcardforge-repo.password=${{ secrets.FTP_PASSWORD }} -Dandroid.sdk.path=/usr/local/lib/android/sdk -Dandroid.buildToolsVersion=30.0.3 -Dmaven.test.skip=true
|
||||
mkdir -p forge-gui-android/target/upload
|
||||
mv forge-gui-android/target/*-signed-aligned.apk forge-gui-android/target/upload/
|
||||
mv forge-gui-android/target/assets.zip forge-gui-android/target/upload/
|
||||
cd forge-gui-android/target/upload/
|
||||
# Get the first APK file in the folder
|
||||
ls
|
||||
apk_file=$(find . -maxdepth 1 -type f -name '*.apk' -print -quit)
|
||||
|
||||
if [ -n "$apk_file" ]; then
|
||||
version=$(echo "$apk_file" | grep -oP 'forge-android-\K\d+\.\d+\.\d+-SNAPSHOT' | sed 's/-signed-aligned.apk//')
|
||||
echo "APK File: $apk_file"
|
||||
echo "Version: $version"
|
||||
mv *.apk "forge-android-$version-$d-signed-aligned.apk"
|
||||
|
||||
echo "$version-$d" > version.txt
|
||||
else
|
||||
echo "No .apk files found in the specified folder."
|
||||
fi
|
||||
|
||||
cd -
|
||||
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: 📂 Sync files
|
||||
uses: SamKirkland/FTP-Deploy-Action@v4.3.4
|
||||
#if: ${{ inputs.upload_package }}
|
||||
with:
|
||||
server: ftp.cardforge.org
|
||||
username: ${{ secrets.FTP_USERNAME }}
|
||||
password: ${{ secrets.FTP_PASSWORD }}
|
||||
local-dir: upload/
|
||||
local-dir: forge-gui-android/target/upload/
|
||||
server-dir: downloads/dailysnapshots/
|
||||
state-name: .ftp-deploy-android-sync-state.json
|
||||
|
||||
- name: Send failure notification to Discord
|
||||
if: failure() # This step runs only if the job fails
|
||||
run: |
|
||||
curl -X POST -H "Content-Type: application/json" \
|
||||
-d "{\"content\": \"🔴 Android Snapshot Build Failed in branch: \`${{ github.ref_name }}\` by \`${{ github.actor }}\`.\nCheck logs: ${{ github.run_url }}\"}" \
|
||||
${{ secrets.DISCORD_AUTOMATION_WEBHOOK }}
|
||||
|
||||
46
.github/workflows/snapshots-pc.yml
vendored
@@ -8,6 +8,9 @@ on:
|
||||
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
|
||||
required: false
|
||||
default: false
|
||||
schedule:
|
||||
# * is a special character in YAML so you have to quote this string
|
||||
- cron: '30 18 * * *'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -20,10 +23,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 17
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
java-version: '11'
|
||||
distribution: 'temurin'
|
||||
cache: 'maven'
|
||||
server-id: cardforge-repo
|
||||
@@ -52,27 +55,13 @@ jobs:
|
||||
|
||||
- name: Rename before upload
|
||||
run: |
|
||||
mkdir izpack
|
||||
# move bz2 and jar from work dir to izpack dir
|
||||
mv /home/runner/work/forge/forge/forge-installer/*/*.{bz2,jar} izpack/
|
||||
# move desktop build.txt to izpack
|
||||
mv /home/runner/work/forge/forge/forge-gui-desktop/target/classes/build.txt izpack/
|
||||
cd izpack
|
||||
d=$(date +%m.%d)
|
||||
# rename files and append date
|
||||
for file in *.jar; do
|
||||
bname="${file%.*}"
|
||||
echo "file renamed to ${bname}-${d}.jar"
|
||||
mv "${bname}.jar" "${bname}-${d}.jar"
|
||||
done
|
||||
for file in *.bz2; do
|
||||
# remove .bz2
|
||||
fname="${file%.*}"
|
||||
# remove .tar
|
||||
bname="${fname%.*}"
|
||||
echo "file renamed to ${bname}-${d}.tar.bz2"
|
||||
mv "${fname}.bz2" "${bname}-${d}.tar.bz2"
|
||||
done
|
||||
mkdir tarball
|
||||
# If this works just gotta figure out how to append datetime
|
||||
mv /home/runner/.m2/repository/forge/forge-gui-desktop/*/*.bz2 tarball/
|
||||
cd tarball
|
||||
out="$(basename -s .tar.bz2 *)"
|
||||
d=$(date +%m-%d)
|
||||
mv "${out}.tar.bz2" "${out}-${d}.tar.bz2"
|
||||
|
||||
- name: 📂 Sync files
|
||||
uses: SamKirkland/FTP-Deploy-Action@v4.3.4
|
||||
@@ -80,16 +69,13 @@ jobs:
|
||||
server: ftp.cardforge.org
|
||||
username: ${{ secrets.FTP_USERNAME }}
|
||||
password: ${{ secrets.FTP_PASSWORD }}
|
||||
local-dir: izpack/
|
||||
local-dir: tarball/
|
||||
server-dir: downloads/dailysnapshots/
|
||||
exclude: |
|
||||
*.jar
|
||||
*.pom
|
||||
*.repositories
|
||||
*.xml
|
||||
|
||||
- name: Send failure notification to Discord
|
||||
if: failure() # This step runs only if the job fails
|
||||
run: |
|
||||
curl -X POST -H "Content-Type: application/json" \
|
||||
-d "{\"content\": \"🔴 Desktop Snapshot Build Failed in branch: \`${{ github.ref_name }}\` by \`${{ github.actor }}\`.\nCheck logs: ${{ github.run_url }}\"}" \
|
||||
${{ secrets.DISCORD_AUTOMATION_WEBHOOK }}
|
||||
|
||||
|
||||
|
||||
60
.github/workflows/test-android-build.yml
vendored
@@ -1,60 +0,0 @@
|
||||
name: Test Android build
|
||||
|
||||
on:
|
||||
push:
|
||||
paths: [ 'forge-gui-android/**' ]
|
||||
pull_request:
|
||||
paths: [ 'forge-gui-android/**' ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
deployments: write
|
||||
packages: write
|
||||
strategy:
|
||||
matrix:
|
||||
java: [ '17' ]
|
||||
name: Test with Java ${{ matrix.Java }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
distribution: 'temurin'
|
||||
cache: 'maven'
|
||||
|
||||
- name: Install old maven (3.8.1)
|
||||
run: |
|
||||
curl -o apache-maven-3.8.1-bin.tar.gz https://archive.apache.org/dist/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz
|
||||
tar xf apache-maven-3.8.1-bin.tar.gz
|
||||
export PATH=$PWD/apache-maven-3.8.1/bin:$PATH
|
||||
export MAVEN_HOME=$PWD/apache-maven-3.8.1
|
||||
mvn --version
|
||||
|
||||
- name: Set Up Android tools
|
||||
run: |
|
||||
JAVA_HOME=${JAVA_HOME_17_X64} ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "build-tools;35.0.0" "platform-tools" "platforms;android-35"
|
||||
|
||||
- name: Install Android maven plugin
|
||||
run: |
|
||||
mkdir -p ~/.m2/repository/com/simpligility/maven/plugins/android-maven-plugin/4.6.2
|
||||
cd ~/.m2/repository/com/simpligility/maven/plugins/android-maven-plugin/4.6.2
|
||||
curl -L -o android-maven-plugin-4.6.2.jar https://github.com/Card-Forge/android-maven-plugin/releases/download/4.6.2/android-maven-plugin-4.6.2.jar
|
||||
curl -L -o android-maven-plugin-4.6.2.pom https://github.com/Card-Forge/android-maven-plugin/releases/download/4.6.2/android-maven-plugin-4.6.2.pom
|
||||
#mvn install:install-file -Dfile=android-maven-plugin-4.6.2.jar -DgroupId=com.simpligility.maven.plugins -DartifactId=android-maven-plugin -Dversion=4.6.2 -Dpackaging=jar
|
||||
cd -
|
||||
mvn install -Dmaven.test.skip=true
|
||||
mvn dependency:tree
|
||||
|
||||
- name: Install virtual framebuffer (if not available) to allow running GUI on a headless server
|
||||
run: command -v Xvfb >/dev/null 2>&1 || { sudo apt update && sudo apt install -y xvfb; }
|
||||
|
||||
- name: Run build in virtual framebuffer
|
||||
run: |
|
||||
export DISPLAY=":1"
|
||||
Xvfb :1 -screen 0 800x600x8 &
|
||||
mvn -U -B -P android-test-build verify -e -T 1C -Dandroid.sdk.path=$ANDROID_SDK_ROOT -Dandroid.buildToolsVersion=35.0.0 -Dmaven.test.skip=true
|
||||
4
.github/workflows/test-build.yaml
vendored
@@ -7,7 +7,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
java: ['17', '21']
|
||||
java: [ '11' ]
|
||||
name: Test with Java ${{ matrix.Java }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -26,4 +26,4 @@ jobs:
|
||||
run: |
|
||||
export DISPLAY=":1"
|
||||
Xvfb :1 -screen 0 800x600x8 &
|
||||
mvn -U -B clean test
|
||||
mvn -U -B clean -P windows-linux test
|
||||
|
||||
4
.github/workflows/test-maven-settings.yml
vendored
@@ -14,10 +14,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 17
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
java-version: '11'
|
||||
distribution: 'temurin'
|
||||
cache: 'maven'
|
||||
server-id: cardforge-repo
|
||||
|
||||
10
.gitignore
vendored
@@ -12,7 +12,6 @@
|
||||
.settings
|
||||
.classpath
|
||||
.project
|
||||
.checkstyle
|
||||
|
||||
# Ignore VS Code config files
|
||||
|
||||
@@ -25,8 +24,6 @@
|
||||
|
||||
nbactions.xml
|
||||
|
||||
# Ignore flattened pom
|
||||
.flattened-pom.xml
|
||||
|
||||
# Ignore binaries, temp files and test output, everywhere
|
||||
|
||||
@@ -66,9 +63,6 @@ forge-gui-mobile-dev/testAssets
|
||||
|
||||
forge-gui/res/cardsfolder/*.bat
|
||||
|
||||
# Generated changelog file
|
||||
forge-gui/release-files/CHANGES.txt
|
||||
|
||||
forge-gui/res/PerSetTrackingResults
|
||||
forge-gui/res/decks
|
||||
forge-gui/res/layouts
|
||||
@@ -90,7 +84,3 @@ forge-gui/tools/PerSetTrackingResults
|
||||
*.tiled-session
|
||||
/forge-gui/res/adventure/*.tiled-project
|
||||
/forge-gui/res/adventure/*.tiled-session
|
||||
|
||||
# Ignore python temporaries
|
||||
__pycache__
|
||||
*.pyc
|
||||
|
||||
33
.gitlab/issue_templates/Bug.md
Normal file
@@ -0,0 +1,33 @@
|
||||
Summary
|
||||
|
||||
(Summarize the bug encountered concisely)
|
||||
|
||||
|
||||
Steps to reproduce
|
||||
|
||||
(How one can reproduce the issue - this is very important. Specific cards and specific actions especially)
|
||||
|
||||
|
||||
Which version of Forge are you on (Release, Snapshot? Desktop, Android?)
|
||||
|
||||
|
||||
What is the current bug behavior?
|
||||
|
||||
(What actually happens)
|
||||
|
||||
|
||||
What is the expected correct behavior?
|
||||
|
||||
(What you should see instead)
|
||||
|
||||
|
||||
Relevant logs and/or screenshots
|
||||
|
||||
(Paste/Attach your game.log from the crash - please use code blocks (```)) Also, provide screenshots of the current state.
|
||||
|
||||
|
||||
Possible fixes
|
||||
|
||||
(If you can, link to the line of code that might be responsible for the problem)
|
||||
|
||||
/label ~needs-investigation
|
||||
15
.gitlab/issue_templates/Feature.md
Normal file
@@ -0,0 +1,15 @@
|
||||
Summary
|
||||
|
||||
(Summarize the feature you wish concisely)
|
||||
|
||||
|
||||
Example screenshots
|
||||
|
||||
(If this is a UI change, please provide an example screenshot of how this feature might work)
|
||||
|
||||
|
||||
Feature type
|
||||
|
||||
(Where in Forge does this belong? e.g. Quest Mode, Deck Editor, Limited, Constructed, etc.)
|
||||
|
||||
/label ~feature request
|
||||
@@ -1,6 +1,18 @@
|
||||
<!--
|
||||
Derived from: https://stackoverflow.com/a/67002852
|
||||
-->
|
||||
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">
|
||||
<mirrors>
|
||||
<mirror>
|
||||
<id>4thline-repo-http-unblocker</id>
|
||||
<mirrorOf>4thline-repo</mirrorOf>
|
||||
<name></name>
|
||||
<url>http://4thline.org/m2</url>
|
||||
</mirror>
|
||||
</mirrors>
|
||||
|
||||
<servers>
|
||||
<server>
|
||||
<id>cardforge-repo</id>
|
||||
|
||||
@@ -6,8 +6,8 @@ Dev instructions here: [Getting Started](https://github.com/Card-Forge/forge/wik
|
||||
|
||||
## Requirements / Tools
|
||||
|
||||
- your favourite Java IDE (IntelliJ, Eclipse, VSCodium, Emacs, Vi...)
|
||||
- Java JDK 17 or later
|
||||
- you favourite Java IDE (IntelliJ, Eclipse, VSCodium, Emacs, Vi...)
|
||||
- Java JDK 8 or later (some IDEs such as Eclipse require JDK11+, whereas the Android build currently only works with JDK8)
|
||||
- Git
|
||||
- Git client (optional)
|
||||
- Maven
|
||||
@@ -28,6 +28,7 @@ Dev instructions here: [Getting Started](https://github.com/Card-Forge/forge/wik
|
||||
|
||||
IntelliJ is the recommended IDE for Forge development. Quick start guide for [setting up the Forge project within IntelliJ](https://github.com/Card-Forge/forge/wiki/IntelliJ-setup).
|
||||
|
||||
|
||||
## Eclipse
|
||||
|
||||
Eclipse includes Maven integration so a separate install is not necessary. For other IDEs, your mileage may vary.
|
||||
@@ -45,9 +46,9 @@ At this time, Eclipse is not the recommended IDE for Forge development.
|
||||
|
||||
- Clone your forked repo to your local machine.
|
||||
|
||||
- Make sure the Java SDK is installed -- not just the JRE. Java 17 or newer required. If you execute `java -version` at the shell or command prompt, it should report version 17 or later.
|
||||
- Make sure the Java SDK is installed -- not just the JRE. Java 8 or newer required. If you execute `java -version` at the shell or command prompt, it should report version 1.8 or later.
|
||||
|
||||
- Install Eclipse 2021-12 or later for Java. Launch it.
|
||||
- Install Eclipse 2018-12 or later for Java. Launch it.
|
||||
|
||||
- Create a workspace. Go to the workbench. Right-click inside of Package Explorer > Import... > Maven > Existing Maven Projects > Navigate to root path of the local forge repo and
|
||||
ensure everything is checked > Finish.
|
||||
@@ -78,15 +79,16 @@ This is the configuration used for doing mobile development using the Windows /
|
||||
|
||||
### Eclipse / Android SDK Integration
|
||||
|
||||
Google no longer supports Android SDK releases for Eclipse. use IntelliJ.
|
||||
Google no longer supports Android SDK releases for Eclipse. That said, it is still possible to build and debug Android platforms.
|
||||
|
||||
#### Android SDK
|
||||
|
||||
TBD
|
||||
Reference SO for obtaining a specific release: https://stackoverflow.com/questions/27043522/where-can-i-download-an-older-version-of-the-android-sdk
|
||||
|
||||
##### Windows
|
||||
|
||||
TBD
|
||||
Download the following archived version of the Android SDK: http://dl-ssl.google.com/android/repository/tools_r25.2.3-windows.zip. Install it somewhere on your machine. This is referenced
|
||||
in the following instructions as your 'Android SDK Install' path.
|
||||
|
||||
##### Linux / Mac OSX
|
||||
|
||||
@@ -94,40 +96,77 @@ TBD
|
||||
|
||||
#### Android Plugin for Eclipse
|
||||
|
||||
TBD
|
||||
Google's last plugin release does not work completely with target's running Android 7.0 or later. Download the ADT-24.2.0-20160729.zip plugin
|
||||
from: https://github.com/khaledev/ADT/releases
|
||||
|
||||
In Eclipse go to: Help > Install New Software... > Add > Name: ADT Update, Click on the "Archive:" button and navigate to the downloaded ADT-24.2.0-20160729.zip file > Add. Install all "Developer Tools". Eclipse
|
||||
should restart and prompt you to run the SDK Manager. Launch it and continue to the next steps below.
|
||||
|
||||
#### Android Platform
|
||||
|
||||
In Intellij, if the SDK Manager is not already running, go to Tools > Android > Android SDK Manager. Install the following options / versions:
|
||||
In Eclipse, if the SDK Manager is not already running, go to Window > Android SDK Manager. Install the following options / versions:
|
||||
|
||||
- Android SDK Build-tools 35.0.0
|
||||
- Android 15 (API 35) SDK Platform
|
||||
- Android SDK Build-tools 26.0.1
|
||||
- Android 8.0.0 (API 26) SDK Platform
|
||||
- Google USB Driver (in case your phone is not detected by ADB)
|
||||
|
||||
Note that this will populate additional tools in the Android SDK install path extracted above.
|
||||
|
||||
#### Proguard update
|
||||
|
||||
Standalone Proguard 7.6.0 is included with the project (proguard.jar) under forge-gui-android > tools and supports up to Java 23 (latest android uses Java 17).
|
||||
The Proguard included with the Android SDK Build-tools is outdated and does not work with Java 1.8. Download Proguard 6.0.3 or later (last tested with 7.0.1) from https://github.com/Guardsquare/proguard
|
||||
- Go to the Android SDK install path. Rename the tools/proguard/ path to tools/proguard-4.7/.
|
||||
|
||||
- Extract your Proguard version to the Android SDK install path under tools/. You will need to either rename the dir proguard-<your-version> to proguard/ or, if your filesystem supports it, use a symbolic link (the later is highly recommended), such as `ln -s proguard proguard-<your-version>`.
|
||||
|
||||
#### Android Build
|
||||
|
||||
TBD
|
||||
The Eclipse plug-ins do NOT support building things for Android. They do however allow you to use the debugger so you can still set breakpoints and trace
|
||||
things out. The steps below show how to generate a debug Android build.
|
||||
|
||||
1) Create a Maven build for the forge top-level project. Right-click on the forge project. Run as.. > Maven build...
|
||||
- On the Main tab, set Goals: clean install
|
||||
|
||||
2) Run forge Maven build. If everything built, you should see "BUILD SUCCESS" in the Console View.
|
||||
|
||||
3) Right-click on the forge-gui-android project. Run as.. > Maven build...
|
||||
|
||||
- On the Main tab, set Goals: install, Profiles: android-debug
|
||||
- On the Environment tab, you may need to define the variable ANDROID_HOME with the value containing the path to your Android SDK installation. For example, Variable: ANDROID_HOME, Value: Your Android SDK install path here.
|
||||
|
||||
4) Run the forge-gui-android Maven build. This may take a few minutes. If everything worked, you should see "BUILD SUCCESS" in the Console View.
|
||||
|
||||
Assuming you got this far, you should have an Android forge-android-[version].apk in the forge-gui-android/target path.
|
||||
|
||||
#### Android Deploy
|
||||
|
||||
TBD
|
||||
You'll need to have the Android SDK install path platform-tools/ path in your command search path to easily deploy builds.
|
||||
|
||||
- Open a command prompt. Navigate to the forge-gui-android/target/ path.
|
||||
|
||||
- Connect your Android device to your dev machine.
|
||||
|
||||
- Ensure the device is visible using `adb devices`
|
||||
|
||||
- Remove the old Forge install if present: `adb uninstall forge.app`
|
||||
|
||||
- Install the new apk: `adb install forge-android-[version].apk`
|
||||
|
||||
#### Android Debugging
|
||||
|
||||
TBD
|
||||
Assuming the apk is installed, launch it from the device.
|
||||
|
||||
In Eclipse, launch the DDMS. Window > Perspective > Open Perspective > Other... > DDMS. You should see the forge app in the list. Highlight the app, click on the green debug button and a
|
||||
green debug button should appear next to the app's name. You can now set breakpoints and step through the source code.
|
||||
|
||||
### Windows / Linux SNAPSHOT build
|
||||
|
||||
SNAPSHOT builds can be built via the Maven integration in Eclipse.
|
||||
|
||||
1. Create a Maven build for the forge top-level project. Right-click on the forge project. Run as.. > Maven build...
|
||||
|
||||
1) Create a Maven build for the forge top-level project. Right-click on the forge project. Run as.. > Maven build...
|
||||
- On the Main tab, set Goals: clean install, set Profiles: windows-linux
|
||||
|
||||
2. Run forge Maven build. If everything built, you should see "BUILD SUCCESS" in the Console View.
|
||||
2) Run forge Maven build. If everything built, you should see "BUILD SUCCESS" in the Console View.
|
||||
|
||||
The resulting snapshot will be found at: forge-gui-desktop/target/forge-gui-desktop-[version]-SNAPSHOT
|
||||
|
||||
@@ -158,19 +197,13 @@ The platform-specific projects are:
|
||||
|
||||
#### forge-ai
|
||||
|
||||
The forge-ai project contains the computer opponent logic for gameplay. It includes decision-making algorithms for specific abilities, cards and turn phases.
|
||||
|
||||
#### forge-core
|
||||
|
||||
The forge-core project contains the core game engine, card mechanics, rules engine, and fundamental game logic. It includes the implementation of Magic: The Gathering rules, card interactions, and the game state management system.
|
||||
|
||||
#### forge-game
|
||||
|
||||
The forge-game project handles the game session management, player interactions, and game flow control. It includes implementations for multiplayer support, game modes, matchmaking, and game state persistence. This module bridges the core game engine with the user interface and networking components.
|
||||
|
||||
#### forge-gui
|
||||
|
||||
The forge-gui project contains the user interface components and rendering logic for the game. It includes the main game window, card displays, player interactions, and the scripting resource definitions in the res/ path.
|
||||
The forge-gui project includes the scripting resource definitions in the res/ path.
|
||||
|
||||
#### forge-gui-android
|
||||
|
||||
|
||||
113
README.md
@@ -1,105 +1,50 @@
|
||||
# ⚔️ Forge: The Magic: The Gathering Rules Engine
|
||||
# Forge
|
||||
|
||||
Join the **Forge community** on [Discord](https://discord.gg/HcPJNyD66a)!
|
||||
Join the [Discord](https://discord.gg/HcPJNyD66a)
|
||||
|
||||
[](https://github.com/Card-Forge/forge/actions/workflows/test-build.yaml)
|
||||
|
||||
---
|
||||
## Introduction
|
||||
|
||||
## ✨ Introduction
|
||||
Forge is a "Rules Engine" for the game Magic: the Gathering.
|
||||
Forge is not related in any way with Wizards of the Coast.
|
||||
Forge is open source software released under the GNU Public License.
|
||||
Forge is developed by a community of programmers who love trading card games.
|
||||
|
||||
**Forge** is a dynamic and open-source **Rules Engine** tailored for **Magic: The Gathering** enthusiasts. Developed by a community of passionate programmers, Forge allows players to explore the rich universe of MTG through a flexible, engaging platform.
|
||||
Forge is a cross-platform application and can be run on Windows, Mac, Linux and Android. It is written in Java. The engine is written in Java. The engine is designed to be extensible, so any interested programmer can join and help add new features and cards to the game. Any tech savvy user could read out card scripting system to create cards to be used inside Forge.
|
||||
The engine allows you to play in a handful of different single player environments or online against other players.
|
||||
|
||||
**Note:** Forge operates independently and is not affiliated with Wizards of the Coast.
|
||||
|
||||
---
|
||||
## Installation
|
||||
|
||||
## 🌟 Key Features
|
||||
For a more in depth User Guide, please visit the [User Guide](https://github.com/Card-Forge/forge/wiki/User-Guide)
|
||||
|
||||
- **🌐 Cross-Platform Support:** Play on **Windows, Mac, Linux,** and **Android**.
|
||||
- **🔧 Extensible Architecture:** Built in **Java**, Forge encourages developers to contribute by adding features and cards.
|
||||
- **🎮 Versatile Gameplay:** Dive into single-player modes or challenge opponents online!
|
||||
For Desktop users, download the [Latest Releases](https://github.com/Card-Forge/forge/releases/latest) which are typically based around Set releases.
|
||||
Or download the [Snapshot Build](https://downloads.cardforge.org/dailysnapshots/) the file that starts with "forge-gui-desktop".
|
||||
This file is tarball, and may need to be extracted twice depending on which program is being used to extract it.
|
||||
We recommend extracting to a new folder rather than on top of an existing installation.
|
||||
**For users who have played Forge before all of your user data is stored separately so you don't have to worry about losing it on upgrade.**
|
||||
|
||||
---
|
||||
Java 8 or later is required to run Forge. Please make sure is the right version is installed in your environment. Check the user guide for more info.
|
||||
|
||||
## 🛠️ Installation Guide
|
||||
For Android users, download the APK file from [Snapshot Build](https://downloads.cardforge.org/dailysnapshots/) to your device.
|
||||
On first run, Forge will download all needed data.
|
||||
|
||||
### 📥 Desktop Installation
|
||||
1. **Latest Releases:** Download the latest version [here](https://github.com/Card-Forge/forge/releases/latest).
|
||||
2. **Snapshot Build:** For the latest development version, grab the `forge-gui-desktop` tarball from our [Snapshot Build](https://github.com/Card-Forge/forge/releases/tag/daily-snapshots).
|
||||
- **Tip:** Extract to a new folder to prevent version conflicts.
|
||||
3. **User Data Management:** Previous players’ data is preserved during upgrades.
|
||||
4. **Java Requirement:** Ensure you have **Java 17 or later** installed.
|
||||
## Modes of Play
|
||||
|
||||
### 📱 Android Installation
|
||||
- _(Note: **Android 11** is the minimum requirements with at least **6GB RAM** to run smoothly. You need to enable **"Install unknown apps"** for Forge to initialize and update itself)_
|
||||
- Download the **APK** from the [Snapshot Build](https://github.com/Card-Forge/forge/releases/tag/daily-snapshots). On the first launch, Forge will automatically download all necessary assets.
|
||||
Forge has a variety of ways to play the game. The most popular way is our Adventure mode, which is a single player campaign that allows you to play against a variety of AI opponents.
|
||||
You walk around an overworld map, and can challenge opponents to games of Magic. As you play, you'll collect more cards and items to improve your abilities.
|
||||
|
||||
---
|
||||
Check the [Gameplay Guide](https://github.com/Card-Forge/forge/wiki/Gameplay-Guide) for more info.
|
||||
|
||||
## 🎮 Modes of Play
|
||||

|
||||
|
||||
Forge offers various exciting gameplay options:
|
||||
|
||||
### 🌍 Adventure Mode
|
||||
Embark on a thrilling single-player journey where you can:
|
||||
- Explore an overworld map.
|
||||
- Challenge diverse AI opponents.
|
||||
- Collect cards and items to boost your abilities.
|
||||
Forge has several Quest modes, which is similar but without the overworld map.
|
||||
|
||||
<img width="1282" height="752" alt="Shandalar World" src="https://github.com/user-attachments/assets/9af31471-d688-442f-9418-9807d8635b72" />
|
||||
You can also play against the AI in a variety of formats, such as Sealed, Draft, Commander and Cube.
|
||||
|
||||
### 🔍 Quest Modes
|
||||
Engage in focused gameplay without the overworld exploration—perfect for quick sessions!
|
||||
## Questions
|
||||
|
||||
<img width="1282" height="752" alt="Quest Duels" src="https://github.com/user-attachments/assets/b9613b1c-e8c3-4320-8044-6922c519aad4" />
|
||||
|
||||
### 🤖 AI Formats
|
||||
Test your skills against AI in multiple formats:
|
||||
- **Sealed**
|
||||
- **Draft**
|
||||
- **Commander**
|
||||
- **Cube**
|
||||
|
||||
For comprehensive gameplay instructions, visit our [Gameplay Guide](https://github.com/Card-Forge/forge/wiki/Gameplay-Guide).
|
||||
|
||||
<img width="1282" height="752" alt="Sealed" src="https://github.com/user-attachments/assets/ae603dbd-4421-4753-a333-87cb0a28d772" />
|
||||
|
||||
---
|
||||
|
||||
## 💬 Support & Community
|
||||
|
||||
Need help? Join our vibrant Discord community!
|
||||
- 📜 Read the **#rules** and explore the **FAQ**.
|
||||
- ❓ Ask your questions in the **#help** channel for assistance.
|
||||
|
||||
---
|
||||
|
||||
## 🤝 Contributing to Forge
|
||||
|
||||
We love community contributions! Interested in helping? Check out our [Contributing Guidelines](CONTRIBUTING.md) for details on how to get started.
|
||||
|
||||
---
|
||||
|
||||
## ℹ️ About Forge
|
||||
|
||||
Forge aims to deliver an immersive and customizable Magic: The Gathering experience for fans around the world.
|
||||
|
||||
### 📊 Repository Statistics
|
||||
|
||||
| Metric | Count |
|
||||
|----------------|-------------------------------------------------------------|
|
||||
| **⭐ Stars:** | [](https://github.com/Card-Forge/forge/stargazers) |
|
||||
| **🍴 Forks:** | [](https://github.com/Card-Forge/forge/network) |
|
||||
| **👥 Contributors:** | [](https://github.com/Card-Forge/forge/graphs/contributors) |
|
||||
|
||||
---
|
||||
|
||||
**📄 License:** [GPL-3.0](LICENSE)
|
||||
<div align="center" style="display: flex; align-items: center; justify-content: center;">
|
||||
<div style="margin-left: auto;">
|
||||
<a href="#top">
|
||||
<img src="https://img.shields.io/badge/Back%20to%20Top-000000?style=for-the-badge&logo=github&logoColor=white" alt="Back to Top">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
If you have any questions, please join the Discord channel. Read the #rules and the frequently-asked-questions.
|
||||
If your question is not answered there, feel free to ask in the #help channel.
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>forge</artifactId>
|
||||
<groupId>forge</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>adventure-editor</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Adventure Editor</name>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}</directory>
|
||||
<includes>
|
||||
<include>**/gear.gif</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<finalName>adventure-editor</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>replacer</artifactId>
|
||||
<version>1.5.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<basedir>${basedir}/${configSourceDirectory}</basedir>
|
||||
<filesToInclude>adventure-editor.sh, adventure-editor.command, adventure-editor.cmd</filesToInclude>
|
||||
<outputBasedir>${project.build.directory}</outputBasedir>
|
||||
<outputDir>.</outputDir>
|
||||
<regex>false</regex>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>$project.build.finalName$</token>
|
||||
<value>${project.build.finalName}-jar-with-dependencies.jar</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<attach>false</attach>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>forge.adventure.Main</mainClass>
|
||||
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
|
||||
</manifest>
|
||||
<manifestEntries>
|
||||
<SplashScreen-Image>splash/gear.gif</SplashScreen-Image>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<!-- this is used for inheritance merges -->
|
||||
<phase>package</phase>
|
||||
<!-- bind to the packaging phase -->
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>forge</groupId>
|
||||
<artifactId>forge-gui</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>forge</groupId>
|
||||
<artifactId>forge-gui-mobile</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>26.0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
Before Width: | Height: | Size: 414 KiB |
@@ -1,24 +0,0 @@
|
||||
@echo off
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
java -version 1>nul 2>nul || (
|
||||
echo no java installed
|
||||
popd
|
||||
exit /b 2
|
||||
)
|
||||
for /f tokens^=2^ delims^=.-_^+^" %%j in ('java -fullversion 2^>^&1') do set "jver=%%j"
|
||||
|
||||
if %jver% LEQ 16 (
|
||||
echo unsupported java
|
||||
popd
|
||||
exit /b 2
|
||||
)
|
||||
|
||||
if %jver% GEQ 17 (
|
||||
java -Xmx4096m -Dfile.encoding=UTF-8 -jar $project.build.finalName$
|
||||
popd
|
||||
exit /b 0
|
||||
)
|
||||
|
||||
popd
|
||||
@@ -1,97 +0,0 @@
|
||||
package forge.adventure.editor;
|
||||
|
||||
import forge.adventure.util.Config;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.JToolBar;
|
||||
import javax.swing.UIManager;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
import java.security.CodeSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Editor class to edit configuration, maybe moved or removed
|
||||
*/
|
||||
public class EditorMainWindow extends JFrame {
|
||||
public final static WorldEditor worldEditor = new WorldEditor();
|
||||
JTabbedPane tabs = new JTabbedPane();
|
||||
|
||||
public EditorMainWindow(Config config) {
|
||||
UIManager.LookAndFeelInfo[] var1 = UIManager.getInstalledLookAndFeels();
|
||||
|
||||
for (UIManager.LookAndFeelInfo info : var1) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
try {
|
||||
UIManager.setLookAndFeel(info.getClassName());
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||
this.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
setVisible(false);
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
BorderLayout layout = new BorderLayout();
|
||||
JToolBar toolBar = new JToolBar("toolbar");
|
||||
JButton newButton = new JButton("GDX Particle Editor Tool");
|
||||
newButton.addActionListener(e -> EventQueue.invokeLater(() -> {
|
||||
newButton.setEnabled(false);
|
||||
try {
|
||||
CodeSource codeSource = EditorMainWindow.class.getProtectionDomain().getCodeSource();
|
||||
File jarFile = new File(codeSource.getLocation().toURI().getPath());
|
||||
String jarDir = jarFile.getParentFile().getPath();
|
||||
Desktop.getDesktop().open(new File(jarDir + "/gdx-particle-editor.jar"));
|
||||
} catch (Exception ex) {
|
||||
new ErrorDialog("Error", ex.getMessage());
|
||||
newButton.setEnabled(true);
|
||||
}
|
||||
}));
|
||||
JButton quit = new JButton("Quit");
|
||||
quit.addActionListener(e -> System.exit(0));
|
||||
toolBar.add(newButton);
|
||||
toolBar.add(quit);
|
||||
setLayout(layout);
|
||||
toolBar.setFloatable(false);
|
||||
add(toolBar, BorderLayout.NORTH);
|
||||
add(tabs, BorderLayout.CENTER);
|
||||
tabs.addTab("World", worldEditor);
|
||||
tabs.addTab("POI", new PointOfInterestEditor());
|
||||
tabs.addTab("Items", new ItemsEditor());
|
||||
tabs.addTab("Enemies", new EnemyEditor());
|
||||
tabs.addTab("Quests", new QuestEditor());
|
||||
setSize(config.getSettingData().width, config.getSettingData().height);
|
||||
setLocationRelativeTo(null);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
static class ErrorDialog {
|
||||
public ErrorDialog(String title, String message) {
|
||||
List<Object> options = new ArrayList<>();
|
||||
JButton ok = new JButton("OK");
|
||||
options.add(ok);
|
||||
JOptionPane pane = new JOptionPane(message, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, options.toArray());
|
||||
JDialog dlg = pane.createDialog(JOptionPane.getRootFrame(), title);
|
||||
ok.addActionListener(e -> {
|
||||
dlg.setVisible(false);
|
||||
System.exit(0);
|
||||
});
|
||||
dlg.setResizable(false);
|
||||
dlg.setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
forge-adventure/fallback_skin/adv_bg_splash.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
forge-adventure/fallback_skin/adv_bg_texture.jpg
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
forge-adventure/fallback_skin/bg_splash.png
Normal file
|
After Width: | Height: | Size: 208 KiB |
BIN
forge-adventure/fallback_skin/bg_texture.jpg
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
forge-adventure/fallback_skin/font1.ttf
Normal file
BIN
forge-adventure/fallback_skin/title_bg_lq.png
Normal file
|
After Width: | Height: | Size: 364 KiB |
BIN
forge-adventure/fallback_skin/title_bg_lq_portrait.png
Normal file
|
After Width: | Height: | Size: 300 KiB |
BIN
forge-adventure/fallback_skin/transition.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
forge-adventure/libs/gdx-backend-lwjgl-natives.jar
Normal file
BIN
forge-adventure/libs/gdx-backend-lwjgl-sources.jar
Normal file
BIN
forge-adventure/libs/gdx-backend-lwjgl.jar
Normal file
BIN
forge-adventure/libs/gdx-freetype-natives.jar
Normal file
BIN
forge-adventure/libs/gdx-natives.jar
Normal file
309
forge-adventure/pom.xml
Normal file
@@ -0,0 +1,309 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>forge</artifactId>
|
||||
<groupId>forge</groupId>
|
||||
<version>1.6.65</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>forge-adventure</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Forge Adventure</name>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>4thline-repo</id>
|
||||
<url>http://4thline.org/m2</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}</directory>
|
||||
<includes>
|
||||
<include>**/*.vert</include>
|
||||
<include>**/*.frag</include>
|
||||
<include>**/title_bg_lq.png</include>
|
||||
<include>**/title_bg_lq_portrait.png</include>
|
||||
<include>**/transition.png</include>
|
||||
<include>**/adv_bg_texture.jpg</include>
|
||||
<include>**/adv_bg_splash.png</include>
|
||||
<include>**/bg_splash.png</include>
|
||||
<include>**/bg_texture.jpg</include>
|
||||
<include>**/font1.ttf</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.akathist.maven.plugins.launch4j</groupId>
|
||||
<artifactId>launch4j-maven-plugin</artifactId>
|
||||
<version>1.7.25</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>l4j-adv</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>launch4j</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<headerType>gui</headerType>
|
||||
<outfile>${project.build.directory}/forge-adventure-editor-java8.exe</outfile>
|
||||
<jar>${project.build.finalName}-jar-with-dependencies.jar</jar>
|
||||
<dontWrapJar>true</dontWrapJar>
|
||||
<errTitle>forge</errTitle>
|
||||
<icon>src/main/config/forge-adventure-editor.ico</icon>
|
||||
<classPath>
|
||||
<mainClass>forge.adventure.Main</mainClass>
|
||||
<addDependencies>false</addDependencies>
|
||||
<preCp>anything</preCp>
|
||||
</classPath>
|
||||
<jre>
|
||||
<minVersion>1.8.0</minVersion>
|
||||
<maxHeapSize>4096</maxHeapSize>
|
||||
<opts>
|
||||
<opt>-Dfile.encoding=UTF-8</opt>
|
||||
</opts>
|
||||
</jre>
|
||||
<versionInfo>
|
||||
<fileVersion>
|
||||
1.0.0.0
|
||||
</fileVersion>
|
||||
<txtFileVersion>
|
||||
1.0.0.0
|
||||
</txtFileVersion>
|
||||
<fileDescription>Forge</fileDescription>
|
||||
<copyright>Forge</copyright>
|
||||
<productVersion>
|
||||
1.0.0.0
|
||||
</productVersion>
|
||||
<txtProductVersion>
|
||||
1.0.0.0
|
||||
</txtProductVersion>
|
||||
<productName>forge-adventure-editor</productName>
|
||||
<internalName>forge-adventure-editor</internalName>
|
||||
<originalFilename>forge-adventure-editor-java8.exe</originalFilename>
|
||||
</versionInfo>
|
||||
</configuration>
|
||||
</execution>
|
||||
<!--extra-->
|
||||
<execution>
|
||||
<id>l4j-adv2</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>launch4j</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<headerType>gui</headerType>
|
||||
<outfile>${project.build.directory}/forge-adventure-editor.exe</outfile>
|
||||
<jar>${project.build.finalName}-jar-with-dependencies.jar</jar>
|
||||
<dontWrapJar>true</dontWrapJar>
|
||||
<errTitle>forge</errTitle>
|
||||
<downloadUrl>https://www.oracle.com/java/technologies/downloads/</downloadUrl>
|
||||
<icon>src/main/config/forge-adventure-editor.ico</icon>
|
||||
<classPath>
|
||||
<mainClass>forge.adventure.Main</mainClass>
|
||||
<addDependencies>false</addDependencies>
|
||||
<preCp>anything</preCp>
|
||||
</classPath>
|
||||
<jre>
|
||||
<minVersion>11.0.1</minVersion>
|
||||
<jdkPreference>jdkOnly</jdkPreference>
|
||||
<maxHeapSize>4096</maxHeapSize>
|
||||
<opts>
|
||||
<opt>-Dfile.encoding=UTF-8</opt>
|
||||
<opt>--add-opens java.base/java.lang=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.base/java.math=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.base/jdk.internal.misc=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.base/java.nio=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens=java.base/sun.nio.ch=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.base/java.util=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.base/java.lang.reflect=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.base/java.text=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/java.awt=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/java.awt.font=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/java.awt.image=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/java.awt.color=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/sun.awt.image=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/javax.swing=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/javax.swing.border=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/javax.swing.event=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/sun.swing=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.desktop/java.beans=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.base/java.util.concurrent=ALL-UNNAMED</opt>
|
||||
<opt>--add-opens java.base/java.net=ALL-UNNAMED</opt>
|
||||
<opt>-Dio.netty.tryReflectionSetAccessible=true</opt>
|
||||
</opts>
|
||||
</jre>
|
||||
<versionInfo>
|
||||
<fileVersion>
|
||||
1.0.0.0
|
||||
</fileVersion>
|
||||
<txtFileVersion>
|
||||
1.0.0.0
|
||||
</txtFileVersion>
|
||||
<fileDescription>Forge</fileDescription>
|
||||
<copyright>Forge</copyright>
|
||||
<productVersion>
|
||||
1.0.0.0
|
||||
</productVersion>
|
||||
<txtProductVersion>
|
||||
1.0.0.0
|
||||
</txtProductVersion>
|
||||
<productName>forge-adventure-editor</productName>
|
||||
<internalName>forge-adventure-editor</internalName>
|
||||
<originalFilename>forge-adventure-editor.exe</originalFilename>
|
||||
</versionInfo>
|
||||
</configuration>
|
||||
</execution>
|
||||
<!--extra-->
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>replacer</artifactId>
|
||||
<version>1.5.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<basedir>${basedir}/${configSourceDirectory}</basedir>
|
||||
<filesToInclude>forge-adventure-editor.sh, forge-adventure-editor-mac.sh, forge-adventure-editor.command, forge-adventure-editor.cmd</filesToInclude>
|
||||
<outputBasedir>${project.build.directory}</outputBasedir>
|
||||
<outputDir>.</outputDir>
|
||||
<regex>false</regex>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>$project.build.finalName$</token>
|
||||
<value>${project.build.finalName}-jar-with-dependencies.jar</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<attach>false</attach>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>forge.adventure.Main</mainClass>
|
||||
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<!-- this is used for inheritance merges -->
|
||||
<phase>package</phase>
|
||||
<!-- bind to the packaging phase -->
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.badlogicgames.gdx</groupId>
|
||||
<artifactId>gdx</artifactId>
|
||||
<version>1.12.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.badlogicgames.gdx</groupId>
|
||||
<artifactId>gdx-platform</artifactId>
|
||||
<version>1.12.1</version>
|
||||
<classifier>natives-desktop</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.badlogicgames.gdx</groupId>
|
||||
<artifactId>gdx-freetype</artifactId>
|
||||
<version>1.12.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.badlogicgames.gdx</groupId>
|
||||
<artifactId>gdx-backend-lwjgl</artifactId>
|
||||
<version>1.12.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.badlogicgames.gdx</groupId>
|
||||
<artifactId>gdx-tools</artifactId>
|
||||
<version>1.12.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.badlogicgames.gdx</groupId>
|
||||
<artifactId>gdx-freetype-platform</artifactId>
|
||||
<version>1.12.1</version>
|
||||
<classifier>natives-desktop</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>forge</groupId>
|
||||
<artifactId>forge-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>forge</groupId>
|
||||
<artifactId>forge-gui</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>forge</groupId>
|
||||
<artifactId>forge-gui-mobile</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>22.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.badlogicgames.gdx-controllers</groupId>
|
||||
<artifactId>gdx-controllers-desktop</artifactId>
|
||||
<version>2.2.3</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.badlogicgames.gdx</groupId>
|
||||
<artifactId>gdx</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
16
forge-adventure/shaders/grayscale.frag
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
uniform float u_grayness;
|
||||
uniform float u_bias;
|
||||
|
||||
void main() {
|
||||
vec4 c = v_color * texture2D(u_texture, v_texCoords);
|
||||
float grey = dot( c.rgb, vec3(0.22, 0.707, 0.071) );
|
||||
vec3 blendedColor = mix(c.rgb, vec3(grey), u_grayness);
|
||||
gl_FragColor = mix(vec4(0.0, 0.0, 0.0, 1.0), vec4(blendedColor.rgb, c.a), u_bias);
|
||||
}
|
||||
14
forge-adventure/shaders/grayscale.vert
Normal file
@@ -0,0 +1,14 @@
|
||||
attribute vec4 a_position;
|
||||
attribute vec4 a_color;
|
||||
attribute vec2 a_texCoord0;
|
||||
|
||||
uniform mat4 u_projTrans;
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
|
||||
void main() {
|
||||
v_color = a_color;
|
||||
v_texCoords = a_texCoord0;
|
||||
gl_Position = u_projTrans * a_position;
|
||||
}
|
||||
40
forge-adventure/shaders/outline.frag
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D u_texture;
|
||||
uniform vec2 u_viewportInverse;
|
||||
uniform vec3 u_color;
|
||||
uniform float u_offset;
|
||||
uniform float u_step;
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoord;
|
||||
|
||||
#define ALPHA_VALUE_BORDER 0.5
|
||||
|
||||
void main() {
|
||||
vec2 T = v_texCoord.xy;
|
||||
|
||||
float alpha = 0.0;
|
||||
bool allin = true;
|
||||
for( float ix = -u_offset; ix < u_offset; ix += u_step )
|
||||
{
|
||||
for( float iy = -u_offset; iy < u_offset; iy += u_step )
|
||||
{
|
||||
float newAlpha = texture2D(u_texture, T + vec2(ix, iy) * u_viewportInverse).a;
|
||||
allin = allin && newAlpha > ALPHA_VALUE_BORDER;
|
||||
if (newAlpha > ALPHA_VALUE_BORDER && newAlpha >= alpha)
|
||||
{
|
||||
alpha = newAlpha;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (allin)
|
||||
{
|
||||
alpha = 0.0;
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(u_color,alpha);
|
||||
}
|
||||
16
forge-adventure/shaders/outline.vert
Normal file
@@ -0,0 +1,16 @@
|
||||
uniform mat4 u_projTrans;
|
||||
|
||||
attribute vec4 a_position;
|
||||
attribute vec2 a_texCoord0;
|
||||
attribute vec4 a_color;
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoord;
|
||||
|
||||
uniform vec2 u_viewportInverse;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projTrans * a_position;
|
||||
v_texCoord = a_texCoord0;
|
||||
v_color = a_color;
|
||||
}
|
||||
26
forge-adventure/shaders/underwater.frag
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifdef GL_ES
|
||||
#define PRECISION mediump
|
||||
precision PRECISION float;
|
||||
precision PRECISION int;
|
||||
#else
|
||||
#define PRECISION
|
||||
#endif
|
||||
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
uniform float u_amount;
|
||||
uniform float u_speed;
|
||||
uniform float u_time;
|
||||
uniform float u_bias;
|
||||
|
||||
void main () {
|
||||
vec2 uv = v_texCoords;
|
||||
|
||||
uv.y += (cos((uv.y + (u_time * 0.04 * u_speed)) * 45.0) * 0.0019 * u_amount) + (cos((uv.y + (u_time * 0.1 * u_speed)) * 10.0) * 0.002 * u_amount);
|
||||
|
||||
uv.x += (sin((uv.y + (u_time * 0.07 * u_speed)) * 15.0) * 0.0029 * u_amount) + (sin((uv.y + (u_time * 0.1 * u_speed)) * 15.0) * 0.002 * u_amount);
|
||||
|
||||
vec4 texColor = texture2D(u_texture, uv);
|
||||
|
||||
gl_FragColor = mix(vec4(0.0, 0.0, 0.0, 1.0), texColor, u_bias);
|
||||
}
|
||||
57
forge-adventure/shaders/warp.frag
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
uniform float u_time;
|
||||
uniform float u_speed;
|
||||
uniform float u_amount;
|
||||
uniform vec2 u_viewport;
|
||||
uniform vec2 u_position;
|
||||
|
||||
float random2d(vec2 n) {
|
||||
return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
|
||||
}
|
||||
|
||||
float randomRange (in vec2 seed, in float min, in float max) {
|
||||
return min + random2d(seed) * (max - min);
|
||||
}
|
||||
|
||||
float insideRange(float v, float bottom, float top) {
|
||||
return step(bottom, v) - step(top, v);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
float time = floor(u_time * u_speed * 60.0);
|
||||
|
||||
vec3 outCol = texture2D(u_texture, v_texCoords).rgb;
|
||||
|
||||
float maxOffset = u_amount/2.0;
|
||||
for (float i = 0.0; i < 2.0; i += 1.0) {
|
||||
float sliceY = random2d(vec2(time, 2345.0 + float(i)));
|
||||
float sliceH = random2d(vec2(time, 9035.0 + float(i))) * 0.25;
|
||||
float hOffset = randomRange(vec2(time, 9625.0 + float(i)), -maxOffset, maxOffset);
|
||||
vec2 uvOff = v_texCoords;
|
||||
uvOff.x += hOffset;
|
||||
if (insideRange(v_texCoords.y, sliceY, fract(sliceY+sliceH)) == 1.0){
|
||||
outCol = texture2D(u_texture, uvOff).rgb;
|
||||
}
|
||||
}
|
||||
|
||||
float maxColOffset = u_amount / 6.0;
|
||||
float rnd = random2d(vec2(time , 9545.0));
|
||||
vec2 colOffset = vec2(randomRange(vec2(time , 9545.0), -maxColOffset, maxColOffset),
|
||||
randomRange(vec2(time , 7205.0), -maxColOffset, maxColOffset));
|
||||
if (rnd < 0.33) {
|
||||
outCol.r = texture2D(u_texture, v_texCoords + colOffset).r;
|
||||
} else if (rnd < 0.66) {
|
||||
outCol.g = texture2D(u_texture, v_texCoords + colOffset).g;
|
||||
} else {
|
||||
outCol.b = texture2D(u_texture, v_texCoords + colOffset).b;
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(outCol, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
cd $(dirname "${0}")
|
||||
java -XstartOnFirstThread -Xmx4096m -Dfile.encoding=UTF-8 -jar $project.build.finalName$
|
||||
25
forge-adventure/src/main/config/forge-adventure-editor.cmd
Normal file
@@ -0,0 +1,25 @@
|
||||
@echo off
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
java -version 1>nul 2>nul || (
|
||||
echo no java installed
|
||||
popd
|
||||
exit /b 2
|
||||
)
|
||||
for /f tokens^=2^ delims^=.-_^+^" %%j in ('java -fullversion 2^>^&1') do set "jver=%%j"
|
||||
|
||||
if %jver% GEQ 17 (
|
||||
java --add-opens java.desktop/java.beans=ALL-UNNAMED --add-opens java.desktop/javax.swing.border=ALL-UNNAMED --add-opens java.desktop/javax.swing.event=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/java.awt.image=ALL-UNNAMED --add-opens java.desktop/java.awt.color=ALL-UNNAMED --add-opens java.desktop/sun.awt.image=ALL-UNNAMED --add-opens java.desktop/javax.swing=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true -Xmx4096m -Dfile.encoding=UTF-8 -jar $project.build.finalName$
|
||||
popd
|
||||
exit /b 0
|
||||
)
|
||||
|
||||
if %jver% GEQ 11 (
|
||||
java --illegal-access=permit -Xmx4096m -Dfile.encoding=UTF-8 -jar $project.build.finalName$
|
||||
popd
|
||||
exit /b 0
|
||||
)
|
||||
|
||||
java -Xmx4096m -Dfile.encoding=UTF-8 -jar $project.build.finalName$
|
||||
popd
|
||||
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 222 KiB After Width: | Height: | Size: 222 KiB |
@@ -15,7 +15,8 @@ public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
GuiBase.setInterface(new GuiMobile(Files.exists(Paths.get("./res"))?"./":"../forge-gui/"));
|
||||
GuiBase.setDeviceInfo(null, 0, 0, System.getProperty("user.home") + "/Downloads/");
|
||||
new EditorMainWindow(Config.instance());
|
||||
GuiBase.setDeviceInfo("", "", 0, 0);
|
||||
Config.instance();
|
||||
new EditorMainWindow();
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,7 @@ package forge.adventure.editor;
|
||||
|
||||
import forge.adventure.data.DialogData;
|
||||
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
@@ -160,9 +158,9 @@ public class ActionEdit extends FormPanel {
|
||||
advanceQuestFlag.setText(currentData.advanceQuestFlag);
|
||||
advanceCharacterFlag.setText(currentData.advanceCharacterFlag);
|
||||
|
||||
battleWithActorID.setText(String.valueOf(currentData.battleWithActorID));
|
||||
activateObjectID.setText(String.valueOf(currentData.battleWithActorID));
|
||||
deleteMapObject.setText(String.valueOf(currentData.deleteMapObject));
|
||||
battleWithActorID.setText("" + currentData.battleWithActorID);
|
||||
activateObjectID.setText("" + currentData.battleWithActorID);
|
||||
deleteMapObject.setText("" + currentData.deleteMapObject);
|
||||
setColorIdentity.setText(currentData.setColorIdentity);
|
||||
addLife.getModel().setValue(currentData.addLife);
|
||||
addReputation.getModel().setValue(currentData.addMapReputation);
|
||||
@@ -2,27 +2,20 @@ package forge.adventure.editor;
|
||||
|
||||
import forge.adventure.data.DialogData;
|
||||
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JToolBar;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* Editor class to edit configuration, maybe moved or removed
|
||||
*/
|
||||
public class ActionEditor extends JComponent {
|
||||
public class ActionEditor extends JComponent{
|
||||
DefaultListModel<DialogData.ActionData> model = new DefaultListModel<>();
|
||||
JList<DialogData.ActionData> list = new JList<>(model);
|
||||
JToolBar toolBar = new JToolBar("toolbar");
|
||||
ActionEdit edit = new ActionEdit();
|
||||
ActionEdit edit=new ActionEdit();
|
||||
boolean updating;
|
||||
|
||||
|
||||
@@ -32,43 +25,43 @@ public class ActionEditor extends JComponent {
|
||||
JList list, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
if (!(value instanceof DialogData.ActionData))
|
||||
if(!(value instanceof DialogData.ActionData))
|
||||
return label;
|
||||
/*DialogData.ActionData action=(DialogData.ActionData) value;
|
||||
DialogData.ActionData action=(DialogData.ActionData) value;
|
||||
StringBuilder builder=new StringBuilder();
|
||||
if(action.type==null||action.type.isEmpty())
|
||||
// if(action.type==null||action.type.isEmpty())
|
||||
builder.append("Action");
|
||||
else
|
||||
builder.append(action.type);*/
|
||||
label.setText("Action");
|
||||
// else
|
||||
// builder.append(action.type);
|
||||
label.setText(builder.toString());
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
public void addButton(String name, ActionListener action) {
|
||||
JButton newButton = new JButton(name);
|
||||
public void addButton(String name, ActionListener action)
|
||||
{
|
||||
JButton newButton=new JButton(name);
|
||||
newButton.addActionListener(action);
|
||||
toolBar.add(newButton);
|
||||
|
||||
}
|
||||
|
||||
public ActionEditor() {
|
||||
public ActionEditor()
|
||||
{
|
||||
|
||||
list.setCellRenderer(new RewardDataRenderer());
|
||||
list.addListSelectionListener(e -> ActionEditor.this.updateEdit());
|
||||
addButton("add", e -> ActionEditor.this.addAction());
|
||||
addButton("remove", e -> ActionEditor.this.remove());
|
||||
addButton("copy", e -> ActionEditor.this.copy());
|
||||
BorderLayout layout = new BorderLayout();
|
||||
BorderLayout layout=new BorderLayout();
|
||||
setLayout(layout);
|
||||
add(list, BorderLayout.LINE_START);
|
||||
add(toolBar, BorderLayout.PAGE_START);
|
||||
add(edit, BorderLayout.CENTER);
|
||||
add(edit,BorderLayout.CENTER);
|
||||
|
||||
|
||||
edit.addChangeListener(e -> emitChanged());
|
||||
}
|
||||
|
||||
protected void emitChanged() {
|
||||
if (updating)
|
||||
return;
|
||||
@@ -80,64 +73,63 @@ public class ActionEditor extends JComponent {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void copy() {
|
||||
|
||||
int selected = list.getSelectedIndex();
|
||||
if (selected < 0)
|
||||
int selected=list.getSelectedIndex();
|
||||
if(selected<0)
|
||||
return;
|
||||
DialogData.ActionData data = new DialogData.ActionData(model.get(selected));
|
||||
model.add(model.size(), data);
|
||||
DialogData.ActionData data=new DialogData.ActionData(model.get(selected));
|
||||
model.add(model.size(),data);
|
||||
}
|
||||
|
||||
private void updateEdit() {
|
||||
|
||||
int selected = list.getSelectedIndex();
|
||||
if (selected < 0)
|
||||
int selected=list.getSelectedIndex();
|
||||
if(selected<0)
|
||||
return;
|
||||
edit.setCurrentAction(model.get(selected));
|
||||
}
|
||||
|
||||
void addAction() {
|
||||
DialogData.ActionData data = new DialogData.ActionData();
|
||||
model.add(model.size(), data);
|
||||
void addAction()
|
||||
{
|
||||
DialogData.ActionData data=new DialogData.ActionData();
|
||||
model.add(model.size(),data);
|
||||
}
|
||||
|
||||
void remove() {
|
||||
int selected = list.getSelectedIndex();
|
||||
if (selected < 0)
|
||||
void remove()
|
||||
{
|
||||
int selected=list.getSelectedIndex();
|
||||
if(selected<0)
|
||||
return;
|
||||
model.remove(selected);
|
||||
}
|
||||
|
||||
public void setAction(DialogData.ActionData[] actions) {
|
||||
|
||||
model.clear();
|
||||
if (actions == null)
|
||||
if(actions==null)
|
||||
return;
|
||||
for (int i = 0; i < actions.length; i++) {
|
||||
if (actions[i].grantRewards.length > 0) {
|
||||
for (int i=0;i<actions.length;i++) {
|
||||
if (actions[i].grantRewards.length > 0){
|
||||
continue; //handled in separate editor and joined in on save, will get duplicated if it appears here
|
||||
}
|
||||
model.add(i, actions[i]);
|
||||
model.add(i,actions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public DialogData.ActionData[] getAction() {
|
||||
|
||||
DialogData.ActionData[] action = new DialogData.ActionData[model.getSize()];
|
||||
for (int i = 0; i < model.getSize(); i++) {
|
||||
action[i] = model.get(i);
|
||||
DialogData.ActionData[] action= new DialogData.ActionData[model.getSize()];
|
||||
for(int i=0;i<model.getSize();i++)
|
||||
{
|
||||
action[i]=model.get(i);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
public void clear(){
|
||||
updating = true;
|
||||
model.clear();
|
||||
updating = false;
|
||||
}
|
||||
|
||||
public void addChangeListener(ChangeListener listener) {
|
||||
listenerList.add(ChangeListener.class, listener);
|
||||
}
|
||||
@@ -45,16 +45,17 @@ public class BiomeStructureDataMappingEditor extends JComponent {
|
||||
JList list, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
if(!(value instanceof BiomeStructureData.BiomeStructureDataMapping biomeData))
|
||||
if(!(value instanceof BiomeStructureData.BiomeStructureDataMapping))
|
||||
return label;
|
||||
BiomeStructureData.BiomeStructureDataMapping data=(BiomeStructureData.BiomeStructureDataMapping) value;
|
||||
// Get the renderer component from parent class
|
||||
|
||||
label.setText(biomeData.name);
|
||||
label.setText(data.name);
|
||||
if(editor.data!=null)
|
||||
{
|
||||
SwingAtlas itemAtlas=new SwingAtlas(Config.instance().getFile(editor.data.structureAtlasPath));
|
||||
if(itemAtlas.has(biomeData.name))
|
||||
label.setIcon(itemAtlas.get(biomeData.name));
|
||||
if(itemAtlas.has(data.name))
|
||||
label.setIcon(itemAtlas.get(data.name));
|
||||
else
|
||||
{
|
||||
ImageIcon img=itemAtlas.getAny();
|
||||
@@ -25,8 +25,9 @@ public class DialogOptionEditor extends JComponent{
|
||||
JList list, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
if(!(value instanceof DialogData dialog))
|
||||
if(!(value instanceof DialogData))
|
||||
return label;
|
||||
DialogData dialog=(DialogData) value;
|
||||
StringBuilder builder=new StringBuilder();
|
||||
if(dialog.name==null||dialog.name.isEmpty())
|
||||
builder.append("[[Blank Option]]");
|
||||
@@ -0,0 +1,62 @@
|
||||
package forge.adventure.editor;
|
||||
|
||||
|
||||
|
||||
import com.badlogic.gdx.tools.particleeditor.ParticleEditor;
|
||||
import forge.localinstance.properties.ForgeConstants;
|
||||
import forge.localinstance.properties.ForgePreferences;
|
||||
import forge.model.FModel;
|
||||
import forge.util.Lang;
|
||||
import forge.util.Localizer;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Editor class to edit configuration, maybe moved or removed
|
||||
*/
|
||||
public class EditorMainWindow extends JFrame {
|
||||
public final static WorldEditor worldEditor = new WorldEditor();
|
||||
JTabbedPane tabs =new JTabbedPane();
|
||||
|
||||
public EditorMainWindow()
|
||||
{
|
||||
UIManager.LookAndFeelInfo[] var1 = UIManager.getInstalledLookAndFeels();
|
||||
FModel.initialize(null, preferences -> {
|
||||
preferences.setPref(ForgePreferences.FPref.LOAD_CARD_SCRIPTS_LAZILY, true);
|
||||
return null;
|
||||
});
|
||||
Lang.createInstance(FModel.getPreferences().getPref(ForgePreferences.FPref.UI_LANGUAGE));
|
||||
Localizer.getInstance().initialize(FModel.getPreferences().getPref(ForgePreferences.FPref.UI_LANGUAGE), ForgeConstants.LANG_DIR);
|
||||
int var2 = var1.length;
|
||||
|
||||
for (UIManager.LookAndFeelInfo info : var1) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
try {
|
||||
UIManager.setLookAndFeel(info.getClassName());
|
||||
} catch (Throwable var6) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
BorderLayout layout=new BorderLayout();
|
||||
JToolBar toolBar = new JToolBar("toolbar");
|
||||
JButton newButton=new JButton("open ParticleEditor");
|
||||
newButton.addActionListener(e -> EventQueue.invokeLater(ParticleEditor::new));
|
||||
toolBar.add(newButton);
|
||||
setLayout(layout);
|
||||
toolBar.setFloatable(false);
|
||||
add(toolBar, BorderLayout.NORTH);
|
||||
add(tabs, BorderLayout.CENTER);
|
||||
tabs.addTab("World",worldEditor);
|
||||
tabs.addTab("POI",new PointOfInterestEditor());
|
||||
tabs.addTab("Items",new ItemsEditor());
|
||||
tabs.addTab("Enemies",new EnemyEditor());
|
||||
tabs.addTab("Quests",new QuestEditor());
|
||||
|
||||
setVisible(true);
|
||||
setSize(800,600);
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow( this );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -27,16 +27,17 @@ public class ItemsEditor extends JComponent {
|
||||
JList list, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
if(!(value instanceof ItemData item))
|
||||
if(!(value instanceof ItemData))
|
||||
return label;
|
||||
ItemData Item=(ItemData) value;
|
||||
// Get the renderer component from parent class
|
||||
|
||||
label.setText(item.name);
|
||||
label.setText(Item.name);
|
||||
if(itemAtlas==null)
|
||||
itemAtlas=new SwingAtlas(Config.instance().getFile(Paths.ITEMS_ATLAS));
|
||||
|
||||
if(itemAtlas.has(item.iconName))
|
||||
label.setIcon(itemAtlas.get(item.iconName));
|
||||
if(itemAtlas.has(Item.iconName))
|
||||
label.setIcon(itemAtlas.get(Item.iconName));
|
||||
else
|
||||
{
|
||||
ImageIcon img=itemAtlas.getAny();
|
||||
@@ -2,23 +2,10 @@ package forge.adventure.editor;
|
||||
|
||||
import forge.adventure.data.AdventureQuestData;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListDataEvent;
|
||||
import javax.swing.event.ListDataListener;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
@@ -298,7 +285,7 @@ public class QuestEdit extends FormPanel {
|
||||
}
|
||||
setVisible(true);
|
||||
updating=true;
|
||||
id.setText(String.valueOf(currentData.getID()));
|
||||
id.setText(currentData.getID() + "");
|
||||
name.setText(currentData.name);
|
||||
description.setText(currentData.description);
|
||||
synopsis.setText(currentData.synopsis);
|
||||
@@ -26,8 +26,9 @@ public class QuestEditor extends JComponent {
|
||||
JList list, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
if(!(value instanceof AdventureQuestData quest))
|
||||
if(!(value instanceof AdventureQuestData))
|
||||
return label;
|
||||
AdventureQuestData quest=(AdventureQuestData) value;
|
||||
// Get the renderer component from parent class
|
||||
|
||||
label.setText(quest.name);
|
||||
@@ -26,8 +26,9 @@ public class QuestStageEditor extends JComponent{
|
||||
JList list, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
if(!(value instanceof AdventureQuestStage stageData))
|
||||
if(!(value instanceof AdventureQuestStage))
|
||||
return label;
|
||||
AdventureQuestStage stageData=(AdventureQuestStage) value;
|
||||
label.setText(stageData.name);
|
||||
//label.setIcon(new ImageIcon(Config.instance().getFilePath(stageData.sourcePath))); //Type icon eventually?
|
||||
return label;
|
||||
@@ -25,10 +25,10 @@ public class RewardEdit extends FormPanel {
|
||||
TextListEdit colors =new TextListEdit(new String[] { "White", "Blue", "Black", "Red", "Green" });
|
||||
TextListEdit rarity =new TextListEdit(new String[] { "Basic Land", "Common", "Uncommon", "Rare", "Mythic Rare" });
|
||||
TextListEdit subTypes =new TextListEdit();
|
||||
TextListEdit cardTypes =new TextListEdit(Arrays.stream(CardType.CoreType.values()).map(CardType.CoreType::toString).toArray(String[]::new));
|
||||
TextListEdit superTypes =new TextListEdit(Arrays.stream(CardType.Supertype.values()).map(CardType.Supertype::toString).toArray(String[]::new));
|
||||
TextListEdit cardTypes =new TextListEdit(Arrays.asList(CardType.CoreType.values()).stream().map(CardType.CoreType::toString).toArray(String[]::new));
|
||||
TextListEdit superTypes =new TextListEdit(Arrays.asList(CardType.Supertype.values()).stream().map(CardType.Supertype::toString).toArray(String[]::new));
|
||||
TextListEdit manaCosts =new TextListEdit();
|
||||
TextListEdit keyWords =new TextListEdit(Arrays.stream(Keyword.values()).map(Keyword::toString).toArray(String[]::new));
|
||||
TextListEdit keyWords =new TextListEdit(Arrays.asList(Keyword.values()).stream().map(Keyword::toString).toArray(String[]::new));
|
||||
JComboBox colorType =new JComboBox(new String[] { "Any", "Colorless", "MultiColor", "MonoColor"});
|
||||
JTextField cardText =new JTextField();
|
||||
private boolean updating=false;
|
||||
@@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -65,7 +65,7 @@ public class SwingAtlas {
|
||||
return new ImageIcon(img.getSubimage(sprite.left,sprite.top, sprite.width, sprite.height).getScaledInstance((int) (imageSize*(sprite.width/(float)sprite.height)),imageSize,SCALE_FAST));
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (IOException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -3,17 +3,10 @@ package forge.adventure.editor;
|
||||
import forge.adventure.data.BiomeData;
|
||||
import forge.adventure.data.BiomeTerrainData;
|
||||
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JToolBar;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
@@ -36,11 +29,11 @@ public class TerrainsEditor extends JComponent{
|
||||
if(!(value instanceof BiomeTerrainData))
|
||||
return label;
|
||||
BiomeTerrainData terrainData=(BiomeTerrainData) value;
|
||||
/*StringBuilder builder=new StringBuilder();
|
||||
StringBuilder builder=new StringBuilder();
|
||||
builder.append("Terrain");
|
||||
builder.append(" ");
|
||||
builder.append(terrainData.spriteName);*/
|
||||
label.setText("Terrain " + terrainData.spriteName);
|
||||
builder.append(terrainData.spriteName);
|
||||
label.setText(builder.toString());
|
||||
return label;
|
||||
}
|
||||
}
|
||||
@@ -43,8 +43,9 @@ public class WorldEditor extends JComponent {
|
||||
JList list, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
if(!(value instanceof BiomeData biome))
|
||||
if(!(value instanceof BiomeData))
|
||||
return label;
|
||||
BiomeData biome=(BiomeData) value;
|
||||
// Get the renderer component from parent class
|
||||
|
||||
label.setText(biome.name);
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<artifactId>forge</artifactId>
|
||||
<groupId>forge</groupId>
|
||||
<version>${revision}</version>
|
||||
<version>1.6.65</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>forge-ai</artifactId>
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class AiDeckStatistics {
|
||||
public class AIDeckStatistics {
|
||||
|
||||
public float averageCMC = 0;
|
||||
// TODO implement this. Use a numerically stable algorithm from
|
||||
@@ -24,9 +24,9 @@ public class AiDeckStatistics {
|
||||
|
||||
// in WUBRGC order from ManaCost.getColorShardCounts()
|
||||
public int[] maxPips = null;
|
||||
// public int[] numSources = new int[6];
|
||||
// public int[] numSources = new int[6];
|
||||
public int numLands = 0;
|
||||
public AiDeckStatistics(float averageCMC, float stddevCMC, int maxCost, int maxColoredCost, int[] maxPips, int numLands) {
|
||||
public AIDeckStatistics(float averageCMC, float stddevCMC, int maxCost, int maxColoredCost, int[] maxPips, int numLands) {
|
||||
this.averageCMC = averageCMC;
|
||||
this.stddevCMC = stddevCMC;
|
||||
this.maxCost = maxCost;
|
||||
@@ -35,7 +35,7 @@ public class AiDeckStatistics {
|
||||
this.numLands = numLands;
|
||||
}
|
||||
|
||||
public static AiDeckStatistics fromCards(List<Card> cards) {
|
||||
public static AIDeckStatistics fromCards(List<Card> cards) {
|
||||
int totalCMC = 0;
|
||||
int totalCount = 0;
|
||||
int numLands = 0;
|
||||
@@ -75,7 +75,7 @@ public class AiDeckStatistics {
|
||||
|
||||
}
|
||||
|
||||
return new AiDeckStatistics(totalCount == 0 ? 0 : totalCMC / (float)totalCount,
|
||||
return new AIDeckStatistics(totalCount == 0 ? 0 : totalCMC / (float)totalCount,
|
||||
0, // TODO use https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
|
||||
maxCost,
|
||||
maxColoredCost,
|
||||
@@ -85,7 +85,7 @@ public class AiDeckStatistics {
|
||||
}
|
||||
|
||||
|
||||
public static AiDeckStatistics fromDeck(Deck deck, Player player) {
|
||||
public static AIDeckStatistics fromDeck(Deck deck, Player player) {
|
||||
List<Card> cardlist = new ArrayList<>();
|
||||
for (final Map.Entry<DeckSection, CardPool> deckEntry : deck) {
|
||||
switch (deckEntry.getKey()) {
|
||||
@@ -104,7 +104,7 @@ public class AiDeckStatistics {
|
||||
return fromCards(cardlist);
|
||||
}
|
||||
|
||||
public static AiDeckStatistics fromPlayer(Player player) {
|
||||
public static AIDeckStatistics fromPlayer(Player player) {
|
||||
Deck deck = player.getRegisteredPlayer().getDeck();
|
||||
if (deck.isEmpty()) {
|
||||
// we're in a test or some weird match, search through the hand and library and build the decklist
|
||||
@@ -120,6 +120,7 @@ public class AiDeckStatistics {
|
||||
}
|
||||
|
||||
return fromDeck(deck, player);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package forge.ai;
|
||||
|
||||
public record AiAbilityDecision(int rating, AiPlayDecision decision) {
|
||||
private static int MIN_RATING = 30;
|
||||
|
||||
public boolean willingToPlay() {
|
||||
return rating > MIN_RATING && decision.willingToPlay();
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
package forge.ai;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import forge.ai.ability.AnimateAi;
|
||||
@@ -37,21 +39,17 @@ import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.SpellAbilityPredicates;
|
||||
import forge.game.staticability.StaticAbility;
|
||||
import forge.game.staticability.StaticAbilityAssignCombatDamageAsUnblocked;
|
||||
import forge.game.staticability.StaticAbilityMode;
|
||||
import forge.game.trigger.Trigger;
|
||||
import forge.game.trigger.TriggerType;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.*;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.Expressions;
|
||||
import forge.util.MyRandom;
|
||||
import forge.util.collect.FCollection;
|
||||
import forge.util.collect.FCollectionView;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
||||
/**
|
||||
@@ -76,9 +74,6 @@ public class AiAttackController {
|
||||
|
||||
private int aiAggression = 0; // how aggressive the ai is attack will be depending on circumstances
|
||||
private final boolean nextTurn; // include creature that can only attack/block next turn
|
||||
private final int timeOut;
|
||||
private final boolean canUseTimeout;
|
||||
private List<CompletableFuture<Integer>> futures = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -96,8 +91,6 @@ public class AiAttackController {
|
||||
myList = ai.getCreaturesInPlay();
|
||||
this.nextTurn = nextTurn;
|
||||
refreshCombatants(defendingOpponent);
|
||||
this.timeOut = ai.getGame().getAITimeout();
|
||||
this.canUseTimeout = ai.getGame().canUseTimeout();
|
||||
} // overloaded constructor to evaluate attackers that should attack next turn
|
||||
|
||||
public AiAttackController(final Player ai, Card attacker) {
|
||||
@@ -111,13 +104,11 @@ public class AiAttackController {
|
||||
attackers.add(attacker);
|
||||
}
|
||||
this.blockers = getPossibleBlockers(oppList, this.attackers, this.nextTurn);
|
||||
this.timeOut = ai.getGame().getAITimeout();
|
||||
this.canUseTimeout = ai.getGame().canUseTimeout();
|
||||
} // overloaded constructor to evaluate single specified attacker
|
||||
|
||||
private void refreshCombatants(GameEntity defender) {
|
||||
if (defender instanceof Card card && card.isBattle()) {
|
||||
this.oppList = getOpponentCreatures(card.getProtectingPlayer());
|
||||
if (defender instanceof Card && ((Card) defender).isBattle()) {
|
||||
this.oppList = getOpponentCreatures(((Card) defender).getProtectingPlayer());
|
||||
} else {
|
||||
this.oppList = getOpponentCreatures(defendingOpponent);
|
||||
}
|
||||
@@ -138,22 +129,20 @@ public class AiAttackController {
|
||||
|
||||
CardCollection tappedDefenders = new CardCollection();
|
||||
for (Card c : CardLists.filter(defender.getCardsIn(ZoneType.Battlefield), canAnimate)) {
|
||||
for (SpellAbility sa : IterableUtil.filter(c.getSpellAbilities(), SpellAbilityPredicates.isApi(ApiType.Animate))) {
|
||||
for (SpellAbility sa : Iterables.filter(c.getSpellAbilities(), SpellAbilityPredicates.isApi(ApiType.Animate))) {
|
||||
if (sa.usesTargeting() || !sa.getParamOrDefault("Defined", "Self").equals("Self")) {
|
||||
continue;
|
||||
}
|
||||
sa.setActivatingPlayer(defender);
|
||||
if (sa.isCrew() && !ComputerUtilCost.checkTapTypeCost(defender, sa.getPayCosts(), c, sa, tappedDefenders)) {
|
||||
continue;
|
||||
}
|
||||
if (!ComputerUtilCost.canPayCost(sa, defender, false) || !sa.getRestrictions().checkOtherRestrictions(c, sa, defender)) {
|
||||
} else if (!ComputerUtilCost.canPayCost(sa, defender, false) || !sa.getRestrictions().checkOtherRestrictions(c, sa, defender)) {
|
||||
continue;
|
||||
}
|
||||
Card animatedCopy = AnimateAi.becomeAnimated(c, sa);
|
||||
if (animatedCopy.isCreature()) {
|
||||
// TODO imprecise, only works 100% for colorless mana
|
||||
int saCMC = sa.getPayCosts() != null && sa.getPayCosts().hasManaCost() ?
|
||||
sa.getPayCosts().getTotalMana().getCMC() : 0;
|
||||
sa.getPayCosts().getTotalMana().getCMC() : 0; // FIXME: imprecise, only works 100% for colorless mana
|
||||
if (totalMana - manaReserved >= saCMC) {
|
||||
manaReserved += saCMC;
|
||||
defenders.add(animatedCopy);
|
||||
@@ -164,7 +153,7 @@ public class AiAttackController {
|
||||
defenders.removeAll(tappedDefenders);
|
||||
|
||||
// Transform (e.g. Incubator tokens)
|
||||
for (SpellAbility sa : IterableUtil.filter(c.getSpellAbilities(), SpellAbilityPredicates.isApi(ApiType.SetState))) {
|
||||
for (SpellAbility sa : Iterables.filter(c.getSpellAbilities(), SpellAbilityPredicates.isApi(ApiType.SetState))) {
|
||||
Card transformedCopy = ComputerUtilCombat.canTransform(c);
|
||||
if (transformedCopy.isCreature()) {
|
||||
int saCMC = sa.getPayCosts() != null && sa.getPayCosts().hasManaCost() ?
|
||||
@@ -315,8 +304,7 @@ public class AiAttackController {
|
||||
}
|
||||
}
|
||||
// Poison opponent if unblocked
|
||||
if (defender instanceof Player player
|
||||
&& ComputerUtilCombat.poisonIfUnblocked(attacker, player) > 0) {
|
||||
if (defender instanceof Player && ComputerUtilCombat.poisonIfUnblocked(attacker, (Player) defender) > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -627,9 +615,9 @@ public class AiAttackController {
|
||||
// TODO: the AI should ideally predict how many times it can activate
|
||||
// for now, unless the opponent is tapped out, break at this point
|
||||
// and do not predict the blocker limit (which is safer)
|
||||
if (defendingOpponent.getLandsInPlay().anyMatch(CardPredicates.UNTAPPED)) {
|
||||
if (Iterables.any(defendingOpponent.getLandsInPlay(), CardPredicates.Presets.UNTAPPED)) {
|
||||
maxBlockersAfterCrew += CardLists.count(CardLists.getNotType(defendingOpponent.getCardsIn(ZoneType.Battlefield), "Creature"),
|
||||
CardPredicates.isType("Vehicle").and(CardPredicates.UNTAPPED));
|
||||
Predicates.and(CardPredicates.isType("Vehicle"), CardPredicates.Presets.UNTAPPED));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -853,9 +841,10 @@ public class AiAttackController {
|
||||
// decided to attack another defender so related lists need to be updated
|
||||
// (though usually rather try to avoid this situation for performance reasons)
|
||||
if (defender != defendingOpponent) {
|
||||
if (defender instanceof Player p) {
|
||||
defendingOpponent = p;
|
||||
} else if (defender instanceof Card defCard) {
|
||||
if (defender instanceof Player) {
|
||||
defendingOpponent = (Player) defender;
|
||||
} else if (defender instanceof Card) {
|
||||
Card defCard = (Card) defender;
|
||||
if (defCard.isBattle()) {
|
||||
defendingOpponent = defCard.getProtectingPlayer();
|
||||
} else {
|
||||
@@ -895,7 +884,7 @@ public class AiAttackController {
|
||||
// TODO: detect Season of the Witch by presence of a card with a specific trigger
|
||||
final boolean seasonOfTheWitch = ai.getGame().isCardInPlay("Season of the Witch");
|
||||
|
||||
final Queue<Card> attackersLeft = new ConcurrentLinkedQueue<>(this.attackers);
|
||||
List<Card> attackersLeft = new ArrayList<>(this.attackers);
|
||||
|
||||
// TODO probably use AttackConstraints instead of only GlobalAttackRestrictions?
|
||||
GlobalAttackRestrictions restrict = GlobalAttackRestrictions.getGlobalRestrictions(ai, combat.getDefenders());
|
||||
@@ -911,27 +900,25 @@ public class AiAttackController {
|
||||
}
|
||||
|
||||
// Attackers that don't really have a choice
|
||||
final AtomicInteger numForcedAttackers = new AtomicInteger(0);
|
||||
int numForcedAttackers = 0;
|
||||
// nextTurn is now only used by effect from Oracle en-Vec, which can skip check must attack,
|
||||
// because creatures not chosen can't attack.
|
||||
if (!nextTurn) {
|
||||
for (final Card attacker : this.attackers) {
|
||||
final GameEntity finalDefender = defender;
|
||||
futures.add(CompletableFuture.supplyAsync(()-> {
|
||||
GameEntity mustAttackDef = null;
|
||||
if (attacker.getSVar("MustAttack").equals("True")) {
|
||||
mustAttackDef = finalDefender;
|
||||
mustAttackDef = defender;
|
||||
} else if (attacker.hasSVar("EndOfTurnLeavePlay")
|
||||
&& isEffectiveAttacker(ai, attacker, combat, finalDefender)) {
|
||||
mustAttackDef = finalDefender;
|
||||
&& isEffectiveAttacker(ai, attacker, combat, defender)) {
|
||||
mustAttackDef = defender;
|
||||
} else if (seasonOfTheWitch) {
|
||||
//TODO: if there are other ways to tap this creature (like mana creature), then don't need to attack
|
||||
mustAttackDef = finalDefender;
|
||||
mustAttackDef = defender;
|
||||
} else {
|
||||
if (combat.getAttackConstraints().getRequirements().get(attacker) == null) return 0;
|
||||
if (combat.getAttackConstraints().getRequirements().get(attacker) == null) continue;
|
||||
// check defenders in order of maximum requirements
|
||||
List<Pair<GameEntity, Integer>> reqs = combat.getAttackConstraints().getRequirements().get(attacker).getSortedRequirements();
|
||||
final GameEntity def = finalDefender;
|
||||
final GameEntity def = defender;
|
||||
reqs.sort((r1, r2) -> {
|
||||
if (r1.getValue() == r2.getValue()) {
|
||||
// try to attack the designated defender
|
||||
@@ -949,8 +936,8 @@ public class AiAttackController {
|
||||
return 1;
|
||||
}
|
||||
// or weakest player
|
||||
if (r1.getKey() instanceof Player p1 && r2.getKey() instanceof Player p2) {
|
||||
return p1.getLife() - p2.getLife();
|
||||
if (r1.getKey() instanceof Player && r2.getKey() instanceof Player) {
|
||||
return ((Player) r1.getKey()).getLife() - ((Player) r2.getKey()).getLife();
|
||||
}
|
||||
}
|
||||
return r2.getValue() - r1.getValue();
|
||||
@@ -967,20 +954,9 @@ public class AiAttackController {
|
||||
if (mustAttackDef != null) {
|
||||
combat.addAttacker(attacker, mustAttackDef);
|
||||
attackersLeft.remove(attacker);
|
||||
numForcedAttackers.incrementAndGet();
|
||||
numForcedAttackers++;
|
||||
}
|
||||
return 0;
|
||||
}).exceptionally(ex -> {
|
||||
ex.printStackTrace();
|
||||
return 0;
|
||||
}));
|
||||
}
|
||||
CompletableFuture<?>[] futuresArray = futures.toArray(new CompletableFuture<?>[0]);
|
||||
if (canUseTimeout)
|
||||
CompletableFuture.allOf(futuresArray).completeOnTimeout(null, timeOut, TimeUnit.SECONDS).join();
|
||||
else
|
||||
CompletableFuture.allOf(futuresArray).join();
|
||||
futures.clear();
|
||||
if (attackersLeft.isEmpty()) {
|
||||
return aiAggression;
|
||||
}
|
||||
@@ -988,19 +964,18 @@ public class AiAttackController {
|
||||
|
||||
// Lightmine Field: make sure the AI doesn't wipe out its own creatures
|
||||
if (lightmineField) {
|
||||
doLightmineFieldAttackLogic(attackersLeft, numForcedAttackers.get(), playAggro);
|
||||
doLightmineFieldAttackLogic(attackersLeft, numForcedAttackers, playAggro);
|
||||
}
|
||||
// Revenge of Ravens: make sure the AI doesn't kill itself and doesn't damage itself unnecessarily
|
||||
if (!doRevengeOfRavensAttackLogic(defender, attackersLeft, numForcedAttackers.get(), attackMax)) {
|
||||
if (!doRevengeOfRavensAttackLogic(defender, attackersLeft, numForcedAttackers, attackMax)) {
|
||||
return aiAggression;
|
||||
}
|
||||
|
||||
if (bAssault && defender == defendingOpponent) { // in case we are forced to attack someone else
|
||||
if (LOG_AI_ATTACKS)
|
||||
System.out.println("Assault");
|
||||
List<Card> left = new ArrayList<>(attackersLeft);
|
||||
CardLists.sortByPowerDesc(left);
|
||||
for (Card attacker : left) {
|
||||
CardLists.sortByPowerDesc(attackersLeft);
|
||||
for (Card attacker : attackersLeft) {
|
||||
// reached max, breakup
|
||||
if (attackMax != -1 && combat.getAttackers().size() >= attackMax)
|
||||
return aiAggression;
|
||||
@@ -1290,20 +1265,19 @@ public class AiAttackController {
|
||||
if ( LOG_AI_ATTACKS )
|
||||
System.out.println("Normal attack");
|
||||
|
||||
List<Card> left = new ArrayList<>(attackersLeft);
|
||||
left = notNeededAsBlockers(combat.getAttackers(), left);
|
||||
left = sortAttackers(left);
|
||||
attackersLeft = notNeededAsBlockers(combat.getAttackers(), attackersLeft);
|
||||
attackersLeft = sortAttackers(attackersLeft);
|
||||
|
||||
if ( LOG_AI_ATTACKS )
|
||||
System.out.println("attackersLeft = " + left);
|
||||
System.out.println("attackersLeft = " + attackersLeft);
|
||||
|
||||
FCollection<GameEntity> possibleDefenders = new FCollection<>(defendingOpponent);
|
||||
possibleDefenders.addAll(defendingOpponent.getPlaneswalkersInPlay());
|
||||
|
||||
while (!left.isEmpty()) {
|
||||
while (!attackersLeft.isEmpty()) {
|
||||
CardCollection attackersAssigned = new CardCollection();
|
||||
for (int i = 0; i < left.size(); i++) {
|
||||
final Card attacker = left.get(i);
|
||||
for (int i = 0; i < attackersLeft.size(); i++) {
|
||||
final Card attacker = attackersLeft.get(i);
|
||||
if (aiAggression < 5 && !attacker.hasFirstStrike() && !attacker.hasDoubleStrike()
|
||||
&& ComputerUtilCombat.getTotalFirstStrikeBlockPower(attacker, defendingOpponent)
|
||||
>= ComputerUtilCombat.getDamageToKill(attacker, false)) {
|
||||
@@ -1317,7 +1291,7 @@ public class AiAttackController {
|
||||
attackersAssigned.add(attacker);
|
||||
|
||||
// check if attackers are enough to finish the attacked planeswalker
|
||||
if (i < left.size() - 1 && defender instanceof Card card) {
|
||||
if (i < attackersLeft.size() - 1 && defender instanceof Card) {
|
||||
final int blockNum = this.blockers.size();
|
||||
int attackNum = 0;
|
||||
int damage = 0;
|
||||
@@ -1331,19 +1305,19 @@ public class AiAttackController {
|
||||
}
|
||||
}
|
||||
// if enough damage: switch to next planeswalker
|
||||
if (damage >= ComputerUtilCombat.getDamageToKill(card, true)) {
|
||||
if (damage >= ComputerUtilCombat.getDamageToKill((Card) defender, true)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
left.removeAll(attackersAssigned);
|
||||
attackersLeft.removeAll(attackersAssigned);
|
||||
possibleDefenders.remove(defender);
|
||||
if (left.isEmpty() || possibleDefenders.isEmpty()) {
|
||||
if (attackersLeft.isEmpty() || possibleDefenders.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
CardCollection pwDefending = new CardCollection(IterableUtil.filter(possibleDefenders, Card.class));
|
||||
CardCollection pwDefending = new CardCollection(Iterables.filter(possibleDefenders, Card.class));
|
||||
if (pwDefending.isEmpty()) {
|
||||
// TODO for now only looks at same player as we'd have to check the others from start too
|
||||
//defender = new PlayerCollection(Iterables.filter(possibleDefenders, Player.class)).min(PlayerPredicates.compareByLife());
|
||||
@@ -1393,13 +1367,12 @@ public class AiAttackController {
|
||||
canTrampleOverDefenders = attacker.hasKeyword(Keyword.TRAMPLE) && attacker.getNetCombatDamage() > Aggregates.sum(validBlockers, Card::getNetToughness);
|
||||
|
||||
// used to check that CanKillAllDangerous check makes sense in context where creatures with dangerous abilities are present
|
||||
dangerousBlockersPresent = validBlockers.anyMatch(
|
||||
CardPredicates.hasKeyword(Keyword.LIFELINK)
|
||||
.or(Card::isWitherDamage)
|
||||
);
|
||||
dangerousBlockersPresent = Iterables.any(validBlockers, Predicates.or(
|
||||
CardPredicates.hasKeyword(Keyword.WITHER), CardPredicates.hasKeyword(Keyword.INFECT),
|
||||
CardPredicates.hasKeyword(Keyword.LIFELINK)));
|
||||
|
||||
// total power of the defending creatures, used in predicting whether a gang block can kill the attacker
|
||||
defPower = CardLists.getTotalPower(validBlockers, null);
|
||||
defPower = CardLists.getTotalPower(validBlockers, true, false);
|
||||
|
||||
// look at the attacker in relation to the blockers to establish a
|
||||
// number of factors about the attacking context that will be relevant
|
||||
@@ -1424,7 +1397,7 @@ public class AiAttackController {
|
||||
canKillAll = false;
|
||||
|
||||
if (blocker.getSVar("HasCombatEffect").equals("TRUE") || blocker.getSVar("HasBlockEffect").equals("TRUE")
|
||||
|| blocker.isWitherDamage() || blocker.hasKeyword(Keyword.LIFELINK)) {
|
||||
|| blocker.hasKeyword(Keyword.WITHER) || blocker.hasKeyword(Keyword.INFECT) || blocker.hasKeyword(Keyword.LIFELINK)) {
|
||||
canKillAllDangerous = false;
|
||||
// there is a creature that can survive an attack from this creature
|
||||
// and combat will have negative effects
|
||||
@@ -1590,7 +1563,7 @@ public class AiAttackController {
|
||||
// but there are no creatures it can target, no need to exert with it
|
||||
boolean missTarget = false;
|
||||
for (StaticAbility st : c.getStaticAbilities()) {
|
||||
if (!st.checkMode(StaticAbilityMode.OptionalAttackCost)) {
|
||||
if (!"OptionalAttackCost".equals(st.getParam("Mode"))) {
|
||||
continue;
|
||||
}
|
||||
SpellAbility sa = st.getPayingTrigSA();
|
||||
@@ -1612,12 +1585,12 @@ public class AiAttackController {
|
||||
break;
|
||||
}
|
||||
if (sa.usesTargeting()) {
|
||||
sa.setActivatingPlayer(c.getController());
|
||||
sa.setActivatingPlayer(c.getController(), true);
|
||||
List<Card> validTargets = CardUtil.getValidCardsToTarget(sa);
|
||||
if (validTargets.isEmpty()) {
|
||||
missTarget = true;
|
||||
break;
|
||||
} else if (sa.isCurse() && validTargets.stream().noneMatch(
|
||||
} else if (sa.isCurse() && !Iterables.any(validTargets,
|
||||
CardPredicates.isControlledByAnyOf(c.getController().getOpponents()))) {
|
||||
// e.g. Ahn-Crop Crasher - the effect is only good when aimed at opponent's creatures
|
||||
missTarget = true;
|
||||
@@ -1724,7 +1697,7 @@ public class AiAttackController {
|
||||
return null; //should never get here
|
||||
}
|
||||
|
||||
private void doLightmineFieldAttackLogic(final Queue<Card> attackersLeft, int numForcedAttackers, boolean playAggro) {
|
||||
private void doLightmineFieldAttackLogic(final List<Card> attackersLeft, int numForcedAttackers, boolean playAggro) {
|
||||
CardCollection attSorted = new CardCollection(attackersLeft);
|
||||
CardCollection attUnsafe = new CardCollection();
|
||||
CardLists.sortByToughnessDesc(attSorted);
|
||||
@@ -1754,15 +1727,13 @@ public class AiAttackController {
|
||||
attackersLeft.removeAll(attUnsafe);
|
||||
}
|
||||
|
||||
private boolean doRevengeOfRavensAttackLogic(final GameEntity defender, final Queue<Card> attackersLeft, int numForcedAttackers, int maxAttack) {
|
||||
private boolean doRevengeOfRavensAttackLogic(final GameEntity defender, final List<Card> attackersLeft, int numForcedAttackers, int maxAttack) {
|
||||
// TODO: detect Revenge of Ravens by the trigger instead of by name
|
||||
boolean revengeOfRavens = false;
|
||||
if (defender instanceof Player player) {
|
||||
revengeOfRavens = !CardLists.filter(player.getCardsIn(ZoneType.Battlefield),
|
||||
CardPredicates.nameEquals("Revenge of Ravens")).isEmpty();
|
||||
} else if (defender instanceof Card card) {
|
||||
revengeOfRavens = !CardLists.filter(card.getController().getCardsIn(ZoneType.Battlefield),
|
||||
CardPredicates.nameEquals("Revenge of Ravens")).isEmpty();
|
||||
if (defender instanceof Player) {
|
||||
revengeOfRavens = !CardLists.filter(((Player)defender).getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Revenge of Ravens")).isEmpty();
|
||||
} else if (defender instanceof Card) {
|
||||
revengeOfRavens = !CardLists.filter(((Card)defender).getController().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Revenge of Ravens")).isEmpty();
|
||||
}
|
||||
|
||||
if (!revengeOfRavens) {
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
package forge.ai;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import forge.card.CardStateName;
|
||||
import forge.game.GameEntity;
|
||||
@@ -161,12 +163,12 @@ public class AiBlockController {
|
||||
// defend battles with fewer defense counters before battles with more defense counters,
|
||||
// if planeswalker/battle will be too difficult to defend don't even bother
|
||||
for (GameEntity defender : defenders) {
|
||||
if ((defender instanceof Card card1 && card1.getController().equals(ai))
|
||||
|| (defender instanceof Card card2 && card2.isBattle() && card2.getProtectingPlayer().equals(ai))) {
|
||||
final CardCollection ccAttackers = combat.getAttackersOf(defender);
|
||||
if ((defender instanceof Card && ((Card) defender).getController().equals(ai))
|
||||
|| (defender instanceof Card && ((Card) defender).isBattle() && ((Card) defender).getProtectingPlayer().equals(ai))) {
|
||||
final CardCollection attackers = combat.getAttackersOf(defender);
|
||||
// Begin with the attackers that pose the biggest threat
|
||||
CardLists.sortByPowerDesc(ccAttackers);
|
||||
sortedAttackers.addAll(ccAttackers);
|
||||
CardLists.sortByPowerDesc(attackers);
|
||||
sortedAttackers.addAll(attackers);
|
||||
} else if (defender instanceof Player && defender.equals(ai)) {
|
||||
firstAttacker = combat.getAttackersOf(defender);
|
||||
CardLists.sortByPowerDesc(firstAttacker);
|
||||
@@ -325,7 +327,7 @@ public class AiBlockController {
|
||||
}
|
||||
|
||||
private Predicate<Card> rampagesOrNeedsManyToBlock(final Combat combat) {
|
||||
return CardPredicates.hasKeyword(Keyword.RAMPAGE).or(input -> {
|
||||
return Predicates.or(CardPredicates.hasKeyword(Keyword.RAMPAGE), input -> {
|
||||
// select creature that has a max blocker
|
||||
return StaticAbilityCantAttackBlock.getMinMaxBlocker(input, combat.getDefenderPlayerByAttacker(input)).getRight() < Integer.MAX_VALUE;
|
||||
});
|
||||
@@ -366,7 +368,7 @@ public class AiBlockController {
|
||||
* @param combat a {@link forge.game.combat.Combat} object.
|
||||
*/
|
||||
private void makeGangBlocks(final Combat combat) {
|
||||
List<Card> currentAttackers = CardLists.filter(attackersLeft, rampagesOrNeedsManyToBlock(combat).negate());
|
||||
List<Card> currentAttackers = CardLists.filter(attackersLeft, Predicates.not(rampagesOrNeedsManyToBlock(combat)));
|
||||
List<Card> blockers;
|
||||
|
||||
// Try to block an attacker without first strike with a gang of first strikers
|
||||
@@ -738,11 +740,11 @@ public class AiBlockController {
|
||||
List<Card> chumpBlockers;
|
||||
|
||||
List<Card> tramplingAttackers = CardLists.getKeyword(attackers, Keyword.TRAMPLE);
|
||||
tramplingAttackers = CardLists.filter(tramplingAttackers, rampagesOrNeedsManyToBlock(combat).negate());
|
||||
tramplingAttackers = CardLists.filter(tramplingAttackers, Predicates.not(rampagesOrNeedsManyToBlock(combat)));
|
||||
|
||||
// TODO - Instead of filtering out rampage-like and similar triggers, make the AI properly count P/T and
|
||||
// reinforce when actually possible without losing material.
|
||||
tramplingAttackers = CardLists.filter(tramplingAttackers, changesPTWhenBlocked(true).negate());
|
||||
tramplingAttackers = CardLists.filter(tramplingAttackers, Predicates.not(changesPTWhenBlocked(true)));
|
||||
|
||||
for (final Card attacker : tramplingAttackers) {
|
||||
if (CombatUtil.getMinNumBlockersForAttacker(attacker, combat.getDefenderPlayerByAttacker(attacker)) > combat.getBlockers(attacker).size()) {
|
||||
@@ -793,11 +795,11 @@ public class AiBlockController {
|
||||
private void reinforceBlockersToKill(final Combat combat) {
|
||||
List<Card> safeBlockers;
|
||||
List<Card> blockers;
|
||||
List<Card> targetAttackers = CardLists.filter(blockedButUnkilled, rampagesOrNeedsManyToBlock(combat).negate());
|
||||
List<Card> targetAttackers = CardLists.filter(blockedButUnkilled, Predicates.not(rampagesOrNeedsManyToBlock(combat)));
|
||||
|
||||
// TODO - Instead of filtering out rampage-like and similar triggers, make the AI properly count P/T and
|
||||
// reinforce when actually possible without losing material.
|
||||
targetAttackers = CardLists.filter(targetAttackers, changesPTWhenBlocked(false).negate());
|
||||
targetAttackers = CardLists.filter(targetAttackers, Predicates.not(changesPTWhenBlocked(false)));
|
||||
|
||||
for (final Card attacker : targetAttackers) {
|
||||
blockers = getPossibleBlockers(combat, attacker, blockersLeft, false);
|
||||
@@ -872,9 +874,9 @@ public class AiBlockController {
|
||||
CardCollection threatenedPWs = new CardCollection();
|
||||
for (final Card attacker : attackers) {
|
||||
GameEntity def = combat.getDefenderByAttacker(attacker);
|
||||
if (def instanceof Card card) {
|
||||
if (def instanceof Card) {
|
||||
if (!onlyIfLethal) {
|
||||
threatenedPWs.add(card);
|
||||
threatenedPWs.add((Card) def);
|
||||
} else {
|
||||
int damageToPW = 0;
|
||||
for (final Card pwatkr : combat.getAttackersOf(def)) {
|
||||
@@ -906,12 +908,12 @@ public class AiBlockController {
|
||||
continue;
|
||||
}
|
||||
GameEntity def = combat.getDefenderByAttacker(attacker);
|
||||
if (def instanceof Card card && threatenedPWs.contains(def)) {
|
||||
if (def instanceof Card && threatenedPWs.contains(def)) {
|
||||
Card blockerDecided = null;
|
||||
for (final Card blocker : chumpPWDefenders) {
|
||||
if (CombatUtil.canBlock(attacker, blocker, combat)) {
|
||||
combat.addBlocker(attacker, blocker);
|
||||
pwsWithChumpBlocks.add(card);
|
||||
pwsWithChumpBlocks.add((Card) def);
|
||||
chosenChumpBlockers.add(blocker);
|
||||
blockerDecided = blocker;
|
||||
blockersLeft.remove(blocker);
|
||||
@@ -1343,11 +1345,11 @@ public class AiBlockController {
|
||||
boolean creatureParityOrAllowedDiff = aiCreatureCount
|
||||
+ (randomTradeIfBehindOnBoard ? maxCreatDiff : 0) >= oppCreatureCount;
|
||||
boolean wantToTradeWithCreatInHand = !checkingOther && randomTradeIfCreatInHand
|
||||
&& ai.getZone(ZoneType.Hand).contains(CardPredicates.CREATURES)
|
||||
&& ai.getZone(ZoneType.Hand).contains(CardPredicates.Presets.CREATURES)
|
||||
&& aiCreatureCount + maxCreatDiffWithRepl >= oppCreatureCount;
|
||||
boolean wantToSavePlaneswalker = MyRandom.percentTrue(chanceToSavePW)
|
||||
&& combat.getDefenderByAttacker(attacker) instanceof Card card
|
||||
&& card.isPlaneswalker();
|
||||
&& combat.getDefenderByAttacker(attacker) instanceof Card
|
||||
&& ((Card) combat.getDefenderByAttacker(attacker)).isPlaneswalker();
|
||||
boolean wantToTradeDownToSavePW = chanceToTradeDownToSaveWalker > 0;
|
||||
|
||||
return ((evalBlk <= evalAtk + 1) || (wantToSavePlaneswalker && wantToTradeDownToSavePW)) // "1" accounts for tapped.
|
||||
|
||||
@@ -18,17 +18,12 @@
|
||||
|
||||
package forge.ai;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* AiCardMemory class.
|
||||
@@ -59,6 +54,7 @@ public class AiCardMemory {
|
||||
ATTACHED_THIS_TURN, // These equipments were attached to something already this turn
|
||||
ANIMATED_THIS_TURN, // These cards had their AF Animate effect activated this turn
|
||||
BOUNCED_THIS_TURN, // These cards were bounced this turn
|
||||
ACTIVATED_THIS_TURN, // These cards had their ability activated this turn
|
||||
CHOSEN_FOG_EFFECT, // These cards are marked as the Fog-like effect the AI is planning to cast this turn
|
||||
MARKED_TO_AVOID_REENTRY, // These cards may cause a stack smash when processed recursively, and are thus marked to avoid a crash
|
||||
PAYS_TAP_COST, // These cards will be tapped as part of a cost and cannot be chosen in another part
|
||||
@@ -66,13 +62,75 @@ public class AiCardMemory {
|
||||
REVEALED_CARDS // These cards were recently revealed to the AI by a call to PlayerControllerAi.reveal
|
||||
}
|
||||
|
||||
private final Supplier<Map<MemorySet, Set<Card>>> memoryMap = Suppliers.memoize(Maps::newConcurrentMap);
|
||||
private final Set<Card> memMandatoryAttackers;
|
||||
private final Set<Card> memTrickAttackers;
|
||||
private final Set<Card> memHeldManaSources;
|
||||
private final Set<Card> memHeldManaSourcesForCombat;
|
||||
private final Set<Card> memHeldManaSourcesForEnemyCombat;
|
||||
private final Set<Card> memHeldManaSourcesForNextSpell;
|
||||
private final Set<Card> memAttachedThisTurn;
|
||||
private final Set<Card> memAnimatedThisTurn;
|
||||
private final Set<Card> memBouncedThisTurn;
|
||||
private final Set<Card> memActivatedThisTurn;
|
||||
private final Set<Card> memChosenFogEffect;
|
||||
private final Set<Card> memMarkedToAvoidReentry;
|
||||
private final Set<Card> memPaysTapCost;
|
||||
private final Set<Card> memPaysSacCost;
|
||||
private final Set<Card> memRevealedCards;
|
||||
|
||||
public AiCardMemory() {
|
||||
this.memMandatoryAttackers = new HashSet<>();
|
||||
this.memHeldManaSources = new HashSet<>();
|
||||
this.memHeldManaSourcesForCombat = new HashSet<>();
|
||||
this.memHeldManaSourcesForEnemyCombat = new HashSet<>();
|
||||
this.memAttachedThisTurn = new HashSet<>();
|
||||
this.memAnimatedThisTurn = new HashSet<>();
|
||||
this.memBouncedThisTurn = new HashSet<>();
|
||||
this.memActivatedThisTurn = new HashSet<>();
|
||||
this.memTrickAttackers = new HashSet<>();
|
||||
this.memChosenFogEffect = new HashSet<>();
|
||||
this.memMarkedToAvoidReentry = new HashSet<>();
|
||||
this.memHeldManaSourcesForNextSpell = new HashSet<>();
|
||||
this.memPaysTapCost = new HashSet<>();
|
||||
this.memPaysSacCost = new HashSet<>();
|
||||
this.memRevealedCards = new HashSet<>();
|
||||
}
|
||||
|
||||
private Set<Card> getMemorySet(MemorySet set) {
|
||||
return memoryMap.get().computeIfAbsent(set, value -> Sets.newConcurrentHashSet());
|
||||
switch (set) {
|
||||
case MANDATORY_ATTACKERS:
|
||||
return memMandatoryAttackers;
|
||||
case TRICK_ATTACKERS:
|
||||
return memTrickAttackers;
|
||||
case HELD_MANA_SOURCES_FOR_MAIN2:
|
||||
return memHeldManaSources;
|
||||
case HELD_MANA_SOURCES_FOR_DECLBLK:
|
||||
return memHeldManaSourcesForCombat;
|
||||
case HELD_MANA_SOURCES_FOR_ENEMY_DECLBLK:
|
||||
return memHeldManaSourcesForEnemyCombat;
|
||||
case HELD_MANA_SOURCES_FOR_NEXT_SPELL:
|
||||
return memHeldManaSourcesForNextSpell;
|
||||
case ATTACHED_THIS_TURN:
|
||||
return memAttachedThisTurn;
|
||||
case ANIMATED_THIS_TURN:
|
||||
return memAnimatedThisTurn;
|
||||
case BOUNCED_THIS_TURN:
|
||||
return memBouncedThisTurn;
|
||||
case ACTIVATED_THIS_TURN:
|
||||
return memActivatedThisTurn;
|
||||
case CHOSEN_FOG_EFFECT:
|
||||
return memChosenFogEffect;
|
||||
case MARKED_TO_AVOID_REENTRY:
|
||||
return memMarkedToAvoidReentry;
|
||||
case PAYS_TAP_COST:
|
||||
return memPaysTapCost;
|
||||
case PAYS_SAC_COST:
|
||||
return memPaysSacCost;
|
||||
case REVEALED_CARDS:
|
||||
return memRevealedCards;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +145,10 @@ public class AiCardMemory {
|
||||
if (c == null) {
|
||||
return false;
|
||||
}
|
||||
return getMemorySet(set).contains(c);
|
||||
|
||||
Set<Card> memorySet = getMemorySet(set);
|
||||
|
||||
return memorySet != null && memorySet.contains(c);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +160,17 @@ public class AiCardMemory {
|
||||
* @return true, if at least one card with the given name is remembered in the given memory set
|
||||
*/
|
||||
public boolean isRememberedCardByName(String cardName, MemorySet set) {
|
||||
return getMemorySet(set).stream().anyMatch(c -> c.getName().equals(cardName));
|
||||
Set<Card> memorySet = getMemorySet(set);
|
||||
|
||||
if (memorySet != null) {
|
||||
for (Card c : memorySet) {
|
||||
if (c.getName().equals(cardName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +184,17 @@ public class AiCardMemory {
|
||||
* @return true, if at least one card with the given name is remembered in the given memory set
|
||||
*/
|
||||
public boolean isRememberedCardByName(String cardName, MemorySet set, Player owner) {
|
||||
return getMemorySet(set).stream().anyMatch(c -> c.getName().equals(cardName) && c.getOwner().equals(owner));
|
||||
Set<Card> memorySet = getMemorySet(set);
|
||||
|
||||
if (memorySet != null) {
|
||||
for (Card c : memorySet) {
|
||||
if (c.getName().equals(cardName) && c.getOwner().equals(owner)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +207,14 @@ public class AiCardMemory {
|
||||
public boolean rememberCard(Card c, MemorySet set) {
|
||||
if (c == null)
|
||||
return false;
|
||||
return getMemorySet(set).add(c);
|
||||
|
||||
Set<Card> memorySet = getMemorySet(set);
|
||||
|
||||
if (memorySet != null) {
|
||||
memorySet.add(c);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +231,14 @@ public class AiCardMemory {
|
||||
if (!isRememberedCard(c, set)) {
|
||||
return false;
|
||||
}
|
||||
return getMemorySet(set).remove(c);
|
||||
|
||||
Set<Card> memorySet = getMemorySet(set);
|
||||
|
||||
if (memorySet != null) {
|
||||
memorySet.remove(c);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,11 +249,16 @@ public class AiCardMemory {
|
||||
* @return true, if at least one card with the given name was previously remembered in the given memory set and was successfully forgotten
|
||||
*/
|
||||
public boolean forgetAnyCardWithName(String cardName, MemorySet set) {
|
||||
for (Card c : getMemorySet(set)) {
|
||||
Set<Card> memorySet = getMemorySet(set);
|
||||
|
||||
if (memorySet != null) {
|
||||
for (Card c : memorySet) {
|
||||
if (c.getName().equals(cardName)) {
|
||||
return forgetCard(c, set);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -171,11 +271,16 @@ public class AiCardMemory {
|
||||
* @return true, if at least one card with the given name was previously remembered in the given memory set and was successfully forgotten
|
||||
*/
|
||||
public boolean forgetAnyCardWithName(String cardName, MemorySet set, Player owner) {
|
||||
for (Card c : getMemorySet(set)) {
|
||||
Set<Card> memorySet = getMemorySet(set);
|
||||
|
||||
if (memorySet != null) {
|
||||
for (Card c : memorySet) {
|
||||
if (c.getName().equals(cardName) && c.getOwner().equals(owner)) {
|
||||
return forgetCard(c, set);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package forge.ai;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.ai.AiCardMemory.MemorySet;
|
||||
import forge.card.CardType;
|
||||
import forge.card.MagicColor;
|
||||
import forge.game.Game;
|
||||
@@ -29,17 +28,10 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
private final CardCollection tapped;
|
||||
|
||||
public AiCostDecision(Player ai0, SpellAbility sa, final boolean effect) {
|
||||
this(ai0, sa, effect, false);
|
||||
}
|
||||
public AiCostDecision(Player ai0, SpellAbility sa, final boolean effect, final boolean payMana) {
|
||||
super(ai0, effect, sa, sa.getHostCard());
|
||||
|
||||
discarded = new CardCollection();
|
||||
tapped = new CardCollection();
|
||||
Set<Card> tappedForMana = AiCardMemory.getMemorySet(ai0, MemorySet.PAYS_TAP_COST);
|
||||
if (!payMana && tappedForMana != null) {
|
||||
tapped.addAll(tappedForMana);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,14 +41,6 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
return PaymentDecision.number(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostBehold cost) {
|
||||
final String type = cost.getType();
|
||||
CardCollectionView hand = player.getCardsIn(cost.getRevealFrom());
|
||||
hand = CardLists.getValidCards(hand, type.split(";"), player, source, ability);
|
||||
return hand.isEmpty() ? null : PaymentDecision.card(getBestCreatureAI(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostChooseColor cost) {
|
||||
int c = cost.getAbilityAmount(ability);
|
||||
@@ -67,7 +51,8 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostChooseCreatureType cost) {
|
||||
String choice = player.getController().chooseSomeType("Creature", ability, CardType.getAllCreatureTypes());
|
||||
String choice = player.getController().chooseSomeType("Creature", ability, CardType.getAllCreatureTypes(),
|
||||
Lists.newArrayList());
|
||||
return PaymentDecision.type(choice);
|
||||
}
|
||||
|
||||
@@ -113,20 +98,20 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
randomSubset = ability.getActivatingPlayer().getController().orderMoveToZoneList(randomSubset, ZoneType.Graveyard, ability);
|
||||
}
|
||||
return PaymentDecision.card(randomSubset);
|
||||
} else if (type.contains("+WithDifferentNames")) {
|
||||
} else if (type.equals("DifferentNames")) {
|
||||
CardCollection differentNames = new CardCollection();
|
||||
CardCollection discardMe = CardLists.filter(hand, CardPredicates.hasSVar("DiscardMe"));
|
||||
while (c > 0) {
|
||||
Card chosen;
|
||||
if (!discardMe.isEmpty()) {
|
||||
chosen = Aggregates.random(discardMe);
|
||||
discardMe = CardLists.filter(discardMe, CardPredicates.sharesNameWith(chosen).negate());
|
||||
discardMe = CardLists.filter(discardMe, Predicates.not(CardPredicates.sharesNameWith(chosen)));
|
||||
} else {
|
||||
final Card worst = ComputerUtilCard.getWorstAI(hand);
|
||||
chosen = worst != null ? worst : Aggregates.random(hand);
|
||||
}
|
||||
differentNames.add(chosen);
|
||||
hand = CardLists.filter(hand, CardPredicates.sharesNameWith(chosen).negate());
|
||||
hand = CardLists.filter(hand, Predicates.not(CardPredicates.sharesNameWith(chosen)));
|
||||
c--;
|
||||
}
|
||||
return PaymentDecision.card(differentNames);
|
||||
@@ -455,6 +440,21 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ("DontPayTapCostWithManaSources".equals(source.getSVar("AIPaymentPreference"))) {
|
||||
CardCollectionView toExclude =
|
||||
CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), type.split(";"),
|
||||
ability.getActivatingPlayer(), ability.getHostCard(), ability);
|
||||
toExclude = CardLists.filter(toExclude, card -> {
|
||||
for (final SpellAbility sa : card.getSpellAbilities()) {
|
||||
if (sa.isManaAbility() && sa.getPayCosts().hasTapCost()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
exclude.addAll(toExclude);
|
||||
}
|
||||
|
||||
String totalP = "";
|
||||
CardCollectionView totap;
|
||||
if (isVehicle) {
|
||||
@@ -566,7 +566,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
int thisRemove = Math.min(prefCard.getCounters(cType), stillToRemove);
|
||||
if (thisRemove > 0) {
|
||||
removed += thisRemove;
|
||||
table.put(null, prefCard, cType, thisRemove);
|
||||
table.put(null, prefCard, CounterType.get(cType), thisRemove);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -576,7 +576,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
@Override
|
||||
public PaymentDecision visit(CostRemoveAnyCounter cost) {
|
||||
final int c = cost.getAbilityAmount(ability);
|
||||
final Card originalHost = ObjectUtils.getIfNull(ability.getOriginalHost(), source);
|
||||
final Card originalHost = ObjectUtils.defaultIfNull(ability.getOriginalHost(), source);
|
||||
|
||||
if (c <= 0) {
|
||||
return null;
|
||||
@@ -719,7 +719,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
int over = Math.min(crd.getCounters(CounterEnumType.QUEST) - e, c - toRemove);
|
||||
if (over > 0) {
|
||||
toRemove += over;
|
||||
table.put(null, crd, CounterEnumType.QUEST, over);
|
||||
table.put(null, crd, CounterType.get(CounterEnumType.QUEST), over);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -770,12 +770,6 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
public PaymentDecision visit(CostRemoveCounter cost) {
|
||||
final String amount = cost.getAmount();
|
||||
final String type = cost.getType();
|
||||
final GameEntityCounterTable counterTable = new GameEntityCounterTable();
|
||||
|
||||
// TODO Help AI filter card with most useless counters and put those counters in countertable for things like
|
||||
// Moxite Refinery, similar to CostRemoveAnyCounter
|
||||
// Probably a lot of that decision making can be re-used or pulled out for both PaymentDecisions to use
|
||||
if (cost.counter == null) return null;
|
||||
|
||||
int c;
|
||||
|
||||
@@ -804,8 +798,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
}
|
||||
for (Card card : typeList) {
|
||||
if (card.getCounters(cost.counter) >= c) {
|
||||
counterTable.put(null, card, cost.counter, c);
|
||||
return PaymentDecision.counters(counterTable);
|
||||
return PaymentDecision.card(card, c);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -816,8 +809,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
return null;
|
||||
}
|
||||
|
||||
counterTable.put(null, source, cost.counter, c);
|
||||
return PaymentDecision.counters(counterTable);
|
||||
return PaymentDecision.card(source, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -846,12 +838,12 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostUnattach cost) {
|
||||
final CardCollection cardToUnattach = cost.findCardToUnattach(source, player, ability);
|
||||
if (cardToUnattach.isEmpty()) {
|
||||
final Card cardToUnattach = cost.findCardToUnattach(source, player, ability);
|
||||
if (cardToUnattach == null) {
|
||||
// We really shouldn't be able to get here if there's nothing to unattach
|
||||
return null;
|
||||
}
|
||||
return PaymentDecision.card(cardToUnattach.getFirst());
|
||||
return PaymentDecision.card(cardToUnattach);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,52 +1,21 @@
|
||||
package forge.ai;
|
||||
|
||||
public enum AiPlayDecision {
|
||||
// Play decision reasons
|
||||
WillPlay,
|
||||
MandatoryPlay,
|
||||
PlayToEmptyHand,
|
||||
ImpactCombat,
|
||||
ResponseToStackResolve,
|
||||
AddBoardPresence,
|
||||
Removal,
|
||||
Tempo,
|
||||
CardAdvantage,
|
||||
|
||||
// Play later decisions
|
||||
WaitForCombat,
|
||||
WaitForMain2,
|
||||
WaitForEndOfTurn,
|
||||
StackNotEmpty,
|
||||
AnotherTime,
|
||||
|
||||
// Don't play decision reasons
|
||||
CantPlaySa,
|
||||
CantPlayAi,
|
||||
CantAfford,
|
||||
CantAffordX,
|
||||
DoesntImpactCombat,
|
||||
DoesntImpactGame,
|
||||
MissingLogic,
|
||||
WaitForMain2,
|
||||
AnotherTime,
|
||||
MissingNeededCards,
|
||||
TimingRestrictions,
|
||||
MissingPhaseRestrictions,
|
||||
ConditionsNotMet,
|
||||
NeedsToPlayCriteriaNotMet,
|
||||
StopRunawayActivations,
|
||||
TargetingFailed,
|
||||
CostNotAcceptable,
|
||||
LifeInDanger,
|
||||
WouldDestroyLegend,
|
||||
WouldDestroyOtherPlaneswalker,
|
||||
WouldBecomeZeroToughnessCreature,
|
||||
WouldDestroyWorldEnchantment,
|
||||
BadEtbEffects,
|
||||
CurseEffects;
|
||||
|
||||
public boolean willingToPlay() {
|
||||
return switch (this) {
|
||||
case WillPlay, MandatoryPlay, PlayToEmptyHand, AddBoardPresence, ImpactCombat, ResponseToStackResolve, Removal, Tempo, CardAdvantage -> true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
CurseEffects
|
||||
}
|
||||
@@ -17,18 +17,19 @@
|
||||
*/
|
||||
package forge.ai;
|
||||
|
||||
import forge.LobbyPlayer;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.TextUtil;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import forge.LobbyPlayer;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.TextUtil;
|
||||
|
||||
/**
|
||||
* Holds default AI personality profile values in an enum.
|
||||
* Loads profile from the given text file when setProfile is called.
|
||||
|
||||