> For the complete documentation index, see [llms.txt](https://casefun.gitbook.io/casefun/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://casefun.gitbook.io/casefun/mechanics-pvp-case-battles-and-ai-bots.md).

# Mechanics: PvP Case Battles & AI Bots

## ⚔️ PvP Case Battles & AI Bots

The **CaseFun PvP Battle Engine** is a competitive, high-velocity "winner-takes-all" arena where users can challenge other players—or instantly face an AI Bot—in multi-case opening duels.

By combining PvP gamification with instant liquidity resolution, Case Battles transform standard token holding into high-stakes social competition.

***

### 📜 Battle Rules & Core Mechanics

* **Battle Creation (1 to 25 Cases):** A user can initiate a battle by bundling anywhere from **1 to 25 active cases** (provided none of the selected cases have reached their Case Duration expiry).
* **The Winner-Takes-All Rule:** Both participants open the exact same sequence of cases simultaneously. The participant who achieves the highest aggregate drop value in USD (calculated using the real-time Token Price parameter) claims 100% of all tokens dropped across both players.
* **Provably Fair Resolution:** Every drop outcome in a battle is resolved transparently on-chain via CaseFun’s verifiable randomness protocol, ensuring neither participant nor protocol can manipulate the outcome.

***

### 🤖 Instant Matchmaking via AI Bots

Finding a matching human opponent for specific case combinations and custom budget limits can sometimes create liquidity wait times. To eliminate friction, CaseFun features an **Instant AI Bot Challenge System**:

| Feature                         | Execution & Technical Mechanism                                                                                                                                  |
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Zero-Wait Execution**         | Users can toggle "Call AI Bot" at any time to instantly start the battle without waiting for another player to accept the criteria.                              |
| **100% Statistical Parity**     | The AI Bot operates under the exact same Provably Fair smart contract rules as human players. The bot possesses no edge, hidden odds, or algorithmic advantages. |
| **On-Chain Balance Settlement** | If the user wins, all tokens dropped for both the user and the bot are transferred directly to the user’s inventory.                                             |

***

### 🛡️ Expiration Guard & Automatic Refund Protection

To protect user funds and maintain accurate market prices during matchmaking, the protocol enforces an automated safety guard:

* A battle cannot start if any of the selected cases hit their Case Duration limit while waiting in the lobby.
* If a case expires before a second player (or AI Bot) joins, the matchmaking lobby is instantly terminated, and **100% of the funds** spent to create the battle are automatically returned to the creator's balance.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://casefun.gitbook.io/casefun/mechanics-pvp-case-battles-and-ai-bots.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
