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
20 changes: 20 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
version: 2
updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: monthly
groups:
prod:
patterns:
- "*"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
groups:
prod:
patterns:
- "*"
57 changes: 56 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,57 @@
# rush
simple game

Rush is a five-player lane battle game that blends elements from risk and battle arena games.
Built in Go, the game emphasises deep, meaningful strategic decisions through [coach personas](internal/ui/rules.md), tactical playbooks, and dynamic lane-based combat.

## Quick Demo

![demo](./docs/rush-demo.gif)

## Prerequisites

- [Go](https://go.dev/doc/install) (latest stable version)
- [Task](https://taskfile.dev/installation/) (task runner)
- [golangci-lint](https://golangci-lint.run/usage/install/) (for linting)
- [sqlc](https://sqlc.dev/usage/install/) (for database code generation)

## Getting Started

### Installation

1. Clone the repository:
```bash
git clone <repository-url>
cd rush
```

2. Tidy dependencies:
```bash
task format
```

### Running the Application

To run the game:
```bash
task dev
```

### Development

We use `Taskfile.yml` to manage project tasks. To see all available commands, run:
```bash
task --list
```

Key tasks include:
- `task test`: Run unit tests.
- `task lint`: Run linters.
- `task format`: Format code and tidy modules.
- `task db-reset`: Reset the database to a clean state.
- `task cover`: Generate and show test coverage.

## Project Structure

- `cmd/`: Application entrypoint.
- `internal/`: Core application logic.
- `docs/`: Documentation.
10 changes: 10 additions & 0 deletions cmd/rush/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"database/sql"
"log/slog"
"os"

Expand All @@ -11,6 +12,7 @@ import (
"github.com/code-gorilla-au/rush/internal/games"
"github.com/code-gorilla-au/rush/internal/playbooks"
"github.com/code-gorilla-au/rush/internal/teams"
"github.com/code-gorilla-au/rush/internal/tournaments"
"github.com/code-gorilla-au/rush/internal/ui"
)

Expand Down Expand Up @@ -42,6 +44,14 @@ func main() {
playbooksSvc := playbooks.NewPlaybooksService(queries)
teamsSvc := teams.NewTeamsService(queries, playbooksSvc)
gameSvc := games.NewService(queries)
_ = tournaments.NewService(tournaments.ServiceDependencies{
GamesSvc: gameSvc,
TeamsSvc: teamsSvc,
Store: queries,
TxnFunc: func(txDB *sql.Tx) tournaments.Store {
return database.New(txDB)
},
})

go func() {
hasAICoaches, tErr := teamsSvc.HasAICoaches(ctx)
Expand Down
Binary file added docs/rush-demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions internal/database/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package database

import (
"database/sql"
"fmt"

_ "modernc.org/sqlite"
)
Expand All @@ -15,3 +16,21 @@ func NewSqLiteProvider(dbPath string) (*sql.DB, error) {

return db, nil
}

func WithTxnCtx(db *sql.DB, fn func(tx *sql.Tx) error) error {
tx, err := db.Begin()
if err != nil {
return err
}

err = fn(tx)
if err != nil {
if rErr := tx.Rollback(); rErr != nil {
return fmt.Errorf("tx rollback failed: %w", rErr)
}

return fmt.Errorf("txn rolled back due to error: %w", err)
}

return tx.Commit()
}
136 changes: 120 additions & 16 deletions internal/database/game.sql.gen.go

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

Loading
Loading