Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
d881f97
updated readme, added task folder
sdeffff Nov 6, 2024
ed97e01
some adjustments
sdeffff Nov 6, 2024
fbe0366
base interfaces and GameBoard
sdeffff Nov 12, 2024
6536ee1
first commit
valdiks1 Nov 13, 2024
3a95aff
PlaceFiguresState
qbitroot Nov 13, 2024
1bd1797
add comment
qbitroot Nov 13, 2024
496e7d5
PlayerBoard init
sdeffff Nov 15, 2024
1dc8162
inplemented stone age observalbes PlayerBoard prep
sdeffff Nov 15, 2024
72d4a4b
Merge pull request #1 from sdeffff/max_tasks
sdeffff Nov 15, 2024
0011005
Added ArbitraryBuilding class
Arsenii-Nemchenko Nov 18, 2024
95484f0
Added VariableBuilding class and test
Arsenii-Nemchenko Nov 18, 2024
cceb6ec
Create interfaces, 2 more classes, tests
qbitroot Nov 19, 2024
6e57111
Create interfaces, 2 more classes, tests
qbitroot Nov 19, 2024
2bdb98c
Merge pull request #2 from sdeffff/havriuk
sdeffff Nov 19, 2024
a10fa02
some changes
sdeffff Nov 19, 2024
2be4ae1
fixes + new implementations
sdeffff Nov 19, 2024
d981629
FigureLocationAdaptor + StoneAgeObservable
sdeffff Nov 19, 2024
f8143f3
update
valdiks1 Nov 20, 2024
899653d
update2
valdiks1 Nov 20, 2024
7efa986
First implementation of PlayerFigures and PlayerTools
EndiUN Nov 20, 2024
3ff5ec0
update branch and add interfaces
valdiks1 Nov 21, 2024
6056370
implement class Throw
valdiks1 Nov 22, 2024
56467c4
add small comment
valdiks1 Nov 22, 2024
b7caf86
add EndOfGameEffect and InterfacePlayerBoardGameBoard, started Curren…
valdiks1 Nov 22, 2024
e5ba144
Merge remote-tracking branch 'refs/remotes/origin/havriuk' into havriuk
qbitroot Nov 22, 2024
b351438
Fix interfaces return
qbitroot Nov 22, 2024
03b74a8
Merge pull request #4 from sdeffff/havriuk
qbitroot Nov 22, 2024
4905e1f
prepared to update
valdiks1 Nov 25, 2024
712744a
Merge branch 'main' of https://github.com/sdeffff/pts24-java
valdiks1 Nov 25, 2024
5b00895
prepared to merge
valdiks1 Nov 25, 2024
446f3ba
Merge pull request #5 from sdeffff/Vladyslav-Rusavkyi
sdeffff Nov 25, 2024
0c1d161
Merge branch 'main' into Arsenii
Arsenii-Nemchenko Nov 25, 2024
27cd9d6
Added ToolMakerHutFields
Arsenii-Nemchenko Nov 27, 2024
e9a16cb
Merge pull request #6 from sdeffff/vlad_peh_tasks
sdeffff Nov 28, 2024
6f58503
Added CivilizationCard datatype
Arsenii-Nemchenko Nov 28, 2024
c93f195
Udated ToolMakerHutFields
Arsenii-Nemchenko Nov 28, 2024
774d718
Added getCard, immediateEffect
Arsenii-Nemchenko Nov 28, 2024
48fd64a
WaitingForToolUseState somewhat done
petrenko4 Nov 28, 2024
22f0db2
Merge branch 'main' into havriuk
qbitroot Nov 28, 2024
41a36ec
Merge branch 'main' into havriuk
qbitroot Nov 28, 2024
5627bf2
move resourecsource
qbitroot Nov 28, 2024
6edd8a5
Merge pull request #7 from sdeffff/havriuk
qbitroot Nov 28, 2024
3cac7c5
Gitignore
qbitroot Nov 28, 2024
23a296b
Merge remote-tracking branch 'refs/remotes/origin/main'
qbitroot Nov 28, 2024
c2f6902
First implementation of FieldsAdaptor and ToolMakerAdaptor
EndiUN Nov 28, 2024
e31c3a7
Buildingtile etc
qbitroot Nov 28, 2024
cc8af5b
Merge remote-tracking branch 'origin/petrenko'
petrenko4 Nov 28, 2024
5acd333
Added GetSomethingChoice
Arsenii-Nemchenko Nov 28, 2024
e108fda
Add a getter
qbitroot Nov 28, 2024
f0cd1d4
Merge pull request #8 from sdeffff/havriuk
qbitroot Nov 28, 2024
3d701af
AllPlayersTakeARewardState method tryToMakeAutomaticAction
petrenko4 Nov 28, 2024
155a6e2
First implementation of FeedTribeState
EndiUN Nov 28, 2024
e45c5a5
AllPlayersTakeARewardState method tryToMakeAutomaticAction
petrenko4 Nov 28, 2024
eeb7768
Merge branch 'main' of https://github.com/sdeffff/pts24-java
petrenko4 Nov 28, 2024
0e5a637
First implementation of PlayerCivilization
EndiUN Nov 28, 2024
f31251d
First impl of PlayerCivilizationCards
EndiUN Nov 28, 2024
f648a4c
Changes in PlayerCivilizationCards
EndiUN Nov 28, 2024
c96347e
Merge branch 'main' of https://github.com/sdeffff/pts24-java into Ars…
Arsenii-Nemchenko Nov 28, 2024
eb9fef8
added PlayerResourcesAndFood class, MakeActionState class, NewRoundSt…
Anatolii-Izotov Nov 28, 2024
5819054
Implemented first version of CurrentThrow class. Changes will probabl…
mis-fe-denyst Nov 29, 2024
5ac8752
Merge branch 'main' into DenysTanashchukClasses
DevinMprz Nov 29, 2024
d4c10bb
Merge pull request #10 from sdeffff/DenysTanashchukClasses
sdeffff Nov 29, 2024
6469687
Merge pull request #11 from sdeffff/Anatolii-Izotov
sdeffff Nov 29, 2024
270c588
Configuration of PlayerCivilizationCards and PlayerTools, aded some t…
EndiUN Nov 29, 2024
233b0aa
Merge conflict resolution
EndiUN Nov 29, 2024
2a746a6
Merge pull request #12 from sdeffff/Vladyslav-Rusavkyi
sdeffff Nov 29, 2024
4ad9bce
Fixed issues with classes
Arsenii-Nemchenko Nov 30, 2024
3c3ef5a
Implemented RewardMenu, made changes to state in CurrentThrow.
mis-fe-denyst Nov 30, 2024
aaf5985
BuildingTile modified
Arsenii-Nemchenko Dec 1, 2024
a46f0ab
Added VariableBuilding unit test
Arsenii-Nemchenko Dec 1, 2024
0f136d5
Updated CurrentThrow, added gameboard, added 1 more method to Interfa…
mis-fe-denyst Dec 1, 2024
e5350f4
Added unit tests to CurrentThrow, GameBoard, RewardMenu.
mis-fe-denyst Dec 1, 2024
a878da8
fix class Throw
valdiks1 Dec 1, 2024
9104628
Added GetSomethingChoice test
Arsenii-Nemchenko Dec 1, 2024
5b357e2
Added GetCardTest
Arsenii-Nemchenko Dec 1, 2024
cfa80ab
Added tests for currentThrow, documentation for GameBoard, RewardMenu…
mis-fe-denyst Dec 1, 2024
acf9dd2
Added ArbitraryBuildingTest
Arsenii-Nemchenko Dec 1, 2024
90ebd31
remove ds store
qbitroot Dec 1, 2024
3322e75
Merge pull request #13 from sdeffff/DenysTanashchukClasses
DevinMprz Dec 1, 2024
1a42fb3
Added ToolMakerHutFieldsTest
Arsenii-Nemchenko Dec 1, 2024
ea83582
Fixed typo
Arsenii-Nemchenko Dec 1, 2024
6757a32
Merge branch 'Arsenii'
Arsenii-Nemchenko Dec 1, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
target
.Makefile.swp
.idea/
.aider.*
.DS_Store
13 changes: 13 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

