Farm Game is a decentralized farming simulation game implemented in Move for the Sui blockchain. Players can plant crops, harvest them, and even steal crops from other players. The game supports various special events and allows for interaction among players within a shared game state.
To get started with the Farm Game, you need to have a Sui development environment set up. Follow the instructions below to set up the project:
-
Clone the repository:
git clone https://github.com/yourusername/farm-game.git cd farm-game
-
Build the project:
sui move build
-
Run the tests:
sui move test
The Farm Game consists of several key mechanics:
- Planting: Players invest in planting crops, which will mature in the next epoch.
- Harvesting: Players can harvest their crops in the epoch following their planting. The rewards are proportional to their investment and special events.
- Stealing: Players have the option to steal crops from other players. Success rates and potential penalties are influenced by special events.
Special events add variability to the game, providing bonuses or penalties to players:
- Double Reward: Players receive double points for their crops.
- Double Anti-Steal Rate: Increases the player's resistance to being stolen from.
- Double Steal Success Rate: Increases the success rate of stealing from other players.
- Steal Fail: Guarantees that any steal attempt against the player will fail.
fun init(otw: FARM, ctx: &mut TxContext)
Initializes the game by setting up the director and admin capabilities.
public entry fun planting(
director: &mut Director,
investment: &mut Coin<0x30a644c3485ee9b604f52165668895092191fcaf5489a846afa7fc11cdb9b24a::spam::SPAM>,
ctx: &mut TxContext)
Allows players to invest in planting crops for the current epoch.
public entry fun steal(director: &mut Director, rnd: &Random, ctx: &mut TxContext)
Allows players to attempt stealing crops from other players.
public entry fun harvest(director: &mut Director, ctx: &mut TxContext)
Allows players to harvest their crops from the previous epoch.
public entry fun pause(_: &AdminCap, director: &mut Director)
Pauses the game.
public entry fun resume(_: &AdminCap, director: &mut Director)
Resumes the game.
- E_INVALID_AMOUNT: The investment amount is invalid.
- E_PAUSED: The game is currently paused.
- E_GAME_DOES_NOT_EXIST: The game for the specified epoch does not exist.
- E_STOLEN: The player has already stolen in the current epoch.
- E_NOT_EXISTED_AVAILABLE_FARMER: No available farmers to steal from.
- E_NOT_INVOLVED_IN_PLANTING: The player is not involved in planting.
- E_REPEATED_HARVEST: The crop has already been harvested.
- sui client publish --gas-budget 600600600 --skip-dependency-verification
- 得到 PackageID: 0x940eba4a918db5ba73c3a56560cf657b5ac7d38fc552c2bc553f9f8043e550c9
- 得到 AdminCap 0x3b418e0b2e0e6c269afedb743c7468e4288c0105b414e89b34c729a00b6892b4
- 得到 Director 0xb654a2d8bc5503fee4d4d97ae6a4e9ff8c6557b68bc0de54f46075a937febcc3
sui client call --package 0x940eba4a918db5ba73c3a56560cf657b5ac7d38fc552c2bc553f9f8043e550c9 --module farm --function get_or_create_epoch_game --args 0xb654a2d8bc5503fee4d4d97ae6a4e9ff8c6557b68bc0de54f46075a937febcc3 --gas-budget 50000000