Last active
March 1, 2020 22:39
-
-
Save johnX9/77ab41aaa67be3f2fadb9e534ee2ac26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Players.hpp" | |
namespace Oasis { | |
using namespace eosio; | |
using std::string; | |
class Players : public contract { | |
using contract::contract; | |
public: | |
Players(account_name self):contract(self) {} | |
//@abi action | |
void add(const account_name account, string& username, uint64_t level) { | |
} | |
//@abi action | |
void update(const account_name account, uint64_t level, int64_t healthPoints, int64_t energyPoints) { | |
} | |
//@abi action | |
void getplayer(const account_name account) { | |
} | |
private: | |
//@abi table player i64 | |
struct player { | |
uint64_t account_name; | |
string username; | |
uint64_t level; | |
uint64_t health_points = 1000; | |
uint64_t energy_points = 1000; | |
uint64_t primary_key() const { return account_name; } | |
EOSLIB_SERIALIZE(player, (account_name)(username)(level)(health_points)(energy_points)) | |
}; | |
typedef multi_index<N(player), player> playerIndex; | |
}; | |
EOSIO_ABI(Players, (add)(update)(getplayer)) | |
} |
The template is
typedef multi_index<N(table_name), object_template_to_use> multi_index_name;
In C++ typedef creates an alias that can be used anywhere in place of a (possibly complex) type name.
EOSIO_ABI renamed to EOSIO_DISPATCH
https://developers.eos.io/manuals/eosio.cdt/v1.4/index/#eosiolibdispatcherhpp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
typedef multi_index<N(player), player> playerIndex;
what is the meaning of this?