Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
a9c6122
zadanie a .idea
Duchyna1 Nov 11, 2024
d86963e
zadanie a .idea
Duchyna1 Nov 11, 2024
d16aae3
small changes
Duchyna1 Nov 12, 2024
848675a
test
FilipSivicek Nov 12, 2024
ef2258c
test test
FilipSivicek Nov 12, 2024
d40b47b
Merge pull request #51 from Duchyna1/test
Duchyna1 Nov 12, 2024
7c64ec9
johamko skuska
JohankoG Nov 12, 2024
6a9ad01
sprava
Nov 12, 2024
9f99fe4
test3
LudkaK Nov 12, 2024
8ec3641
Merge branch 'main' of https://github.com/Duchyna1/pts24-java
LudkaK Nov 12, 2024
3502858
GameEndState
LudkaK Nov 13, 2024
5ca0db0
add workflow
Duchyna1 Nov 13, 2024
b72705b
Update issue-status.yml
Duchyna1 Nov 13, 2024
8c982ca
Fix issue-status.yml
Duchyna1 Nov 13, 2024
65ec928
Update issue-status.yml
Duchyna1 Nov 13, 2024
f1eed81
Update issue-status.yml
Duchyna1 Nov 13, 2024
b3f274b
GameEndStateTest
LudkaK Nov 13, 2024
7be9bcb
Change issue-status.yml
Duchyna1 Nov 13, 2024
0aef751
Update issue-status.yml
Duchyna1 Nov 13, 2024
c332060
GameEndState
LudkaK Nov 13, 2024
43031be
GameEndState
LudkaK Nov 13, 2024
fd4a46d
interface (#53)
johankogoodvibes Nov 13, 2024
7763fbd
GameEndStateTest
LudkaK Nov 13, 2024
d9bc527
GameEndState
LudkaK Nov 13, 2024
01f3794
Merge pull request #71 from Duchyna1/lk
TokarovaMichaela Nov 13, 2024
2853ddb
Update issue-status.yml
Duchyna1 Nov 13, 2024
6279d7f
deletes test.txt
Duchyna1 Nov 13, 2024
aeefcab
Update issue-status.yml
Duchyna1 Nov 13, 2024
cd07087
Created PlayerTools class (#73)
FilipSivicek Nov 13, 2024
d47d9b0
cleanup
Duchyna1 Nov 13, 2024
7224694
give figure functionality (#78)
johankogoodvibes Nov 14, 2024
907cdd6
Created PlayerCivilisationCards class (#75)
FilipSivicek Nov 14, 2024
833b476
new FeedTribeState class
Nov 15, 2024
32902c5
added test class FeedTribeStateTest
Nov 15, 2024
90000b5
Fix tests to cover all states
Stanko2 Nov 16, 2024
130ffcc
Merge pull request #80 from Duchyna1/FeedTribeState
TokarovaMichaela Nov 16, 2024
8d76059
waitingfortooluse classa
Nov 16, 2024
46fef13
PlayerFigures + TribeFedStatus (#76)
Duchyna1 Nov 16, 2024
4bfdc7b
Reward state lk (#77)
LudkaK Nov 16, 2024
b7b3061
GameBoard (#72)
Duchyna1 Nov 16, 2024
b346d5e
GameBoard CivilisationCards (#74)
johankogoodvibes Nov 16, 2024
686a3f6
uprava formatovanie
Nov 16, 2024
1ef10b9
dalsie formatovanie
Nov 16, 2024
abaab82
dalsie, sorry
Nov 16, 2024
36f9801
fix typo
Nov 16, 2024
27c0a4b
add PlaceFigureState class
Nov 16, 2024
99e15b6
change to pass lint check
Nov 17, 2024
c9384ab
change to pass lint check
Nov 17, 2024
27d6b40
add PlaceFigureStateTest
Nov 17, 2024
77f4288
add check input condition
Nov 17, 2024
74cded3
Merge pull request #84 from Duchyna1/PlaceFigureState
LudkaK Nov 17, 2024
d2e4b82
Merge branch 'main' of https://github.com/Duchyna1/pts24-java into Wa…
Nov 18, 2024
311b0bd
waitingfortooluse test
Nov 19, 2024
9fbe25d
add one test case
Nov 19, 2024
6dfe629
Format
Duchyna1 Nov 19, 2024
01b7208
Merge remote-tracking branch 'origin/WaitingForToolUse' into WaitingF…
Duchyna1 Nov 19, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target
.Makefile.swp
.idea/uiDesigner.xml
4 changes: 4 additions & 0 deletions .idea/.gitignore

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

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.

12 changes: 12 additions & 0 deletions .idea/misc.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
all: check_and_test lint format

check_and_test: FORCE
mvn test

lint: FORCE
mvn checkstyle:check

format: FORCE
mvn googleformatter:format
mvn formatter:format
FORCE: ;
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Stone Age

This is the Java version of the semestral project from Principles of Software Design (1) course on FMFI UK, 2024/25.
This is the Java version of the semestral project from Principles of Software Design (1) course on FMFI UK, 2024/25.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package sk.uniba.fmph.dcs.game_board;

import sk.uniba.fmph.dcs.stone_age.Effect;
import sk.uniba.fmph.dcs.stone_age.InterfaceGamePhaseController;

import java.util.ArrayList;
import java.util.List;

public class AllPlayersTakeReward implements EvaluateCivilisationCardImmediateEffect {

private final RewardMenu menu;
private static final int WOODID = 1;
private static final int CLAYID = 2;
private static final int STONEID = 3;
private static final int GOLDID = 4;
private static final int TOOLID = 5;
private final InterfaceGamePhaseController controller;

/**
* @param menu
* RewardMenu that is already existing
* @param controller
* controller to call in performEffect
*/
public AllPlayersTakeReward(final RewardMenu menu, final InterfaceGamePhaseController controller) {
this.menu = menu;
this.controller = controller;
int n = menu.getPlayersCount();
int[] t = Throw.hod(n);
List<Effect> m = new ArrayList<>();
for (var i : t) {
if (i == WOODID) {
m.add(Effect.WOOD);
} else if (i == CLAYID) {
m.add(Effect.CLAY);
} else if (i == STONEID) {
m.add(Effect.STONE);
} else if (i == GOLDID) {
m.add(Effect.GOLD);
} else if (i == TOOLID) {
m.add(Effect.TOOL);
} else {
m.add(Effect.FIELD);
}
}
menu.initiate(m);
}

/**
* call controller.
*
* @param player
* player that takes from menu
* @param choice
* resource to take from menu
*
* @return true if resource was successfully taken
*/
@Override
public boolean performEffect(final Player player, final Effect choice) {
return controller.makeAllPlayersTakeARewardChoice(player.playerOrder(), choice);
}
}
34 changes: 34 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,34 @@
package sk.uniba.fmph.dcs.game_board;

import org.json.JSONObject;
import sk.uniba.fmph.dcs.stone_age.Effect;

import java.util.Collection;
import java.util.Map;
import java.util.OptionalInt;

public final class ArbitraryBuilding implements Building {
private final int numberOfResources;

public ArbitraryBuilding(final int numberOfResources) {
this.numberOfResources = numberOfResources;
}

@Override
public OptionalInt build(final Collection<Effect> resources) {
if (resources.size() > numberOfResources) {
return OptionalInt.empty();
}
int sum = 0;
for (Effect resource : resources) {
sum += resource.points();
}
return OptionalInt.of(sum);
}

@Override
public String state() {
Map<String, String> state = Map.of("numberOfResources", Integer.toString(numberOfResources));
return new JSONObject(state).toString();
}
}
5 changes: 4 additions & 1 deletion src/main/java/sk/uniba/fmph/dcs/game_board/Building.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package sk.uniba.fmph.dcs.game_board;

import sk.uniba.fmph.dcs.stone_age.Effect;

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

interface Building {
OptionalInt build(Collection<Effect> resources);

String state();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package sk.uniba.fmph.dcs.game_board;

import sk.uniba.fmph.dcs.stone_age.CivilisationCard;

import java.util.Optional;

public final class CivilizationCardDeck {
public Optional<CivilisationCard> getTop() {
return Optional.empty();
}

public String state() {
return "TODO";
}
}
30 changes: 30 additions & 0 deletions src/main/java/sk/uniba/fmph/dcs/game_board/CurrentThrow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package sk.uniba.fmph.dcs.game_board;

import sk.uniba.fmph.dcs.stone_age.Effect;
import sk.uniba.fmph.dcs.stone_age.InterfaceToolUse;

public final class CurrentThrow implements InterfaceToolUse {

public CurrentThrow(final Effect throwsFor, final int throwResult) {
// todo
}

public void initiate(final Player player, final Effect effect, final int dices) {
return; // todo
}

@Override
public boolean useTool(final int idx) {
return false;
}

@Override
public boolean canUseTools() {
return false;
}

@Override
public boolean finishUsingTools() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package sk.uniba.fmph.dcs.game_board;

import sk.uniba.fmph.dcs.stone_age.Effect;

public interface EvaluateCivilisationCardImmediateEffect {
boolean performEffect(Player player, Effect choice);
}
36 changes: 36 additions & 0 deletions src/main/java/sk/uniba/fmph/dcs/game_board/GetCard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package sk.uniba.fmph.dcs.game_board;

import sk.uniba.fmph.dcs.stone_age.CivilisationCard;
import sk.uniba.fmph.dcs.stone_age.Effect;

import java.util.Optional;

public class GetCard implements EvaluateCivilisationCardImmediateEffect {
private final CivilizationCardDeck deck;

/**
* @param deck
* to draw cards from
*/
public GetCard(final CivilizationCardDeck deck) {
this.deck = deck;
}

/**
* @param player
* gives player top card of the deck
* @param choice
* ignored
*
* @return true if card exists
*/
@Override
public boolean performEffect(final Player player, final Effect choice) {
Optional<CivilisationCard> c = deck.getTop();
if (c.isEmpty()) {
return false;
}
player.playerBoard().giveEndOfGameEffect(c.get().endOfGameEffect());
return true;
}
}
38 changes: 38 additions & 0 deletions src/main/java/sk/uniba/fmph/dcs/game_board/GetChoice.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package sk.uniba.fmph.dcs.game_board;

import sk.uniba.fmph.dcs.stone_age.Effect;

public class GetChoice implements EvaluateCivilisationCardImmediateEffect {
private int numberOfResources;

/**
* @param numberOfResources
* number of resources available to choose.
*/
public GetChoice(final int numberOfResources) {
this.numberOfResources = numberOfResources;
}

/**
* gives one resource of any type.
*
* @param player
* player to give resource to
* @param choice
* resource wanted
*
* @return true if player can take resource, false otherwise
*/
@Override
public boolean performEffect(final Player player, final Effect choice) {
if (!choice.isResource()) {
return false;
}
if (numberOfResources == 0) {
return false;
}
numberOfResources--;
player.playerBoard().giveEffect(new Effect[] {choice});
return true;
}
}
36 changes: 36 additions & 0 deletions src/main/java/sk/uniba/fmph/dcs/game_board/GetSomethingFixed.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package sk.uniba.fmph.dcs.game_board;

import sk.uniba.fmph.dcs.stone_age.Effect;

import java.util.ArrayList;
import java.util.List;

public class GetSomethingFixed implements EvaluateCivilisationCardImmediateEffect {
private final List<Effect> effects;

/**
* @param effect
* list of effects that can be chosen.
*/
public GetSomethingFixed(final List<Effect> effect) {
effects = new ArrayList<>();
effects.addAll(effect);
}

/**
* give all resources to player.
*
* @param player
* player to give choice to
* @param choice
* ignores
*
* @return true - it is always possible to give resources to player
*/
@Override
public boolean performEffect(final Player player, final Effect choice) {
player.playerBoard().giveEffect(effects.toArray(new Effect[0]));
effects.clear();
return true;
}
}
Loading