Skip to content

Commit d7a0cd5

Browse files
author
longnn5
committed
docs: Add comprehensive README for 'The Last King' game, detailing features, architecture, and setup.
1 parent 586abc4 commit d7a0cd5

1 file changed

Lines changed: 76 additions & 10 deletions

File tree

README.md

Lines changed: 76 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,82 @@
1-
# magnetic_event
1+
# The Last King (Vị Vua Cuối Cùng)
22

3-
A new Flutter project.
3+
A historical strategy card game built with **Flutter**, inspired by *Reigns*. Guide your dynasty through turbulent times by making binary choices that affect the balance of your kingdom.
44

5-
## Getting Started
5+
## 🌟 Features
66

7-
This project is a starting point for a Flutter application.
7+
- **Swipe Mechanic**: Tinder-like card swiping (Left/Right) to make decisions (`flutter_card_swiper`).
8+
- **Resource Management**: Balance four key pillars of the kingdom:
9+
- 💰 **Money** (Tiền)
10+
- 👥 **People** (Dân)
11+
- 🛡️ **Army** (Quân)
12+
- 🔯 **Religion** (Đạo)
13+
- **Dynamic visual effects**: Confetti blasts on resource changes (`confetti`).
14+
- **Persistent High Scores**: Track your longest reign using local storage (`shared_preferences`).
15+
- **Monetization**:
16+
- **Banner Ads**: Always visible at the bottom of the screen.
17+
- **Interstitial Ads**: Randomly triggered after 2-9 swipes.
818

9-
A few resources to get you started if this is your first Flutter project:
19+
## 🏗️ Architecture
1020

11-
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12-
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
21+
The project follows a clean architecture pattern utilizing **Riverpod** for state management.
1322

14-
For help getting started with Flutter development, view the
15-
[online documentation](https://docs.flutter.dev/), which offers tutorials,
16-
samples, guidance on mobile development, and a full API reference.
23+
### File Structure
24+
```
25+
lib/
26+
├── data/
27+
│ └── scenarios_data.dart # Hardcoded content (Questions/Events)
28+
├── models/
29+
│ └── scenario.dart # Data models (Scenario, Choice, Effect)
30+
├── providers/
31+
│ └── game_provider.dart # Game Logic & State Management (Riverpod)
32+
├── screens/
33+
│ └── game_screen.dart # Main UI: Card Stack, Stats, and Ads
34+
├── services/
35+
│ └── shared_preference_service.dart # Local Storage Abstraction
36+
├── utils/
37+
│ └── ad_helper.dart # AdMob Unit IDs & Test Mode Configuration
38+
├── widgets/
39+
│ ├── resource_bar.dart # Animated Stat Bar
40+
│ └── scenario_card.dart # Swipeable Card UI
41+
└── main.dart # App Entry & dependency overrides
42+
```
43+
44+
### State Management (`GameNotifier`)
45+
The `GameProvider` manages the `GameState`, which includes:
46+
- **Resources**: Values clamped between 0 and 100.
47+
- **Game Over Logic**: Checks if any resource hits 0.
48+
- **Swipe Tracking**: Counts swipes to determine when to show Interstitial Ads.
49+
- **High Score**: Auto-updates when the current reign exceeds the stored record.
50+
51+
## 🎮 Game Logic
52+
53+
1. **Core Loop**:
54+
- Player reads a scenario.
55+
- Swiping **Left** or **Right** triggers different effects on resources.
56+
- If any resource depletes to 0, the game ends (Dynasty Falls).
57+
2. **Ads Logic**:
58+
- **Banner**: Loaded immediately on start.
59+
- **Interstitial**: A threshold is randomized between 2 and 9 swipes. When the user swipes enough times to hit this threshold, a full-screen ad is shown, and the counter resets with a new random threshold.
60+
3. **Storage**:
61+
- "Years Reigned" (Score) is saved to `SharedPreferences` only if it beats the previous high score.
62+
63+
## 🛠️ Tech Stack
64+
65+
- **Framework**: Flutter (Dart)
66+
- **State Management**: `flutter_riverpod`
67+
- **UI Components**: `flutter_card_swiper`, `confetti`
68+
- **Ads**: `google_mobile_ads`
69+
- **Fonts**: `google_fonts`
70+
71+
## 🚀 Getting Started
72+
73+
1. **Prerequisites**: Flutter SDK installed.
74+
2. **Install Dependencies**:
75+
```bash
76+
flutter pub get
77+
```
78+
3. **Run the App**:
79+
- **iOS Simulator**: `flutter run -d <device_id>`
80+
- **Android Emulator**: `flutter run -d <emulator_id>`
81+
82+
> **Note**: AdMob IDs are configured for **Test Mode** in `lib/utils/ad_helper.dart`.

0 commit comments

Comments
 (0)