Skip to content
Merged
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
12 changes: 5 additions & 7 deletions src/main/scala/controller/GameController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@ class GameController[P <: Playable[P]](
selectedMacroAction = Some(chosenAction)

chosenAction match
case Action.ObservePlayer(_) | Action.ChooseReplace(_) |
Action.ChooseDiscard(_) =>
case Action.ObservePlayer(_) | Action.ChooseReplace(_) | Action.ChooseDiscard(_) =>
state = syncState(InputMode.SelectCardOnBoard)

case Action.ObserveOpponent(_) | Action.GiveBack(_) =>
case Action.ObserveOpponent(_) =>
state = syncState(InputMode.SelectAdversaryCardOnBoard)

case Action.Swap(_, _) =>
Expand Down Expand Up @@ -278,7 +277,6 @@ class GameController[P <: Playable[P]](
isVsBot = isVsBot
)


def getWinner: Option[Player] =
val scores = game.playerScore
val p1Score = scores(Player1)
Expand All @@ -302,13 +300,13 @@ class GameController[P <: Playable[P]](
def getGame: Game = game

def getPlayable: P = playable

/** Executes actions on behalf of the bot until its turn ends */
private def botTurn(): Unit =
if !game.isOver then
val (nextTurn, chosenAction) = opponentBot.play(turn)
executeAction(chosenAction)

private def isMandatoryOrRoutine(action: Action): Boolean = action match
case Action.Draw | Action.EndTurn | Action.Confirm | Action.Activate | Action.ChooseDiscard => true
case _ => false
case Action.Draw | Action.EndTurn | Action.Confirm | Action.Activate | Action.ChooseDiscard => true
case _ => false
7 changes: 3 additions & 4 deletions src/main/scala/view/CLIMenu.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.pps.functus
package view

import utils.{MenuItem, SelectableMenuItem, ShowCaseOption, TargetScoreOption, Utils}
import utils.Utils.{SEPARATOR_CHAR, separator, terminalWidth, viewBuilder}
import utils.Utils.{SEPARATOR_CHAR, terminalWidth, viewBuilder}

class CLIMenu:

Expand All @@ -28,8 +28,7 @@ class CLIMenu:

/** Renders the target score selection menu for match mode.
*
* Clears the terminal screen and draws the header before printing the list of [[TargetScoreOption]]
* options.
* Clears the terminal screen and draws the header before printing the list of [[TargetScoreOption]] options.
*
* @param selectedScoreIndex
* the index of the target score option currently highlighted
Expand All @@ -56,7 +55,7 @@ class CLIMenu:
def renderRules(): Unit =
Utils.clearScreen()
Utils.drawHeader

val separator: String = SEPARATOR_CHAR * terminalWidth
val transitionBlock = StringBuilder()
transitionBlock.append(s"$separator\n\n")
transitionBlock.append(Utils.centerText(s"$RULES_TITLE\n"))
Expand Down
2 changes: 0 additions & 2 deletions src/test/scala/view/CLIMenuTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import utils.{MenuItem, SelectableMenuItem, ShowCaseOption, TargetScoreOption, Utils}

import org.scalatest.BeforeAndAfterEach

import java.io.{OutputStream, PrintStream}

class CLIMenuTest extends AnyFlatSpec with Matchers with SilentTest:
Expand Down
2 changes: 0 additions & 2 deletions src/test/scala/view/CLIViewTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import model.board.Player.*
import view.CLIView
import utils.{GameState, InputMode, Utils, ViewAction}

import org.scalatest.BeforeAndAfterEach

class CLIViewTest extends AnyFlatSpec with Matchers with SilentTest:

// Sample helper to construct a default base GameState
Expand Down
Loading