# Kemoverse

A gacha-style bot for the Fediverse built with Python. Users can roll for characters, trade, duel, and perhaps engage with popularity-based mechanics. Currently designed for use with Misskey. Name comes from Kemonomimi and Fediverse.

## Installation

## Roadmap

![Fediverse Gacha Bot Logo](./web/static/logo.png)

## ๐Ÿ”ง Features

### โœ… Implemented
- ๐ŸŽฒ Character roll system
- ๐Ÿง  Core database structure for cards
- ๐Ÿ“ฆ Basic support for storing pulls per player
- โฑ๏ธ Time-based limitations on rolls

### ๐Ÿงฉ In Progress
- ๐Ÿ“ Whitelist system to limit access
- โš ๏ธ  Explicit account creation/deletion

## ๐Ÿง  Roadmap

[See our v2.0 board for more details](https://git.waifuism.life/waifu/kemoverse/projects/3)

### ๐Ÿ›’ Gameplay & Collection
- ๐Ÿ” **Trading system** between players
- โญ **Favorite characters** (pin them or set profiles)
- ๐Ÿ“ข **Public post announcements** for rare card pulls
- ๐Ÿ“Š **Stats** for cards
- ๐ŸŽฎ **Games** to play
  - โš”๏ธ Dueling
- ๐Ÿงฎ **Leaderboards**
  - Most traded cards
  - Most owned cards
  - Most voted cards
  - Most popular cards (via usage-based popularity metrics)
  - Users with the rarest cards

### ๐ŸŽจ Card Aesthetics
- ๐Ÿ–ผ๏ธ Simple card template for character rendering
- ๐ŸŒ Web app to generate cards from images

### ๐ŸŒ Fediverse Support
โœ… Anyone from the fediverse can play, but the server only works using a Misskey instance. Want to rewrite the program in Elixir for Pleroma? Let us know!

## ๐Ÿ—ƒ๏ธ Tech Stack

- Python (3.12+)
- SQLite
- Fediverse API integration (via Misskey endpoints)
- Flask
- Modular DB design for extensibility

## ๐Ÿ’ก Philosophy

The bot is meant to feel *light, fun, and competitive*. Mixing social, gacha and duel tactics.

## ๐Ÿงช Installation

### Download and install dependencies

Clone the repo

```sh
git clone https://git.waifuism.life/waifu/kemoverse.git
cd kemoverse
```

Setup a virtual environment (Optional, recommended)

```sh
python3 -m venv venv
source venv/bin/activate
```

Install project dependencies via pip

```sh
python3 -m pip install -r requirements.txt
```

### Setup config file

A sample config file is included with the project as a template: `example_config.ini`

Create a copy of this file and replace its' values with your own. Consult the
template for more information about individual config values and their meaning.

Config files are environment-specific. Use `config_dev.ini` for development and
`config_prod.ini` for production. Switch between environments using the
`KEMOVERSE_ENV` environment variable.

```sh
cp example_config.ini config_dev.ini
# Edit config_dev.ini
```

### Setup database

To set up the database, run:

```sh
KEMOVERSE_ENV=dev python3 setup_db.py
```

### Run the bot

```sh
KEMOVERSE_ENV=dev ./startup.sh
```

If all goes well, you should now be able to interact with the bot.

### Running in production

To run the the in a production environment, use `KEMOVERSE_ENV=prod`. You will
also need to create a `config_prod.ini` file and run the database setup step
again if pointing prod to a different database. (you are pointing dev and prod
to different databases, right? ๐Ÿคจ)

### Updating

To update the bot, first pull new changes from upstream:

```sh
git pull
```

Then run any database migrations. We recommend testing in dev beforehand to
make sure nothing breaks in the update process.

**Always backup your prod database before running any migrations!**

```sh
# Backup database file
cp gacha_game_dev.db gacha_game_dev.db.bak
# Run migrations
KEMOVERSE_ENV=dev python3 setup_db.py
```

```mermaid
flowchart TD

  subgraph Player Interaction
    A1[Misskey bot]
    A2[Web]
  end

  subgraph Misskey
    B1[Misskey instance]
  end

  subgraph Bot
    C1[Bot core in Python]
    C2[Notification parser]
    C3[Gacha roll logic]
    C4[Database interface]
    C5[Misskey API poster]
  end

  subgraph Website
    D1[Flask backend]
    D2[User account system]
    D3[Image gallery]
  end

  subgraph Backend
    E1[Shared database]
    E2[Virtual environment]
    E3[Debian Linux server]
  end

  A1 <-->|Send or receive mention| B1
  B1 -->|Send mention| C2
  C2 -->|Command and information| C3
  C3 <-->|Ask for command information and confirmed roll setting| C4
  C4 <--> E1
  C3 -->|Command result and info| C5
  C5 -->|Resulting Mention| B1

  A2 --> D1
  D1 --> D2
  D1 --> D3
  D2 --> E1
  D3 --> E1

  C1 --> E2
  D1 --> E2

  E1 --> E3
  B1 --> E3

```