108 changes: 108 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 44 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
# Stone Age
# Assignment - Stone Age game

This is the Java version of the semestral project from Principles of Software Design (1) course on FMFI UK, 2024/25.
Your task is to construct a component implementing the logic of board game Stone Age. These are the [rules](https://images.zmangames.com/filer_public/ee/88/ee888bec-5000-4566-9fb0-8c6475e706a0/zm7260_stone_age_rules.pdf).

[!Classes Description!](https://github.com/sdeffff/pts24-java/blob/main/src/task/classes.md)


## Design

I prepared a [design](pts24.png) template for your implementation. Besides that I prepared [simple description of the classes](classes.md) with estimations

Note that the design is by no means complete. Most notably
- You have to add appropriate constructors. Chose your constructors in a way that enables good testing. E.g. card deck and building stacks do not need to be full.
- You have to add interfaces that separate classes that need to be separated.
- You probably want to do something with Bag class to handle the randomness involved better.
Also, it is highly likely, that I overlooked something and there are some issues that need to be resolved. Feel free to do necessary changes and adjustments.

I recommend to stick to the following timeline
- 11. 11. create teams, understand game rules, understand the design (so we can have a meaningful discussion on the lecture).
- 20. 11. the common part of the project is finished
- 27. 11. you are done

## Implementation remarks

You should build your project either in Python or in Java. I started the projects for you, including several tools that might help you. See [pts24-python](https://github.com/relatko/pts1-23-python) and [pts24-java](https://github.com/relatko/pts1-23-java). Note that if you use Python, your code should be type annotated and mypy --strict should show no errors. Do not use any except for when handling json.

This is a fairly large project and it would take too long to implement. Thus you will collaborate while implementing the project.

* Create groups of, ideally, six to eight people. and fork the repository you agree to use. Green classes are provided in the project (Java GamePhaseController will be implemented soonish).
* Collaboratively implement the elements marked white (trivial) and blue, including factories and integration tests for two components. For blue elements create a PR (typically one PR per element, but you may merge several very trivial ones into one PR), discuss it and merge it into the master (I recommend main branch protection requiring PR with at least 1 approval). Blue classes are not of particular interest to me. The amount of points given here is quite limited (up to 20 points including non-coding aspects of common work like like making and reviewing PRs), so do not overthink stuff, but make it sound enough so you actually can write working integration tests. This also implies that the test coverage does not have to be great in these classes. While collaborating create new features in own branches and merge it to main with a PR after code review is done. Turn on branch protection. Try to keep CI green (you can enforce this by branch protection rules). You may use github issues to your the progress. You may split large task into smaller tasks. You may want to meet one time before you start your work. Splitting L tasks is a good thing to do.
It is expected that everybody prepares and reviews 3-5 PRs.
* After this, you should add your own implementation of the red classes (including unit tests) and prepare two integration tests. To reduce the amount of work necessary, it is sufficient to create one end to end scenario for each of these integration test.

Unit tests for Game should be solitary. Do a sociable unit test of CivilisationCardPlace that also uses CivilisationCardDeck. Tests of ResourceSource must be solitary. You can discuss technical aspects of the implementation, but everybody should implement the red classes and the red integration tests on his own. You can either work on local machine or use a private repository for your effort.

You should use Git and produce a reasonable history of commits. Note that to work on the red classes you do not need the blue ones. You are also free to adjust the implementation of blue and green classes according to the needs of your project (but, the changes, hopefully should not be large, a good example is changing interface name, adding a new interface, ...).


## Instructions for submitting your project

Send your solution to [lukotka.pts@gmail.com](lukotka.pts@gmail.com). The deadline is 30.11.2022 23:59:59. The solutions sent later will be accepted, however the number of points awarded may be reduced.

Send the solution to me either as compressed folders containing the whole repository (including the hidden .git files) or as a link to private repository with read access granted (GitHub handle `relatko`). Attach a link to the public repository for the team part of the project and link PRs you have made and PRs you have reviewed.

![UML of the task](https://github.com/sdeffff/pts24-java/blob/main/src/task/pts24.png?raw=true)
21 changes: 21 additions & 0 deletions STONE_AGE.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="$MODULE_DIR$/pom.xml" external.system.module.type="SINGLE_MODULE" external.system.module.version="223-2" org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_21">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.4" level="project" />
<orderEntry type="library" name="Maven: org.json:json:20190722" level="project" />
</component>
</module>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>21</maven.compiler.release>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencies>
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/sk/uniba/fmph/dcs/game_board/ArbitraryBuilding.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package sk.uniba.fmph.dcs.game_board;

import sk.uniba.fmph.dcs.stone_age.Effect;
import java.util.Collection;
import java.util.OptionalInt;

public class ArbitraryBuilding implements Building {
private final int maxNumberOfResources;

public ArbitraryBuilding(int maxNumberOfResources) {
this.maxNumberOfResources = maxNumberOfResources;
}

@Override
public OptionalInt build(Collection<Effect> resources) {
if (resources.isEmpty() || resources.size() > maxNumberOfResources) {
return OptionalInt.empty();
}

// Verify all resources are valid
for (Effect resource : resources) {
if (!resource.isResource()) {
return OptionalInt.empty();
}
}

// Calculate points
int points = 0;
for (Effect resource : resources) {
points += resource.points();
}

return OptionalInt.of(points);
}

@Override
public String state() {
return String.format("ArbitraryBuilding[maxResources=%d]", maxNumberOfResources);
}
}
3 changes: 2 additions & 1 deletion src/main/java/sk/uniba/fmph/dcs/game_board/Building.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.OptionalInt;
import sk.uniba.fmph.dcs.stone_age.Effect;

interface Building {
public interface Building {
OptionalInt build(Collection<Effect> resources);
String state();
}
99 changes: 99 additions & 0 deletions src/main/java/sk/uniba/fmph/dcs/game_board/BuildingTile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package sk.uniba.fmph.dcs.game_board;

import sk.uniba.fmph.dcs.stone_age.PlayerOrder;
import sk.uniba.fmph.dcs.stone_age.Effect;
import sk.uniba.fmph.dcs.stone_age.Player;
import sk.uniba.fmph.dcs.stone_age.HasAction;
import sk.uniba.fmph.dcs.stone_age.ActionResult;

import java.util.*;

import org.json.JSONObject;

public class BuildingTile implements InterfaceFigureLocationInternal {
private final Stack<Building> buildings;
private final ArrayList<PlayerOrder> figures;
private static final int MAX_FIGURES = 1;

public BuildingTile(List<Building> building) {
this.buildings = new Stack<>();
this.buildings.addAll(building);
this.figures = new ArrayList<>();
}

@Override
public boolean placeFigures(Player player, int figureCount) {
if (figureCount != MAX_FIGURES || !figures.isEmpty()) {
return false;
}
figures.add(player.playerOrder());
return true;
}

@Override
public HasAction tryToPlaceFigures(Player player, int count) {
if (count != MAX_FIGURES || !figures.isEmpty()) {
return HasAction.NO_ACTION_POSSIBLE;
}
if (!player.playerBoard().hasFigures(count)) {
return HasAction.NO_ACTION_POSSIBLE;
}
return HasAction.WAITING_FOR_PLAYER_ACTION;
}

@Override
public ActionResult makeAction(Player player, Effect[] inputResources, Effect[] outputResources) {
if (figures.isEmpty() || !figures.get(0).equals(player.playerOrder())) {
return ActionResult.FAILURE;
}

Collection<Effect> resources = List.of(inputResources);

if(buildings.isEmpty()){
return ActionResult.FAILURE;
}
OptionalInt points = buildings.pop().build(resources);

// Give points to player
List<Effect> pointsToGive = new ArrayList<>();
for(int i=0; i<points.getAsInt(); i++){
pointsToGive.add(Effect.POINT);
}
player.playerBoard().giveEffect(pointsToGive);
return ActionResult.ACTION_DONE;
}

@Override
public boolean skipAction(Player player) {
if (figures.isEmpty() || !figures.get(0).equals(player.playerOrder())) {
return false;
}
figures.clear();
return true;
}

@Override
public HasAction tryToMakeAction(Player player) {
if (figures.isEmpty() || !figures.get(0).equals(player.playerOrder())) {
return HasAction.NO_ACTION_POSSIBLE;
}
return HasAction.WAITING_FOR_PLAYER_ACTION;
}

@Override
public boolean newTurn() {
if(buildings.isEmpty()){
return true;
}
figures.clear();
return false;
}

public String state() {
Map<String, Object> state = Map.of(
"building", buildings,
"figures", figures.stream().map(PlayerOrder::getOrder).toList()
);
return new JSONObject(state).toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package sk.uniba.fmph.dcs.game_board;

public class CivilisationCardDeck {

}
Loading