Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added WorldFactory and Worlds, as well as a Character Generator #2

Open
wants to merge 9 commits into
base: games-dev
Choose a base branch
from
Open
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
Binary file added Group 9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,40 @@
<div align="center">
<a href="https://optimism.io"><img alt="Optimism" src="https://raw.githubusercontent.com/ethereum-optimism/brand-kit/main/assets/svg/OPTIMISM-R.svg" width=320></a>
<a href="https://www.notion.so/danj-o/S3-Block-Magic-Hackathon-2024-d0ed09047ec648a087ace9b078736518"><img alt="Ceptor Club" src="Group 9.png" width=128></a>
<br />
<br />
</div>

# 🏗🔴 Scaffold-OP
# 🏗🔴 Ceptor-Games-Scaffold

<h4 align="center">
<a href="https://docs.scaffoldeth.io">Documentation</a> |
<a href="https://scaffoldeth.io">Website</a>
</h4>

Scaffold-OP is a fork of Scaffold-ETH2 with minimal differences, providing additional dApp examples, native support for Superchain testnets, and more low-level instructions. We highly recommend the Scaffold-ETH2 docs as the primary guideline.
Ceptor-Scaffold-OP is a fork of Scaffold-ETH2 with fantastic differences, providing additional dApp examples, native support for Superchain testnets, and more low-level instructions. We highly recommend the Scaffold-ETH2 docs as the primary guideline.

# Games Contracts

### [Game World Generator](BuyMeACeptor.sol)
Step into the realms of creativity with our Game World Generator. This contract spawns a unique game world, sculpted by your chosen vibe and number of players. Picture a planet alive with scenarios, locations, descriptions, maps, denizens, secrets, goals, and players. Each world, distinct and thriving on its own blockchain, is birthed for 10 gameTokens. Craft your world, or join the adventure: 5 gT as a GM, 2 gT as a player.

**Inside worlds:**
- Games: Rich with adventure.
- Schedules: Timed meticulously.
- Sessions: Verified attendance.

### [Character Generator](packages/hardhat/contracts/CeptorCharacterGenerator.sol)
Unleash your avatar in the game world. This contract creates characters with abilities, class, name, alignment, and background. Each character boasts unique attributes. Note: Currently restricted to contract owner, slated for VRF2.5 upgrade.

### [World and Game Management](packages/hardhat/contracts/WorldFactory.sol)
The World Generator deploys a World contract. Each World tracks its games, ensuring verifiable truth within sessions.

### [NPC Generator]
Forge the world’s inhabitants. The NPC Generator creates non-player characters, each with unique abilities, class, name, alignment, hometown, and background. This, too, is destined for the VRF2.5 upgrade.

---

Crafted with the prowess of a Level 5 Barbarian, the ingenuity of an Artificer 2, and the cosmic insight of a Druid of the Stars 2, by Tippi Fifestarr.

🧪 An open-source, up-to-date toolkit for building decentralized applications (dapps) on the Ethereum blockchain. It's designed to make it easier for developers to create and deploy smart contracts and build user interfaces that interact with those contracts.

Expand Down
137 changes: 137 additions & 0 deletions packages/hardhat/contracts/BuyMeACeptor.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;

/**
* @title World
* @dev World struct
*/
struct World {
string vibe;
string gameMasterName;
string gameMasterTwitterHandle;
string description;
uint256 time;
address gameMasterAddress;
}

/**
* @title BuyMeACeptorWorld
* @dev BuyMeACeptorWorld contract to accept donations and for our users to create a world for us
*/
contract BuyMeACeptor{
address payable public owner;
uint256 public price;
World[] public worlds;

error InsufficientFunds();
error InvalidArguments(string message);
error OnlyOwner();

event BuyMeACeptorWorldEvent(address indexed buyer, uint256 price);
event NewWorld(address indexed gameMasterAddress, uint256 time, string vibe, string gameMasterName, string gameMasterTwitterHandle, string description);

constructor() {
owner = payable(msg.sender);
price = 0.0001 ether;
}

/**
* WRITE FUNCTIONS *************
*/

/**
* @dev Function to buy a world
* @param gameMasterName The name of the game master
* @param gameMasterTwitterHandle The Twitter handle of the game master
* @param description The description of the world
* (Note: Using calldata for gas efficiency)
*/
function buyWorld(string calldata vibe, string calldata gameMasterName, string calldata gameMasterTwitterHandle, string calldata description) public payable {
if (msg.value < price) {
revert InsufficientFunds();
}

emit BuyMeACeptorWorldEvent(msg.sender, msg.value);

if (bytes(gameMasterName).length == 0 && bytes(description).length == 0) {
revert InvalidArguments("Invalid gameMasterName or description");
}

worlds.push(World(vibe, gameMasterName, gameMasterTwitterHandle, description, block.timestamp, msg.sender));

emit NewWorld(msg.sender, block.timestamp, vibe, gameMasterName, gameMasterTwitterHandle, description);
}

/**
* @dev Function to remove a world
* @param index The index of the world
*/
function removeWorld(uint256 index) public {
if (index >= worlds.length) {
revert InvalidArguments("Invalid index");
}

World memory world = worlds[index];

// if operation isnt sent from the same game master or the owner, then not allowed
if (world.gameMasterAddress != msg.sender && msg.sender != owner) {
revert InvalidArguments("Operation not allowed");
}

World memory indexWorld = worlds[index];
worlds[index] = worlds[worlds.length - 1];
worlds[worlds.length - 1] = indexWorld;
worlds.pop();
}

/**
* @dev Function to modify a world description
* @param index The index of the world
* @param description The description of the world
*/
function modifyWorldDescription(uint256 index, string memory description) public {
if (index >= worlds.length) {
revert InvalidArguments("Invalid index");
}

World memory world = worlds[index];

if (world.gameMasterAddress != msg.sender || msg.sender != owner) {
revert InvalidArguments("Operation not allowed");
}

worlds[index].description = description;
}

/**
* @dev Function to withdraw the balance
*/
function withdrawTips() public {
if (msg.sender != owner) {
revert OnlyOwner();
}

if (address(this).balance == 0) {
revert InsufficientFunds();
}

(bool sent,) = owner.call{value: address(this).balance}("");
require(sent, "Failed to send Ether");
}

/**
* READ FUNCTIONS *************
*/

/**
* @dev Function to get the worlds
*/
function getWorlds() public view returns (World[] memory) {
return worlds;
}

/**
* @dev Recieve function to accept ether
*/
receive() external payable {}
}
156 changes: 0 additions & 156 deletions packages/hardhat/contracts/BuyMeACoffee.sol

This file was deleted.

Loading