Skip to content

Commit

Permalink
Merge branch 'master' into linkedAbilityV2
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanmac authored Apr 26, 2022
2 parents eba393f + 6c5aa30 commit fef579b
Show file tree
Hide file tree
Showing 576 changed files with 13,014 additions and 5,692 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/test-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test build

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '8', '11' ]
name: Test with Java ${{ matrix.Java }}
steps:
- uses: actions/checkout@v3

- name: Setup java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
cache: 'maven'

- 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 tests in virtual framebuffer
run: |
export DISPLAY=":1"
Xvfb :1 -screen 0 800x600x8 &
mvn -U -B clean -P windows-linux test
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Forge

[Official GitLab repo](https://git.cardforge.org/core-developers/forge).
[Official repo](https://github.com/Card-Forge/forge.git).

Dev instructions here: [Getting Started](https://git.cardforge.org/core-developers/forge/-/wikis/(SM-autoconverted)-how-to-get-started-developing-forge) (Somewhat outdated)
Dev instructions here: [Getting Started](https://github.com/Card-Forge/forge/wiki) (Somewhat outdated)

Discord channel [here](https://discord.gg/fWfNgCUNRq)

Expand All @@ -13,14 +13,14 @@ Discord channel [here](https://discord.gg/fWfNgCUNRq)
- Git
- Git client (optional)
- Maven
- Gitlab account
- GitHub account
- Libgdx (optional: familiarity with this library is helpful for mobile platform development)
- Android SDK (optional: for Android releases)
- RoboVM (optional: for iOS releases) (TBD: Current status of support by libgdx)

## Project Quick Setup

- Log in to gitlab with your user account and fork the project.
- Login into GitHub with your user account and fork the project.

- Clone your forked project to your local machine

Expand All @@ -32,13 +32,13 @@ Eclipse includes Maven integration so a separate install is not necessary. For

### Project Setup

- Follow the instructions for cloning from Gitlab. You'll need a Gitlab account setup and an SSH key defined.
- Follow the instructions for cloning from GitHub. You'll need to setup an account and your SSH key.

If you are on a Windows machine you can use Putty with TortoiseGit for SSH keys. Run puttygen.exe to generate the key -- save the private key and export
the OpenSSH public key. If you just leave the dialog open, you can copy and paste the key from it to your Gitlab profile under
"SSH keys". Run pageant.exe and add the private key generated earlier. TortoiseGit will use this for accessing Gitlab.
the OpenSSH public key. If you just leave the dialog open, you can copy and paste the key from it to your GitHub profile under
"SSH keys". Run pageant.exe and add the private key generated earlier. TortoiseGit will use this for accessing GitHub.

- Fork the Forge git repo to your Gitlab account.
- Fork the Forge git repo to your GitHub account.

- Clone your forked repo to your local machine.

Expand Down Expand Up @@ -168,11 +168,11 @@ The resulting snapshot will be found at: forge-gui-desktop/target/forge-gui-desk

## IntelliJ

Quick start guide for [setting up the Forge project within IntelliJ](https://git.cardforge.org/core-developers/forge/-/wikis/Development/intellij-setup).
Quick start guide for [setting up the Forge project within IntelliJ](https://github.com/Card-Forge/forge/wiki/IntelliJ-setup).

## Card Scripting

Visit [this page](https://git.cardforge.org/core-developers/forge/-/wikis/Card-scripting-API/Card-scripting-API) for information on scripting.
Visit [this page](https://github.com/Card-Forge/forge/wiki/Card-scripting-API) for information on scripting.

Card scripting resources are found in the forge-gui/res/ path.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public EditorMainWindow()
BorderLayout layout=new BorderLayout();
setLayout(layout);
add(tabs);
tabs.addTab("POI",new PointOfInterestEditor());
tabs.addTab("World",new WorldEditor());
tabs.addTab("Items",new ItemsEditor());
tabs.addTab("Enemies",new EnemyEditor());
setVisible(true);
setSize(800,600);
Expand Down
115 changes: 115 additions & 0 deletions forge-adventure/src/main/java/forge/adventure/editor/EffectEditor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package forge.adventure.editor;

import forge.adventure.data.EffectData;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;

public class EffectEditor extends JComponent {
EffectData currentData;


JTextField name =new JTextField();
JSpinner changeStartCards = new JSpinner(new SpinnerNumberModel(0, 0, 1000, 1));
JSpinner lifeModifier = new JSpinner(new SpinnerNumberModel(0, 0, 1000, 1));
JSpinner moveSpeed = new JSpinner(new SpinnerNumberModel(0f, 0, 1, 0.1f));
TextListEdit startBattleWithCard =new TextListEdit();
JCheckBox colorView =new JCheckBox();
EffectEditor opponent = null;
private boolean updating=false;

public EffectEditor(boolean isOpponentEffect)
{
if(!isOpponentEffect)
opponent=new EffectEditor(true);
setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
JPanel parameters=new JPanel();
parameters.setBorder(BorderFactory.createTitledBorder("Effect"));
parameters.setLayout(new GridLayout(7,2)) ;

parameters.add(new JLabel("Name:")); parameters.add(name);
parameters.add(new JLabel("Start with extra cards:")); parameters.add(changeStartCards);
parameters.add(new JLabel("Change life:")); parameters.add(lifeModifier);
parameters.add(new JLabel("Movement speed:")); parameters.add(moveSpeed);
parameters.add(new JLabel("Start battle with cards:")); parameters.add(startBattleWithCard);
parameters.add(new JLabel("color view:")); parameters.add(colorView);
add(parameters);
if(!isOpponentEffect)
{ add(new JLabel("Opponent:")); add(opponent);}


changeStartCards.addChangeListener(e -> EffectEditor.this.updateEffect());
lifeModifier.addChangeListener(e -> EffectEditor.this.updateEffect());
moveSpeed.addChangeListener(e -> EffectEditor.this.updateEffect());
colorView.addChangeListener(e -> EffectEditor.this.updateEffect());
name.getDocument().addDocumentListener(new DocumentChangeListener(() -> EffectEditor.this.updateEffect()));
startBattleWithCard.getEdit().getDocument().addDocumentListener(new DocumentChangeListener(() -> EffectEditor.this.updateEffect()));
if(opponent!=null)

opponent.addChangeListener(e -> EffectEditor.this.updateEffect());

}

private void updateEffect() {
if(currentData==null||updating)
return;



currentData.name=name.getText();
currentData.changeStartCards=((Integer)changeStartCards.getValue()).intValue();
currentData.lifeModifier= ((Integer)lifeModifier.getValue()).intValue();
currentData.moveSpeed= ((Float)moveSpeed.getValue()).floatValue();
currentData.startBattleWithCard = startBattleWithCard.getList();
currentData.colorView = colorView.isSelected();
currentData.opponent = opponent.currentData;

ChangeListener[] listeners = listenerList.getListeners(ChangeListener.class);
if (listeners != null && listeners.length > 0) {
ChangeEvent evt = new ChangeEvent(this);
for (ChangeListener listener : listeners) {
listener.stateChanged(evt);
}
}

}
public void addChangeListener(ChangeListener l) {
listenerList.add(ChangeListener.class, l);
}
public void setCurrentEffect(EffectData data)
{
if(data==null)
return;
currentData=data;
refresh();
}
public EffectData getCurrentEffect()
{
return currentData;
}

private void refresh() {
setEnabled(currentData!=null);
if(currentData==null)
{
return;
}
updating=true;
name.setText(currentData.name);



lifeModifier.setValue(currentData.lifeModifier);
changeStartCards.setValue(currentData.changeStartCards);
startBattleWithCard.setText(currentData.startBattleWithCard);
colorView.setSelected(currentData.colorView);
moveSpeed.setValue(currentData.moveSpeed);
if(opponent!=null)
opponent.setCurrentEffect(currentData.opponent);


updating=false;
}
}
79 changes: 16 additions & 63 deletions forge-adventure/src/main/java/forge/adventure/editor/EnemyEdit.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import forge.adventure.data.EnemyData;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;

/**
Expand All @@ -15,6 +13,7 @@ public class EnemyEdit extends JComponent {


JTextField nameField=new JTextField();
JTextField colorField=new JTextField();
JSpinner lifeFiled= new JSpinner(new SpinnerNumberModel(0, 0, 1000, 1));
JSpinner spawnRate= new JSpinner(new SpinnerNumberModel(0.0, 0., 1, 0.1));
JSpinner difficulty= new JSpinner(new SpinnerNumberModel(0.0, 0., 1, 0.1));
Expand All @@ -30,7 +29,7 @@ public EnemyEdit()
{

JComponent center=new JComponent() { };
center.setLayout(new GridLayout(8,2));
center.setLayout(new GridLayout(9,2));

center.add(new JLabel("Name:")); center.add(nameField);
center.add(new JLabel("Life:")); center.add(lifeFiled);
Expand All @@ -40,79 +39,32 @@ public EnemyEdit()
center.add(new JLabel("Deck:")); center.add(deck);
center.add(new JLabel("Sprite:")); center.add(atlas);
center.add(new JLabel("Equipment:")); center.add(equipment);
center.add(new JLabel("Colors:")); center.add(colorField);
BorderLayout layout=new BorderLayout();
setLayout(layout);
add(center,BorderLayout.PAGE_START);
add(rewards,BorderLayout.CENTER);
add(preview,BorderLayout.LINE_START);

equipment.getDocument().addDocumentListener(new DocumentChangeListener(new Runnable() {
@Override
public void run() {
EnemyEdit.this.updateEnemy();
}
}));
atlas.getEdit().getDocument().addDocumentListener(new DocumentChangeListener(new Runnable() {
@Override
public void run() {
EnemyEdit.this.updateEnemy();
}
}));
nameField.getDocument().addDocumentListener(new DocumentChangeListener(new Runnable() {
@Override
public void run() {
EnemyEdit.this.updateEnemy();
}
}));
deck.getEdit().getDocument().addDocumentListener(new DocumentChangeListener(new Runnable() {
@Override
public void run() {
EnemyEdit.this.updateEnemy();
}
}));
lifeFiled.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
EnemyEdit.this.updateEnemy();
}
});
speed.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
EnemyEdit.this.updateEnemy();
}
});
difficulty.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
EnemyEdit.this.updateEnemy();
}
});
spawnRate.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
EnemyEdit.this.updateEnemy();
}
});
rewards.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
EnemyEdit.this.updateEnemy();
}
});
lifeFiled.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
EnemyEdit.this.updateEnemy();
}
});
equipment.getDocument().addDocumentListener(new DocumentChangeListener(() -> EnemyEdit.this.updateEnemy()));
atlas.getEdit().getDocument().addDocumentListener(new DocumentChangeListener(() -> EnemyEdit.this.updateEnemy()));
colorField.getDocument().addDocumentListener(new DocumentChangeListener(() -> EnemyEdit.this.updateEnemy()));
nameField.getDocument().addDocumentListener(new DocumentChangeListener(() -> EnemyEdit.this.updateEnemy()));
deck.getEdit().getDocument().addDocumentListener(new DocumentChangeListener(() -> EnemyEdit.this.updateEnemy()));
lifeFiled.addChangeListener(e -> EnemyEdit.this.updateEnemy());
speed.addChangeListener(e -> EnemyEdit.this.updateEnemy());
difficulty.addChangeListener(e -> EnemyEdit.this.updateEnemy());
spawnRate.addChangeListener(e -> EnemyEdit.this.updateEnemy());
rewards.addChangeListener(e -> EnemyEdit.this.updateEnemy());
lifeFiled.addChangeListener(e -> EnemyEdit.this.updateEnemy());
refresh();
}

private void updateEnemy() {
if(currentData==null||updating)
return;
currentData.name=nameField.getText();
currentData.colors=colorField.getText();
currentData.life= (int) lifeFiled.getValue();
currentData.sprite= atlas.getEdit().getText();
if(equipment.getText().isEmpty())
Expand Down Expand Up @@ -141,6 +93,7 @@ private void refresh() {
}
updating=true;
nameField.setText(currentData.name);
colorField.setText(currentData.colors);
lifeFiled.setValue(currentData.life);
atlas.getEdit().setText(currentData.sprite);
if(currentData.equipment!=null)
Expand Down
Loading

1 comment on commit fef579b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[stale:linkedAbilityV2]

@Hanmac Your branch linkedAbilityV2 hasn't been updated in the last 90 days and is marked as stale. It will be removed in a 7 days.
If you want to keep this branch around, add new commits to this branch or protect it.

Please sign in to comment.