diff --git a/src/main/scala/scatan/model/game/ScatanEffects.scala b/src/main/scala/scatan/model/game/ScatanEffects.scala index cdacacd..1f8532e 100644 --- a/src/main/scala/scatan/model/game/ScatanEffects.scala +++ b/src/main/scala/scatan/model/game/ScatanEffects.scala @@ -9,7 +9,7 @@ import scatan.model.game.state.ops.BuildingOps.{assignBuilding, build} import scatan.model.game.state.ops.DevelopmentCardOps.* import scatan.model.game.state.ops.ResourceCardOps.* import scatan.model.game.state.ops.RobberOps.moveRobber -import scatan.model.game.state.ops.TradeOps.{tradeWithBank, tradeWithPlayer} +import scatan.model.game.state.ops.TradeOps.{tradeWithBank, tradeBetweenPlayers} import scatan.model.map.{Hexagon, RoadSpot, StructureSpot} object ScatanEffects: @@ -249,4 +249,4 @@ object ScatanEffects: senderCards: Seq[ResourceCard], receiverCards: Seq[ResourceCard] ): Effect[TradeWithPlayer.type, ScatanState] = - (state: ScatanState) => state.tradeWithPlayer(sender, receiver, senderCards, receiverCards) + (state: ScatanState) => state.tradeBetweenPlayers(sender, receiver, senderCards, receiverCards) diff --git a/src/main/scala/scatan/model/game/state/ops/DevelopmentCardOps.scala b/src/main/scala/scatan/model/game/state/ops/DevelopmentCardOps.scala index 0bb0f9e..4a4fbbf 100644 --- a/src/main/scala/scatan/model/game/state/ops/DevelopmentCardOps.scala +++ b/src/main/scala/scatan/model/game/state/ops/DevelopmentCardOps.scala @@ -15,6 +15,8 @@ import scatan.model.map.{Hexagon, RoadSpot} */ object DevelopmentCardOps: + type DevelopmentCardEffect = ScatanState => Option[ScatanState] + extension (state: ScatanState) /** Returns a new ScatanState with the given development card assigned to the given player. The development card is * added to the player's list of development cards. The assigned awards are updated. @@ -115,7 +117,7 @@ object DevelopmentCardOps: player: ScatanPlayer, developmentType: DevelopmentType, turnNumber: Int - )(effect: ScatanState => Option[ScatanState]): Option[ScatanState] = + )(effect: DevelopmentCardEffect): Option[ScatanState] = val stateWithCardConsumed = for developmentCards <- state.developmentCards.get(player) card <- developmentCards.find(card => diff --git a/src/main/scala/scatan/model/game/state/ops/TradeOps.scala b/src/main/scala/scatan/model/game/state/ops/TradeOps.scala index d5d2212..889d33c 100644 --- a/src/main/scala/scatan/model/game/state/ops/TradeOps.scala +++ b/src/main/scala/scatan/model/game/state/ops/TradeOps.scala @@ -11,7 +11,7 @@ object TradeOps: val tradeWithBankRequiredCards = 4 extension (state: ScatanState) - /** Trade with a player. The sender must have the senderCards and the receiver must have the receiverCards The + /** Trade between two players. The sender must have the senderCards and the receiver must have the receiverCards The * sender will give the senderCards to the receiver and vice versa * * @param sender @@ -25,7 +25,7 @@ object TradeOps: * @return * Some(state) if the trade is allowed, None otherwise */ - def tradeWithPlayer( + def tradeBetweenPlayers( sender: ScatanPlayer, receiver: ScatanPlayer, senderCards: Seq[ResourceCard], diff --git a/src/test/scala/scatan/model/game/state/ops/TradeOpsTest.scala b/src/test/scala/scatan/model/game/state/ops/TradeOpsTest.scala index 7473e67..d053a09 100644 --- a/src/test/scala/scatan/model/game/state/ops/TradeOpsTest.scala +++ b/src/test/scala/scatan/model/game/state/ops/TradeOpsTest.scala @@ -4,7 +4,7 @@ import scatan.model.components.* import scatan.model.game.BaseScatanStateTest import scatan.model.game.state.ScatanState import scatan.model.game.state.ops.ResourceCardOps.assignResourceCard -import scatan.model.game.state.ops.TradeOps.{tradeWithBank, tradeWithPlayer} +import scatan.model.game.state.ops.TradeOps.{tradeWithBank, tradeBetweenPlayers} class TradeOpsTest extends BaseScatanStateTest: @@ -19,7 +19,7 @@ class TradeOpsTest extends BaseScatanStateTest: stateWithResourceAssigned match case Some(stateWithResourceAssigned) => val stateWithTrade = - stateWithResourceAssigned.tradeWithPlayer( + stateWithResourceAssigned.tradeBetweenPlayers( sender, receiver, Seq(ResourceCard(ResourceType.Wood), ResourceCard(ResourceType.Wood)), @@ -49,7 +49,12 @@ class TradeOpsTest extends BaseScatanStateTest: state.resourceCards(sender) should be(Seq(ResourceCard(ResourceType.Wood))) state.resourceCards(receiver) should be(Seq(ResourceCard(ResourceType.Brick))) val stateWithTrade = - state.tradeWithPlayer(sender, receiver, Seq(ResourceCard(ResourceType.Brick)), state.resourceCards(receiver)) + state.tradeBetweenPlayers( + sender, + receiver, + Seq(ResourceCard(ResourceType.Brick)), + state.resourceCards(receiver) + ) stateWithTrade should be(None) case None => fail("Resources not assigned") } @@ -66,7 +71,7 @@ class TradeOpsTest extends BaseScatanStateTest: stateWithResourceAssigned match case Some(state) => val stateWithTrade = - state.tradeWithPlayer( + state.tradeBetweenPlayers( sender, receiver, Seq(ResourceCard(ResourceType.Wood)),