Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 182 additions & 0 deletions docs/Development/Architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# Architecture

The following guide describes each module in the project, it's purpose, and any particular files and objects of interest.

## Project Structure Dependency Diagram

```mermaid
flowchart LR
AI[forge-ai]
CORE[forge-core]
GAME[forge-game]
GUI[forge-gui]
ANDROID[forge-gui-android]
DESKTOP[forge-gui-desktop]
IOS[forge-gui-ios]
MOBILE[forge-gui-mobile]
MOBILE_DEV[forge-gui-mobile-dev]
INSTALLER[forge-installer]
LDA[forge-lda]

AI--depends on-->CORE
AI--depends on-->GAME

GAME--depends on-->CORE

GUI--depends on-->GAME
GUI--depends on-->CORE
GUI--depends on-->AI

ANDROID--depends on -->CORE
ANDROID--depends on-->GAME
ANDROID--depends on-->AI
ANDROID--depends on-->GUI
ANDROID--depends on-->MOBILE

DESKTOP--depends on-->CORE
DESKTOP--depends on-->GAME
DESKTOP--depends on-->AI
DESKTOP--depends on-->GUI

IOS--depends on-->CORE
IOS--depends on-->GAME
IOS--depends on-->AI
IOS--depends on-->GUI
IOS--depends on-->MOBILE

MOBILE--depends on-->CORE
MOBILE--depends on-->GAME
MOBILE--depends on-->AI
MOBILE--depends on-->GUI

MOBILE_DEV--depends on-->MOBILE

INSTALLER--depends on-->MOBILE_DEV
INSTALLER--depends on-->DESKTOP

LDA--depends on-->CORE
LDA--depends on-->GAME
LDA--depends on-->AI
LDA--depends on-->GUI
LDA--depends on-->DESKTOP
```

## forge-ai

The module handles the AI for playing a single round.

There are 3 general areas forming decision making in this module:

1. Is playing a card or ability beneficial?
2. If many choices are beneficial, which is the best choice?
3. Decision branching given current state of game. An example would be deciding to play a spell before playing a land.

### Points of interest

[SpellApiToAi](https://github.com/Card-Forge/forge/blob/e95673e0a211699f2df1d8a535d9636379c59174/forge-ai/src/main/java/forge/ai/SpellApiToAi.java#L13)
handles sending the game event (`ApiType` enum) to the correct AI handler (`SpellAbilityAi` interface implementation).

[SimulationController](https://github.com/Card-Forge/forge/blob/e95673e0a211699f2df1d8a535d9636379c59174/forge-ai/src/main/java/forge/ai/simulation/SimulationController.java#L13)
handles copying the game state, tracking the AI decisions and simulating how the decisions could unfold.

[AiController](https://github.com/Card-Forge/forge/blob/e95673e0a211699f2df1d8a535d9636379c59174/forge-ai/src/main/java/forge/ai/AiController.java#L88)
provides the primary logic for describing how an AI player operates.

[saComparator](https://github.com/Card-Forge/forge/blob/e95673e0a211699f2df1d8a535d9636379c59174/forge-ai/src/main/java/forge/ai/ComputerUtilAbility.java#L233)
is an implementation of `Comparator<SpellAbility>` to decide the priority of spells/abilities to play (i.e. decision making order).

### Glossary

| Term | Definition |
| -- |-----------------------------------------------------------------------|
| SA | Spell Ability; This is effectively any decision a player can perform. |

## forge-core

### Points of interest

### Glossary

| Term | Definition |
| -- | -- |

## forge-game

### Points of interest

### Glossary

| Term | Definition |
| -- | -- |

## forge-gui

### Points of interest

### Glossary

| Term | Definition |
| -- | -- |

## forge-gui-android

### Points of interest

### Glossary

| Term | Definition |
| -- | -- |

## forge-gui-desktop

### Points of interest

### Glossary

| Term | Definition |
| -- | -- |

## forge-gui-ios

### Points of interest

### Glossary

| Term | Definition |
| -- | -- |

## forge-gui-mobile

### Points of interest

### Glossary

| Term | Definition |
| -- | -- |

## forge-gui-mobile-dev

### Points of interest

### Glossary

| Term | Definition |
| -- | -- |

## forge-installer

### Points of interest

### Glossary

| Term | Definition |
| -- | -- |

## forge-lda

### Points of interest

### Glossary

| Term | Definition |
| -- | -- |
14 changes: 13 additions & 1 deletion docs/Development/Snapshots-and-Releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,16 @@ It would be useful for other people to be comfortable with the release process.
* Create a new release from https://github.com/Card-Forge/forge/releases
* Upload the package and its sha to the create new release page
5. Marketing
* Advertise in the #announcements channel in the Discord
* Advertise in the #announcements channel in the Discord

### Updating an existing installation with a local build

Often, to test your code, you may want to use an existing installation and overwrite only the code files.

The following steps will help perform an incremental update to your existing installation.

1. Run `mvn clean install -DskipTests` from the main project directory to build the artifacts.
2. Copy `forge-gui-desktop/target/forge-gui-desktop-${VERSION}-jar-with-dependencies.jar` to the root installation directory.
3. Copy `forge-gui-mobile-dev/target/forge-gui-mobile-dev-*-jar-with-dependencies.jar` to the root installation directory.
4. Make sure the scripts you use to launch Forge, located in the root instalation directory, are referencing the copied files.

3 changes: 2 additions & 1 deletion docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
- [Snapshots & Releases](Development/Snapshots-and-Releases.md)
- [Android Builds](Development/Android-Builds.md)
- [Dev Mode](Development/DevMode.md)
- [Architecture](Development/Architecture.md)
- [Ownership](Development/ownership.md)
- [Docker Container](docker-setup.md)

Expand All @@ -63,4 +64,4 @@
- [Missing Cards in Forge](Missing-Cards-in-Forge.md)
- [Un‐cards, Playtest Cards, and Other Funny Cards](Un‐cards,-Playtest-Cards,-and-Other-Funny-Cards.md)

- [Credit & Thanks](Credit-and-Thanks.md)
- [Credit & Thanks](Credit-and-Thanks.md)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is probably line endings change to CRLF, though I don't know. If it were introducing a new line we would see a character at the end of this line change.