This commit is contained in:
timothykim committed 2026-10-06 08:28:23 -04:00
1 parent a348f6d025
commit e9521b58d2
9 files changed
+133

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
target/
project/target/
project/project/
.bsp/
.metals/
.bloop/
.idea/
.vscode/
# Vim
*.swp
*.swo
*.swn
*~
Session.vim
.netrwhist
tags
+1
View File
@@ -1,6 +1,7 @@
# Response style # Response style
- Be concise and to the point. Answer only what was asked. - Be concise and to the point. Answer only what was asked.
- Don't include implementation code unless explicitly asked. Answer design questions in prose.
- Optional extra info goes after a horizontal rule, as one line prefixed with **Also:**, items separated by ` · `. No bullet lists. - Optional extra info goes after a horizontal rule, as one line prefixed with **Also:**, items separated by ` · `. No bullet lists.
- The extra info must never be longer than the answer itself. - The extra info must never be longer than the answer itself.
+10
View File
@@ -0,0 +1,10 @@
ThisBuild / scalaVersion := "3.9.0"
ThisBuild / organization := "clilatro"
ThisBuild / version := "0.1.0-SNAPSHOT"
lazy val root = (project in file("."))
.settings(
name := "clilatro",
scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-Wunused:all"),
libraryDependencies += "org.scalameta" %% "munit" % "1.3.6" % Test
)
+1
View File
@@ -0,0 +1 @@
sbt.version=2.0.10
+8
View File
@@ -0,0 +1,8 @@
// format: off
// DO NOT EDIT! This file is auto-generated.
// This file enables sbt-bloop to create bloop config files.
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "2.1.2")
// format: on
+69
View File
@@ -0,0 +1,69 @@
package clilatro
import scala.util.Random
enum Rank(val chips: Int, val display: String):
case Two extends Rank(2, " 2")
case Three extends Rank(3, " 3")
case Four extends Rank(4, " 4")
case Five extends Rank(5, " 5")
case Six extends Rank(6, " 6")
case Seven extends Rank(7, " 7")
case Eight extends Rank(8, " 8")
case Nine extends Rank(9, " 9")
case Ten extends Rank(10, "10")
case Jack extends Rank(10, " J")
case Queen extends Rank(10, " Q")
case King extends Rank(10, " K")
case Ace extends Rank(11, " A")
enum Suit(val display: String):
case Spades extends Suit("♠")
case Hearts extends Suit("♥")
case Clubs extends Suit("♣")
case Diamonds extends Suit("♦")
enum Enhancement:
case Bonus, Multi, Wild, Glass, Steel, Stone, Gold, Lucky
def chips: Int = this match
case Bonus => 30
case Stone => 50
case _ => 0
enum Seal:
case Gold, Blue, Red, Purple
enum Edition:
case Foil, Polychrome
enum Sticker:
case Persi
case class PlayingCard(
rank: Rank,
suit: Suit,
enabled: Boolean = true,
enhancement: Option[Enhancement] = None,
seal: Option[Seal] = None,
edition: Option[Edition] = None,
sticker: Option[Sticker] = None,
):
def chips: Int = if enabled then rank.chips + enhancement.map(_.chips).getOrElse(0) else 0;
def display: String = rank.display + suit.display
case class Hand(size: Int, cards: List[PlayingCard])
case class Deck(cards: List[PlayingCard]):
def shuffle(rng: Random): Deck = Deck(rng.shuffle(cards))
def draw(size: Int): (Hand, Deck) =
val (hand, deck) = cards.splitAt(size)
(Hand(size, hand), Deck(deck))
object Deck:
val standard: Deck =
Deck(for
suit <- Suit.values.toList
rank <- Rank.values.toList
yield PlayingCard(rank, suit))
+13
View File
@@ -0,0 +1,13 @@
package clilatro
object Clilatro:
def main(args: Array[String]): Unit =
val seed = scala.util.Random.nextLong()
val rng = scala.util.Random(seed)
val deck = Deck.standard.shuffle(rng)
val (hand, _) = deck.draw(8);
println(hand.cards.map(_.display))
@@ -0,0 +1,4 @@
package clilatro
class DummyService:
def add(a: Int, b: Int): Int = a + b
@@ -0,0 +1,10 @@
package clilatro
class DummyServiceSuite extends munit.FunSuite:
private val service = DummyService()
test("add sums two positive ints"):
assertEquals(service.add(2, 3), 5)
test("add handles negatives"):
assertEquals(service.add(-2, -3), -5)