more structure to forms and views

shared ui got an interface to demo the components
This commit is contained in:
2026-08-28 16:20:35 -04:00
parent d1ef2956d8
commit 2e47b8bfce
50 changed files with 941 additions and 610 deletions
@@ -20,7 +20,7 @@ import kotlinx.serialization.json.Json
*
* Client for accessing the Dopewars API server
*/
class ApiClient() {
class ApiClient {
private var address: String = ""
private val client = HttpClient(CIO) {
install(ContentNegotiation) {
@@ -17,6 +17,6 @@ enum class Drug {
companion object {
fun all() = listOf(WEED, COCAINE, HASH, ACID, HEROIN, MUSHROOMS, METH)
fun random() = Drug.WEED
fun random() = WEED
}
}
@@ -5,11 +5,11 @@ import kotlin.random.Random
@Serializable
data class DrugInfo(
val drug: Drug,
val minValue: Float,
val maxValue: Float,
var drug: Drug,
val minValue: Int,
val maxValue: Int,
) {
fun newPrice(): Float {
return Random.nextFloat() * (this.maxValue - this.minValue)
fun newPrice(): Int {
return Random.nextInt() * (this.maxValue - this.minValue)
}
}
@@ -2,13 +2,13 @@ package dev.geekback.dopewars.shared
object Drugs {
val all = listOf(
DrugInfo(Drug.WEED, 300.0f, 1000.0f),
DrugInfo(Drug.ACID, 1000.0f, 4500.0f),
DrugInfo(Drug.COCAINE, 15000.0f, 30000.0f),
DrugInfo(Drug.HASH, 5000.0f, 14000.0f),
DrugInfo(Drug.MUSHROOMS, 500.0f, 2500.0f),
DrugInfo(Drug.METH, 2000.0f, 9000.0f),
DrugInfo(Drug.HEROIN, minValue = 4000.0f, 9500.0f)
DrugInfo(Drug.WEED, 30000, 100000),
DrugInfo(Drug.ACID, 100000, 450000),
DrugInfo(Drug.COCAINE, 1500000, 3000000),
DrugInfo(Drug.HASH, 500000, 1400000),
DrugInfo(Drug.MUSHROOMS, 50000, 250000),
DrugInfo(Drug.METH, 200000, 900000),
DrugInfo(Drug.HEROIN, minValue = 400000, 950000)
)
fun random() = all.random()
@@ -3,6 +3,24 @@ package dev.geekback.dopewars.shared
import kotlinx.serialization.Serializable
@Serializable
data class Location(
var name: String
)
enum class Location {
BROOKLYN,
BRONX,
STATTEN_ISLAND,
QUEENS;
companion object {
fun all(): List<Location> {
return listOf(
BROOKLYN,
BRONX,
STATTEN_ISLAND,
QUEENS
)
}
fun random(): Location {
return all().random()
}
}
}
@@ -1,13 +0,0 @@
package dev.geekback.dopewars.shared
object Locations {
val all = listOf(
Location("Brooklyn"),
Location("Bronx"),
Location("Queens"),
Location("Statten Island"),
)
fun random() = all.random()
}
@@ -4,9 +4,10 @@ import kotlinx.serialization.Serializable
@Serializable
data class Market(
// Location of the market
val location: Location,
val prices: Map<Drug, Float>
// Map of Drug to price in cents
val prices: Map<Drug, Int>
) {
companion object {
}
companion object
}
@@ -2,15 +2,18 @@ package dev.geekback.dopewars.shared
import kotlinx.serialization.Serializable
import kotlin.time.Clock
import kotlin.uuid.Uuid
@Serializable
data class Player(
val id: String,
val name: String,
var cash: Float = 2000f,
var debt: Float = 5500f,
// Cash in cents
var cash: Int = 200000,
// Debt in cents
var debt: Int = 550000,
var health: Int = 100,
var location: Location = Location("Brooklyn"),
var location: Location = Location.BROOKLYN,
var day: Int = 1,
val inventory: MutableList<InventoryItem> = mutableListOf(),
var lastMarket: Market? = null,
@@ -19,7 +22,7 @@ data class Player(
companion object {
fun new(): Player {
return Player(
id = "",
id = Uuid.random().toString(),
name = "Default Player",
)
}
@@ -1,3 +1,3 @@
package dev.geekback.dopewars.shared
const val DRUG_MAX_PRICE: Float = 100_000f;
const val DRUG_MAX_PRICE: Float = 100_000f
@@ -5,5 +5,4 @@ import kotlinx.serialization.Serializable
@Serializable
data class MarketResult(
val market: Market) {
}
val market: Market)